f@0: #pragma once f@0: f@3: /** f@3: * Enumeration of all the possible commands exchanged between audio thread and graphic thread. f@3: * f@3: */ f@0: enum class Command { f@0: // message carrying info about one chunk of recorder audio. f@0: WAVE_CHUNK, f@0: // message sent when a new recording starts. The gui resets the wave upon receiving it. f@0: WAVE_START, f@0: f@0: TRIGGER_UPDATE, f@0: TRIGGER_END, f@0: f@0: NOTE_ON, f@0: NOTE_OFF, f@0: f@0: LOOP_ON, f@0: LOOP_OFF f@0: }; f@0: f@3: /** Message sent from the audio thread to the graphic wave when a new wave is recorded. f@3: * f@3: * The graphic thread set the chunks of the wave to reflect the level of the recorded audio. f@3: * The algorithm takes the maximum and minimum value of a group of samples and this becomes the top and bottom of the samples. f@3: * It contains the inde f@3: * the cursor position when the grains are reset. f@3: */ f@0: struct RecordWaveMsg f@0: { f@3: Command cmd; // WAVE_CHUNK or WAVE_START f@0: std::size_t index; f@0: float arg1; f@0: float arg2; f@0: }; f@0: f@3: /** f@3: * Utility function to create a new RecordWaveMsg. f@3: */ f@0: inline RecordWaveMsg makeRecordWaveMsg( Command cmd, std::size_t index, float arg1, float arg2 ) f@0: { f@0: RecordWaveMsg msg; f@0: msg.cmd = cmd; f@0: msg.index = index; f@0: msg.arg1 = arg1; f@0: msg.arg2 = arg2; f@0: f@0: return msg; f@0: } f@0: f@3: /** f@3: * Message sent from the audio thread to the graphic thread when a new grain is triggered in the granular synthesizer. f@3: * This creates a new cursor that travels from the beginning to the end of the selection to graphically represent the evolution of the grain in time. f@3: * f@3: */ f@0: struct CursorTriggerMsg f@0: { f@3: Command cmd; // TRIGGER_UPDATE or TRIGGER_END f@0: int synthID; f@0: }; f@0: f@3: /** f@3: * Utility function to create a new CursorTriggerMsg. f@3: */ f@0: inline CursorTriggerMsg makeCursorTriggerMsg( Command cmd, std::uint8_t synthID ) f@0: { f@0: CursorTriggerMsg msg; f@0: f@0: msg.cmd = cmd; f@0: msg.synthID = synthID; f@0: f@0: return msg; f@0: } f@0: f@3: /** f@3: * Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer. f@3: */ f@0: struct NoteMsg f@0: { f@3: Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF f@0: int midiNote; f@0: double rate; f@0: }; f@0: f@3: /** f@3: * Utility function to create a new NoteMsg. f@3: */ f@0: inline NoteMsg makeNoteMsg( Command cmd, int midiNote, double rate ) f@0: { f@0: NoteMsg msg; f@0: f@0: msg.cmd = cmd; f@0: msg.midiNote = midiNote; f@0: msg.rate = rate; f@0: f@0: return msg; f@3: }