I'm trying to design a method for generating audio signals rapidly. I need this for electrophysiological experiments in which I will play tone sequences for the purpose of examining neuronal responses in the brain's auditory system.
I need to be able to quickly construct a novel sequence in which I can specify features of each tone (e.g. frequency, duration, amplitude, etc.), silent pauses (i.e. rests), and the sequence of tones and pauses.
I want to do this from the terminal using a simple sequence of codes. For instance, entering tone(440,2) rest(2) tone(880,1) rest(1) tone(880,1)
would generate a "song" that plays a 2-second sine wave tone at 440 Hz, then a 2-second rest, then a 1-second tone at 880 Hz, etc.
I have Python functions for producing tones and rests, but I don't know how to access and control them from the terminal for this purpose. After some reading, it seems like using textX or PyParsing might be good options, but I have no background in creating domain-specific languages or parsers, so I'm not sure. I've completed this textX tutorial and read this PyParsing description, but it's not yet clear how or whether I can use these methods for the rapid, terminal-based audio construction and playback that I need. Do you have any suggestions?
This would be an initial solution for textX:
You can also easily take your input recipe from external file by changing above
mm.model_from_str
tomm.model_from_file
.