-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshared.h
More file actions
195 lines (170 loc) · 5.58 KB
/
shared.h
File metadata and controls
195 lines (170 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
Scoreview (R)
Copyright (C) 2015 Patrick Areny
All Rights Reserved.
Scoreview is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#define BACK_COLOR 0xFF7C7F35
//#define BACK_COLOR 0xFFC13411
#define BACK_COLOR 0xFFCC0404
//#define BACK_COLOR 0xFFFF0000
#define MAXBANDS 16
#define REPLAY_FIFO_SIZE 7
#define PRACTICE_BETWEEN_REPLAY_TIME 2.
enum eplay_state
{
state_stop,
state_record,
state_play,
state_wait_practice,
state_practice,
state_wait_practiceloop,
state_practiceloop,
state_practiceloop_rewind
};
// For spectrogram texture updates, avoiding rewrites of same data
typedef struct s_update_segment
{
int xstart;
int xstop;
} t_update_segment;
enum enotestate
{
state_wait_filtering,
state_filtered,
state_ready_2play,
state_playing,
state_done
};
typedef struct s_audioOutCmd
{
double start;
double stop;
double playstart;
double playdelay;
int bands;
float fhicut[MAXBANDS];
float flocut[MAXBANDS];
bool bsubstract;
bool bloop_data;
int notestate;
// Note pointer used only to display the note in the score in green when played
void *pnote;
} t_audioOutCmd;
typedef struct s_audio_strip
{
double playtimecode;
float *samples;
int samplenum;
int current_sample;
} t_audio_strip;
enum audio_track_command
{
ac_play,
ac_stop,
ac_record,
ac_move,
ac_reset,
ac_change_io,
ac_flush_strips,
ac_practice_loop
};
enum audio_track_direction
{
ad_thread2app,
ad_app2threadaudio,
ad_app2threadspectr
};
typedef struct s_audio_track_cmd
{
audio_track_command command;
audio_track_direction direction;
double v;
} t_audio_track_cmd;
typedef struct s_shared
{
bool bquit;
pthread_mutex_t datamutex;
pthread_mutex_t dftmutex; // Locks only *ptrackimg and *poutimg
pthread_mutex_t filtermutex; // Locks only filtered_sound_list
pthread_mutex_t cond_drawspectremutex;
pthread_cond_t cond_drawspectre;
bool bOpenClEnabled;
float zoom_f;
float zoom_t;
float tfprecision;
// w and h of the dft image
int dft_w;
int dft_h;
int *poutimg;
//int circularindex;
std::list<t_update_segment> update_segment_list;
int circularcut;
bool bspectre_img_updated;
float fbase; // Base frequency
float fmax; // Changing max frequency
float viewtime; // Mult that by samplerate + 4 seconds to get the samples needed by the GPU
bool blogdb; // Calibrated view
// Sound image
int *ptrackimg;
int trackimgw;
int trackimgh;
bool btrack_img_updated;
// Attack data for the current spectrometer
float *pattackdata;
// Audio parameters
t_channel_select_strings chs;
std::list<t_portaudio_api> pa_api_list;
// In
bool baudioready;
int samplerate;
double timecode; // Like PaTime in seconds
double trackend;
double lastimgtimecode;
double practice_countdown_tick;
double practice_start;
double practice_loop_duration;
float practicespeed;
Caudiodata *pad; // Audio input and edition buffer
eplay_state play_State;
std::list<t_audio_track_cmd> audio_cmds;
int audio_cmd_sdlevent;
// Out
pthread_mutex_t soundmutex;
pthread_mutex_t cond_soundmutex;
pthread_cond_t cond_sound;
std::list<t_audioOutCmd> filter_cmd_list;
std::list<t_audio_strip> filtered_sound_list;
// Used to replay selections from the keyboard keys r to p
std::list<t_audioOutCmd> replay_cmd_fifo;
} t_shared;
//#define blu
#ifdef blu
extern int g_ct;
extern int g_tm;
extern int g_dur;
extern int g_lcount;
#include "assert.h"
//#define LOCK pthread_mutex_lock(&pshared_data->datamutex); g_ct++; printf("file %s line %d - %d\n", __FILE__, __LINE__, g_lcount);assert(g_lcount++ == 0); g_tm = SDL_GetTicks(); g_tm = g_tm == 0? 1 : g_tm;
//#define UNLOCK assert(g_lcount-- == 1); assert(g_tm != 0); g_tm = SDL_GetTicks() - g_tm; g_dur = g_dur < g_tm? g_tm : g_dur; if (g_dur > 15000) assert(false); printf("unlock file %s line %d - %d\n", __FILE__, __LINE__, g_lcount); pthread_mutex_unlock(&pshared_data->datamutex);
#define ILOCK pthread_mutex_lock(&pshared_data->datamutex); g_ct++; assert(g_lcount++ == 0); g_tm = SDL_GetTicks(); g_tm = g_tm == 0? 1 : g_tm;
#define IUNLOCK assert(g_lcount-- == 1); assert(g_tm != 0); g_tm = SDL_GetTicks() - g_tm; g_dur = g_dur < g_tm? g_tm : g_dur; if (g_dur > 15000) assert(false); pthread_mutex_unlock(&pshared_data->datamutex);
#endif
#define LOCK pthread_mutex_lock(&pshared_data->datamutex);
#define UNLOCK pthread_mutex_unlock(&pshared_data->datamutex);
#define ILOCK pthread_mutex_lock(&pshared_data->dftmutex);
#define IUNLOCK pthread_mutex_unlock(&pshared_data->dftmutex);
#define SLOCK pthread_mutex_lock(&pshared_data->soundmutex);
#define SUNLOCK pthread_mutex_unlock(&pshared_data->soundmutex);
#define FLOCK pthread_mutex_lock(&pshared_data->filtermutex);
#define FUNLOCK pthread_mutex_unlock(&pshared_data->filtermutex);
#define MAX_VIEW_TIME 20