Skip to content

Commit

Permalink
Probability 2.0: Add MIDI actions for humanize time & velocity, swing…
Browse files Browse the repository at this point in the history
… and fill value & randomize
  • Loading branch information
elpescado committed Oct 8, 2018
1 parent d3b8905 commit 888ffdb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/include/hydrogen/midi_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class MidiActionManager : public H2Core::Object
bool redo_action(Action * , H2Core::Hydrogen * , targeted_element );
bool gain_level_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool pitch_level_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool humanize_velocity_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool humanize_time_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool swing_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool fill_value_absolute(Action * , H2Core::Hydrogen * , targeted_element );
bool fill_randomize_absolute(Action * , H2Core::Hydrogen * , targeted_element );

QStringList eventList;

Expand Down
47 changes: 47 additions & 0 deletions src/core/src/midi_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ MidiActionManager::MidiActionManager() : Object( __class_name ) {
actionMap.insert(make_pair("MASTER_VOLUME_ABSOLUTE", make_pair(&MidiActionManager::master_volume_absolute, empty)));
actionMap.insert(make_pair("STRIP_VOLUME_RELATIVE", make_pair(&MidiActionManager::strip_volume_relative, empty)));
actionMap.insert(make_pair("STRIP_VOLUME_ABSOLUTE", make_pair(&MidiActionManager::strip_volume_absolute, empty)));

actionMap.insert(make_pair("HUMANIZE_VELOCITY_ABSOLUTE", make_pair(&MidiActionManager::humanize_velocity_absolute, empty)));
actionMap.insert(make_pair("HUMANIZE_TIME_ABSOLUTE", make_pair(&MidiActionManager::humanize_time_absolute, empty)));
actionMap.insert(make_pair("SWING_ABSOLUTE", make_pair(&MidiActionManager::swing_absolute, empty)));
actionMap.insert(make_pair("FILL_VALUE_ABSOLUTE", make_pair(&MidiActionManager::fill_value_absolute, empty)));
actionMap.insert(make_pair("FILL_RANDOMIZE_ABSOLUTE", make_pair(&MidiActionManager::fill_randomize_absolute, empty)));

for(int i = 0; i < MAX_FX; ++i) {
targeted_element effect = {i,0};
ostringstream toChar;
Expand Down Expand Up @@ -438,6 +445,46 @@ bool MidiActionManager::master_volume_absolute(Action * pAction, Hydrogen* pEngi
return true;
}

bool MidiActionManager::humanize_velocity_absolute(Action * pAction, H2Core::Hydrogen* pEngine , targeted_element ) {
bool ok;
int value = pAction->getParameter2().toInt(&ok,10);

Song *song = pEngine->getSong();
song->set_humanize_velocity_value( value / 127.0 );
}

bool MidiActionManager::humanize_time_absolute(Action *pAction , H2Core::Hydrogen* pEngine , targeted_element ) {
bool ok;
int value = pAction->getParameter2().toInt(&ok,10);

Song *song = pEngine->getSong();
song->set_humanize_time_value( value / 127.0 );
}

bool MidiActionManager::swing_absolute(Action *pAction , H2Core::Hydrogen* pEngine , targeted_element ) {
bool ok;
int value = pAction->getParameter2().toInt(&ok,10);

Song *song = pEngine->getSong();
song->set_swing_factor( value / 127.0 );
}

bool MidiActionManager::fill_value_absolute(Action *pAction , H2Core::Hydrogen* pEngine , targeted_element ) {
bool ok;
int value = pAction->getParameter2().toInt(&ok,10);

Song *song = pEngine->getSong();
song->set_fill_value( value / 127.0 );
}

bool MidiActionManager::fill_randomize_absolute(Action *pAction , H2Core::Hydrogen* pEngine , targeted_element ) {
bool ok;
int value = pAction->getParameter2().toInt(&ok,10);

Song *song = pEngine->getSong();
song->set_fill_randomize( value / 127.0 );
}

bool MidiActionManager::master_volume_relative(Action * pAction, Hydrogen* pEngine, targeted_element ) {
//increments/decrements the volume of the whole song

Expand Down
5 changes: 5 additions & 0 deletions src/gui/src/Mixer/MixerLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,22 +688,27 @@ MasterMixerLine::MasterMixerLine(QWidget* parent)
m_pHumanizeVelocityRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Humanize velocity" ), false, false );
m_pHumanizeVelocityRotary->move( 74, 88 -64 );
connect( m_pHumanizeVelocityRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
m_pHumanizeVelocityRotary->setAction( new Action("HUMANIZE_VELOCITY_ABSOLUTE") );

m_pHumanizeTimeRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Humanize time" ), false, false );
m_pHumanizeTimeRotary->move( 74, 125 -64);
connect( m_pHumanizeTimeRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
m_pHumanizeTimeRotary->setAction( new Action("HUMANIZE_TIME_ABSOLUTE") );

m_pSwingRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Swing" ), false, false );
m_pSwingRotary->move( 74, 162 -64);
connect( m_pSwingRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
m_pSwingRotary->setAction( new Action("SWING_ABSOLUTE") );

m_pFillValueRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Fill" ), false, false );
m_pFillValueRotary->move( 74, 162 );
connect( m_pFillValueRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
m_pFillValueRotary->setAction( new Action("FILL_VALUE_ABSOLUTE") );

m_pFillRandomizeRotary = new Rotary( this, Rotary::TYPE_NORMAL, trUtf8( "Randomize" ), false, false );
m_pFillRandomizeRotary->move( 74, 162 +64);
connect( m_pFillRandomizeRotary, SIGNAL( valueChanged(Rotary*) ), this, SLOT( rotaryChanged(Rotary*) ) );
m_pFillRandomizeRotary->setAction( new Action("FILL_RANDOMIZE_ABSOLUTE") );

// Mute btn
m_pMuteBtn = new ToggleButton(
Expand Down

0 comments on commit 888ffdb

Please sign in to comment.