63 , m_pInstrument( nullptr )
64 , m_nSelectedLayer( 0 )
65 , m_fPreviousMidiOutChannel( -1.0 )
66 , m_nSelectedComponent( -1 )
77 pCommonStrings->getGeneralButton(),
false, QSize(),
78 tr(
"Show instrument properties" ) );
85 pCommonStrings->getLayersButton(),
false, QSize(),
86 tr(
"Show layers properties" ) );
107 pCommonStrings->getMidiOutLabel() );
108 pMidiOutLbl->move( 22, 281 );
118 pCommonStrings->getMidiOutChannelLabel() );
129 pCommonStrings->getMidiOutNoteLabel() );
140 pCommonStrings->getPitchLabel() );
145 tr(
"Pitch offset (Coarse)" ),
true, -24, 24 );
151 pCommonStrings->getPitchCoarseLabel() );
155 tr(
"Pitch offset (Fine)" ),
false, -0.5, 0.5 );
161 pCommonStrings->getPitchFineLabel() );
167 tr(
"Random pitch factor" ),
false );
172 pCommonStrings->getPitchRandomLabel() );
177 "", pCommonStrings->getBypassButton(),
true,
178 QSize( 0, 0 ),
"",
false,
true );
184 tr(
"Filter Cutoff" ),
false );
189 pCommonStrings->getCutoffLabel() );
193 tr(
"Filter resonance" ),
false );
197 pCommonStrings->getResonanceLabel() );
206 tr(
"Length of Attack phase.\n\nValue" ),
false );
208 tr(
"Length of Decay phase.\n\nValue" ),
false );
210 tr(
"Sample volume in Sustain phase.\n\nValue" ),
false );
213 tr(
"Length of Release phase.\n\nValue" ),
false );
229 pCommonStrings->getAttackLabel() );
232 pCommonStrings->getDecayLabel() );
235 pCommonStrings->getSustainLabel() );
238 pCommonStrings->getReleaseLabel() );
245 tr(
"Instrument gain" ),
false, 0.0, 5.0 );
252 pCommonStrings->getGainLabel() );
263 pCommonStrings->getMuteGroupLabel() );
270 m_pIsStopNoteCheckBox->setToolTip( tr(
"Stop the current playing instrument-note before trigger the next note sample" ) );
275 pCommonStrings->getIsStopNoteLabel() );
282 m_pApplyVelocity->setToolTip( tr(
"Don't change the layers' gain based on velocity" ) );
287 pCommonStrings->getApplyVelocityLabel() );
300 pCommonStrings->getHihatGroupLabel() );
309 pCommonStrings->getHihatMinRangeLabel() );
318 pCommonStrings->getHihatMaxRangeLabel() );
338 false, QSize( 12, 12 ) );
368 "", pCommonStrings->getLoadLayerButton() );
373 "", pCommonStrings->getDeleteLayerButton() );
378 "", pCommonStrings->getEditLayerButton() );
391 tr(
"Layer gain" ),
false , 0.0, 5.0);
396 pCommonStrings->getLayerGainLabel() );
401 tr(
"Component volume" ),
false, 0.0, 5.0 );
406 pCommonStrings->getComponentGainLabel() );
412 pCommonStrings->getPitchLabel() );
416 tr(
"Layer pitch (Coarse)" ),
true, -24.0, 24.0 );
420 pCommonStrings->getPitchCoarseLabel() );
424 tr(
"Layer pitch (Fine)" ),
true, -50.0, 50.0 );
428 pCommonStrings->getPitchFineLabel() );
452 pCommonStrings->getSampleSelectionLabel() );
461 connect(
popCompo, SIGNAL( triggered(QAction*) ),
502 std::shared_ptr<Song> pSong = pHydrogen->
getSong();
503 auto pCompoList = pSong->getComponents();
509 pCompoList !=
nullptr && pCompoList->size() > 0 ) {
581 for (
const auto& pComponent : *pSong->getComponents() ) {
582 if ( !
itemsCompo.contains( pComponent->get_name() ) ) {
594 for (
const auto& ppComponent : *pCompoList ) {
606 assert(pTmpComponent);
613 if ( pComponent !=
nullptr ) {
616 sprintf( tmp,
"%#.2f", pComponent->get_gain());
622 if ( pLayer !=
nullptr ) {
654 if (
m_pInstrument == pInstrumentList->get( nInstrumentNumber ) ||
655 nInstrumentNumber == -1 ) {
695 sprintf( tmp,
"%#.2f", newPitch);
702 sprintf( tmp,
"%#.2f", newPitch);
709 if ( fVal > 0.95f ) {
728 sprintf( tmp,
"%#.2f", fVal );
735 pLayer->set_gain( fVal );
742 sprintf( tmp,
"%#.2f", fVal );
746 pCompo->set_gain( fVal );
757 pLayer->set_pitch( fCoarse + fFine );
769 pLayer->set_pitch( fCoarse + fFine );
776 sprintf( tmp,
"%#.2f", fVal );
781 ERRORLOG(
"[rotaryChanged] unhandled rotary" );
808 auto pSample = pLayer->get_sample();
810 if( pSample !=
nullptr ) {
811 QString name = pSample->get_filepath();
826 if ( pLayer !=
nullptr ) {
827 auto pSample = pLayer->get_sample();
828 if ( pSample ==
nullptr ) {
831 QString name = pSample->get_filepath();
841 pHydrogen->getAudioEngine()->lock(
RIGHT_HERE );
845 if( pCompo !=
nullptr ) {
848 pHydrogen->setIsModified(
true );
854 int nNextLayerIndex = 0;
857 auto pLayer = pCompo->get_layer( n );
858 if( pLayer !=
nullptr ){
878 pHydrogen->getAudioEngine()->unlock();
890 QString sFilename =
"";
892 sPath = QDir::homePath();
901 if ( pComponent !=
nullptr ) {
904 if ( pLayer !=
nullptr ) {
905 auto pSample = pLayer->get_sample();
907 if ( pSample !=
nullptr ) {
908 if ( ! pSample->get_filepath().isEmpty() ) {
909 QFileInfo fileInfo( pSample->get_filepath() );
910 sPath = fileInfo.absoluteDir().absolutePath();
911 sFilename = fileInfo.absoluteFilePath();
922 QStringList filename;
923 filename <<
"false" <<
"false" <<
"";
925 if (pFileBrowser->exec() == QDialog::Accepted) {
931 if ( sFilename.isEmpty() ||
939 if ( filename[2].isEmpty() ) {
944 if ( filename[0] ==
"true" ){
949 int firstSelection = selectedLayer;
958 if (filename.size() > 2) {
960 for (
int i=2; i < filename.size(); ++i )
983 auto pLayer = pCompo->get_layer( selectedLayer );
985 if (pLayer !=
nullptr) {
987 pLayer->set_sample( pNewSample );
990 pLayer = std::make_shared<H2Core::InstrumentLayer>( pNewSample );
995 QString newFilename = filename[i].section(
'/', -1 );
996 newFilename.replace(
"." + newFilename.section(
'.', -1 ),
"");
1001 if ( filename[1] ==
"true" ){
1023 if ( pCompo ==
nullptr ) {
1030 auto pLayer = pCompo->get_layer( i );
1031 if ( pLayer !=
nullptr ) {
1040 float velocityrange = 1.0 / nLayers;
1044 auto pLayer = pCompo->get_layer( i );
1045 if ( pLayer !=
nullptr ) {
1046 pLayer->set_start_velocity( nLayer * velocityrange);
1047 pLayer->set_end_velocity( nLayer * velocityrange + velocityrange );
1058 if ( pSong ==
nullptr ) {
1062 if ( pComponent ==
nullptr ) {
1065 QString sOldName = pComponent->get_name();
1067 QString sNewName = QInputDialog::getText(
this,
"Hydrogen", tr(
"New component name" ), QLineEdit::Normal, sOldName, &bIsOkPressed );
1069 if ( bIsOkPressed && sOldName != sNewName ) {
1070 pComponent->set_name( sNewName );
1096 QString sNewName = QInputDialog::getText(
this,
"Hydrogen", tr(
"New instrument name" ), QLineEdit::Normal, sOldName, &bIsOkPressed );
1098 if ( bIsOkPressed && sNewName != sOldName ) {
1104 pHydrogen->setIsModified(
true );
1106#ifdef H2CORE_HAVE_JACK
1107 pHydrogen->getAudioEngine()->lock(
RIGHT_HERE );
1108 pHydrogen->renameJackPorts( pHydrogen->getSong() );
1109 pHydrogen->getAudioEngine()->unlock();
1130 if(pComponent && nLayer >= 0 ){
1131 auto pLayer = pComponent->get_layer( nLayer );
1133 if ( pLayer !=
nullptr ) {
1139 sprintf( tmp,
"%#.2f", pLayer->get_gain() );
1144 sprintf( tmp2,
"%#.2f", pComponent->get_gain());
1150 float fCoarsePitch = round( pLayer->get_pitch() );
1151 float fFinePitch = pLayer->get_pitch() - fCoarsePitch;
1159 .arg( fFinePitch * 100, 0,
'f', 0 ) );
1243 if ( fValue != 0.0 ) {
1274 for(
int i = 0; i <
itemsCompo.size(); i++ ) {
1285 bool bFoundFreeSlot =
true;
1287 for (
const auto& pComponent : *pDrumkitComponentList ) {
1288 if ( pComponent->get_id() == startingPoint ) {
1289 bFoundFreeSlot =
false;
1294 if(bFoundFreeSlot) {
1295 return startingPoint;
1303 QString sSelectedAction = pAction->text();
1307 if( sSelectedAction.compare(
"add") == 0 ) {
1310 QString sNewName = QInputDialog::getText(
this,
"Hydrogen", tr(
"Component name" ), QLineEdit::Normal,
"New Component", &bIsOkPressed );
1311 if ( bIsOkPressed ) {
1313 pHydrogen->
getSong()->getComponents()->push_back( pDrumkitComponent );
1327#ifdef H2CORE_HAVE_JACK
1336 else if( sSelectedAction.compare(
"delete") == 0 ) {
1337 auto pDrumkitComponents = pHydrogen->
getSong()->getComponents();
1339 if(pDrumkitComponents->size() == 1){
1340 ERRORLOG(
"There is just a single component remaining. This one can not be deleted." );
1346 auto pInstruments = pHydrogen->
getSong()->getInstrumentList();
1347 for (
int n = (
int )pInstruments->size() - 1; n >= 0; n-- ) {
1348 auto pInstrument = pInstruments->get( n );
1349 for(
int o = 0 ; o < pInstrument->get_components()->size() ; o++ ) {
1350 auto pInstrumentComponent = pInstrument->get_components()->at( o );
1351 if( pInstrumentComponent->get_drumkit_componentID() == pDrumkitComponent->get_id() ) {
1352 pInstrument->get_components()->erase( pInstrument->get_components()->begin() + o );;
1358 for (
int n = 0 ; n < pDrumkitComponents->size() ; n++ ) {
1359 auto pTmpDrumkitComponent = pDrumkitComponents->at( n );
1360 if( pTmpDrumkitComponent->get_id() == pDrumkitComponent->get_id() ) {
1361 pDrumkitComponents->erase( pDrumkitComponents->begin() + n );
1373 else if( sSelectedAction.compare(
"rename") == 0 ) {
1378 auto pDrumkitComponents = pHydrogen->
getSong()->getComponents();
1379 for (
const auto& pComponent : *pDrumkitComponents ) {
1380 if ( pComponent->get_name().compare( sSelectedAction ) == 0) {
1388 INFOLOG(
"Component needs to be added");
1391 pInstrComponent->set_gain( 1.0f );
1397#ifdef H2CORE_HAVE_JACK
1415 if ( selected == 0 ){
1418 else if ( selected == 1 ){
1421 else if ( selected == 2){
1452 setStyleSheet( QString(
"QLabel { background: %1 }" )
1453 .arg( pPref->getColorTheme()->m_windowColor.name() ) );
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
This dialog is used to preview audiofiles.
QString getSelectedDirectory()
QStringList getSelectedFiles()
Custom QLabel that emits a signal when clicked.
void setText(const QString &sNewText)
void unlock()
Mutex unlocking of the AudioEngine.
void lock(const char *file, unsigned int line, const char *function)
Mutex locking of the AudioEngine.
static EventQueue * get_instance()
Returns a pointer to the current EventQueue singleton stored in __instance.
void push_event(const EventType type, const int nValue)
Queues the next event into the EventQueue.
static bool dir_readable(const QString &path, bool silent=false)
returns true if the given path is a readable regular directory
void renameJackPorts(std::shared_ptr< Song > pSong)
Calls audioEngine_renameJackPorts() if Preferences::m_bJackTrackOuts is set to true.
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 int getMaxLayers()
float get_filter_resonance() const
get the filter resonance of the instrument
float get_filter_cutoff() const
get the filter cutoff of the instrument
int get_mute_group() const
get the mute group of the instrument
void set_name(const QString &name)
get the name of the instrument
void set_pitch_offset(float val)
set the pitch offset of the instrument
const QString & get_name() const
set the id of the instrument
float get_gain() const
get gain of the instrument
float get_pitch_offset() const
get the pitch offset of the instrument
bool get_apply_velocity() const
void set_sample_selection_alg(SampleSelectionAlgo selected_algo)
bool is_stop_notes() const
get the stop notes of the instrument
void set_filter_resonance(float val)
set the filter resonance of the instrument
int get_higher_cc() const
set the path of the related drumkit
void set_random_pitch_factor(float val)
set the random pitch factor of the instrument
void set_filter_active(bool active)
activate the filter of the instrument
int get_hihat_grp() const
std::shared_ptr< InstrumentComponent > get_component(int DrumkitComponentID)
void set_midi_out_channel(int channel)
set the midi out channel of the instrument
void set_apply_velocity(bool apply_velocity)
int get_midi_out_note() const
get the midi out note of the instrument
void set_stop_notes(bool stopnotes)
set the stop notes status of the instrument
void set_gain(float gain)
set gain of the instrument
void set_midi_out_note(int note)
set the midi out note of the instrument
void set_hihat_grp(int hihat_grp)
float get_random_pitch_factor() const
get the random pitch factor of the instrument
void set_mute_group(int group)
set the mute group of the instrument
std::shared_ptr< ADSR > get_adsr() const
get the ADSR of the instrument
void set_filter_cutoff(float val)
set the filter cutoff of the instrument
bool is_filter_active() const
get the status of the filter of the instrument
void set_higher_cc(int message)
SampleSelectionAlgo sample_selection_alg() const
void set_lower_cc(int message)
std::vector< std::shared_ptr< InstrumentComponent > > * get_components()
int get_midi_out_channel() const
get the midi out channel of the instrument
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
void setLastOpenLayerDirectory(QString sPath)
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
@ Colors
At least one of the colors has changed.
QString getLastOpenLayerDirectory() const
static std::shared_ptr< Sample > load(const QString &filepath, const License &license=License())
void addEventListener(EventListener *pListener)
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
void showSampleEditor(QString name, int mSelectedComponemt, int mSelectedLayer)
void selectLayer(int nLayer)
static InstrumentEditorPanel * get_instance()
Rotary * m_pRandomPitchRotary
void labelCompoClicked(ClickableLabel *pRef)
void onDropDownCompoClicked()
Rotary * m_pPitchFineRotary
ClickableLabel * m_pLayerPitchLbl
PixmapWidget * m_pInstrumentPropTop
LCDSpinBox * m_pMidiOutNoteLCD
Rotary * m_pPitchCoarseRotary
LCDDisplay * m_pInstrumentGainLCD
void sampleSelectionChanged(int)
LCDSpinBox * m_pHihatMaxRangeLCD
void selectLayer(int nLayer)
ClickableLabel * m_pGainLbl
ClickableLabel * m_pMidiOutNoteLbl
Button * m_buttonDropDownCompo
ClickableLabel * m_pLayerGainLbl
void showLayers(bool bShow)
Used by #Shotlist.
Button * m_pSampleEditorBtn
Rotary * m_pLayerGainRotary
ClickableLabel * m_pPitchFineLbl
Rotary * m_pSustainRotary
void removeLayerButtonClicked()
ClickableLabel * m_pMuteGroupLbl
ClickableLabel * m_pCompoNameLbl
void hihatGroupChanged(double fValue)
ClickableLabel * m_pReleaseLbl
Rotary * m_pReleaseRotary
double m_fPreviousMidiOutChannel
In order to allow for enumerations starting at 1 while using -1 to turn off the LCD.
LCDDisplay * m_pLayerPitchFineLCD
void loadLayerBtnClicked()
ClickableLabel * m_pHihatGroupLbl
Rotary * m_pCompoGainRotary
void filterActiveBtnClicked()
void labelClicked(ClickableLabel *pRef)
ClickableLabel * m_pNameLbl
PixmapWidget * m_pInstrumentProp
void muteGroupChanged(double fValue)
Rotary * m_pInstrumentGain
ClickableLabel * m_pCutoffLbl
Button * m_pFilterBypassBtn
ClickableLabel * m_pDecayLbl
void onPreferencesChanged(H2Core::Preferences::Changes changes)
void onIsApplyVelocityCheckBoxClicked(bool on)
void onIsStopNoteCheckBoxClicked(bool on)
ClickableLabel * m_pAttackLbl
void selectComponent(int nComponent)
QCheckBox * m_pApplyVelocity
void compoChangeAddDelete(QAction *)
ClickableLabel * m_pHihatMinRangeLbl
virtual void drumkitLoadedEvent() override
virtual void instrumentParametersChangedEvent(int) override
ClickableLabel * m_pCompoGainLbl
ClickableLabel * m_pLayerPitchFineLbl
LCDDisplay * m_pLayerPitchCoarseLCD
Rotary * m_pLayerPitchCoarseRotary
ClickableLabel * m_pIsStopNoteLbl
Button * m_pShowInstrumentBtn
ClickableLabel * m_pResonanceLbl
PixmapWidget * m_pLayerProp
ClickableLabel * m_pPitchCoarseLbl
WaveDisplay * m_pWaveDisplay
ClickableLabel * m_pApplyVelocityLbl
ClickableLabel * m_pLayerPitchCoarseLbl
virtual void selectedInstrumentChangedEvent() override
ClickableLabel * m_pSustainLbl
virtual void updateSongEvent(int) override
ClickableLabel * m_pHihatMaxRangeLbl
LCDSpinBox * m_pMidiOutChannelLCD
Button * m_pShowLayersBtn
void hihatMinRangeChanged(double fValue)
LayerPreview * m_pLayerPreview
Rotary * m_pLayerPitchFineRotary
static int findFreeDrumkitComponentId(int startingPoint=0)
InstrumentEditor(QWidget *parent)
Button * m_pRemoveLayerBtn
LCDSpinBox * m_pMuteGroupLCD
Rotary * m_pResonanceRotary
LCDDisplay * m_pLayerGainLCD
void hihatMaxRangeChanged(double fValue)
LCDCombo * m_sampleSelectionAlg
LCDDisplay * m_pCompoGainLCD
void rotaryChanged(WidgetWithInput *ref)
ClickableLabel * m_pPitchLbl
LCDSpinBox * m_pHihatMinRangeLCD
std::shared_ptr< H2Core::Instrument > m_pInstrument
QScrollArea * m_pLayerScrollArea
LCDSpinBox * m_pHihatGroupLCD
void midiOutNoteChanged(double fValue)
void waveDisplayDoubleClicked(QWidget *pRef)
void midiOutChannelChanged(double fValue)
QCheckBox * m_pIsStopNoteCheckBox
ClickableLabel * m_pMidiOutChannelLbl
ClickableLabel * m_pSampleSelectionLbl
ClickableLabel * m_pPitchRandomLbl
void addItem(const QString &text, const QVariant &userData=QVariant())
Non-interactive display used for both numerical values and the status display.
void setValue(double fValue)
void setSelectedLayer(int nSelectedLayer)
void set_selected_component(int SelectedComponent)
@ Center
The arc features a point at its upmost position.
@ Normal
The arc is of solid red color.
virtual void updateDisplay(std::shared_ptr< H2Core::InstrumentLayer > pLayer)
@ EVENT_SELECTED_INSTRUMENT_CHANGED