nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Concurrency & polyphony & low latency #87

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello guys,

Would you guys please make this plugin support multiple file playback at a time with low latency? That would help a lot in my project..

and I would like to request:

Thanks, keep up the good works!

bradmartin commented 6 years ago

Hi @jamesharvey2 that's a lot of additions so I don't think I'll have time to work on that anytime soon. We'd definitely welcome a PR with all of that functionality. Some of your points might already have possible functionality:

At any rate, thanks for looking at the plugin and hope you can contribute 😄 👍

bradmartin commented 6 years ago

I just read over you message again, the part of playing multiple sound files at once, this isn't possible with one instance of the Android MediaPlayer, it only supports one file (datasource) at a time. You'd have to create multiple instances of the player and set the sources individually, which should be possible in the plugins current state. Please try and let me know if you need any help.

ghost commented 6 years ago

@bradmartin Thanks for your reply.

Yes, I will try solutions you have suggested!

Here's an example of waveform generated from a track: https://transloadit.com/demos/audio-encoding/generate-a-waveform-image-from-an-audio-file/ It's not that complicated to do in other javascript audio frameworks. Honestly, I don't know how to implement this feature into your plugin.. I will look into it though.

Is it possible for you to make this plugin provide gapless loop playback? for instance, when you loop an audio track, there's 0.7 second gap (silence) between each loop. I would really appreciate it if you make this happen. Then I can use short audio files and loop it rather than using a long audio track containing loops.

https://en.wikipedia.org/wiki/Gapless_playback

Thanks again, and happy holidays.

bradmartin commented 6 years ago

The plugin could potentially support doing what you want with a waveform, Android does have this class https://developer.android.com/reference/android/media/audiofx/Visualizer.html to visualize audio playing which seems what you are wanting. As for doing the changes, I don't really have a need for this right now so I can't say if/when it will ever happen. If you'd like you can check on the NS forums or slack channel for help if you want to work on it. You can also ping team@nstudio.io if you'd like to pay someone to work on it. Thanks again. Keep me posted if you have any questions on what you attempt.

ghost commented 6 years ago

Okay, I will try to make it work by myself. Yes, Android does come with lots of useful audio APIs and NativeScript can use them all. I just learned that.

Thanks again for creating this plugin & appreciated!

suparnavg commented 6 years ago

@jamesharvey2 did you figure out how to get the waveform working? This is a pretty cool feature (and necessary imo) and I'm trying to get it to work myself. @bradmartin it would be a fantastic addition to this plugin!