f@5: /* f@5: f@5: Copyright (C) 2016 Queen Mary University of London f@5: Author: Fiore Martin f@5: f@5: This file is part of Collidoscope. f@5: f@5: Collidoscope is free software: you can redistribute it and/or modify f@5: it under the terms of the GNU General Public License as published by f@5: the Free Software Foundation, either version 3 of the License, or f@5: (at your option) any later version. f@5: f@5: This program is distributed in the hope that it will be useful, f@5: but WITHOUT ANY WARRANTY; without even the implied warranty of f@5: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the f@5: GNU General Public License for more details. f@5: f@5: You should have received a copy of the GNU General Public License f@5: along with this program. If not, see . f@5: */ f@5: 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@16: // new grain created f@0: TRIGGER_UPDATE, f@16: // synth became idle 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@16: * The graphic thread sets the chunks of the wave to reflect the level of the recorded audio. f@16: * The algorithm takes the maximum and minimum value of a group of samples and this becomes the top and bottom of the chunk. f@16: * The message carries also the index of the chunk it refers to 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: }