To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / CollidoscopeApp / include / Messages.h @ 3:7fb593d53361

History | View | Annotate | Download (2.27 KB)

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