Hi,
I've done simple patch for handling playlist via MIDI. For my purpose I use it
for precisely select song to play live (via CC). In my M-Audio Axiom I can set
fixed MIDI CC value to buttons.
Meantime I have two question:
1) I want to add support for playlist in h2cli. Please tell me it is enough to
just call
LocalFileMng::loadPlayList
?
2) Currently Program Change messages are restricted to pattern switching , will
be OK for you to add support for mapping this messages ? I imagine scenario
where I could load playlist in h2cli and change songs via Program Change
messages - this is actually my long term goal ;-)
Best Regards
Xj
diff --git a/src/core/src/midi_action.cpp b/src/core/src/midi_action.cpp
index d1cca6b..46a3353 100644
--- a/src/core/src/midi_action.cpp
+++ b/src/core/src/midi_action.cpp
@@ -38,7 +38,7 @@
using namespace H2Core;
-/* Helperfunction */
+/* Helperfunctions */
bool setAbsoluteFXLevel( int nLine, int fx_channel , int fx_param)
{
@@ -64,6 +64,16 @@ bool setAbsoluteFXLevel( int nLine, int fx_channel , int fx_param)
}
+bool setSong( int songnumber ) {
+ Hydrogen *pEngine = Hydrogen::get_instance();
+
+ int asn = Playlist::get_instance()->getActiveSongNumber();
+ if(asn != songnumber && songnumber >= 0 && songnumber <= pEngine->m_PlayList.size()-1){
+ Playlist::get_instance()->setNextSongByNumber( songnumber );
+ }
+ return true;
+}
+
/**
* @class MidiAction
*
@@ -162,6 +172,7 @@ MidiActionManager::MidiActionManager() : Object( __class_name )
<< "PAN_ABSOLUTE"
<< "BEATCOUNTER"
<< "TAP_TEMPO"
+ << "PLAYLIST_SONG"
<< "PLAYLIST_NEXT_SONG"
<< "PLAYLIST_PREV_SONG"
<< "TOGGLE_METRONOME"
@@ -196,13 +207,10 @@ void MidiActionManager::create_instance()
}
}
-
/**
* The handleAction method is the heard of the MidiActionManager class.
* It executes the operations that are needed to carry the desired action.
*/
-
-
bool MidiActionManager::handleAction( MidiAction * pAction ){
Hydrogen *pEngine = Hydrogen::get_instance();
@@ -247,7 +255,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
return true;
}
-
if( sActionString == "PAUSE" )
{
pEngine->sequencer_stop();
@@ -354,9 +361,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
return true;
}
-
-
-
if( sActionString == "EFFECT1_LEVEL_ABSOLUTE" ){
bool ok;
int nLine = pAction->getParameter1().toInt(&ok,10);
@@ -385,10 +389,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
setAbsoluteFXLevel( nLine, 3 , fx_param );
}
-
-
-
-
if( sActionString == "MASTER_VOLUME_RELATIVE" ){
//increments/decrements the volume of the whole song
@@ -414,8 +414,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
}
-
-
if( sActionString == "MASTER_VOLUME_ABSOLUTE" ){
//sets the volume of a master output to a given level (percentage)
@@ -435,8 +433,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
}
-
-
if( sActionString == "STRIP_VOLUME_RELATIVE" ){
//increments/decrements the volume of one mixer strip
@@ -495,12 +491,10 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine);
}
-
if( sActionString == "PAN_ABSOLUTE" ){
// sets the absolute panning of a given mixer channel
-
bool ok;
int nLine = pAction->getParameter1().toInt(&ok,10);
int pan_param = pAction->getParameter2().toInt(&ok,10);
@@ -558,12 +552,10 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
// changes the panning of a given mixer channel
// this is useful if the panning is set by a rotary control knob
-
bool ok;
int nLine = pAction->getParameter1().toInt(&ok,10);
int pan_param = pAction->getParameter2().toInt(&ok,10);
-
float pan_L;
float pan_R;
@@ -615,7 +607,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
return true;
}
-
if( sActionString == "BPM_CC_RELATIVE" ){
/*
* increments/decrements the BPM
@@ -700,7 +691,6 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
return true;
}
-
if( sActionString == "BPM_INCR" ){
AudioEngine::get_instance()->lock( RIGHT_HERE );
@@ -748,20 +738,20 @@ bool MidiActionManager::handleAction( MidiAction * pAction ){
return true;
}
+ if( sActionString == "PLAYLIST_SONG"){
+ bool ok;
+ int songnumber = pAction->getParameter2().toInt(&ok,10);
+ return setSong( songnumber );
+ }
+
if( sActionString == "PLAYLIST_NEXT_SONG"){
int songnumber = Playlist::get_instance()->getActiveSongNumber();
- if(songnumber+1 >= 0 && songnumber+1 <= pEngine->m_PlayList.size()-1){
- Playlist::get_instance()->setNextSongByNumber( songnumber + 1 );
- }
- return true;
+ return setSong( ++songnumber );
}
if( sActionString == "PLAYLIST_PREV_SONG"){
int songnumber = Playlist::get_instance()->getActiveSongNumber();
- if(songnumber-1 >= 0 && songnumber-1 <= pEngine->m_PlayList.size()-1){
- Playlist::get_instance()->setNextSongByNumber( songnumber - 1 );
- }
- return true;
+ return setSong( --songnumber );
}
if( sActionString == "RECORD_READY"){
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel