cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lala
Level VIII

How to play Windows WAV sound with JSL?

Can I not use this command?

run program(executable(""),options({""}))

 

audio files

C:\Windows\Media\tada.wav

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to play Windows WAV sound with JSL?

this might be all you need

beep( );

You might be able to use

speak("Ready!")

but I don't know how to localize it to a language other than English. You can make it say some random sounds.

speak("aeiou"); 

It will use a different voice/algorithm on different computers/OSs/versions...

 

Craige

View solution in original post

7 REPLIES 7
lala
Level VIII

Re: How to play Windows WAV sound with JSL?

  • I write the code like this and it automatically shuts down without success.

RunProgram( executable( "C:\Program Files\Windows Media Player\wmplayer.exe" ), options( {"C:\Windows\Media\tada.wav"} ) );
Wait( 3 );
RunProgram( executable( "cmd.exe" ), options( {"/c Taskkill /im wmplayer.exe /f /t"} ) );
lala
Level VIII

Re: How to play Windows WAV sound with JSL?

AutoHotkey can play this file like this:

SoundPlay, %A_WinDir%\Media\tada.wav
Sleep 2000
peng_liu
Staff

Re: How to play Windows WAV sound with JSL?

I am not sure that JMP can do that. I vaguely remembered JMP can play midi. But if anyone has the experience about this, I would think of @Craige_Hales . Why don't you first check out his post Working with WAV files 

Even if his post might not have said how to play a WAV file, you may trace his work to find out how to deal with windows DLL. It seems possible to use WINMM.DLL to play WAV; see here (though might be out-dated.)

lala
Level VIII

Re: How to play Windows WAV sound with JSL?

Thanks for the tip!

Craige_Hales
Super User

Re: How to play Windows WAV sound with JSL?

Audio Note in an Envelope  uses

	If( playFromMemory & useSoundPlayer, // from memory
		mmdll << PlaySoundA( Blob To Matrix( riffblob, "float", 8, "native" ), 0, 5 )//
	, // else via file
		filename = Save Text File( "$desktop/note.wav", riffblob );
		If( useSoundPlayer,
			mmdll << PlaySoundA(
				Blob To Matrix( Char To Blob( filename ) || Matrix To Blob( [0, 0, 0, 0, 0, 0, 0, 0, 0], "int", 1, "little" ), "float", 8, "native" ),
				0,
				131073
			)
		);
	);

the PlaySoundA entrypoint in the DLL can't overlap audio files and is a bit arcane and needs a bit of setup.

 

Plucked note synthesis  and Mandelbrot Sound  use

wavname = RiffUtil:WavWriter( "$temp/rotate.wav", bigbuf ); 
Open( wavname );

and Midi (music) File Editor  is similar, Open( temp ), for a .mid file extension. Open() opens the built in player. The midi player example uses two files because the open player keeps the other one in use.

 

Using a Project for a Project  uses (This is the best way to play overlapping sound files.)

pgm = Eval Insert( "(New-Object Media.SoundPlayer \!"^filename^\!").PlaySync();" );
			//write("\!npowershell ",pgm);
			Insert Into(Audio:rphandles,
				Run Program( executable( "powershell" ), options( {"-c", pgm} ), readfunction( Function( {this}, Write( this << read ) ) ) )
			);

This project is a side-scroller game with a rich sound tapestry to enhance the ambiance...

 

Pumpkin Rush  uses the built-in speech function to make an ooomph! sound. (This, and the beep function, are easy but not very flexible.) Another game. Beware the shaking screen!

 

Working with WAV files  appears to write a file to disk but not actually play it. Wav files have a modestly complex format to hold a set of samples (mono, stereo, 48 ... 8 kHz, ...)

 

As much as I love audio, I was never able to justify spending time adding audio support to a statistics package. If you have a great use-case, add it here!

Craige
lala
Level VIII

Re: How to play Windows WAV sound with JSL?

Thank Craige!

 

 

The reason I wanted JSL to play the audio was simple: to use JSL to play the sound to remind when the data conditions of the data sheet are specified.The simplest way to implement the alert will do.Thanks!

Craige_Hales
Super User

Re: How to play Windows WAV sound with JSL?

this might be all you need

beep( );

You might be able to use

speak("Ready!")

but I don't know how to localize it to a language other than English. You can make it say some random sounds.

speak("aeiou"); 

It will use a different voice/algorithm on different computers/OSs/versions...

 

Craige