-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodt1.cpp
403 lines (350 loc) · 9.29 KB
/
odt1.cpp
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
// odt1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#define _USE_MATH_DEFINES
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::ifstream;
settings ustawienia;
std::queue<string> foldery;
vector<string> valbums;
void FMODErrorCheck(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
cout << "FMOD error! (" << result << ") " << FMOD_ErrorString(result) << endl;
exit(-1);
}
}
vector<string> wektor;
void fshuffle(int liczba_utworow) { //everyday we're shuffling
for(int i=0 ; i<liczba_utworow ; i++)
{
int r = rand()%liczba_utworow;
swap(wektor[i], wektor[r]);
}
}
void printvolume(float volume) {
cout.setf(std::ios::fixed);
std::streamsize p = cout.precision();
cout.precision(0);
cout << "Volume: " << volume << endl << endl;
cout.unsetf(std::ios::fixed);
cout.precision(p);
}
void lista(int i, int liczba_utworow) {
for(int j=max(0, i-3) ; j<min(liczba_utworow, i+5) ; j++)
{
if(i!=j)
cout << wektor[j] << endl;
else
cout << endl << " " << wektor[j] << endl << endl;
}
}
int main() {
srand ( (unsigned int)time(NULL) );
std::ios_base::sync_with_stdio(0);
clock_t start_timer;
start_timer = clock();
// ================================================================================================
// Application-independent initialization
// ================================================================================================
FMOD::System *system;
FMOD_RESULT result;
unsigned int version;
int numDrivers;
FMOD_SPEAKERMODE speakerMode;
FMOD_CAPS caps;
char name[256];
// Create FMOD interface object
result = FMOD::System_Create(&system);
FMODErrorCheck(result);
// Check version
result = system->getVersion(&version);
FMODErrorCheck(result);
if (version < FMOD_VERSION)
{
cout << "Error! You are using an old version of FMOD " << version << ". This program requires " << FMOD_VERSION << endl;
return 0;
}
// Get number of sound cards
result = system->getNumDrivers(&numDrivers);
FMODErrorCheck(result);
// No sound cards (disable sound)
if (numDrivers == 0)
{
result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
FMODErrorCheck(result);
}
// At least one sound card
else
{
// Get the capabilities of the default (0) sound card
result = system->getDriverCaps(0, &caps, 0, &speakerMode);
FMODErrorCheck(result);
// Set the speaker mode to match that in Control Panel
result = system->setSpeakerMode(speakerMode);
FMODErrorCheck(result);
// Increase buffer size if user has Acceleration slider set to off
if (caps & FMOD_CAPS_HARDWARE_EMULATED)
{
result = system->setDSPBufferSize(1024, 10);
FMODErrorCheck(result);
}
// Get name of driver
result = system->getDriverInfo(0, name, 256, 0);
FMODErrorCheck(result);
// SigmaTel sound devices crackle for some reason if the format is PCM 16-bit.
// PCM floating point output seems to solve it.
if (strstr(name, "SigmaTel"))
{
result = system->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
FMODErrorCheck(result);
}
}
// Initialise FMOD
result = system->init(100, FMOD_INIT_NORMAL, 0);
// If the selected speaker mode isn't supported by this sound card, switch it back to stereo
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
{
result = system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
FMODErrorCheck(result);
result = system->init(100, FMOD_INIT_NORMAL, 0);
}
FMODErrorCheck(result);
// ================================================================================================
// End of the stupid part
// ================================================================================================
ftime();
manual();
inicjalizuj_szukanie();
double seconds;
clock_t end_timer;
end_timer = clock();
seconds = ((double)end_timer - start_timer)/CLOCKS_PER_SEC;
cout << "Application starting time: ";
cout.precision(2);
cout << seconds;
cout << " seconds." << endl << endl;
while(true)
{
float i_loudness = 50;
float f_loudness = i_loudness / 100;
bool isPaused;
bool ready = true;
int i, j;
int key = 0;
int numer_albumu;
int liczba_utworow;
cout << "Pick the album:" << endl;
for(i=1 ; i <= valbums.size() ; i++)
{
cout << i << ": " << valbums[i-1] << endl;
}
cin >> numer_albumu;
if(numer_albumu>valbums.size())
{
cout << "Error, the number is incorrect" << endl;
return 0;
}
string nazwa;
string sciezka_albumu = valbums[numer_albumu-1];
cout << sciezka_albumu << endl;
string sciezka_piosenki;
liczba_utworow = stworz_playliste(sciezka_albumu);
if(ustawienia.shuffle)
fshuffle(liczba_utworow);
for(i=0 ; i<liczba_utworow ; i++)
{
rudimentary(i_loudness);
nazwa = wektor[i];
/*if(i>0)
{
cout << wektor[i-1] << endl << endl;
}
else
{
cout << "<<First track of album" << ">>" << endl << endl;
}
cout << " " << nazwa << endl << endl;
if(i+1<liczba_utworow)
{
cout << wektor[i+1] << endl << endl;
}
else
{
cout << "<<Last track of album" << ">>" << endl << endl;
}*/
lista(i, liczba_utworow);
sciezka_piosenki = sciezka_albumu + "/" + nazwa;
FMOD::Sound *audioStream;
system->createStream(sciezka_piosenki.c_str(), FMOD_DEFAULT, 0, &audioStream);
FMODErrorCheck(result);
FMOD::Channel *channel;
system->playSound(FMOD_CHANNEL_FREE, audioStream, false, &channel);
FMODErrorCheck(result);
channel->setVolume(f_loudness);
FMODErrorCheck(result);
bool isPlayin;
while (channel->isPlaying(&isPlayin) == FMOD_OK && isPlayin) {
FMODErrorCheck(system->update());
if(ustawienia.on_top)
{
if (GetAsyncKeyState(VK_NUMPAD2))
{
i_loudness = max(i_loudness - 5, 0);
f_loudness = i_loudness / 100;
//printvolume(i_loudness);
rudimentary(i_loudness);
lista(i, liczba_utworow);
channel->setVolume(f_loudness);
while (GetAsyncKeyState(VK_NUMPAD2));
}
if (GetAsyncKeyState(VK_NUMPAD8))
{
i_loudness = min(i_loudness + 5, 100);
f_loudness = i_loudness / 100;
//printvolume(i_loudness);
rudimentary(i_loudness);
lista(i, liczba_utworow);
channel->setVolume(f_loudness);
while (GetAsyncKeyState(VK_NUMPAD8));
}
if (GetAsyncKeyState(VK_NUMPAD4))
{
channel->stop();
if(i>=1)
i -= 2;
else
i -= 1;
while (GetAsyncKeyState(VK_NUMPAD4));
}
if (GetAsyncKeyState(VK_NUMPAD6))
{
channel->stop();
while (GetAsyncKeyState(VK_NUMPAD6));
}
if (GetAsyncKeyState(VK_NUMPAD9))
{
channel->stop();
i -= 1;
while (GetAsyncKeyState(VK_NUMPAD9));
}
if (GetAsyncKeyState(VK_NUMPAD5))
{
channel->getPaused(&isPaused);
if(isPaused)
cout << "*UNPAUSED*" << endl;
else
cout << "*PAUSED*" << endl;
channel->setPaused(!isPaused);
while (GetAsyncKeyState(VK_NUMPAD5));
}
if (GetAsyncKeyState(VK_NUMPAD0))
{
channel->stop();
system->release();
return 0;
while (GetAsyncKeyState(VK_NUMPAD0));
}
if (GetAsyncKeyState(VK_NUMPAD3))
{
modify_settings();
while (GetAsyncKeyState(VK_NUMPAD3));
}
if (GetAsyncKeyState(VK_NUMPAD1))
{
credits();
while (GetAsyncKeyState(VK_NUMPAD1));
}
if (GetAsyncKeyState(VK_NUMPAD7))
{
while (GetAsyncKeyState(VK_NUMPAD7));
}
}
else
{
if (_kbhit())
{
key = _getch();
if (key == '2')
{
i_loudness = max(i_loudness - 5, 0);
f_loudness = i_loudness / 100;
//printvolume(i_loudness);
rudimentary(i_loudness);
lista(i, liczba_utworow);
channel->setVolume(f_loudness);
}
if (key == '8')
{
i_loudness = min(i_loudness + 5, 100);
f_loudness = i_loudness / 100;
//printvolume(i_loudness);
rudimentary(i_loudness);
lista(i, liczba_utworow);
channel->setVolume(f_loudness);
}
if (key == '4')
{
channel->stop();
if(i>=1)
i -= 2;
else
i -= 1;
}
if (key == '6')
{
channel->stop();
}
if (key == '9')
{
channel->stop();
i -= 1;
}
if (key == '5')
{
channel->getPaused(&isPaused);
if(isPaused)
cout << "*UNPAUSED*" << endl;
else
cout << "*PAUSED*" << endl;
channel->setPaused(!isPaused);
}
if (key == '0')
{
channel->stop();
system->release();
return 0;
}
if (key == '3')
{
modify_settings();
while(_kbhit()) _getch();
}
if (key == '1')
{
credits();
}
if (key == '7')
{
while(_kbhit()) _getch();
}
}
}
}
FMODErrorCheck(result);
system->update();
}
rudimentary(i_loudness);
wektor.clear();
}
return 0;
}
/*int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}*/