Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MazeWizzard
Visitor

3.0 r 2227 roAudioResource reliability

Anyone get roAudioResource to play on time reliably for beeps/boops?

I can seem to get it working with a single sound file, however, it is intermittent with others. For example, it would be one beep/boop off, playing the beep from the previous "hit" when the boop from the current hit was called. This is not a bug in my code as far as I can tell. I'm trying to produce a small program to isolate and reproduce the issue, but I thought I'd ask in the meantime.

Anyone out there have more experience with small short duration wav files with the 3.0 SDK and have them work wonkey? Anyone else experience this error or other errors with roAudioResource?

Additionally, it appears that loading over 24 sounds is rebooting my box (telnet: "connection to host lost"). For example:

    AudioObjects[0]=CreateObject("roAudioResource", "pkg:/sounds/sound1234.wav")
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blip.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipC0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipC0S.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipD0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipE0b.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipE0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipF0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipF0S.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipG0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipA0b.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipA0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipB0b.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipB0.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipC1.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipC1S.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipD1.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipE1b.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipE1.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipF1.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipF1S.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipG1.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipA1b.wav"))
AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipA1.wav"))
'AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipB1b.wav"))
' AudioObjects.push(CreateObject("roAudioResource", "pkg:/sounds/blipB1.wav"))


Will work. But if I remove the comment from either of the last 2 lines, it reboots the box. IDK if it's a total # bytes loaded issue (the files are mostly 4k each, one is 18K). I tried dropping the 18K file out and adding the last 2 4K files, to no avail. Is there some limit to the # of roAudioResources I can load at once?
0 Kudos
8 REPLIES 8
destruk
Streaming Star

Re: 3.0 r 2227 roAudioResource reliability

That is normal/ie can be easily reproduced and has been this way since roAudioResource was introduced. I'm not sure on a limit of file handles, but having it play a sound reliably can only seem to be done with mp3's - and then you have a second delay while it buffers and will kill the box if you need to play video later in your app. Of course if someone else has a fix or insight, I'd be interested to hear from them.
0 Kudos
jbrave
Channel Surfer

Re: 3.0 r 2227 roAudioResource reliability

I would first of all, investigate if one of your wav files is corrupt or weird in some way, by commenting them all out except for the last two and see if it still reboots, if not, then start adding the rest in one at a time.

Also, try doing it like this:

AudioObjects=[CreateObject("roAudioResource", "pkg:/sounds/sound1234.wav")
CreateObject("roAudioResource", "pkg:/sounds/blip.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipC0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipC0S.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipD0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipE0b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipE0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipF0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipF0S.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipG0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipA0b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipA0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipB0b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipB0.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipC1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipC1S.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipD1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipE1b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipE1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipF1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipF1S.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipG1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipA1b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipA1.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipB1b.wav")
CreateObject("roAudioResource", "pkg:/sounds/blipB1.wav")]


works in one of my projects just fine. I think my project may be in a similar vein to yours, based on the names of your files. Very Cool.

I don't find roAudioResource to be at all unreliable. There are some limitations, for example on the length of the file, seems to be around 250k. All my files are 44.1khz 16bit mono.

If a file doesn't work properly, I load it up in Quicktime Pro, then export it as 16bit, 44.1khz mono wav, which seems to sort out any anomalies that may come from other audio software.

Also, a better way of dealing with sound files is to download them to tmp:/ from a webserver at load time, if you can, that way you have a smaller installer package.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
MazeWizzard
Visitor

Re: 3.0 r 2227 roAudioResource reliability

Thanks for the responses. If it is indeed a file handle issue, swapping the files and checking for corrupt files won't solve it. However, I don't use all notes at all times (yet) so I may have a different solution. Thanks Destruk.

The corrupt files issue is possible I guess. I know they all load, as I have swapped out the last few files for different ones and still had no problem. I think Destruk is correct ... it's the # of files open at the same time. IDK why the syntax change (although it may be faster to load that way... thanks) would make any difference... it's just an alternate way to fill the array... I will try it though. Thanks again.

I am surprised, jbrave/Joel that your program worked with that # of files... did you count them? Do you have more than that (this is Roku 1 and 3.0 SDK right?)???? How many were you able to load? I'd love another octive. 8-) 😉 There is a way to handle it... maybe... but it is much slower. (Destruck... one "fix"/"workaround" may to cache the objects using a LRU algorithm... but you'd have to force old roAudioResource objects out of scope/force garbage collection and pray that the destructor releases the file handles... since there is no specific "destroy/close/not-needed-anymore" method.... I haven't tried it yet).

I haven't tried to reproduce the "offset sounds" issue yet, as I am still working on the file-handle issue and tone duration using wav files (ugh) rather than having a tone generator. (Probably a device limitation with a decoder chip rather than a sound synth or bit-banging method for controlling audio output... I'm not too optimistic about sound changes in the future on roku1). However, if I do isolate and reproduce it, I'll make another post. I withdraw that part of the question for the time being.

Thanks again for the feedback gang.
0 Kudos
jbrave
Channel Surfer

Re: 3.0 r 2227 roAudioResource reliability

Nope, my bad, turns out you are 100% correct about the roAudioResource reboot issue. I miscounted yesterday, was counting first array element as zero (which it is, but it is the 1st element).
I'm testing on Roku2.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
destruk
Streaming Star

Re: 3.0 r 2227 roAudioResource reliability

I was trying to use roAudioResource to play different sounds based on button presses on the remote control. What I found is that - after exiting a large gridscreen, the sounds would play before the graphics were done being cleared from the previous screen. When pressing left/right repeatedly, roaudioresource sometimes misses events to play a sound. Depending on the sound length (less than a second or greater than a second) there are also delays including differences in the sample rate if you introduce those mixed type of files - in short, it's fine for a few sounds, but to generate compositions or 'chip tunes' with variable timing it is inadequate. Of course that's just from my testing, maybe I'm trying to push it more than intended. This was seen even with the sound files included in the pkg.
0 Kudos
jbrave
Channel Surfer

Re: 3.0 r 2227 roAudioResource reliability

"destruk" wrote:
in short, it's fine for a few sounds, but to generate compositions or 'chip tunes' with variable timing it is inadequate.


IMO it is actually pretty good for that. Make sure all your sound files are the same length. Suggest again, 44.1khz mono and use Quicktime Pro to export your final sounds. Trust me, it is worth the $20.

I have a full on tr-909 style Drum Machine I've written that works pretty well on 3.0 firmware. Don't mix sample rates! Sample rate conversion is always going to take time and produce inferior sound quality.

Roku2 has a click/pop issue with roAudioResources that makes it almost unusable.

The only real timing issue is that the clock is a millisecond clock, not a 44.1 sample clock, so there will be a little bit of inaccuracy.

I'm able to do real time updates to the screen while playing without serious timing issues, except when editing the current loop while it is playing, which results in slight timing errors due to all the if/then processing.
The pink line on the bottom of the top row in this picture shows the currently playing note.

Main challenge for me is to make the UI compatible with the old-fashioned Roku remotes.

Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
destruk
Streaming Star

Re: 3.0 r 2227 roAudioResource reliability

I didn't try making all the sound files the same duration - just thought it was smarter than that. 🙂 Thanks.
0 Kudos
gonzotek
Visitor

Re: 3.0 r 2227 roAudioResource reliability

"jbrave" wrote:

Main challenge for me is to make the UI compatible with the old-fashioned Roku remotes.
This channel looks like fun!

Can you make press-and-hold actions? If the picture of the remote above covers all the possible actions, then may I suggest press-and-hold OK to save and press-and-hold Play/Pause for Accent. Or maybe put accent on >>, if that's available.

Users could also use a network remote, perhaps(I know it's not the same).
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.