Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Sound Effects

Is there anyway to use custom sound effects for navigation within a channel?
How can these sounds be changed?

Thank you for your help. Smiley Happy
0 Kudos
12 Replies
belltown
Level 7

Re: Custom Sound Effects

Yes, I just tried it out. I changed my channel to emit a fart sound every time a button or remote key is pressed. You need to use an roAudioResource It works very well, although I would suggest using something other than a fart sound.
https://github.com/belltown/
0 Kudos
TheEndless
Level 7

Re: Custom Sound Effects

You cannot, however, replace the system sounds on standard SDK screens, if that's your goal.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos

Re: Custom Sound Effects

I added a .wav file to a sounds folder in my channel. I then tried the variations of code bellow and all of them resulted in a similar error.

'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...pkg:/source/appHomeScreen.brs(662)
662: sound.trigger("75")

sound = CreateObject("roAudioResource", "pkg:/sounds/arrow_x.wav")
sound.Trigger(75)

sound = CreateObject("roAudioResource", "pkg:/sounds/arrow_x.wav")
sound.trigger(75)

sound = CreateObject("roAudioResource", "pkg:/sounds/arrow_x.wav")
sound.Trigger("75")

sound = CreateObject("roAudioResource", "pkg:/sounds/arrow_x.wav")
sound.trigger("75")


I have also tried using the files whole path but this gives me the same results.
How do I make the sound play correctly? What am I doing wrong?

Thank you very much for your help. Smiley Happy
0 Kudos
BradC
Level 7

Re: Custom Sound Effects

should work. below is what I use.

either sound is a reserved word, or you should try a different sample to see if your file is bad. the only files that seem to moderately work for me are 44100 Hz wav files.




sound_squish=CreateObject("roAudioResource", "pkg:/assets/sounds/squish.wav")
sound_squish.Trigger(100)

♦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♦
0 Kudos

Re: Custom Sound Effects

When I create the roAudioResource object and then check the type it is saying that it is invalid. I am using a 44100 Hz wav file.

my_sound = CreateObject("roAudioResource", "pkg:/sounds/4ch.wav")
print"Type(my_sound) = " ; Type(my_sound)

Debuger:
Type(my_sound) = Invalid
0 Kudos
destruk
Level 10

Re: Custom Sound Effects

works fine for me - are you using stereo?
quotes probably shouldn't be used for trigger, as it is an integer, not a string. (might work, just I never used quotes there)
0 Kudos
squirreltown
Level 8

Re: Custom Sound Effects

"lock_4815162342" wrote:
When I create the roAudioResource object and then check the type it is saying that it is invalid. I am using a 44100 Hz wav file.

Try it without the extension. This is what I had to do:
m.beep=CreateObject("roAudioResource", "pkg:/locale/default/images/rokusound")

Obviously, not everyone has the issue I did, in fact I can't shed a bit of light on why I had to do it that way, but it never worked for me with the .wav extension and did work when i removed it.
One other thing is that ( I think it was ) renojim figured out a while back that sounds need to be a minimum of 1 second, so if it's shorter than that, add some silence to the end until its at least 1000ms.
Kinetics Screensavers
0 Kudos
EnTerr
Level 8

Re: Custom Sound Effects

"lock_4815162342" wrote:
When I create the roAudioResource object and then check the type it is saying that it is invalid.

Right. That's what the error "'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec)" almost always (99.28%) means: you are trying "." on variable holding the value invalid and not an object.

And invalid means that CreateObject("roAudioResource", "pkg:/sounds/arrow_x.wav") has failed. My guess is that you forgot to include the file in the bundle deployed to Roku. Try this and if it says false, file is not where (or named as) you thought it was:
BrightScript Debugger> ? createObject("roFileSystem").exists("pkg:/sounds/arrow_x.wav")
false


PS.
"squirreltown" wrote:
... in fact I can't shed a bit of light on why I had to do it that way, but it never worked for me with the .wav extension and did work when i removed it.
I will take a guess: perhaps while working on a Mac, the file has been "Save As..."-ed in WAV format but without adding the ".wav" suffix in the name? Do a Get Info (Command-i) on the file and see what it says under "Name & Extension".
0 Kudos

Re: Custom Sound Effects

My problem was that the file was not mono.

Thank you to everyone for your help.
0 Kudos