To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / Messages.h @ 5:75b744078d66
History | View | Annotate | Download (2.99 KB)
| 1 | 5:75b744078d66 | f | /*
|
|---|---|---|---|
| 2 | |||
| 3 | Copyright (C) 2016 Queen Mary University of London
|
||
| 4 | Author: Fiore Martin
|
||
| 5 | |||
| 6 | This file is part of Collidoscope.
|
||
| 7 | |||
| 8 | Collidoscope is free software: you can redistribute it and/or modify
|
||
| 9 | it under the terms of the GNU General Public License as published by
|
||
| 10 | the Free Software Foundation, either version 3 of the License, or
|
||
| 11 | (at your option) any later version.
|
||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful,
|
||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 16 | GNU General Public License for more details.
|
||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License
|
||
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
| 20 | */
|
||
| 21 | |||
| 22 | 0:02467299402e | f | #pragma once
|
| 23 | |||
| 24 | 3:7fb593d53361 | f | /**
|
| 25 | * Enumeration of all the possible commands exchanged between audio thread and graphic thread.
|
||
| 26 | *
|
||
| 27 | */
|
||
| 28 | 0:02467299402e | f | enum class Command {
|
| 29 | // message carrying info about one chunk of recorder audio.
|
||
| 30 | WAVE_CHUNK, |
||
| 31 | // message sent when a new recording starts. The gui resets the wave upon receiving it.
|
||
| 32 | WAVE_START, |
||
| 33 | |||
| 34 | TRIGGER_UPDATE, |
||
| 35 | TRIGGER_END, |
||
| 36 | |||
| 37 | NOTE_ON, |
||
| 38 | NOTE_OFF, |
||
| 39 | |||
| 40 | LOOP_ON, |
||
| 41 | LOOP_OFF |
||
| 42 | }; |
||
| 43 | |||
| 44 | 3:7fb593d53361 | f | /** Message sent from the audio thread to the graphic wave when a new wave is recorded.
|
| 45 | *
|
||
| 46 | * The graphic thread set the chunks of the wave to reflect the level of the recorded audio.
|
||
| 47 | * The algorithm takes the maximum and minimum value of a group of samples and this becomes the top and bottom of the samples.
|
||
| 48 | * It contains the inde
|
||
| 49 | * the cursor position when the grains are reset.
|
||
| 50 | */
|
||
| 51 | 0:02467299402e | f | struct RecordWaveMsg
|
| 52 | {
|
||
| 53 | 3:7fb593d53361 | f | Command cmd; // WAVE_CHUNK or WAVE_START
|
| 54 | 0:02467299402e | f | std::size_t index; |
| 55 | float arg1;
|
||
| 56 | float arg2;
|
||
| 57 | }; |
||
| 58 | |||
| 59 | 3:7fb593d53361 | f | /**
|
| 60 | * Utility function to create a new RecordWaveMsg.
|
||
| 61 | */
|
||
| 62 | 0:02467299402e | f | inline RecordWaveMsg makeRecordWaveMsg( Command cmd, std::size_t index, float arg1, float arg2 ) |
| 63 | {
|
||
| 64 | RecordWaveMsg msg; |
||
| 65 | msg.cmd = cmd; |
||
| 66 | msg.index = index; |
||
| 67 | msg.arg1 = arg1; |
||
| 68 | msg.arg2 = arg2; |
||
| 69 | |||
| 70 | return msg;
|
||
| 71 | } |
||
| 72 | |||
| 73 | 3:7fb593d53361 | f | /**
|
| 74 | * Message sent from the audio thread to the graphic thread when a new grain is triggered in the granular synthesizer.
|
||
| 75 | * 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.
|
||
| 76 | *
|
||
| 77 | */
|
||
| 78 | 0:02467299402e | f | struct CursorTriggerMsg
|
| 79 | {
|
||
| 80 | 3:7fb593d53361 | f | Command cmd; // TRIGGER_UPDATE or TRIGGER_END
|
| 81 | 0:02467299402e | f | int synthID;
|
| 82 | }; |
||
| 83 | |||
| 84 | 3:7fb593d53361 | f | /**
|
| 85 | * Utility function to create a new CursorTriggerMsg.
|
||
| 86 | */
|
||
| 87 | 0:02467299402e | f | inline CursorTriggerMsg makeCursorTriggerMsg( Command cmd, std::uint8_t synthID )
|
| 88 | {
|
||
| 89 | CursorTriggerMsg msg; |
||
| 90 | |||
| 91 | msg.cmd = cmd; |
||
| 92 | msg.synthID = synthID; |
||
| 93 | |||
| 94 | return msg;
|
||
| 95 | } |
||
| 96 | |||
| 97 | 3:7fb593d53361 | f | /**
|
| 98 | * Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer.
|
||
| 99 | */
|
||
| 100 | 0:02467299402e | f | struct NoteMsg
|
| 101 | {
|
||
| 102 | 3:7fb593d53361 | f | Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF
|
| 103 | 0:02467299402e | f | int midiNote;
|
| 104 | double rate;
|
||
| 105 | }; |
||
| 106 | |||
| 107 | 3:7fb593d53361 | f | /**
|
| 108 | * Utility function to create a new NoteMsg.
|
||
| 109 | */
|
||
| 110 | 0:02467299402e | f | inline NoteMsg makeNoteMsg( Command cmd, int midiNote, double rate ) |
| 111 | {
|
||
| 112 | NoteMsg msg; |
||
| 113 | |||
| 114 | msg.cmd = cmd; |
||
| 115 | msg.midiNote = midiNote; |
||
| 116 | msg.rate = rate; |
||
| 117 | |||
| 118 | return msg;
|
||
| 119 | 3:7fb593d53361 | f | } |