82 QString newfilename = sSampleFilename.section(
'/', -1 );
89 setWindowTitle ( QString( tr(
"SampleEditor " ) + newfilename) );
100 LoopCountSpinBox->setRange(0, 20000 );
101 StartFrameSpinBox->setRange(0, slframes );
102 LoopFrameSpinBox->setRange(0, slframes );
103 EndFrameSpinBox->setRange(0, slframes );
104 EndFrameSpinBox->setValue( slframes );
105 rubberbandCsettingscomboBox->setCurrentIndex( 4 );
106 rubberComboBox->setCurrentIndex( 0 );
109 pitchdoubleSpinBox->setLocale( QLocale( QLocale::C, QLocale::AnyCountry ) );
117 setFixedSize ( width(), height() );
119#ifndef H2CORE_HAVE_RUBBERBAND
121 RubberbandCframe->setDisabled (
true );
125 RubberbandCframe->setDisabled (
false );
159 int err = QMessageBox::information(
this,
"Hydrogen",
160 pCommonStrings->getUnsavedChanges(),
161 pCommonStrings->getButtonOk(),
162 pCommonStrings->getButtonCancel(),
179 if ( pInstrument ==
nullptr ) {
180 ERRORLOG(
"No instrument selected" );
185 if ( pCompo ==
nullptr ) {
192 if ( pLayer ==
nullptr ) {
198 return pLayer->get_sample();
204 if ( pInstrument ==
nullptr ) {
205 ERRORLOG(
"No instrument selected" );
210 if ( pCompo ==
nullptr ) {
217 if ( pLayer ==
nullptr ) {
223 auto pSample = pLayer->get_sample();
224 if ( pSample ==
nullptr ) {
225 ERRORLOG(
"Unable to retrieve sample" );
234 __loops = pSample->get_loops();
237 if ( pSample->get_velocity_envelope()->size()==0 ) {
244 for(
auto& pt : *pSample->get_velocity_envelope() ){
249 if ( pSample->get_pan_envelope()->size()==0 ) {
254 for(
auto& pt : *pSample->get_pan_envelope() ){
262 ProcessingTypeComboBox->setCurrentIndex ( 0 );
265 ProcessingTypeComboBox->setCurrentIndex ( 1 );
268 ProcessingTypeComboBox->setCurrentIndex ( 2 );
284 rubberComboBox->setCurrentIndex( 0 );
289 rubberbandCsettingscomboBox->setCurrentIndex( 4 );
294 pitchdoubleSpinBox->setValue( 0.0 );
298 rubberComboBox->setCurrentIndex( 1 );
301 rubberComboBox->setCurrentIndex( 2 );
303 rubberComboBox->setCurrentIndex( 3 );
305 rubberComboBox->setCurrentIndex( 4 );
307 rubberComboBox->setCurrentIndex( 5 );
309 rubberComboBox->setCurrentIndex( 6 );
325 connect( rubberComboBox, SIGNAL( currentIndexChanged (
const QString ) ),
this, SLOT(
valueChangedrubberComboBox(
const QString ) ) );
359 int err = QMessageBox::information(
this,
"Hydrogen",
360 pCommonStrings->getUnsavedChanges(),
361 pCommonStrings->getButtonOk(),
362 pCommonStrings->getButtonCancel(),
381 QApplication::setOverrideCursor(Qt::WaitCursor);
386 QApplication::restoreOverrideCursor();
397 int err = QMessageBox::information(
this,
"Hydrogen",
398 pCommonStrings->getUnsavedChanges(),
399 pCommonStrings->getButtonOk(),
400 pCommonStrings->getButtonCancel(),
416 auto pAudioEngine = pHydrogen->getAudioEngine();
418 if ( pOldSample ==
nullptr ) {
419 ERRORLOG(
"Unable to retrieve sample" );
420 assert( pOldSample );
425 pOldSample->getLicense() );
426 pEditSample->set_loops(
__loops );
431 if( ! pEditSample->load( pAudioEngine->getTransportPosition()->getBpm() ) ){
432 ERRORLOG(
"Unable to load modified sample" );
438 std::shared_ptr<H2Core::Instrument> pInstrument =
nullptr;
439 auto pSong = pHydrogen->getSong();
440 if ( pSong !=
nullptr ) {
441 auto pInstrList = pSong->getInstrumentList();
442 int nInstr = pHydrogen->getSelectedInstrumentNumber();
443 if ( nInstr >=
static_cast<int>(pInstrList->size()) ) {
448 pInstrument =
nullptr;
451 pInstrument = pInstrList->get( nInstr );
455 std::shared_ptr<H2Core::InstrumentLayer> pLayer =
nullptr;
456 if( pInstrument !=
nullptr ) {
460 pLayer->set_sample( pEditSample );
463 pAudioEngine->unlock();
465 if ( pLayer !=
nullptr ) {
511 PrevChangesPushButton->setDisabled (
false );
512 PrevChangesPushButton->setFlat (
false );
519 PrevChangesPushButton->setDisabled (
true );
520 PrevChangesPushButton->setFlat (
true );
601 if (PlayPushButton->text() ==
"Stop" ){
609 if ( pSong ==
nullptr ) {
613 if ( pInstr ==
nullptr ) {
617 if ( pCompo ==
nullptr ) {
620 auto pLayer = pCompo->get_layer( selectedLayer );
621 if ( pLayer ==
nullptr ) {
624 Note *pNote =
new Note( pInstr, 0, pLayer->get_end_velocity() - 0.01 );
649 PlayPushButton->setText( QString(
"Stop") );
655 if (PlayOrigPushButton->text() ==
"Stop" ){
663 if ( pInstr ==
nullptr ) {
664 DEBUGLOG(
"No instrument selected" );
675 if ( pNewSample !=
nullptr ){
676 int length = ( ( pNewSample->get_frames() / pNewSample->get_sample_rate() + 1) * 100 );
686 PlayOrigPushButton->setText( QString(
"Stop") );
706 PlayPushButton->setText( pCommonString->getButtonPlay() );
707 PlayOrigPushButton->setText( pCommonString->getButtonPlayOriginalSample() );
715 unsigned targetSampleLength;
730 PlayPushButton->setText( pCommonString->getButtonPlay() );
731 PlayOrigPushButton->setText( pCommonString->getButtonPlayOriginalSample() );
745 unsigned newLength = 0;
746 if (oneSampleLength == loopLength){
747 newLength = oneSampleLength + oneSampleLength *
__loops.
count ;
750 newLength =oneSampleLength + repeatsLength;
755 unsigned * normalFrames =
new unsigned[ normalLength ];
756 unsigned * tempFrames =
new unsigned[ newLength ];
757 unsigned * loopFrames =
new unsigned[ loopLength ];
759 for (
unsigned i = 0; i < normalLength; i++ ) {
767 for (
unsigned i = 0; i < newLength; i++){
771 for (
unsigned i = 0; i < oneSampleLength; i++, y++){
773 tempFrames[i] = normalFrames[y];
776 for (
unsigned i = 0; i < loopLength; i++, z++){
778 loopFrames[i] = normalFrames[z];
782 std::reverse(loopFrames, loopFrames + loopLength);
786 std::reverse( tempFrames, tempFrames + oneSampleLength );
790 std::reverse(loopFrames, loopFrames + loopLength);
794 unsigned tempdataend = oneSampleLength + ( loopLength * i );
796 std::copy( loopFrames, loopFrames+loopLength ,tempFrames+ tempdataend );
799 std::reverse(loopFrames, loopFrames + loopLength);
802 std::copy( loopFrames, loopFrames+loopLength ,tempFrames+ tempdataend );
819 delete[] normalFrames;
830 unsigned newLength = 0;
832 if ( oneSampleLength == loopLength ){
833 newLength = oneSampleLength + oneSampleLength *
__loops.
count ;
835 newLength =oneSampleLength + repeatsLength;
839 newlengthLabel->setText(QString( tr(
"new sample length" ) )
840 .append( QString(
": %1 " ).arg(newLength) )
841 .append( tr(
"frames" )));
850 int count = LoopCountSpinBox->value();
858 const auto pAudioDriver = pHydrogen->getAudioOutput();
859 if ( pAudioDriver ==
nullptr ) {
860 ERRORLOG(
"AudioDriver is not ready!" );
864 if (
m_nSlframes > pAudioDriver->getSampleRate() * 60 ){
865 pHydrogen->getAudioEngine()->getSampler()->stopPlayingNotes();
873 if (
m_nSlframes > pAudioDriver->getSampleRate() * 60 * 30){
874 LoopCountSpinBox->setMaximum(LoopCountSpinBox->value() -1);
883 int new_settings = rubberbandCsettingscomboBox->currentIndex();
896 double new_value = pitchdoubleSpinBox->value();
909 if( rubberComboBox->currentText() !=
"off" ){
918 switch ( rubberComboBox->currentIndex() ){
960 if (induration != 0.0)
m_fRatio = durationtime / induration;
972 rubberComboBox->setStyleSheet(
"QComboBox { background-color: green; }");
976 rubberComboBox->setStyleSheet(
"QComboBox { background-color: yellow; }");
980 rubberComboBox->setStyleSheet(
"QComboBox { background-color: red; }");
982 QString text = QString( tr(
" RB-Ratio" ) )
983 .append( QString(
" %1" ).arg(
m_fRatio ) );
984 ratiolabel->setText( text );
988 rubberComboBox->setStyleSheet(
"QComboBox { background-color: 58, 62, 72; }");
989 ratiolabel->setText(
"" );
996 switch ( ProcessingTypeComboBox->currentIndex() ){
1045 PlayPushButton->setText( pCommonString->getButtonPlay() );
1046 PlayOrigPushButton->setText( pCommonString->getButtonPlayOriginalSample() );
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
void setDetailSamplePosition(unsigned posi, float zoomfactor, QString type)
void updateDisplay(QString filename)
Sampler * getSampler() const
const std::shared_ptr< TransportPosition > getTransportPosition() const
long long getRealtimeFrame() const
A container for a sample, being able to apply modifications on it.
static bool file_executable(const QString &path, bool silent=false)
returns true if the given path is an existing executable regular file
std::shared_ptr< Song > getSong() const
Get the current song.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
AudioEngine * getAudioEngine() const
std::shared_ptr< Instrument > getSelectedInstrument() const
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
static std::shared_ptr< Instrument > load_instrument(const QString &drumkit_path, const QString &instrument_name)
creates a new Instrument, loads samples from a given instrument within a given drumkit
A note plays an associated instrument with a velocity left and right pan.
void set_specific_compo_id(int value)
__specific_compo_id setter
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
LoopMode
possible sample editing loop mode
int end_frame
the frame index where to end the new sample to
int start_frame
the frame index where to start the new sample from
LoopMode mode
one of the possible loop modes
int count
the counts of loops to apply
int loop_frame
the frame index where to start the loop from
int c_settings
TODO should be crispness, see rubberband -h.
float divider
TODO should be ratio : desired time ratio.
bool use
is rubberband enabled
static std::shared_ptr< Sample > load(const QString &filepath, const License &license=License())
void preview_instrument(std::shared_ptr< Instrument > pInstr)
void noteOn(Note *pNote)
Start playing a note.
void stopPlayingNotes(std::shared_ptr< Instrument > pInstr=nullptr)
void preview_sample(std::shared_ptr< Sample > pSample, int length)
Preview, uses only the first layer.
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()
static InstrumentEditorPanel * get_instance()
void updateDisplayPointer()
void updateDisplay(const QString &filename)
int m_nStartFramePosition
bool m_bLoopSliderIsMoved
void paintLocatorEvent(int pos, bool last_event)
bool m_bStartSliderIsMoved
void updateTargetsamplePositionRuler()
void updateMainsamplePositionRuler()
MainSampleWaveDisplay * m_pMainSampleWaveDisplay
bool returnAllMainWaveDisplayValues()
unsigned * m_pPositionsRulerPath
std::shared_ptr< H2Core::Sample > m_pSampleFromFile
void valueChangedLoopFrameSpinBox(int)
void getAllLocalFrameInfos()
std::shared_ptr< H2Core::Sample > retrieveSample() const
void returnAllTargetDisplayValues()
void createPositionsRulerPath()
H2Core::Sample::Loops __loops
unsigned long m_nRealtimeFrameEndForTarget
void valueChangedProcessingTypeComboBox(const QString)
QTimer * m_pTargetDisplayTimer
bool m_bSampleEditorClean
void setSamplelengthFrames()
bool m_bSampleIsModified
true if sample is modified
void valueChangedrubberComboBox(const QString)
virtual void closeEvent(QCloseEvent *event) override
void on_PrevChangesPushButton_clicked()
void on_PlayPushButton_clicked()
H2Core::Sample::Rubberband __rubberband
void valueChangedrubberbandCsettingscomboBox(const QString)
virtual void mouseReleaseEvent(QMouseEvent *ev) override
TargetWaveDisplay * m_pTargetSampleView
void checkRatioSettings()
SampleEditor(QWidget *pParent, int nSelectedComponent, int nSelectedLayer, QString nSampleFilename)
void valueChangedEndFrameSpinBox(int)
void testPositionsSpinBoxes()
void on_verticalzoomSlider_valueChanged(int value)
void valueChangedStartFrameSpinBox(int)
void on_ClosePushButton_clicked()
void valueChangedpitchdoubleSpinBox(double)
void on_PlayOrigPushButton_clicked()
void valueChangedLoopCountSpinBox(int)
DetailWaveDisplay * m_pSampleAdjustView
unsigned long m_nRealtimeFrameEnd
H2Core::Sample::PanEnvelope * get_pan()
void updateDisplay(std::shared_ptr< H2Core::InstrumentLayer > pLayer)
void paintLocatorEventTargetDisplay(int pos, bool last_event)
H2Core::Sample::VelocityEnvelope * get_velocity()