PDA

View Full Version : Sound in UI; Smooth Lines


wjpiovano
05-24-2008, 04:41 PM
Is there any way to play a .mp3 (or any format) file when a button is pressed?

Is there a way to create a smooth curved line (like a spline curve) out of only 3 points? I want to make a smooth random line without specifying a dozen points.

Can you call rand with a variable? e.g. rand $var. Maya seems not to like it; if not, is there any way around it?

Thanks.

Gravedigger
05-25-2008, 11:44 AM
hei wjpiovano
a whole bunch of questions! :D

1. Is there any way to play a .mp3 (or any format) file when a button is pressed?

-> you can write a script which opens the mp3 file. you can use the system command to do this:

system("start file.mp3");

well the problem is that it'll open in your standard audio player.

2. Is there a way to create a smooth curved line (like a spline curve) out of only 3 points? I want to make a smooth random line without specifying a dozen points.

->yes you can. you have to go to the options of the cv curve tool and change the degree to 2.

3. Can you call rand with a variable? e.g. rand $var. Maya seems not to like it; if not, is there any way around it?

-> i have no problems using rand with a variable:

int $var = 10;
print (`rand $var`+"\n");

this works fine for me

hope this helps!
grs Gravedigger

wjpiovano
05-25-2008, 11:09 PM
Hey there! Thanks for the useful replies.

I think I was doing something strange (or going crazy). Rand does in fact seem to work. =D

I have the misfortune of having Maya PLE which doesn't support 'system' or 'exec'. Do you happen to know any possible ways around it?

Thanks again!

GiantG
05-26-2008, 12:14 AM
Check the MEL documentation for sound.
I found this here...

// Create an audio node for a sound file, and have it
// start at time 10. This command will return the name
// of the created node, something like "audio1".
//
sound -offset 10 -file "ohNo.aiff";

// In order to have this sound displayed in a
// timeControl widget (like the timeSlider) use a
// command like this one, where the global MEL variable
// $gPlayBackSlider is the name of the widget to display
// the sound in.
//
global string $gPlayBackSlider;
timeControl -edit -sound audio1 $gPlayBackSlider;
// To display sound in a soundControl, there must first be a sound
// node in the scene. We'll create one and give it the name "ohNo".
// Note that the argument to the -file flag must be a path to a valid
// soundfile.
//
sound -file "ohNo.aiff" -name "ohNo";

// Create a sound control (named "soundScrubber")
// and have it display the sound associated with audio node "ohNo".
//
window;
frameLayout -lv false;
soundControl -width 600 -height 45 -sound ohNo
-displaySound true -waveform both soundScrubber;
showWindow;

// Now setup "soundScrubber" to actually scrub with
// mouse drags.
//
string $pressCmd = "soundControl -e -beginScrub soundScrubber";
string $releaseCmd = "soundControl -e -endScrub soundScrubber";

soundControl -e -pc $pressCmd -rc $releaseCmd soundScrubber;


Cheerz...

CGTalk Moderation
05-26-2008, 12:14 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.