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 @ 16:4dad0b810f18

History | View | Annotate | Download (3.03 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 16:4dad0b810f18 f
    // new grain created
35 0:02467299402e f
    TRIGGER_UPDATE,
36 16:4dad0b810f18 f
    // synth became idle
37 0:02467299402e f
    TRIGGER_END,
38
39
    NOTE_ON,
40
    NOTE_OFF,
41
42
    LOOP_ON,
43
    LOOP_OFF
44
};
45
46 3:7fb593d53361 f
/** Message sent from the audio thread to the graphic wave when a new wave is recorded.
47
 *
48 16:4dad0b810f18 f
 *  The graphic thread sets the chunks of the wave to reflect the level of the recorded audio.
49
 *  The algorithm takes the maximum and minimum value of a group of samples and this becomes the top and bottom of the chunk.
50
 *  The message carries also the index of the chunk it refers to
51 3:7fb593d53361 f
 */
52 0:02467299402e f
struct RecordWaveMsg
53
{
54 3:7fb593d53361 f
    Command cmd; // WAVE_CHUNK or WAVE_START
55 0:02467299402e f
    std::size_t index;
56
    float arg1;
57
    float arg2;
58
};
59
60 3:7fb593d53361 f
/**
61
 * Utility function to create a new RecordWaveMsg.
62
 */
63 0:02467299402e f
inline RecordWaveMsg makeRecordWaveMsg( Command cmd, std::size_t index, float arg1, float arg2 )
64
{
65
    RecordWaveMsg msg;
66
    msg.cmd = cmd;
67
    msg.index = index;
68
    msg.arg1 = arg1;
69
    msg.arg2 = arg2;
70
71
    return msg;
72
}
73
74 3:7fb593d53361 f
/**
75
 * Message sent from the audio thread to the graphic thread when a new grain is triggered in the granular synthesizer.
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.
77
 *
78
 */
79 0:02467299402e f
struct CursorTriggerMsg
80
{
81 3:7fb593d53361 f
    Command cmd; // TRIGGER_UPDATE or TRIGGER_END
82 0:02467299402e f
    int synthID;
83
};
84
85 3:7fb593d53361 f
/**
86
 * Utility function to create a new CursorTriggerMsg.
87
 */
88 0:02467299402e f
inline CursorTriggerMsg makeCursorTriggerMsg( Command cmd, std::uint8_t synthID )
89
{
90
    CursorTriggerMsg msg;
91
92
    msg.cmd = cmd;
93
    msg.synthID = synthID;
94
95
    return msg;
96
}
97
98 3:7fb593d53361 f
/**
99
 * Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer.
100
 */
101 0:02467299402e f
struct NoteMsg
102
{
103 3:7fb593d53361 f
    Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF
104 0:02467299402e f
    int midiNote;
105
    double rate;
106
};
107
108 3:7fb593d53361 f
/**
109
 * Utility function to create a new NoteMsg.
110
 */
111 0:02467299402e f
inline NoteMsg makeNoteMsg( Command cmd, int midiNote, double rate )
112
{
113
    NoteMsg msg;
114
115
    msg.cmd = cmd;
116
    msg.midiNote = midiNote;
117
    msg.rate = rate;
118
119
    return msg;
120 3:7fb593d53361 f
}