--- linuxsampler/trunk/src/network/lscp.y 2004/08/22 14:46:47 225 +++ linuxsampler/trunk/src/network/lscp.y 2005/05/22 20:43:32 563 @@ -3,6 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * + * Copyright (C) 2005 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 * @@ -68,7 +69,7 @@ %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 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 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 buffer_size_type %type key_val_list @@ -85,7 +86,7 @@ line : /* epsilon (empty line ignored) */ { return LSCP_DONE; } | comment { return LSCP_DONE; } | command { LSCPSERVER->AnswerClient($1); return LSCP_DONE; } - | error { LSCPSERVER->AnswerClient("Err:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; } + | error { LSCPSERVER->AnswerClient("ERR:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; } ; comment : '#' @@ -105,25 +106,26 @@ | 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 { $$ = LSCPSERVER->ResetSampler(); } | QUIT { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; } ; -subscribe_event : CHANNELS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channels); } - | VOICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); } - | STREAM_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); } - | BUFFER_FILL { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); } - | INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_info); } - | MISCELLANEOUS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); } +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); } + | BUFFER_FILL { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); } + | CHANNEL_INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_info); } + | MISCELLANEOUS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); } ; -unsubscribe_event : CHANNELS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channels); } - | VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); } - | STREAM_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); } - | BUFFER_FILL { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); } - | INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_info); } - | MISCELLANEOUS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); } +unsubscribe_event : CHANNEL_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_count); } + | VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); } + | STREAM_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); } + | BUFFER_FILL { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); } + | CHANNEL_INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_info); } + | MISCELLANEOUS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); } ; get_instruction : AVAILABLE_ENGINES { $$ = LSCPSERVER->GetAvailableEngines(); } @@ -149,14 +151,15 @@ | CHANNEL SP STREAM_COUNT SP sampler_channel { $$ = LSCPSERVER->GetStreamCount($5); } | CHANNEL SP VOICE_COUNT SP sampler_channel { $$ = LSCPSERVER->GetVoiceCount($5); } | ENGINE SP INFO SP engine_name { $$ = LSCPSERVER->GetEngineInfo($5); } + | SERVER SP INFO { $$ = LSCPSERVER->GetServerInfo(); } ; -set_instruction : AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7); } - | AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); } - | MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7); } - | MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9); } - | CHANNEL SP set_chan_instruction { $$ = $3; } - | ECHO SP boolean { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3); } +set_instruction : AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7); } + | AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); } + | 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; } + | ECHO SP boolean { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3); } ; create_instruction : AUDIO_OUTPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); } @@ -184,24 +187,27 @@ | VOLUME SP sampler_channel SP volume_value { $$ = LSCPSERVER->SetVolume($5, $3); } ; -key_val_list : string '=' param_val { $$[$1] = $3; } - | key_val_list SP string '=' param_val { $$ = $1; $$[$3] = $5; } +key_val_list : string '=' param_val_list { $$[$1] = $3; } + | key_val_list SP string '=' param_val_list { $$ = $1; $$[$3] = $5; } ; buffer_size_type : BYTES { $$ = fill_response_bytes; } | PERCENTAGE { $$ = fill_response_percentage; } ; -list_instruction : AUDIO_OUTPUT_DEVICES { $$ = LSCPSERVER->GetAudioOutputDevices(); } - | MIDI_INPUT_DEVICES { $$ = LSCPSERVER->GetMidiInputDevices(); } - | CHANNELS { $$ = LSCPSERVER->ListChannels(); } +list_instruction : AUDIO_OUTPUT_DEVICES { $$ = LSCPSERVER->GetAudioOutputDevices(); } + | MIDI_INPUT_DEVICES { $$ = LSCPSERVER->GetMidiInputDevices(); } + | CHANNELS { $$ = LSCPSERVER->ListChannels(); } + | AVAILABLE_ENGINES { $$ = LSCPSERVER->ListAvailableEngines(); } + | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableMidiInputDrivers(); } + | AVAILABLE_AUDIO_OUTPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers(); } ; load_instr_args : filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); } | NON_MODAL SP filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true); } ; -load_engine_args : engine_name SP sampler_channel { $$ = LSCPSERVER->LoadEngine($1, $3); } +load_engine_args : engine_name SP sampler_channel { $$ = LSCPSERVER->SetEngineType($1, $3); } ; device_index : number @@ -217,6 +223,7 @@ ; midi_input_channel_index : number + | ALL { $$ = 16; } ; midi_input_type_name : string @@ -238,10 +245,15 @@ filename : stringval ; +param_val_list : param_val + | param_val_list','param_val { $$ = $1 + "," + $3; } + ; + param_val : string - | stringval - | number { std::stringstream ss; ss << $1; $$ = ss.str(); } - | dotnum { std::stringstream ss; ss << $1; $$ = ss.str(); } + | '\'' string '\'' { $$ = "\'" + $2 + "\'"; } // we eleminate encapsulating (apostrophe) limiters later + | '\"' string '\"' { $$ = "\"" + $2 + "\""; } // s.a. + | number { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } + | dotnum { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } ; @@ -291,7 +303,7 @@ char : 'A' { $$ = 'A'; } | 'B' { $$ = 'B'; } | 'C' { $$ = 'C'; } | 'D' { $$ = 'D'; } | 'E' { $$ = 'E'; } | 'F' { $$ = 'F'; } | 'G' { $$ = 'G'; } | 'H' { $$ = 'H'; } | 'I' { $$ = 'I'; } | 'J' { $$ = 'J'; } | 'K' { $$ = 'K'; } | 'L' { $$ = 'L'; } | 'M' { $$ = 'M'; } | 'N' { $$ = 'N'; } | 'O' { $$ = 'O'; } | 'P' { $$ = 'P'; } | 'Q' { $$ = 'Q'; } | 'R' { $$ = 'R'; } | 'S' { $$ = 'S'; } | 'T' { $$ = 'T'; } | 'U' { $$ = 'U'; } | 'V' { $$ = 'V'; } | 'W' { $$ = 'W'; } | 'X' { $$ = 'X'; } | 'Y' { $$ = 'Y'; } | 'Z' { $$ = 'Z'; } | 'a' { $$ = 'a'; } | 'b' { $$ = 'b'; } | 'c' { $$ = 'c'; } | 'd' { $$ = 'd'; } | 'e' { $$ = 'e'; } | 'f' { $$ = 'f'; } | 'g' { $$ = 'g'; } | 'h' { $$ = 'h'; } | 'i' { $$ = 'i'; } | 'j' { $$ = 'j'; } | 'k' { $$ = 'k'; } | 'l' { $$ = 'l'; } | 'm' { $$ = 'm'; } | 'n' { $$ = 'n'; } | 'o' { $$ = 'o'; } | 'p' { $$ = 'p'; } | 'q' { $$ = 'q'; } | 'r' { $$ = 'r'; } | 's' { $$ = 's'; } | 't' { $$ = 't'; } | 'u' { $$ = 'u'; } | 'v' { $$ = 'v'; } | 'w' { $$ = 'w'; } | 'x' { $$ = 'x'; } | 'y' { $$ = 'y'; } | 'z' { $$ = 'z'; } | '0' { $$ = '0'; } | '1' { $$ = '1'; } | '2' { $$ = '2'; } | '3' { $$ = '3'; } | '4' { $$ = '4'; } | '5' { $$ = '5'; } | '6' { $$ = '6'; } | '7' { $$ = '7'; } | '8' { $$ = '8'; } | '9' { $$ = '9'; } - | '!' { $$ = '!'; } | '#' { $$ = '#'; } | '$' { $$ = '$'; } | '%' { $$ = '%'; } | '&' { $$ = '&'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } | '*' { $$ = '*'; } | '+' { $$ = '+'; } | '-' { $$ = '-'; } | '.' { $$ = '.'; } | '/' { $$ = '/'; } + | '!' { $$ = '!'; } | '#' { $$ = '#'; } | '$' { $$ = '$'; } | '%' { $$ = '%'; } | '&' { $$ = '&'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } | '*' { $$ = '*'; } | '+' { $$ = '+'; } | '-' { $$ = '-'; } | '.' { $$ = '.'; } | ',' { $$ = ','; } | '/' { $$ = '/'; } | ':' { $$ = ':'; } | ';' { $$ = ';'; } | '<' { $$ = '<'; } | '=' { $$ = '='; } | '>' { $$ = '>'; } | '?' { $$ = '?'; } | '@' { $$ = '@'; } | '[' { $$ = '['; } | '\\' { $$ = '\\'; } | ']' { $$ = ']'; } | '^' { $$ = '^'; } | '_' { $$ = '_'; } | '{' { $$ = '{'; } | '|' { $$ = '|'; } | '}' { $$ = '}'; } | '~' { $$ = '~'; } @@ -380,6 +392,9 @@ LOAD : 'L''O''A''D' ; +ALL : 'A''L''L' + ; + NON_MODAL : 'N''O''N''_''M''O''D''A''L' ; @@ -395,6 +410,9 @@ UNSUBSCRIBE : 'U''N''S''U''B''S''C''R''I''B''E' ; +SELECT : 'S''E''L''E''C''T' + ; + CHANNEL : 'C''H''A''N''N''E''L' ; @@ -410,6 +428,12 @@ INFO : 'I''N''F''O' ; +CHANNEL_COUNT : 'C''H''A''N''N''E''L''_''C''O''U''N''T' + ; + +CHANNEL_INFO : 'C''H''A''N''N''E''L''_''I''N''F''O' + ; + BUFFER_FILL : 'B''U''F''F''E''R''_''F''I''L''L' ; @@ -482,6 +506,9 @@ MIDI_INPUT : 'M''I''D''I''_''I''N''P''U''T' ; +SERVER : 'S''E''R''V''E''R' + ; + VOLUME : 'V''O''L''U''M''E' ;