SetSoundVolume

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

SetSoundVolume

Post 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.
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: SetSoundVolume

Post 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.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
mrblp
Posts: 82
Joined: 02 Oct 2010, 14:33

Re: SetSoundVolume

Post 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
Bye Marvin

- "I think you ought to know I'm feeling very depressed." - (Android Marvin in "The Hitchhiker's Guide to the Galaxy" by Douglas Adams, 1978)
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: SetSoundVolume

Post 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. :oops:

Thank both of you.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: SetSoundVolume

Post by HaWe »

don't worry, it's the aging...
;)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests