f@0
|
1 #pragma once
|
f@0
|
2
|
f@3
|
3 /**
|
f@3
|
4 * Enumeration of all the possible commands exchanged between audio thread and graphic thread.
|
f@3
|
5 *
|
f@3
|
6 */
|
f@0
|
7 enum class Command {
|
f@0
|
8 // message carrying info about one chunk of recorder audio.
|
f@0
|
9 WAVE_CHUNK,
|
f@0
|
10 // message sent when a new recording starts. The gui resets the wave upon receiving it.
|
f@0
|
11 WAVE_START,
|
f@0
|
12
|
f@0
|
13 TRIGGER_UPDATE,
|
f@0
|
14 TRIGGER_END,
|
f@0
|
15
|
f@0
|
16 NOTE_ON,
|
f@0
|
17 NOTE_OFF,
|
f@0
|
18
|
f@0
|
19 LOOP_ON,
|
f@0
|
20 LOOP_OFF
|
f@0
|
21 };
|
f@0
|
22
|
f@3
|
23 /** Message sent from the audio thread to the graphic wave when a new wave is recorded.
|
f@3
|
24 *
|
f@3
|
25 * The graphic thread set the chunks of the wave to reflect the level of the recorded audio.
|
f@3
|
26 * 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
|
27 * It contains the inde
|
f@3
|
28 * the cursor position when the grains are reset.
|
f@3
|
29 */
|
f@0
|
30 struct RecordWaveMsg
|
f@0
|
31 {
|
f@3
|
32 Command cmd; // WAVE_CHUNK or WAVE_START
|
f@0
|
33 std::size_t index;
|
f@0
|
34 float arg1;
|
f@0
|
35 float arg2;
|
f@0
|
36 };
|
f@0
|
37
|
f@3
|
38 /**
|
f@3
|
39 * Utility function to create a new RecordWaveMsg.
|
f@3
|
40 */
|
f@0
|
41 inline RecordWaveMsg makeRecordWaveMsg( Command cmd, std::size_t index, float arg1, float arg2 )
|
f@0
|
42 {
|
f@0
|
43 RecordWaveMsg msg;
|
f@0
|
44 msg.cmd = cmd;
|
f@0
|
45 msg.index = index;
|
f@0
|
46 msg.arg1 = arg1;
|
f@0
|
47 msg.arg2 = arg2;
|
f@0
|
48
|
f@0
|
49 return msg;
|
f@0
|
50 }
|
f@0
|
51
|
f@3
|
52 /**
|
f@3
|
53 * Message sent from the audio thread to the graphic thread when a new grain is triggered in the granular synthesizer.
|
f@3
|
54 * 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
|
55 *
|
f@3
|
56 */
|
f@0
|
57 struct CursorTriggerMsg
|
f@0
|
58 {
|
f@3
|
59 Command cmd; // TRIGGER_UPDATE or TRIGGER_END
|
f@0
|
60 int synthID;
|
f@0
|
61 };
|
f@0
|
62
|
f@3
|
63 /**
|
f@3
|
64 * Utility function to create a new CursorTriggerMsg.
|
f@3
|
65 */
|
f@0
|
66 inline CursorTriggerMsg makeCursorTriggerMsg( Command cmd, std::uint8_t synthID )
|
f@0
|
67 {
|
f@0
|
68 CursorTriggerMsg msg;
|
f@0
|
69
|
f@0
|
70 msg.cmd = cmd;
|
f@0
|
71 msg.synthID = synthID;
|
f@0
|
72
|
f@0
|
73 return msg;
|
f@0
|
74 }
|
f@0
|
75
|
f@3
|
76 /**
|
f@3
|
77 * Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer.
|
f@3
|
78 */
|
f@0
|
79 struct NoteMsg
|
f@0
|
80 {
|
f@3
|
81 Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF
|
f@0
|
82 int midiNote;
|
f@0
|
83 double rate;
|
f@0
|
84 };
|
f@0
|
85
|
f@3
|
86 /**
|
f@3
|
87 * Utility function to create a new NoteMsg.
|
f@3
|
88 */
|
f@0
|
89 inline NoteMsg makeNoteMsg( Command cmd, int midiNote, double rate )
|
f@0
|
90 {
|
f@0
|
91 NoteMsg msg;
|
f@0
|
92
|
f@0
|
93 msg.cmd = cmd;
|
f@0
|
94 msg.midiNote = midiNote;
|
f@0
|
95 msg.rate = rate;
|
f@0
|
96
|
f@0
|
97 return msg;
|
f@3
|
98 }
|