182
185
void loadChunkFromFile( const std::string & _file, int _len );
184
187
// restore settings chunk of plugin from file
185
void loadChunkFromPresetFile( const std::string & _file );
187
// restore settings chunk of plugin from file
188
void rotateProgram( int _len );
190
// Load names VST of presets/programs
191
void loadPrograms( int _len );
188
void loadPresetFile( const std::string & _file );
190
// sets given program index
191
void setProgram( int index );
193
// rotate current program by given offset
194
void rotateProgram( int offset );
196
// Load names of presets/programs
197
void getProgramNames();
193
199
// Save presets/programs
194
200
void savePreset( const std::string & _file );
401
419
sendMessage( IdLoadSettingsFromFile );
404
case IdLoadChunkFromPresetFile:
405
loadChunkFromPresetFile( _m.getString( 0 ) );
406
sendMessage( IdLoadChunkFromPresetFile );
409
case IdRotateProgram:
422
case IdLoadPresetFile:
423
loadPresetFile( _m.getString( 0 ) );
424
sendMessage( IdLoadPresetFile );
427
case IdVstSetProgram:
428
setProgram( _m.getInt( 0 ) );
429
sendMessage( IdVstSetProgram );
432
case IdVstCurrentProgram:
433
sendMessage( message( IdVstCurrentProgram ).addInt( m_currentProgram ) );
436
case IdVstRotateProgram:
410
437
rotateProgram( _m.getInt( 0 ) );
411
sendMessage( IdRotateProgram );
415
loadPrograms( _m.getInt( 0 ) );
416
sendMessage( IdLoadPrograms );
438
sendMessage( IdVstRotateProgram );
441
case IdVstProgramNames:
445
case IdSavePresetFile:
420
446
savePreset( _m.getString( 0 ) );
421
sendMessage( IdSavePreset );
447
sendMessage( IdSavePresetFile );
450
case IdVstSetParameter:
425
452
m_plugin->setParameter( m_plugin, _m.getInt( 0 ), _m.getFloat( 1 ) );
426
sendMessage( IdSetParameter );
454
sendMessage( IdVstSetParameter );
458
case IdVstIdleUpdate:
460
int newCurrentProgram = pluginDispatch( effGetProgram );
461
if( newCurrentProgram != m_currentProgram )
463
m_currentProgram = newCurrentProgram;
464
sendCurrentProgramName();
432
471
return RemotePluginClient::processMessage( _m );
771
const char * RemoteVstPlugin::presetName()
810
const char * RemoteVstPlugin::programName()
776
m_plugin->dispatcher(m_plugin, effGetProgramName, 0, 0, buf, 0);
814
memset( buf, 0, sizeof( buf ) );
816
pluginDispatch( effGetProgramName, 0, 0, buf );
825
void RemoteVstPlugin::sendCurrentProgramName()
828
sprintf( presName, "%d/%d: %s", pluginDispatch( effGetProgram ) + 1, m_plugin->numPrograms, programName() );
830
sendMessage( message( IdVstCurrentProgramName ).addString( presName ) );
784
835
void RemoteVstPlugin::getParameterDump()
786
char curPresName[30];
787
//VstParameterProperties vst_props;
788
message m( IdVstParameterDump );
789
m.addInt( m_plugin->numParams );
790
for( int i = 0; i < m_plugin->numParams; ++i )
792
//pluginDispatch( effGetParameterProperties, i, 0, &vst_props );
793
m_plugin->dispatcher(m_plugin, effGetParamName, i, 0, curPresName, 0);
795
m.addString( /*vst_props.shortLabel*/curPresName );
796
m.addFloat( m_plugin->getParameter( m_plugin, i ) );
839
message m( IdVstParameterDump );
840
m.addInt( m_plugin->numParams );
842
for( int i = 0; i < m_plugin->numParams; ++i )
845
memset( paramName, 0, sizeof( paramName ) );
846
pluginDispatchNoLocking( effGetParamName, i, 0, paramName );
847
paramName[sizeof(paramName)-1] = 0;
850
m.addString( paramName );
851
m.addFloat( m_plugin->getParameter( m_plugin, i ) );
872
void RemoteVstPlugin::rotateProgram( int _len )
875
if (isInitialized() == false) return;
877
currProgram = m_plugin->dispatcher(m_plugin, effGetProgram, 0, 0, 0, 0) + _len;
878
if (currProgram >= m_plugin->numPrograms) currProgram = m_plugin->numPrograms - 1;
879
if (currProgram < 0) currProgram = 0;
880
m_plugin->dispatcher(m_plugin, effSetProgram, 0, currProgram++, 0, 0);
882
m_plugin->dispatcher(m_plugin, effSetProgram, 0, _len - 2, 0, 0);
883
currProgram = _len - 1;
887
sprintf( presName, " %d/%d: %s", currProgram, m_plugin->numPrograms, presetName() );
889
sendMessage( message( IdVstPluginPresetString ).addString( presName ) );
895
void RemoteVstPlugin::loadPrograms( int _len )
932
void RemoteVstPlugin::setProgram( int program )
934
if( isInitialized() == false )
943
else if( program >= m_plugin->numPrograms )
945
program = m_plugin->numPrograms - 1;
947
pluginDispatch( effSetProgram, 0, program );
949
sendCurrentProgramName();
955
void RemoteVstPlugin::rotateProgram( int offset )
957
if( isInitialized() == false )
962
int newProgram = pluginDispatch( effGetProgram ) + offset;
968
else if( newProgram >= m_plugin->numPrograms )
970
newProgram = m_plugin->numPrograms - 1;
972
pluginDispatch( effSetProgram, 0, newProgram );
974
sendCurrentProgramName();
980
void RemoteVstPlugin::getProgramNames()
897
982
char presName[1024+256*30];
898
983
char curProgName[30];
899
984
if (isInitialized() == false) return;
900
bool progNameIndexed = (m_plugin->dispatcher(m_plugin, 29, 0, -1, curProgName, 0) == 1);
985
bool progNameIndexed = ( pluginDispatch( 29, 0, -1, curProgName ) == 1 );
902
987
if (m_plugin->numPrograms > 1) {
903
988
if (progNameIndexed) {
904
for (int i = 0; i< (m_plugin->numPrograms >= 256?256:m_plugin->numPrograms); i++) {
905
m_plugin->dispatcher(m_plugin, 29, i, -1, curProgName, 0);
989
for (int i = 0; i< (m_plugin->numPrograms >= 256?256:m_plugin->numPrograms); i++)
991
pluginDispatch( 29, i, -1, curProgName );
906
992
if (i == 0) sprintf( presName, "%s", curProgName );
907
993
else sprintf( presName + strlen(presName), "|%s", curProgName );
910
int currProgram = m_plugin->dispatcher(m_plugin, effGetProgram, 0, 0, 0, 0);
911
for (int i = 0; i< (m_plugin->numPrograms >= 256?256:m_plugin->numPrograms); i++) {
912
m_plugin->dispatcher(m_plugin, effSetProgram, 0, i, 0, 0);
913
if (i == 0) sprintf( presName, "%s", presetName() );
914
else sprintf( presName + strlen(presName), "|%s", presetName() );
998
int currProgram = pluginDispatch( effGetProgram );
999
for (int i = 0; i< (m_plugin->numPrograms >= 256?256:m_plugin->numPrograms); i++)
1001
pluginDispatch( effSetProgram, 0, i );
1002
if (i == 0) sprintf( presName, "%s", programName() );
1003
else sprintf( presName + strlen(presName), "|%s", programName() );
916
m_plugin->dispatcher(m_plugin, effSetProgram, 0, currProgram, 0, 0);
1005
pluginDispatch( effSetProgram, 0, currProgram );
918
} else sprintf( presName, "%s", presetName() );
920
sendMessage( message( IdVstPluginPresetsString ).addString( presName ) );
1007
} else sprintf( presName, "%s", programName() );
1009
presName[sizeof(presName)-1] = 0;
1011
sendMessage( message( IdVstProgramNames ).addString( presName ) );
950
1041
bool isPreset = _file.substr( _file.find_last_of( "." ) + 1 ) == "fxp";
951
1042
int presNameLen = _file.find_last_of( "/" ) + _file.find_last_of( "\\" ) + 2;
954
for (int i = 0; i < _file.length() - 4 - presNameLen; i++)
1046
for (size_t i = 0; i < _file.length() - 4 - presNameLen; i++)
955
1047
progName[i] = i < 23 ? _file[presNameLen + i] : 0;
956
m_plugin->dispatcher(m_plugin, 4, 0, 0, progName, 0);
957
} // m_plugin->dispatcher( m_plugin, effGetProgramName, 0, 0, progName, 0.0f );
1048
pluginDispatch( 4, 0, 0, progName );
959
chunk_size = m_plugin->dispatcher( m_plugin, 23, isPreset, 0, &data, false );
1051
chunk_size = pluginDispatch( 23, isPreset, 0, &data );
962
1054
chunk_size = m_plugin->numParams * sizeof( float );
963
1055
data = new char[ chunk_size ];
964
1056
unsigned int* toUIntArray = reinterpret_cast<unsigned int*>( data );
965
1058
for ( int i = 0; i < m_plugin->numParams; i++ )
967
1060
float value = m_plugin->getParameter( m_plugin, i );
968
1061
unsigned int * pValue = ( unsigned int * ) &value;
969
1062
toUIntArray[ i ] = endian_swap( *pValue );
971
1065
} else chunk_size = (((m_plugin->numParams * sizeof( float )) + 56)*m_plugin->numPrograms);
1010
1104
unsigned int* pValue,* toUIntArray = reinterpret_cast<unsigned int*>( data );
1012
1106
for (int j = 0; j < numPrograms; j++) {
1013
m_plugin->dispatcher(m_plugin, effSetProgram, 0, j, 0, 0);
1014
m_plugin->dispatcher(m_plugin, effGetProgramName, 0, 0, pBank->prgName, 0);
1107
pluginDispatch( effSetProgram, 0, j );
1108
pluginDispatch( effGetProgramName, 0, 0, pBank->prgName );
1015
1109
fwrite ( pBank, 1, 56, stream );
1016
1111
for ( int i = 0; i < m_plugin->numParams; i++ )
1018
1113
value = m_plugin->getParameter( m_plugin, i );
1019
1114
pValue = ( unsigned int * ) &value;
1020
1115
toUIntArray[ i ] = endian_swap( *pValue );
1022
1118
fwrite ( data, 1, chunk_size, stream );
1024
m_plugin->dispatcher(m_plugin, effSetProgram, 0, currProgram, 0, 0);
1120
pluginDispatch( effSetProgram, 0, currProgram );
1026
1122
fclose( stream );
1071
1167
if(_file.substr(_file.find_last_of(".") + 1) == "fxp") {
1072
1168
pBank->prgName[23] = 0;
1073
m_plugin->dispatcher(m_plugin, 4, 0, 0, pBank->prgName, 0);
1169
pluginDispatch( 4, 0, 0, pBank->prgName );
1074
1170
if(pBank->fxMagic != 0x6B437846)
1075
m_plugin->dispatcher(m_plugin, 24, 1, len, chunk, 0);
1171
pluginDispatch( 24, 1, len, chunk );
1077
1175
unsigned int* toUIntArray = reinterpret_cast<unsigned int*>( chunk );
1078
for (int i = 0; i < pBank->numPrograms; i++ ) {
1176
for (int i = 0; i < pBank->numPrograms; i++ )
1079
1178
toUInt = endian_swap( toUIntArray[ i ] );
1080
1179
pFloat = ( float* ) &toUInt;
1081
1180
m_plugin->setParameter( m_plugin, i, *pFloat );
1085
1185
if(pBank->fxMagic != 0x6B427846) {
1086
m_plugin->dispatcher(m_plugin, 24, 0, len, chunk, 0);
1186
pluginDispatch( 24, 0, len, chunk );
1088
1188
int numPrograms = pBank->numPrograms;
1089
1189
unsigned int * toUIntArray;
1090
int currProgram = m_plugin->dispatcher(m_plugin, effGetProgram, 0, 0, 0, 0);
1190
int currProgram = pluginDispatch( effGetProgram );
1091
1191
chunk = new char[ len = sizeof(float)*m_plugin->numParams ];
1092
1192
toUIntArray = reinterpret_cast<unsigned int *>( chunk );
1093
1194
for (int i =0; i < numPrograms; i++) {
1094
1195
fread (pBank, 1, 56, stream);
1095
1196
fread (chunk, len, 1, stream);
1096
m_plugin->dispatcher(m_plugin, effSetProgram, 0, i, 0, 0);
1197
pluginDispatch( effSetProgram, 0, i );
1097
1198
pBank->prgName[23] = 0;
1098
m_plugin->dispatcher(m_plugin, 4, 0, 0, pBank->prgName, 0);
1199
pluginDispatch( 4, 0, 0, pBank->prgName );
1099
1200
for (int j = 0; j < m_plugin->numParams; j++ ) {
1100
1201
toUInt = endian_swap( toUIntArray[ j ] );
1101
1202
pFloat = ( float* ) &toUInt;
1102
1203
m_plugin->setParameter( m_plugin, j, *pFloat );
1105
m_plugin->dispatcher(m_plugin, effSetProgram, 0, currProgram, 0, 0);
1207
pluginDispatch( effSetProgram, 0, currProgram );
1106
1208
fclose( stream );
1110
int currProgram = m_plugin->dispatcher(m_plugin, effGetProgram, 0, 0, 0, 0) + 1;
1111
sprintf( presName, " %d/%d: %s", currProgram, m_plugin->numPrograms, presetName() );
1113
sendMessage( message( IdVstPluginPresetString ).addString( presName ) );
1212
sendCurrentProgramName();
1115
1214
delete[] (unsigned int*)pLen;
1116
1215
delete[] (sBank*)pBank;