To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / Messages.h @ 4:ab6db404403a
History | View | Annotate | Download (2.27 KB)
| 1 |
#pragma once
|
|---|---|
| 2 |
|
| 3 |
/**
|
| 4 |
* Enumeration of all the possible commands exchanged between audio thread and graphic thread.
|
| 5 |
*
|
| 6 |
*/
|
| 7 |
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 |
/** 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 |
struct RecordWaveMsg
|
| 31 |
{
|
| 32 |
Command cmd; // WAVE_CHUNK or WAVE_START
|
| 33 |
std::size_t index; |
| 34 |
float arg1;
|
| 35 |
float arg2;
|
| 36 |
}; |
| 37 |
|
| 38 |
/**
|
| 39 |
* Utility function to create a new RecordWaveMsg.
|
| 40 |
*/
|
| 41 |
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 |
/**
|
| 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 |
struct CursorTriggerMsg
|
| 58 |
{
|
| 59 |
Command cmd; // TRIGGER_UPDATE or TRIGGER_END
|
| 60 |
int synthID;
|
| 61 |
}; |
| 62 |
|
| 63 |
/**
|
| 64 |
* Utility function to create a new CursorTriggerMsg.
|
| 65 |
*/
|
| 66 |
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 |
/**
|
| 77 |
* Message sent from the graphic (main) thread to the audio thread to start a new voice of the granular synthesizer.
|
| 78 |
*/
|
| 79 |
struct NoteMsg
|
| 80 |
{
|
| 81 |
Command cmd; // NOTE_ON/OFF ot LOOP_ON/OFF
|
| 82 |
int midiNote;
|
| 83 |
double rate;
|
| 84 |
}; |
| 85 |
|
| 86 |
/**
|
| 87 |
* Utility function to create a new NoteMsg.
|
| 88 |
*/
|
| 89 |
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 |
} |