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@0
|
34 TRIGGER_UPDATE,
|
f@0
|
35 TRIGGER_END,
|
f@0
|
36
|
f@0
|
37 NOTE_ON,
|
f@0
|
38 NOTE_OFF,
|
f@0
|
39
|
f@0
|
40 LOOP_ON,
|
f@0
|
41 LOOP_OFF
|
f@0
|
42 };
|
f@0
|
43
|
f@3
|
44 /** Message sent from the audio thread to the graphic wave when a new wave is recorded.
|
f@3
|
45 *
|
f@3
|
46 * The graphic thread set the chunks of the wave to reflect the level of the recorded audio.
|
f@3
|
47 * 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
|
48 * It contains the inde
|
f@3
|
49 * the cursor position when the grains are reset.
|
f@3
|
50 */
|
f@0
|
51 struct RecordWaveMsg
|
f@0
|
52 {
|
f@3
|
53 Command cmd; // WAVE_CHUNK or WAVE_START
|
f@0
|
54 std::size_t index;
|
f@0
|
55 float arg1;
|
f@0
|
56 float arg2;
|
f@0
|
57 };
|
f@0
|
58
|
f@3
|
59 /**
|
f@3
|
60 * Utility function to create a new RecordWaveMsg.
|
f@3
|
61 */
|
f@0
|
62 inline RecordWaveMsg makeRecordWaveMsg( Command cmd, std::size_t index, float arg1, float arg2 )
|
f@0
|
63 {
|
f@0
|
64 RecordWaveMsg msg;
|
f@0
|
65 msg.cmd = cmd;
|
f@0
|
66 msg.index = index;
|
f@0
|
67 msg.arg1 = arg1;
|
f@0
|
68 msg.arg2 = arg2;
|
f@0
|
69
|
f@0
|
70 return msg;
|
f@0
|
71 }
|
f@0
|
72
|
f@3
|
73 /**
|
f@3
|
74 * Message sent from the audio thread to the graphic thread when a new grain is triggered in the granular synthesizer.
|
f@3
|
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.
|
f@3
|
76 *
|
f@3
|
77 */
|
f@0
|
78 struct CursorTriggerMsg
|
f@0
|
79 {
|
f@3
|
80 Command cmd; // TRIGGER_UPDATE or TRIGGER_END
|
f@0
|
81 int synthID;
|
f@0
|
82 };
|
f@0
|
83
|
f@3
|
84 /**
|
f@3
|
85 * Utility function to create a new CursorTriggerMsg.
|
f@3
|
86 */
|
f@0
|
87 inline CursorTriggerMsg makeCursorTriggerMsg( Command cmd, std::uint8_t synthID )
|
f@0
|
88 {
|
f@0
|
89 CursorTriggerMsg msg;
|
f@0
|
90
|
f@0
|
91 msg.cmd = cmd;
|
f@0
|
92 msg.synthID = synthID;
|
f@0
|
93
|
f@0
|
94 return msg;
|
f@0
|
95 }
|
f@0
|
96
|
f@3
|
97 /**
|
f@3
|
98 * Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer.
|
f@3
|
99 */
|
f@0
|
100 struct NoteMsg
|
f@0
|
101 {
|
f@3
|
102 Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF
|
f@0
|
103 int midiNote;
|
f@0
|
104 double rate;
|
f@0
|
105 };
|
f@0
|
106
|
f@3
|
107 /**
|
f@3
|
108 * Utility function to create a new NoteMsg.
|
f@3
|
109 */
|
f@0
|
110 inline NoteMsg makeNoteMsg( Command cmd, int midiNote, double rate )
|
f@0
|
111 {
|
f@0
|
112 NoteMsg msg;
|
f@0
|
113
|
f@0
|
114 msg.cmd = cmd;
|
f@0
|
115 msg.midiNote = midiNote;
|
f@0
|
116 msg.rate = rate;
|
f@0
|
117
|
f@0
|
118 return msg;
|
f@3
|
119 }
|