1

I am creating a piano game. In the game a player can touch the same key quickly many times and the note's sound should be played the same way. What I need to do in this case?

I have read this question but didn't find answer for my case.

I thought about the pause SuperpoweredAdvancedAudioPlayer instance, the replacement progress to start the position and play it again. But in such a case the sound sounds intermittent and ugly. Also I thought about creating a new SuperpoweredAdvancedAudioPlayer instance, using the open method and playing it independently. But I'm afraid, that I need to wait for the loading file and I will get the latency. Or superpowered loads it only once and reuse it?

Give me advice please.

Community
  • 1
  • 1

1 Answers1

1

The SuperpoweredAdvancedAudioPlayer is like an expensive DJ player, not a sample player. You need a sample player with polyphonic capability, so it can play the same sound overlapped with itself. You can do this with multiple instances of the SuperpoweredAdvancedAudioPlayer too, but it might be too heavy for this.

Gabor Szanto
  • 1,329
  • 8
  • 12
  • What do you propose to use? Currently I have 16 `SuperpoweredAdvancedAudioPlayer` objects which I think might be too heavy on the resources. My case is also a bit different because the user can have 16 samples loaded at once. – c0dehunter Sep 24 '17 at 12:45
  • I'm guessing your samples are not very big. Put them as PCM audio into simply memory buffers, and play from there. – Gabor Szanto Sep 24 '17 at 12:49
  • I don't understand fully. Which [class from Superpowered](http://superpowered.com/docs/annotated.html) should I look into? The samples can be from 1s to up to 3-4 minutes long. – c0dehunter Sep 25 '17 at 16:16
  • If your samples are long like you mentioned, then. SuperpoweredAdvancedAudioPlayer is a good tool for this. But please note, it's not a "polyphonic" instrument. If you need the same sound played simultaneously, then you need to prepare multiple instances with the same sound "opened". – Gabor Szanto Sep 25 '17 at 19:49
  • Thanks for reaffirming. This is what I have now - 16 instances of `SuperpoweredAdvancedAudioPlayer`. The user can load any sample he wants into any of the 16 players and trigger them at anytime. It works, but I can hear "clicks" (short pause, a few 10ms long) every now and then (each ~30s). It happens even when just 1 instance is playing. I am not doing any other processing on the audio. Should I open a ticket on GitHub to explain the issue more deeply? [The app](https://play.google.com/store/apps/details?id=com.bitsboy.samply_djsampler) is here if you want to try it out. – c0dehunter Sep 25 '17 at 21:14
  • Are you "looping" compressed audio? Because compressed audio always starts with silence. You need to use the loop or loopBetween functions with correct positioning for gapless looping. – Gabor Szanto Sep 28 '17 at 09:15
  • I am using MP3s, but this "clicks" happens at the middle of the sample and never when the loop is done. So basically you are saying that my approach is correct, which is good. Maybe it's just the phone that I am testing on that does this (Samsung S5). Will try with different models and let you know. If you have any other proposition, you are most welcome to let me know too. – c0dehunter Sep 28 '17 at 13:30
  • The S5 should easily handle 16 instances of the player. – Gabor Szanto Sep 28 '17 at 17:53