40 , __hihat_cc_openess ( 127 )
59 bool bIsChannelValid =
true;
64 bIsChannelValid =
false;
76 bIsChannelValid =
true;
79 if ( !bIsChannelValid) {
86 ERRORLOG(
"No song loaded, skipping note" );
118 auto pAction = std::make_shared<Action>(
"PLAY");
124 auto pAction = std::make_shared<Action>(
"PLAY");
130 auto pAction = std::make_shared<Action>(
"PAUSE");
144 ERRORLOG( QString(
"MIDI message of type [%1] is not supported by Hydrogen" )
153 ERRORLOG( QString(
"unhandled midi message type: %1 (%2)" )
154 .arg(
static_cast<int>( msg.
m_type ) )
170 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
171 auto pNewAction = std::make_shared<Action>( ppAction );
172 pNewAction->setValue( QString::number( msg.
m_nData2 ) );
191 for (
const auto& ppAction : pMidiMap->
getPCActions() ) {
192 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
193 auto pNewAction = std::make_shared<Action>( ppAction );
194 pNewAction->setValue( QString::number( msg.
m_nData1 ) );
208 float fVelocity = msg.
m_nData2 / 127.0;
210 if ( fVelocity == 0 ) {
223 bool bActionSuccess =
false;
225 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
226 auto pNewAction = std::make_shared<Action>( ppAction );
227 pNewAction->setValue( QString::number( msg.
m_nData2 ) );
229 bActionSuccess =
true;
234 if ( bActionSuccess && pPref->m_bMidiDiscardNoteAfterAction ) {
238 static const float fPan = 0.f;
240 int nInstrument = nNote - 36;
241 auto pInstrList = pHydrogen->
getSong()->getInstrumentList();
242 std::shared_ptr<Instrument> pInstr =
nullptr;
244 if ( pPref->__playselectedinstrument ){
248 else if ( pPref->m_bMidiFixedMapping ){
249 pInstr = pInstrList->findMidiNote( nNote );
250 nInstrument = pInstrList->index( pInstr );
253 if( nInstrument < 0 || nInstrument >= pInstrList->size()) {
254 WARNINGLOG( QString(
"Instrument number [%1] - derived from note [%2] - out of bound note [%3,%4]" )
255 .arg( nInstrument ).arg( nNote )
256 .arg( 0 ).arg( pInstrList->size() ) );
259 pInstr = pInstrList->get(
static_cast<uint
>(nInstrument) );
262 if( pInstr ==
nullptr ) {
263 WARNINGLOG( QString(
"Can't find corresponding Instrument for note %1" ).arg( nNote ));
272 if ( pInstr !=
nullptr &&
273 pInstr->get_hihat_grp() >= 0 &&
274 ( __hihat_cc_openess < pInstr->get_lower_cc() ||
277 for (
int i = 0; i <= pInstrList->size(); i++ ) {
278 auto instr_contestant = pInstrList->get( i );
279 if ( instr_contestant !=
nullptr &&
280 pInstr->get_hihat_grp() == instr_contestant->get_hihat_grp() &&
282 __hihat_cc_openess <= instr_contestant->get_higher_cc() ) {
290 pHydrogen->
addRealtimeNote( nInstrument, fVelocity, fPan,
false, nNote );
313 auto pInstrList = pHydrogen->
getSong()->getInstrumentList();
316 int nInstrument = nNote - 36;
317 std::shared_ptr<Instrument> pInstr =
nullptr;
324 pInstr = pInstrList->findMidiNote( nNote );
325 nInstrument = pInstrList->index( pInstr );
328 if( nInstrument < 0 || nInstrument >= pInstrList->size()) {
329 WARNINGLOG( QString(
"Instrument number [%1] - derived from note [%2] - out of bound note [%3,%4]" )
330 .arg( nInstrument ).arg( nNote )
331 .arg( 0 ).arg( pInstrList->size() ) );
334 pInstr = pInstrList->get( nInstrument );
337 if( pInstr ==
nullptr ) {
338 WARNINGLOG( QString(
"Can't find corresponding Instrument for note %1" ).arg( nNote ));
422 INFOLOG( QString(
"MIDI Machine Control command: [%1]" )
431 WARNINGLOG(
"Unknown MIDI Machine Control (MMC) Command" );
436 WARNINGLOG(
"MMC GOTO Message not implemented yet" );
447 WARNINGLOG( QString(
"Unsupported SysEx message: [%1]" )
@ Playing
Transport is rolling.
bool locateToColumn(int nPatternGroup)
Relocates transport to the beginning of a particular column/Pattern group.
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.
void setLastMidiEventParameter(int nParam)
void addRealtimeNote(int instrument, float velocity, float fPan=0.0f, bool noteoff=false, int msg1=0)
std::shared_ptr< Song > getSong() const
Get the current song.
int getSelectedInstrumentNumber() const
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
AudioEngine * getAudioEngine() const
void setLastMidiEvent(MidiMessage::Event event)
CoreActionController * getCoreActionController() const
QString toQString(const QString &sPrefix="", bool bShort=true) const
Formatted string version for debugging purposes.
Event
Subset of incoming MIDI events that will be handled by Hydrogen.
static QString TypeToQString(MidiMessageType type)
@ POLYPHONIC_KEY_PRESSURE
std::vector< unsigned char > m_sysexData
static QString EventToQString(Event event)
Manager for User Preferences File (singleton)
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
The MidiActionManager cares for the execution of MidiActions.
bool handleAction(std::shared_ptr< Action > action)
The handleAction method is the heart of the MidiActionManager class.
static MidiActionManager * get_instance()
Returns a pointer to the current MidiActionManager singleton stored in __instance.
bool handleActions(std::vector< std::shared_ptr< Action > > actions)
Handles multiple actions at once and calls handleAction() on them.
The MidiMap maps MidiActions to MidiEvents.
std::vector< std::shared_ptr< Action > > getCCActions(int nParameter)
Returns the cc action which was linked to the given event.
std::vector< std::shared_ptr< Action > > getPCActions() const
Returns the pc action which was linked to the given event.
static MidiMap * get_instance()
Returns a pointer to the current MidiMap singleton stored in __instance.
std::vector< std::shared_ptr< Action > > getNoteActions(int nNote)
Returns all note actions which are linked to the given event.
std::vector< std::shared_ptr< Action > > getMMCActions(QString sEventString)
Returns all MMC actions which are linked to the given event.