-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcontrol.c
executable file
·185 lines (125 loc) · 3.75 KB
/
control.c
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
/* Copyright 2000 Kjetil S. Matheussen
This program 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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "nsmtracker.h"
//#include "PEQmempool_proc.h"
//#include "PEQ_type_proc.h"
#include "playerclass.h"
#include "song_proc.h"
#include "patch_proc.h"
#include "instruments_proc.h"
#include "OS_endprogram_proc.h"
#include "input.h"
//#include "PEQ_clock_proc.h"
#include "../audio/Mixer_proc.h"
#include "../midi/midi_i_input_proc.h"
#include "scheduler_proc.h"
#include "quantitize_proc.h"
#include "control_proc.h"
struct Root *root=NULL;
extern PlayerClass *pc;
vector_t g_symbols = {0};
extern void RADIUM_ensure_bin_packages_gc_is_used(void);
bool InitProgram(void){
// GC_INIT();
bool ret;
#if !defined(FOR_MACOSX)
RADIUM_ensure_bin_packages_gc_is_used();
#endif
printf("Initializing...\n");
printf("...Error handler\n");
Error_init();
printf("...Memory handler\n");
init_memory();
root=tralloc(sizeof(struct Root));
if(root==NULL){
fprintf(stderr,"Not enough memory\n");
return false;
}
root->keyoct=36;
root->quantitize_options = Quantitize_get_default_options();
root->grid_numerator=1;
root->grid_denominator=1;
root->min_standardvel=MAX_VELOCITY*40/100;
root->standardvel=MAX_VELOCITY*80/100;
ATOMIC_SET(root->editonoff, true);
ATOMIC_SET(root->play_cursor_onoff, false);
ATOMIC_SET(root->editor_follows_play_cursor_onoff, false);
root->song=SONG_create();
pc=tralloc(sizeof(PlayerClass));
if(root->song==NULL || pc==NULL){
fprintf(stderr,"Not enough memory\n");
return false;
}
pc->pfreq = 48000; // Default value. Should be overridden in MIXER_start().
/*
if( ( ! InitPEQmempool(1000) ) || ( ! Input_Init(4000) ) ){ // 1000 and 4000 are hardcoded values. Not good.
return false;
}
*/
printf("...Midi\n");
MIDI_input_init();
SCHEDULER_init();
PATCH_init();
printf("...Sound\n");
if(MIXER_start()==false){
fprintf(stderr,"Could not open Sound\n");
return false;
}
printf("...Player 1/2\n");
#if 0
if( ( ! InitPEQmempool() ) ){ // 1000 and 4000 are hardcoded values. Not good.
return false;
}
#endif
#if 0
printf("...Clock handler\n");
if( ! InitClock() ) return false;
#endif
printf("...Player 2/2\n");
#if 0
PEQ_GetType_Init();
#endif
printf("...Instrument\n");
if( OpenInstruments()==false ){
return false;
}
printf("...Kebang\n");
ret=NewSong();
#if !USE_OPENGL
printf("...Blitting\n");
if(ret==true){
Blt_blt(root->song->tracker_windows);
}
#endif
printf("Initialization finished.\n");
return ret;
}
void EndProgram(void){
OS_EndProgram();
printf("Closing down os independent stuff...\n");
printf("...Instruments\n");
//CloseAllInstruments(); // Removed since it's still used in the audio thread, which is still alive.
printf("...Song\n");
ClearSong();
#if 0
printf("...Clock handler\n");
CloseClock();
#endif
printf("...Error handler\n");
Error_uninit();
// Input_uninit();
printf("Finished closing down OS independent stuff.\n\n");
OS_EndProgram2();
fflush(stdout);
fflush(stdin);
}