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