-
Notifications
You must be signed in to change notification settings - Fork 79
/
Player.h
131 lines (100 loc) · 3.19 KB
/
Player.h
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
/*
Copyright (C) 2011 Nasca Octavian Paul
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
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 (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PLAYER_H
#define PLAYER_H
#include <string>
#include "Input/AInputS.h"
#include "Input/VorbisInputS.h"
#include "Input/MP3InputS.h"
#include "ProcessedStretch.h"
#include "Thread.h"
#include "BinauralBeats.h"
#include "Mutex.h"
#include "globals.h"
#define PA_SOUND_BUFFER_SIZE 8192
class Player:public Thread{
public:
Player();
~Player();
void startplay(std::string filename, REALTYPE startpos,REALTYPE rap, int fftsize,FILE_TYPE intype,bool bypass,ProcessParameters *ppar,BinauralBeatsParameters *bbpar);
//startpos is from 0 (start) to 1.0 (end of file)
void stop();
void pause();
void freeze();
void setrap(REALTYPE newrap);
void seek(REALTYPE pos);
void getaudiobuffer(int nsamples, float *out);//data este stereo
enum ModeType{
MODE_PLAY,MODE_STOP,MODE_PREPARING,MODE_PAUSE
};
ModeType getmode();
struct{
float position;//0 is for start, 1 for end
int playing;
int samplerate;
bool eof;
}info;
bool is_freeze(){
return freeze_mode;
};
void set_window_type(FFTWindow window);
void set_volume(REALTYPE vol);
void set_onset_detection_sensitivity(REALTYPE onset);
void set_process_parameters(ProcessParameters *ppar,BinauralBeatsParameters *bbpar);
BinauralBeats *binaural_beats;
private:
void run();
InputS *ai;
ProcessedStretch *stretchl,*stretchr;
short int *inbuf_i;
int inbufsize;
Mutex taskmutex,bufmutex;
ModeType mode;
enum TaskMode{
TASK_NONE, TASK_START, TASK_STOP,TASK_SEEK,TASK_RAP,TASK_PARAMETERS, TASK_ONSET
};
struct {
TaskMode mode;
REALTYPE startpos;
REALTYPE rap;
int fftsize;
std::string filename;
FILE_TYPE intype;
bool bypass;
ProcessParameters *ppar;
BinauralBeatsParameters *bbpar;
}newtask,task;
struct{
REALTYPE *l,*r;
}inbuf;
struct{
int n;//how many buffers
float **datal,**datar;//array of buffers
int size;//size of one buffer
int computek,outk;//current buffer
int outpos;//the sample position in the current buffer (for out)
int nfresh;//how many buffers are fresh added and need to be played
//nfresh==0 for empty buffers, nfresh==n-1 for full buffers
float *in_position;//the position(for input samples inside the input file) of each buffers
}outbuf;
bool first_in_buf;
void newtaskcheck();
void computesamples();
bool freeze_mode,bypass_mode,paused;
REALTYPE volume,onset_detection_sensitivity;
std::string current_filename;
FFTWindow window_type;
};
#endif