# Sound under windows

**URL:** <https://rubytalk.org/t/sound-under-windows/2773>\
**Category:** ruby-talk\
**Created:** [9 November 2002 11:48 UTC](https://rubytalk.org/t/sound-under-windows/2773 "2002-11-09T11:48:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MENON\_Jean-Francois](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MENON\_Jean-Francois](https://rubytalk.org/u/MENON_Jean-Francois)\
**Post date:** [9 November 2002 11:48 UTC](https://rubytalk.org/t/sound-under-windows/2773/1 "2002-11-09T11:48:09Z")

</div>

hello,  
what is the good way for output simple sounds with Ruby under windows ?  
I looked in the RAA but it seems to be only libs for linux  
thx,  
jf

---

<div class="post-metadata">

**Author:** ![Armin\_Roehrl](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@Armin\_Roehrl](https://rubytalk.org/u/Armin_Roehrl)\
**Post date:** [9 November 2002 12:11 UTC](https://rubytalk.org/t/sound-under-windows/2773/2 "2002-11-09T12:11:19Z")

</div>

You might want to look at VRuby.  
There exists one demo called mediatest. That might  
just be what you want.

Alternatively using the OLE-stuff you might be able  
to control an external Windows-program.

Bye,  
-A.

> **···**
>
> Am Samstag, 9. November 2002 12:48 schrieb MENON Jean-Francois:
> 
> > hello,  
> > what is the good way for output simple sounds with Ruby under windows ?  
> > I looked in the RAA but it seems to be only libs for linux  
> > thx,  
> > jf
> 
> * * *
> 
> Armin Roehrl, [http://www.approximity.com](http://www.approximity.com)  
> Training, Development and Mentoring  
> OOP, XP, Java, Ruby, Smalltalk, .Net, Datamining, Parallel computing,  
> Webservices
> 
> How could you do all that?  
> I did not know it was hard.  
> –??

---

<div class="post-metadata">

**Author:** ![Armin\_Roehrl](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@Armin\_Roehrl](https://rubytalk.org/u/Armin_Roehrl)\
**Post date:** [9 November 2002 12:14 UTC](https://rubytalk.org/t/sound-under-windows/2773/3 "2002-11-09T12:14:22Z")

</div>

here is the link:  
[http://www.threeweb.ad.jp/~nyasu/vruby/samples-e.html](http://www.threeweb.ad.jp/~nyasu/vruby/samples-e.html)  
search for mp3, wav, or avi.

> **···**
>
> Am Samstag, 9. November 2002 12:48 schrieb MENON Jean-Francois:
> 
> > hello,  
> > what is the good way for output simple sounds with Ruby under windows ?  
> > I looked in the RAA but it seems to be only libs for linux  
> > thx,  
> > jf  
> > –  
> > -A.
> 
> * * *
> 
> Armin Roehrl, [http://www.approximity.com](http://www.approximity.com)  
> Training, Development and Mentoring  
> OOP, XP, Java, Ruby, Smalltalk, .Net, Datamining, Parallel computing,  
> Webservices
> 
> How could you do all that?  
> I did not know it was hard.  
> –??

---

<div class="post-metadata">

**Author:** ![Bill\_Kelly](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@Bill\_Kelly](https://rubytalk.org/u/Bill_Kelly)\
**Post date:** [9 November 2002 18:26 UTC](https://rubytalk.org/t/sound-under-windows/2773/4 "2002-11-09T18:26:09Z")

</div>

Hi,

> hello,  
> what is the good way for output simple sounds with Ruby under windows ?  
> I looked in the RAA but it seems to be only libs for linux

One way is to use Win32API:

SND\_MEMORY = 0x00000004 # from “mmsystem.h”  
SND\_FILENAME = 0x00020000

PlaySound = Win32API.new(“winmm”, “PlaySound”, [‘P’, ‘L’, ‘L’], ‘I’)

# play from file:

PlaySound.call(“C:/your/sound.wav”, 0, SND\_FILENAME)

# play from memory:

wav = File.open(“C:/your/sound.wav”, File::RDONLY) {|f| f.binmode; f.read }  
PlaySound.call(wav, 0, SND\_MEMORY)

HTH,

Bill

> **···**
>
> From: “MENON Jean-Francois” [jean-francois.menon@meteo.fr](mailto:jean-francois.menon@meteo.fr)

---

<div class="post-metadata">

**Author:** ![MENON\_Jean-Francois](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MENON\_Jean-Francois](https://rubytalk.org/u/MENON_Jean-Francois)\
**Post date:** [10 November 2002 19:12 UTC](https://rubytalk.org/t/sound-under-windows/2773/5 "2002-11-10T19:12:11Z")

</div>

Bill Kelly wrote:

> Hi,
> 
> From: “MENON Jean-Francois” [jean-francois.menon@meteo.fr](mailto:jean-francois.menon@meteo.fr)
> 
> > hello,  
> > what is the good way for output simple sounds with Ruby under windows ?  
> > I looked in the RAA but it seems to be only libs for linux
> 
> One way is to use Win32API:
> 
> SND\_MEMORY = 0x00000004 # from “mmsystem.h”  
> SND\_FILENAME = 0x00020000
> 
> PlaySound = Win32API.new(“winmm”, “PlaySound”, [‘P’, ‘L’, ‘L’], ‘I’)
> 
> # play from file:
> 
> PlaySound.call(“C:/your/sound.wav”, 0, SND\_FILENAME)
> 
> # play from memory:
> 
> wav = File.open(“C:/your/sound.wav”, File::RDONLY) {|f| f.binmode; f.read }  
> PlaySound.call(wav, 0, SND\_MEMORY)
> 
> HTH,
> 
> Bill

thank you very much :-\>  
I don’t know if it is planned for future releases of Ruby, but I think  
it would be good to have a standard (platform independent) way to play  
wav files with ruby.

regards,  
jf
