sound stopping

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

sound stopping

Post by wekilledbambi03 »

i have a sound clip (.wav) playing. its about 30sec long. problem is i dont know how to stop it. i tried bgmusic:stop() (bgmusic is the var for the file) then it says something to the effect of loop in gettable. i forget exactly what it said. can anyone help me out?
JetSpike
Posts: 8
Joined: Mon Sep 19, 2005 2:38 am

Post by JetSpike »

Load your sound file into a variable like this: (use false if you don't want it to loop)

mySound = Sound.load("sound.wav",true)

Then later you can stop it by using:

mySound:stop()
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

thats basically what i have. and it gives me this error message "loop in gettable"
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

Yeah i dont like .wav sounds. you can only have like 45 seconds of it. but im too lazy to do it in a different format. and when you do a 3mb mp3, it goes to a 64mb .wav file. it pretty much sux so you have to put it on a really really bad quality. Mine works fine though. only i have this

Code: Select all

sound=Sound.load('file.wav', true)
some code goes here
sound = nil
it works fine. in fact i never even tried sound:stop() because i just use this.
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

thanks that works. now i have another sound question. i would like music to play during a race. problem is i have sounds for the engine constantly playing. the music plays for about half a second before it is drowned out by the engine. is the problem that the music isnt load enough or that the constant engine sounds override the music?
heres the code i have for the engine. if i take it out the music plays fine. but i still want to have the other sounds. is there anyway to keep them both?

Code: Select all

if rpm < 1500 then
	idle&#58;play&#40;&#41; end
if rpm > 1500 and rpm < 2000 then
	revlow&#58;play&#40;&#41; end
if rpm > 2000 and rpm < 4000 then
	revlow2&#58;play&#40;&#41; end
if rpm > 4000 and rpm < 6000 then
	revmid&#58;play&#40;&#41; end
if rpm > 6000 and rpm < 9000 then
	revhigh&#58;play&#40;&#41; end
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

you need to load music and not all .wav files. make your engine noise .wav and your music .it(best choice i dont know). then do this:

Code: Select all

Music.playfile&#40; 'filename.it', true&#41;
if rpm < 1500 then 
   idle&#58;play&#40;&#41; end 
if rpm > 1500 and rpm < 2000 then 
   revlow&#58;play&#40;&#41; end 
if rpm > 2000 and rpm < 4000 then 
   revlow2&#58;play&#40;&#41; end 
if rpm > 4000 and rpm < 6000 then 
   revmid&#58;play&#40;&#41; end 
if rpm > 6000 and rpm < 9000 then 
   revhigh&#58;play&#40;&#41; end
Music.stop&#40;&#41;
that is the basic idea. i think LUA player only lets one sound play at a time and .wav files are considered sound in LUA's eyes. but you can have "music" and sound playing at the same time. just get a file converter and make some compatible music. i never used anything off of .it because it came with a game.
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

does anyone know where some good converters are? ive looked a few times but never found any good ones.
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

You found a CONVERTER? But it wasnt good??

Look, the MOD format is like MIDI, all composed of beats. .it, .mod, .xm, .s3m, ect are different MOD formats. Search for Modplug Tracker. Thats what I believe to be the best MOD mixer.[/u]
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

sorry. like i said i only used .wav files. but here are the "music" types supported if you dont know

UNI, IT, XM, S3M, MOD, MTM, STM, DSM, MED, FAR, ULT or 669

but looking around what does this do?

Code: Select all

SoundSystem.SFXVolume&#40; number &#123;0-128&#125; &#41;
???? does that change the volume of your "sound"? i think it does but im not sure. it would be sweet if lua supported mp3 files. :( while we are on the subject of sound, does lua sound output in stereo or is it just mono?
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

im not sure about the volume thing but i do believe that the sound is mono. also has anyone noticed that if you write in a new font the sound gets really slow?
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

if it was stereo you could make a robot! you see here are my master plans. you take psp apart. rewire the cross button, and others for sensors. then the only out put is sound so connect your speaker wires to a headphone amplifier to pump up the signal. then write some code so if one of the sensors get bumbed, play a diffrent sound or no sound.

record a sound so the balance is all on the right for left turns, record a sound so the balance is all on the left for right turns then make a sound so the balance is equal for straight forward driving. then you make a kill switch sensor so if it goes off of stairs or something no sound would be played and your robot would stop moving.

the robot would have to be 2 wheels because there are only two speakers and you would void your warranty. but it sounds practical but you would have to really make the sound signal strong.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

...Or just buy a LEGO Mindstorms set for less than the cost of a PSP and build all the robots you want.
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

whats the fun in that?
00100000 01101001 01101101 00100000 01110010 01101001 01100111 01101000 01110100 00100000 01100010 01100101 01101000 01101001 01101110 01100100 00100000 01111001 01101111 01110101 00100001
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

...Then program your PSP to control your LEGO Mindstorms robots using the IR link.
Post Reply