7
7
8
8
#include " ofFileUtils.h"
9
9
#include " ofxEmscriptenSoundPlayer.h"
10
- #include " html5audio.h"
10
+ // #include "html5audio.h"
11
11
12
12
using namespace std ;
13
13
@@ -17,7 +17,7 @@ int ofxEmscriptenAudioContext(){
17
17
static bool initialized=false ;
18
18
static int context = -1 ;
19
19
if (!initialized){
20
- context = html5audio_context_create ();
20
+ context = // html5audio_context_create();
21
21
initialized = true ;
22
22
}
23
23
return context;
@@ -30,126 +30,128 @@ ofxEmscriptenSoundPlayer::ofxEmscriptenSoundPlayer()
30
30
,speed(1 )
31
31
,pan(0 )
32
32
,playing(false )
33
- ,player_id(html5audio_player_create()){
33
+ ,player_id(0 ){
34
+ // ,player_id(//html5audio_player_create()){
34
35
}
35
36
36
37
ofxEmscriptenSoundPlayer::~ofxEmscriptenSoundPlayer (){
37
- html5audio_sound_free (player_id);
38
+ // html5audio_sound_free(player_id);
38
39
}
39
40
40
41
bool ofxEmscriptenSoundPlayer::load (const of::filesystem::path& filePath, bool stream){
41
42
auto soundFilePath = filePath.string ();
42
43
if ( soundFilePath.substr (0 , 7 ) != " http://" && soundFilePath.substr (0 , 8 ) != " https://" ){
43
44
soundFilePath = ofToDataPath (soundFilePath);
44
45
}
45
- html5audio_sound_load (player_id, soundFilePath.c_str ());
46
+ // html5audio_sound_load(player_id, soundFilePath.c_str());
46
47
return true ;
47
48
}
48
49
49
50
// bool ofxEmscriptenSoundPlayer::load(const std::string& fileName, bool stream){
50
- // html5audio_sound_load(player_id, fileName.c_str());
51
+ // // html5audio_sound_load(player_id, fileName.c_str());
51
52
// return true;
52
53
// }
53
54
54
55
void ofxEmscriptenSoundPlayer::unload (){
55
- html5audio_sound_free (player_id);
56
+ // html5audio_sound_free(player_id);
56
57
}
57
58
58
59
void ofxEmscriptenSoundPlayer::play (){
59
- if (playing && !multiplay && !html5audio_sound_done (player_id)){
60
- html5audio_sound_stop (player_id);
61
- }
62
- html5audio_sound_play (player_id, multiplay, volume, speed, pan, 0 );
63
- html5audio_sound_set_rate (player_id, speed);
64
- html5audio_sound_set_volume (player_id, volume);
60
+ // if(playing && !multiplay && !// html5audio_sound_done(player_id)){
61
+ // html5audio_sound_stop(player_id);
62
+ // }
63
+ // html5audio_sound_play(player_id, multiplay, volume, speed, pan, 0);
64
+ // html5audio_sound_set_rate(player_id, speed);
65
+ // html5audio_sound_set_volume(player_id, volume);
65
66
playing = true ;
66
67
}
67
68
68
69
void ofxEmscriptenSoundPlayer::stop (){
69
- html5audio_sound_stop (player_id);
70
+ // html5audio_sound_stop(player_id);
70
71
playing = false ;
71
72
}
72
73
73
74
74
75
void ofxEmscriptenSoundPlayer::setVolume (float vol){
75
76
volume = vol;
76
- html5audio_sound_set_volume (player_id, vol);
77
+ // html5audio_sound_set_volume(player_id, vol);
77
78
}
78
79
79
80
void ofxEmscriptenSoundPlayer::setPan (float panorama){
80
81
pan = panorama;
81
- html5audio_sound_set_pan (player_id, pan);
82
+ // html5audio_sound_set_pan(player_id, pan);
82
83
}
83
84
84
85
void ofxEmscriptenSoundPlayer::setSpeed (float spd){
85
86
speed = spd;
86
- html5audio_sound_set_rate (player_id, spd);
87
+ // html5audio_sound_set_rate(player_id, spd);
87
88
}
88
89
89
90
void ofxEmscriptenSoundPlayer::setPaused (bool bP){
90
- if (bP) html5audio_sound_pause (player_id);
91
- else html5audio_sound_play (player_id, multiplay, volume, speed, pan, 0 );
91
+ // if(bP) // html5audio_sound_pause(player_id);
92
+ // else // html5audio_sound_play(player_id, multiplay, volume, speed, pan, 0);
92
93
}
93
94
94
95
void ofxEmscriptenSoundPlayer::setLoop (bool bLp){
95
- html5audio_sound_set_loop (player_id, bLp);
96
+ // html5audio_sound_set_loop(player_id, bLp);
96
97
}
97
98
98
99
void ofxEmscriptenSoundPlayer::setMultiPlay (bool bMp){
99
100
multiplay = bMp;
100
101
}
101
102
102
103
void ofxEmscriptenSoundPlayer::setPosition (float pct){
103
- html5audio_sound_set_position (player_id, pct);
104
+ // html5audio_sound_set_position(player_id, pct);
104
105
}
105
106
106
107
void ofxEmscriptenSoundPlayer::setPositionMS (int ms){
107
- html5audio_sound_set_position (player_id, ms / html5audio_sound_duration (player_id) / 1000 );
108
+ // html5audio_sound_set_position(player_id, ms / // html5audio_sound_duration(player_id) / 1000);
108
109
}
109
110
110
111
float ofxEmscriptenSoundPlayer::getPosition () const {
111
- return html5audio_sound_position (player_id);
112
+ return 0 ; // html5audio_sound_position(player_id);
112
113
}
113
114
114
115
int ofxEmscriptenSoundPlayer::getPositionMS () const {
115
- return html5audio_sound_position (player_id) * html5audio_sound_duration (player_id) * 1000 ;
116
+ return 0 ; // html5audio_sound_position(player_id) * // html5audio_sound_duration(player_id) * 1000;
116
117
}
117
118
118
119
bool ofxEmscriptenSoundPlayer::isPlaying () const {
119
- return playing && !html5audio_sound_done (player_id);
120
+ return false ;
121
+ // return playing && !//html5audio_sound_done(player_id);
120
122
}
121
123
122
124
float ofxEmscriptenSoundPlayer::getSpeed () const {
123
- return html5audio_sound_rate (player_id);
125
+ return 0 ; // html5audio_sound_rate(player_id);
124
126
}
125
127
126
128
float ofxEmscriptenSoundPlayer::getPan () const {
127
- return html5audio_sound_pan (player_id);
129
+ return 0 ; // html5audio_sound_pan(player_id);
128
130
}
129
131
130
132
bool ofxEmscriptenSoundPlayer::isLoaded () const {
131
- return html5audio_sound_is_loaded (player_id);
133
+ return false ; // html5audio_sound_is_loaded(player_id);
132
134
}
133
135
134
136
float ofxEmscriptenSoundPlayer::getVolume () const {
135
- return html5audio_sound_volume (player_id);
137
+ return 0 ; // html5audio_sound_volume(player_id);
136
138
}
137
139
138
140
float ofxEmscriptenSoundPlayer::getDuration () const {
139
- return html5audio_sound_duration (player_id);
141
+ return 0 ; // html5audio_sound_duration(player_id);
140
142
}
141
143
142
144
unsigned int ofxEmscriptenSoundPlayer::getDurationMS () const {
143
- return html5audio_sound_duration (player_id) * 1000 ;
145
+ return 0 ; // html5audio_sound_duration(player_id) * 1000;
144
146
}
145
147
146
148
double ofxEmscriptenSoundPlayer::getDurationSecs () const {
147
- return html5audio_sound_duration (player_id);
149
+ return 0 ; // html5audio_sound_duration(player_id);
148
150
}
149
151
150
152
float * ofxEmscriptenSoundPlayer::getSystemSpectrum (int bands){
151
153
systemSpectrum.resize (bands);
152
- html5audio_context_spectrum (bands, &systemSpectrum[0 ]);
154
+ // html5audio_context_spectrum(bands, &systemSpectrum[0]);
153
155
for (size_t i = 0 ; i < systemSpectrum.size (); i++){
154
156
systemSpectrum[i] = (systemSpectrum[i]+100 ) * 0.01 ;
155
157
}
0 commit comments