Page 1 of 1
SetSoundVolume
Posted: 10 Mar 2012, 14:18
by mcsummation
I used SoundVolume() to check the volume setting in my NXT and the result came back as 1, which is what I specified in the NXT menu system. However, when I play a file it is loud. How can I control the volume? The file was one of the "standard" system files, like "! Attention.rso". SetSoundVolume(1) seemed to have no affect.
Re: SetSoundVolume
Posted: 10 Mar 2012, 14:33
by h-g-t
Not an expert, but a quick trawl though the 'net indicates that you might have to use this (taken from John Hansen's NXC Guide) -
PlayFileEx(filename, volume, bLoop) Function
Play the specified sound file (.rso) or a melody file (.rmd). The filename may be any
valid string expression. Volume should be a number from 0 (silent) to 4 (loudest).
bLoop is a boolean value indicating whether to repeatedly play the file.
PlayFileEx("startup.rso", 3, true);
I think PlayFile just sends the file to the speaker at full volume.
Re: SetSoundVolume
Posted: 10 Mar 2012, 14:44
by mrblp
Hello,
In NXCDefs.h you find:
Code: Select all
#define PlayTone(_f, _d) PlayToneEx(_f, _d, 4, 0)
#define PlayFile(_f) PlayFileEx(_f, 4, 0)
so PlayTone and PlayFile always play at volume 4. Read the volume via SoundVolume() and use PlayFileEx instead of PlayFile.
Bye marvin
Re: SetSoundVolume
Posted: 10 Mar 2012, 15:59
by mcsummation
Ofttimes I amaze myself with my ability to look at a line next to the one I should be looking at and not see the correct line.
Thank both of you.
Re: SetSoundVolume
Posted: 10 Mar 2012, 16:43
by HaWe
don't worry, it's the aging...
;)