JorenSix / TarsosDSP

A Real-Time Audio Processing Framework in Java
http://0110.be/tag/TarsosDSP
GNU General Public License v3.0
1.97k stars 472 forks source link

How to play audio file in raw folder #180

Open pupil72 opened 4 years ago

pupil72 commented 4 years ago

No matter what I do I can't play an audio file either if it is in my phone or in the raw folder. The following code play correctly a file in my raw folder:

Uri myUri1 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hola); MediaPlayer mPlayer = new MediaPlayer(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mPlayer.setDataSource(getApplicationContext(), myUri1); mPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } mPlayer.start();

However with tarsosdsp the following plays nothing:

String s = "android.resource://" + getPackageName() + "/" + R.raw.hola; AudioDispatcher adp; adp = AudioDispatcherFactory.fromPipe(s,44100,5000,2500); adp.addAudioProcessor(new AndroidAudioPlayer(adp.getFormat(),5000, AudioManager.STREAM_MUSIC)); new Thread(adp, "Sound Thread").start();

Please, I spent 10 days now trying to figure it out. How do I pipe my file into the dispatcher?