1. Sound in Euphoria Programs for Beginners

Hello fellows , Hello all Data jugglers ,

may i ask a simple question ?

How about to simple add some sound ( mp3 or wav files )

to a small program in euphoria 4.0 under Windows.

Are the topics described in the tutorial?

Hans

new topic     » topic index » view message » categorize

2. Re: Sound in Euphoria Programs for Beginners

Hi

Look these up in the archive

BASS

BASSMOD

FMOD

OpenAl

Musubi

Should be enough to get you started!

http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=sound

Will give even more examples

Chris

new topic     » goto parent     » topic index » view message » categorize

3. Re: Sound in Euphoria Programs for Beginners

Assuming you have a .wav file called "shot.wav" (change that to whatever your .wav is called) this would play that every time you pressed the ENTER key:

include std/machine.e  --for allocate_string 
include std/dll.e  --for open_dll 
include std/get.e   
 
constant SND_ASYNC = #1, NULL = 0 
 
function link_c_func(atom dll, sequence name, sequence args, atom result) 
-- dynamically link a C routine as an Euphoria function 
    integer handle 
 
    handle = define_c_func(dll, name, args, result) 
    if handle = -1 then 
        puts(1,"Couldn't find PlaySound\n") 
    else 
        return handle 
    end if 
end function 
 
atom winmm = open_dll("winmm.dll")  --PlaySound is located in this dll 
    if winmm = 0 then 
        puts(1,"Couldn't open winmm.dll\n") 
    end if 
 
atom PlaySound = link_c_func(winmm, "PlaySound", {C_POINTER,C_INT,C_DOUBLE},C_INT) 
 
atom Shot = allocate_string("shot.wav") 
 
while 1 do 
	if getc(0) then 
		c_func(PlaySound,{Shot,NULL,SND_ASYNC}) 
	end if 
end while 

Not being a professional (or even semi-professional) programmer, this probably isn't best practice, but it'll get the job done.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu