Your Digital Media Has Never Looked So Good

 
User avatar
Romans_I_XVI
Topic Author
Posts: 269
Joined: Wed Nov 19, 2014 10:25 pm
Contact:

Optimal bitrate for roAudioResource

Sat Jan 03, 2015 8:27 pm

So after spending a few days now trying to make my game optimized and running as smoothly as possible I was somewhat discouraged that after all of my work I was still having times of the entire game freezing up for a split second. This was always occurring around the time I would say destroy a few ships and absorb a few bullets at the same time. I thought there could possibly be too many collisions happening and data being processed and that was slowing it down. But after optimizing my game extensively and investigating this thoroughly I determined it was the Roku hanging while calling the roAudioResource SomeSound.Trigger() . But if that's the case I'm supposedly out of luck right? Wrong! I just went here http://audio.online-convert.com/convert-to-wav . Uploaded the .wav files I had and (re)converted them to .wav with the bitrate set to 16Bit . Now the problem is solved!

Any thoughts on this? Is this a known issue?
 
renojim
** Valued Community Member **
Posts: 3490
Joined: Mon Feb 15, 2010 1:35 pm

Re: Optimal bitrate for roAudioResource

Sat Jan 03, 2015 11:19 pm

Romans_I_XVI wrote:
converted them to .wav with the bitrate set to 16Bit . Now the problem is solved!

The bitrate set to 16-bit? I'm guessing you mean sample size (or bit resolution as that link refers to it as).

Out of curiosity, what sample size and sample rate were your original WAV files? The only issues I'm aware of is that some combinations of sample size and sample rate didn't work at all and sometimes very short WAV files wouldn't play, but it's been a long time since I've experimented and those issues may have been eliminated.

-JT
 
User avatar
Romans_I_XVI
Topic Author
Posts: 269
Joined: Wed Nov 19, 2014 10:25 pm
Contact:

Re: Optimal bitrate for roAudioResource

Sun Jan 04, 2015 2:07 am

Yeah if "bit resolution" is sample size than that's it. I don't know anything about working with audio and can hardly get through making simple changes with audacity. I don't know what my originals were but I do know that I've tried quite a few different sample rates when I was trying to reduce the size. All with the same results. I'm just glad it's working right this time. The Roku seems touchy with audio. First I had to change my background music to .WMA so it would playback smoother, and now this.
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Optimal bitrate for roAudioResource

Sun Jan 04, 2015 2:31 pm

I don't have first-hand experience but here viewtopic.php?f=34&t=78670&p=468951#p468951 BradC recommends sticking to 44k mono audio samples for some of the players. Probably somebody Roku* can clarify?
 
User avatar
BradC
Posts: 305
Joined: Sun Dec 16, 2012 1:50 am

Re: Optimal bitrate for roAudioResource

Sun Jan 04, 2015 4:06 pm

this may seem like a silly question, but are you loading the sounds in realtime or pre-loading them and calling them as needed?

I haven't done any tests on this, but I have always just assumed that reading audio files at runtime would cause behavior like you described.




I've always had bad luck getting sounds to work well across all players, so I'm very interested in anything you may find out. (I've really only ever run into audio quality issues, not performance problems, though)
 
User avatar
Romans_I_XVI
Topic Author
Posts: 269
Joined: Wed Nov 19, 2014 10:25 pm
Contact:

Re: Optimal bitrate for roAudioResource

Sun Jan 04, 2015 8:28 pm

I am pre-loading them. Actually I used to create the roAudioResource object each time a round started along with the creation of all the other variables. But now I create the object only once when the entire game is started instead of in the function that runs the gameplay. I did that just because I knew the sound was causing issues, but that didn't seem to make any difference. Again what fixed everything was when I used that website to change the bit resolution/sample size (whatever it's called) to 16bit. I had used Audacity to change the sample rate before this (mainly in an attempt to reduce the file size) but those all behaved the same. Well actually not 100%, I did get some instances of sound effects only playing half of the sound or none at all, but it was sparatic and inconclusive. Just picked whichever sample rate seemed the best at the time. After using https://tinypng.com/ to reduce my sprite sizes I was much less concerned about the size of the .wav files and so I was ok with using the ones that http://audio.online-convert.com/convert-to-wav spit out. Which for whatever reason are much larger ?

I believe what I currently have implimented is sample rate 8000hz, sample size 16-bit, and mono. Please note I still have the behavior where it sometimes only plays 50% of the sound effect or not at all of multiple activate in a short period of time. But I prefer this 1000% over having it slow down my entire game!

Not sure if any of that helps at all, but that's essentially my entire story. I think I'm in the same boat as you, Roku is quirky when it comes to audio, and there is a lot of fiddling around to try to find what works best.
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 1:21 pm

I've personally settled on using 16 bit 44.1 mono files in my work with roAudioResource as I get the best results with those, there were some bugs with various other lower rates and i'm not sure if those were ever resolved.

Your .wav files need to be small, generally 250k or less work for me. (the limitation is officially 5 seconds in length).

One thing you can do if sounds are being cut off is to alternate channels when playing audio files - there are two channels available on most non-legacy players. Look in the beep example in your SDK for these (currently) not-really-documented features, here they are in a nutshell:

sound1=createobject("roAudioResource","pkg:/sounds/boom.wav")
sound2=createobject("roAudioResource","pkg:/sounds/laser.wav")
numchannels=sound1.maxSimulStreams()
volume=100
if numchannels < 2 then
    print "Two channels not supported"
    stop
else
   print numchannels;" are supported"
end if
    channel=0
        sound1.trigger(volume,channel)
    channel=1
        sound2.trigger(volume,channel)



Note that you are still likely to experience retriggering glitches even if you alternate channels, but this should improve things significantly.

- Joel
 
User avatar
Romans_I_XVI
Topic Author
Posts: 269
Joined: Wed Nov 19, 2014 10:25 pm
Contact:

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 3:04 pm

Wow. Thanks for the tip on multiple channels. Based on your code you are just showing us how to check if 2 channels are available, but you don't have the code verifying that it's available when calling trigger. So I'm guessing if it's not available it will just be ignored and not cause an error?
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 3:50 pm

Romans_I_XVI wrote:
So I'm guessing if it's not available it will just be ignored and not cause an error?


Not sure. Definitely will cause an error on Legacy. I'm not 100% sure what will happen on every other platform. Seems to support two channels on every non-legacy device I've tested so far including RokuTV, but I'm not sure I've tested all variants yet. Best bet would be to disable the second channel usage if the maxSimulStreams() call reports only one channel.

- Joel
 
User avatar
Romans_I_XVI
Topic Author
Posts: 269
Joined: Wed Nov 19, 2014 10:25 pm
Contact:

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 3:52 pm

I don't think I will use it anyway. It's a nice idea, but I just tried it out and it makes it so that the audio plays quite sometimes... IDK why, it wasn't with each swap of channels, it was just randomly.
 
User avatar
BradC
Posts: 305
Joined: Sun Dec 16, 2012 1:50 am

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 4:31 pm

Romans_I_XVI wrote:
I still have the behavior where it sometimes only plays 50% of the sound effect or not at all of multiple activate in a short period of time.


As Joel said, it's important to note that if you trigger a sound, it will stop any currently playing sound. This is by design. So, if for example, you shoot, and play a shoot sound, and then shoot again before the shoot sound completes, the first shoot sound will cut off as the new shoot sound is triggered. This is how it's supposed to happen unless you use the method Joel outlined. I can tell you from experience that will (or used to) crash players like the HD, so be careful before using it.


Another thing you might do is something I've done in most of my games, and prioritize your sounds. For example, a shot may be a more important sound than an explosion. So if something is about to explode, you can check if the shot sound is playing, and if so, you just skip the explosion sound, because it's really not as important as having the feedback to the player of the shot sound. It's a bit of a pain, but the results are worth it in lots of cases (imo)
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Optimal bitrate for roAudioResource

Mon Jan 05, 2015 5:47 pm

That thing about audio channel and maxSimulStreams() is undocumented, right?
I cannot find a read on it and http://sdkdocs.roku.com/display/sdkdoc/ifAudioResource does not show 2nd argument for Trigger().

Seems quite useful, so... document it, pls?

Hat-tip @BradC: doing triage on the audio (prioritizing) - that is smart!
 
User avatar
Komag
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Re: Optimal bitrate for roAudioResource

Thu Apr 09, 2015 1:46 pm

Okay, so this thread is really important for me now, working through audio issues.

First off I have a problem with a certain sound effect that sometimes cuts out and then NEVER works again! It's a sound when the player is hit, and the problem seems to occur when I have multiple enemies hitting the player at the same time. I assume it might have something to do with the sound being called twice at the same time.
here is the sound.GetMetaData() info:
NumChannels: 1
SamplesPerSecond: 44100
BitsPerSample: 16
Length: 10752
I even tried a test function (triggered by my pressing Replay on my remote) to invalidate all the existing roAudioResource objects and rebuild/refresh them all over again, but it didn't help, the sound will never play again, forever. This is a serious problem!

Also, regarding the undocumented roAudioResource.MaxSimulStreams():
My Roku HD 2500 says 1, but my Roku 2 XS 3100 says 2. I'd be interested to know what all the other models (non-classic) say, as I'd really love to implement two sound effects at the same time on boxes that can.

And if I want to prioritize my sounds, how? I see that I can check if a particular sound is playing using sound.IsPlaying(), but I can't simply check WHAT sound is playing. Are you saying that if I want to prioritize, I'd have to run a series of individual sound.IsPlaying() checks for each sound I don't want to override?

EDIT - My Roku 1 2710 reports 1 MaxSimulStreams as well.
ignoring classic models, and listing models listed on wikipedia:
MODEL.....AUDIO STREAMS
2400
2450
2500.......1
3000
3050
3100.......2
3400
3420
3500
2700
2710.......1
2720
4200
 
User avatar
Komag
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Re: Optimal bitrate for roAudioResource

Thu Apr 09, 2015 6:54 pm

One of my problems is now solved - the hitPlayer sound that used to cut out FOREVER was my own dumb fault - my player was DEAD after a while, and I have the sound set up to only play when he's alive, haha. :lol: So that at least is not a Roku bug.

But now I've discovered something more troubling:
HDMI audio is less reliable than AV audio!
Roku 1 2710
AV audio - works reliably, all sounds play at correct volume, all sounds work, nothing broken.
HDMI audio - the first few (3 or 4) sounds don't play at all, every time. Then sounds start working, but volume adjusts sometimes for no reason, some play quiet, most normal, some silent (either 0 volume or not playing, can't tell), no pattern that I can tell.
This is all with my sound effect volumes all at 100. I tried setting all volumes to 50, same thing happens, first few sounds don't play, then they play but vary in volume randomly, most are normal, but every so often one is quiet or silent.
 
User avatar
squirreltown
Posts: 870
Joined: Sun Apr 21, 2013 2:20 pm

Re: Optimal bitrate for roAudioResource

Thu Apr 09, 2015 7:05 pm

Is the AV going through an amp and the HDMI TV only? Maybe an auto-leveling TV feature you forgot about? Sure sounds like one of those silly compressors TV's have.
Kinetics Screensavers

Who is online

Users browsing this forum: No registered users and 3 guests