--- linuxsampler/trunk/src/network/lscp.y 2005/09/23 06:58:26 778 +++ linuxsampler/trunk/src/network/lscp.y 2006/12/15 21:40:27 973 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005 Christian Schoenebeck * + * Copyright (C) 2005, 2006 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -21,8 +21,12 @@ * MA 02111-1307 USA * ***************************************************************************/ -/* Note: don't forget to run 'make parser' after you changed this file, */ -/* otherwise the parser will not be regenerated! */ +/* CAUTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* */ +/* don't forget to run 'make parser' after you changed this file, */ +/* otherwise the parser will not be regenerated ! */ +/* */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ %{ @@ -68,10 +72,11 @@ %type char digit %type dotnum volume_value boolean -%type number sampler_channel instrument_index audio_channel_index device_index midi_input_channel_index midi_input_port_index -%type string text stringval digits param_val_list param_val filename engine_name command create_instruction destroy_instruction get_instruction list_instruction load_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type_name midi_input_type_name set_instruction subscribe_event unsubscribe_event +%type number sampler_channel instrument_index audio_channel_index device_index midi_input_channel_index midi_input_port_index midi_map midi_bank midi_prog +%type string text stringval digits param_val_list param_val filename map_name entry_name engine_name command add_instruction create_instruction destroy_instruction get_instruction list_instruction load_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type_name midi_input_type_name remove_instruction unmap_instruction set_instruction subscribe_event unsubscribe_event map_instruction reset_instruction clear_instruction %type buffer_size_type %type key_val_list +%type instr_load_mode %start input @@ -80,9 +85,10 @@ //TODO: return more meaningful error messages /* - The LSCP specification input file (Documentation/lscp.xml) is automatically - updated with this file using the scripts/update_grammar.pl script. Do not - modify or delete the GRAMMAR_BNF_BEGIN and GRAMMAR_BNF_END lines ! + The LSCP specification document input file (Documentation/lscp.xml) is + automatically updated with this file using the scripts/update_grammar.pl + script. Do not modify or delete the GRAMMAR_BNF_BEGIN and GRAMMAR_BNF_END + lines ! */ // GRAMMAR_BNF_BEGIN - do NOT delete or modify this line !!! @@ -104,22 +110,30 @@ | comment string ; -command : ADD SP CHANNEL { $$ = LSCPSERVER->AddChannel(); } +command : ADD SP add_instruction { $$ = $3; } + | MAP SP map_instruction { $$ = $3; } + | UNMAP SP unmap_instruction { $$ = $3; } | GET SP get_instruction { $$ = $3; } | CREATE SP create_instruction { $$ = $3; } | DESTROY SP destroy_instruction { $$ = $3; } | LIST SP list_instruction { $$ = $3; } | LOAD SP load_instruction { $$ = $3; } - | REMOVE SP CHANNEL SP sampler_channel { $$ = LSCPSERVER->RemoveChannel($5); } + | REMOVE SP remove_instruction { $$ = $3; } | SET SP set_instruction { $$ = $3; } | SUBSCRIBE SP subscribe_event { $$ = $3; } | UNSUBSCRIBE SP unsubscribe_event { $$ = $3; } | SELECT SP text { $$ = LSCPSERVER->QueryDatabase($3); } - | RESET SP CHANNEL SP sampler_channel { $$ = LSCPSERVER->ResetChannel($5); } + | RESET SP reset_instruction { $$ = $3; } + | CLEAR SP clear_instruction { $$ = $3; } | RESET { $$ = LSCPSERVER->ResetSampler(); } | QUIT { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; } ; +add_instruction : CHANNEL { $$ = LSCPSERVER->AddChannel(); } + | MIDI_INSTRUMENT_MAP { $$ = LSCPSERVER->AddMidiInstrumentMap(); } + | MIDI_INSTRUMENT_MAP SP map_name { $$ = LSCPSERVER->AddMidiInstrumentMap($3); } + ; + subscribe_event : CHANNEL_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_count); } | VOICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); } | STREAM_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); } @@ -138,6 +152,20 @@ | TOTAL_VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_voice_count); } ; +map_instruction : MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($3,$5,$7,$9,$11,$13,$15,MidiInstrumentMapper::VOID,""); } + | MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP instr_load_mode { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($3,$5,$7,$9,$11,$13,$15,$17,""); } + | MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP entry_name { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($3,$5,$7,$9,$11,$13,$15,MidiInstrumentMapper::VOID,$17); } + | MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP instr_load_mode SP entry_name { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($3,$5,$7,$9,$11,$13,$15,$17,$19); } + ; + +unmap_instruction : MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog { $$ = LSCPSERVER->RemoveMIDIInstrumentMapping($3,$5,$7); } + ; + +remove_instruction : CHANNEL SP sampler_channel { $$ = LSCPSERVER->RemoveChannel($3); } + | MIDI_INSTRUMENT_MAP SP midi_map { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3); } + | MIDI_INSTRUMENT_MAP SP ALL { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps(); } + ; + get_instruction : AVAILABLE_ENGINES { $$ = LSCPSERVER->GetAvailableEngines(); } | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->GetAvailableMidiInputDrivers(); } | MIDI_INPUT_DRIVER SP INFO SP string { $$ = LSCPSERVER->GetMidiInputDriverInfo($5); } @@ -164,6 +192,11 @@ | SERVER SP INFO { $$ = LSCPSERVER->GetServerInfo(); } | TOTAL_VOICE_COUNT { $$ = LSCPSERVER->GetTotalVoiceCount(); } | TOTAL_VOICE_COUNT_MAX { $$ = LSCPSERVER->GetTotalVoiceCountMax(); } + | MIDI_INSTRUMENTS SP midi_map { $$ = LSCPSERVER->GetMidiInstrumentMappings($3); } + | MIDI_INSTRUMENTS SP ALL { $$ = LSCPSERVER->GetAllMidiInstrumentMappings(); } + | MIDI_INSTRUMENT SP INFO SP midi_map SP midi_bank SP midi_prog { $$ = LSCPSERVER->GetMidiInstrumentMapping($5,$7,$9); } + | MIDI_INSTRUMENT_MAPS { $$ = LSCPSERVER->GetMidiInstrumentMaps(); } + | MIDI_INSTRUMENT_MAP SP INFO SP midi_map { $$ = LSCPSERVER->GetMidiInstrumentMap($5); } ; set_instruction : AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7); } @@ -171,6 +204,7 @@ | MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7); } | MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9); } | CHANNEL SP set_chan_instruction { $$ = $3; } + | MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7); } | ECHO SP boolean { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3); } ; @@ -180,6 +214,13 @@ | MIDI_INPUT_DEVICE SP string { $$ = LSCPSERVER->CreateMidiInputDevice($3); } ; +reset_instruction : CHANNEL SP sampler_channel { $$ = LSCPSERVER->ResetChannel($3); } + ; + +clear_instruction : MIDI_INSTRUMENTS SP midi_map { $$ = LSCPSERVER->ClearMidiInstrumentMappings($3); } + | MIDI_INSTRUMENTS SP ALL { $$ = LSCPSERVER->ClearAllMidiInstrumentMappings(); } + ; + destroy_instruction : AUDIO_OUTPUT_DEVICE SP number { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); } | MIDI_INPUT_DEVICE SP number { $$ = LSCPSERVER->DestroyMidiInputDevice($3); } ; @@ -199,6 +240,9 @@ | VOLUME SP sampler_channel SP volume_value { $$ = LSCPSERVER->SetVolume($5, $3); } | MUTE SP sampler_channel SP boolean { $$ = LSCPSERVER->SetChannelMute($5, $3); } | SOLO SP sampler_channel SP boolean { $$ = LSCPSERVER->SetChannelSolo($5, $3); } + | MIDI_INSTRUMENT_MAP SP sampler_channel SP midi_map { $$ = LSCPSERVER->SetChannelMap($3, $5); } + | MIDI_INSTRUMENT_MAP SP sampler_channel SP NONE { $$ = LSCPSERVER->SetChannelMap($3, -1); } + | MIDI_INSTRUMENT_MAP SP sampler_channel SP DEFAULT { $$ = LSCPSERVER->SetChannelMap($3, -2); } ; key_val_list : string '=' param_val_list { $$[$1] = $3; } @@ -215,6 +259,9 @@ | AVAILABLE_ENGINES { $$ = LSCPSERVER->ListAvailableEngines(); } | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableMidiInputDrivers(); } | AVAILABLE_AUDIO_OUTPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers(); } + | MIDI_INSTRUMENTS SP midi_map { $$ = LSCPSERVER->ListMidiInstrumentMappings($3); } + | MIDI_INSTRUMENTS SP ALL { $$ = LSCPSERVER->ListAllMidiInstrumentMappings(); } + | MIDI_INSTRUMENT_MAPS { $$ = LSCPSERVER->ListMidiInstrumentMaps(); } ; load_instr_args : filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); } @@ -224,6 +271,11 @@ load_engine_args : engine_name SP sampler_channel { $$ = LSCPSERVER->SetEngineType($1, $3); } ; +instr_load_mode : ON_DEMAND { $$ = MidiInstrumentMapper::ON_DEMAND; } + | ON_DEMAND_HOLD { $$ = MidiInstrumentMapper::ON_DEMAND_HOLD; } + | PERSISTENT { $$ = MidiInstrumentMapper::PERSISTENT; } + ; + device_index : number ; @@ -243,6 +295,15 @@ midi_input_type_name : string ; +midi_map : number + ; + +midi_bank : number + ; + +midi_prog : number + ; + volume_value : dotnum | number { $$ = $1; } ; @@ -259,13 +320,18 @@ filename : stringval ; +map_name : stringval + ; + +entry_name : stringval + ; + param_val_list : param_val | param_val_list','param_val { $$ = $1 + "," + $3; } ; param_val : string - | '\'' string '\'' { $$ = "\'" + $2 + "\'"; } // we eleminate encapsulating (apostrophe) limiters later - | '\"' string '\"' { $$ = "\"" + $2 + "\""; } // s.a. + | stringval | number { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } | dotnum { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } ; @@ -396,6 +462,15 @@ GET : 'G''E''T' ; +MAP : 'M''A''P' + ; + +UNMAP : 'U''N''M''A''P' + ; + +CLEAR : 'C''L''E''A''R' + ; + CREATE : 'C''R''E''A''T''E' ; @@ -411,6 +486,12 @@ ALL : 'A''L''L' ; +NONE : 'N''O''N''E' + ; + +DEFAULT : 'D''E''F''A''U''L''T' + ; + NON_MODAL : 'N''O''N''_''M''O''D''A''L' ; @@ -471,6 +552,15 @@ ENGINE : 'E' 'N' 'G' 'I' 'N' 'E' ; +ON_DEMAND : 'O''N''_''D''E''M''A''N''D' + ; + +ON_DEMAND_HOLD : 'O''N''_''D''E''M''A''N''D''_''H''O''L''D' + ; + +PERSISTENT : 'P''E''R''S''I''S''T''E''N''T' + ; + AUDIO_OUTPUT_DEVICE_PARAMETER : 'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E''_''P''A''R''A''M''E''T''E''R' ; @@ -513,6 +603,18 @@ MIDI_INPUT_DRIVER_PARAMETER : 'M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R''_''P''A''R''A''M''E''T''E''R' ; +MIDI_INSTRUMENT : 'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T' + ; + +MIDI_INSTRUMENTS : 'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''S' + ; + +MIDI_INSTRUMENT_MAP : 'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P' + ; + +MIDI_INSTRUMENT_MAPS : 'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P''S' + ; + MIDI_INPUT_DRIVER : 'M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R' ; @@ -552,6 +654,9 @@ MISCELLANEOUS : 'M''I''S''C''E''L''L''A''N''E''O''U''S' ; +NAME : 'N''A''M''E' + ; + ECHO : 'E''C''H''O' ;