Hi,
I think I really need to learn about audio units.
This really doesn't cut it:
It seems iOS can just forget about the sound if it hasn't been played for
a while, and needs to hold everything to reload it if you play it again.
This can appear to fix it, but still... something going on, like it only works
temporarily or something.
AVFoundation doesn't play the same sound in harmony, so I did this:
So that an identical sound can be playing, more than one instance simultaneously
(i.e. user presses a button twice very fast).
By the time the counter is reset to zero, the first sound has actually
finished, and ready to play again, so the user can go crazy with the button.
If a button is not pushed for a while, all of the sounds are forgotten, and
the App paused a short period while they are reloaded.
Everything is fine as long as the sound has been played fairly recently,
so I think it can be fixed with a shovel:
Just keep playing them.... very desperate. When the button routine goes to play one,
it should have been used recently, but not currently in use.
Where's a good place to start with Audio Units, or a very bare bones example?
I used something similar (I think) on the PSP, where you had an
audio thread where a 16 bit buffer needed to be filled when it was ready for the next sample.
The sample data was a .wav file with stripped header for raw PCM file.
I converted that to C arrays, and still have a lot of sound sample data in that format.
Cheers, Art.
I think I really need to learn about audio units.
This really doesn't cut it:
Code:
[avbeep play];
a while, and needs to hold everything to reload it if you play it again.
Code:
[avbeep prepareToPlay];
temporarily or something.
AVFoundation doesn't play the same sound in harmony, so I did this:
Code:
beepcnt++;
if (beepcnt > 3) {beepcnt = 0;}
if (beepcnt == 0) {[avbeep play];}
if (beepcnt == 1) {[avbeepx play];}
if (beepcnt == 2) {[avbeepy play];}
if (beepcnt == 3) {[avbeepz play];}
(i.e. user presses a button twice very fast).
By the time the counter is reset to zero, the first sound has actually
finished, and ready to play again, so the user can go crazy with the button.
If a button is not pushed for a while, all of the sounds are forgotten, and
the App paused a short period while they are reloaded.
Everything is fine as long as the sound has been played fairly recently,
so I think it can be fixed with a shovel:
Code:
// somewhere execution occurs every second or so
beepcnt++;
if (beepcnt > 3) {beepcnt = 0;}
if (beepcnt == 0) {avbeep.volume = 0.0; [avbeep play]; avbeep.volume = 1.0;}
if (beepcnt == 1) {avbeepx.volume = 0.0; [avbeepx play]; avbeepx.volume = 1.0;}
if (beepcnt == 2) {avbeepy.volume = 0.0; [avbeepy play]; avbeepy.volume = 1.0;}
if (beepcnt == 3) {avbeepz.volume = 0.0; [avbeepz play]; avbeepz.volume = 1.0;}
it should have been used recently, but not currently in use.
Where's a good place to start with Audio Units, or a very bare bones example?
I used something similar (I think) on the PSP, where you had an
audio thread where a 16 bit buffer needed to be filled when it was ready for the next sample.
The sample data was a .wav file with stripped header for raw PCM file.
I converted that to C arrays, and still have a lot of sound sample data in that format.
Cheers, Art.
Last edited: