Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > raw audio in windows

Reply
Thread Tools

raw audio in windows

 
 
Putty
Guest
Posts: n/a
 
      09-01-2006
Hi. I've written a small python script that was primarily meant for
use in a unix-compatible environment. It writes a bunch of raw audio
to a file and then sends the file to /dev/audio and the system plays
the audio. Very simple.

Is there a simple way I could edit the script (which just uses the
system call to do this) to run under windows?

This is the code that would have to change:
os.system("cat audioBuf > /dev/audio")

 
Reply With Quote
 
 
 
 
spiffy
Guest
Posts: n/a
 
      09-01-2006
On 31 Aug 2006 21:34:13 -0700, "Putty" <(E-Mail Removed)> wrote:

>Hi. I've written a small python script that was primarily meant for
>use in a unix-compatible environment. It writes a bunch of raw audio
>to a file and then sends the file to /dev/audio and the system plays
>the audio. Very simple.
>
>Is there a simple way I could edit the script (which just uses the
>system call to do this) to run under windows?
>
>This is the code that would have to change:
>os.system("cat audioBuf > /dev/audio")



hey, that sounds like some stuff i've been working on...
is there any possibility that you could send me that script so I could
take a look at it and learn?
i'm new to python and programming in general. i'm working on some
algorithmic composition stuff and also trying to write some synths....
here's my email...
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Ben Sizer
Guest
Posts: n/a
 
      09-01-2006
Putty wrote:
> Hi. I've written a small python script that was primarily meant for
> use in a unix-compatible environment. It writes a bunch of raw audio
> to a file and then sends the file to /dev/audio and the system plays
> the audio. Very simple.
>
> Is there a simple way I could edit the script (which just uses the
> system call to do this) to run under windows?
>
> This is the code that would have to change:
> os.system("cat audioBuf > /dev/audio")


Not really. You'll have to convert it to .wav and then pass it to a
helper app.

<http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1103.mspx>

--
Ben Sizer

 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      09-01-2006
Ben Sizer wrote:

> Not really. You'll have to convert it to .wav and then pass it to a
> helper app.
>
> <http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1103.mspx>


>>> import winsound
>>> help(winsound)

Help on module winsound:

NAME
winsound

FILE
c:\python24\dlls\winsound.pyd

DESCRIPTION
PlaySound(sound, flags) - play a sound
SND_FILENAME - sound is a wav file name
SND_ALIAS - sound is a registry sound association name
SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC
SND_MEMORY - sound is a memory image of a wav file
SND_PURGE - stop all instances of the specified sound
SND_ASYNC - PlaySound returns immediately
SND_NODEFAULT - Do not play a default beep if the sound can not be found
SND_NOSTOP - Do not interrupt any sounds currently playing
SND_NOWAIT - Return immediately if the sound driver is busy

Beep(frequency, duration) - Make a beep through the PC speaker.

FUNCTIONS
Beep(...)
Beep(frequency, duration) - a wrapper around the Windows Beep API

The frequency argument specifies frequency, in hertz, of the sound.
This parameter must be in the range 37 through 32,767.
The duration argument specifies the number of milliseconds.
On WinNT and 2000, the platform Beep API is used directly. Else funky
code doing direct port manipulation is used; it's unknown whether that
will work on all systems.

MessageBeep(...)
MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.

PlaySound(...)
PlaySound(sound, flags) - a wrapper around the Windows PlaySound API

The sound argument can be a filename, data, or None.
For flag values, ored together, see module documentation.

DATA
MB_ICONASTERISK = 64L
MB_ICONEXCLAMATION = 48L
MB_ICONHAND = 16L
MB_ICONQUESTION = 32L
MB_OK = 0L
SND_ALIAS = 65536L
SND_APPLICATION = 128L
SND_ASYNC = 1L
SND_FILENAME = 131072L
SND_LOOP = 8L
SND_MEMORY = 4L
SND_NODEFAULT = 2L
SND_NOSTOP = 16L
SND_NOWAIT = 8192L
SND_PURGE = 64L

</F>



 
Reply With Quote
 
Jay
Guest
Posts: n/a
 
      09-01-2006
I'm afraid I can't do that. Don't take it personally. I would send it
to you, but at this time, I'm developing this app with a friend and I
don't know his feelings about the program's distribution or licensing.
I can't send it around until I speak to him about it.

Sorry.


spiffy wrote:
> On 31 Aug 2006 21:34:13 -0700, "Putty" <(E-Mail Removed)> wrote:
>
> >Hi. I've written a small python script that was primarily meant for
> >use in a unix-compatible environment. It writes a bunch of raw audio
> >to a file and then sends the file to /dev/audio and the system plays
> >the audio. Very simple.
> >
> >Is there a simple way I could edit the script (which just uses the
> >system call to do this) to run under windows?
> >
> >This is the code that would have to change:
> >os.system("cat audioBuf > /dev/audio")

>
>
> hey, that sounds like some stuff i've been working on...
> is there any possibility that you could send me that script so I could
> take a look at it and learn?
> i'm new to python and programming in general. i'm working on some
> algorithmic composition stuff and also trying to write some synths....
> here's my email...
> (E-Mail Removed)


 
Reply With Quote
 
Jay
Guest
Posts: n/a
 
      09-01-2006
So, are you saying this would be possible to do with the PlaySound
function?

Fredrik Lundh wrote:
> Ben Sizer wrote:
>
> > Not really. You'll have to convert it to .wav and then pass it to a
> > helper app.
> >
> > <http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1103.mspx>

>
> >>> import winsound
> >>> help(winsound)

> Help on module winsound:
>
> NAME
> winsound
>
> FILE
> c:\python24\dlls\winsound.pyd
>
> DESCRIPTION
> PlaySound(sound, flags) - play a sound
> SND_FILENAME - sound is a wav file name
> SND_ALIAS - sound is a registry sound association name
> SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC
> SND_MEMORY - sound is a memory image of a wav file
> SND_PURGE - stop all instances of the specified sound
> SND_ASYNC - PlaySound returns immediately
> SND_NODEFAULT - Do not play a default beep if the sound can not be found
> SND_NOSTOP - Do not interrupt any sounds currently playing
> SND_NOWAIT - Return immediately if the sound driver is busy
>
> Beep(frequency, duration) - Make a beep through the PC speaker.
>
> FUNCTIONS
> Beep(...)
> Beep(frequency, duration) - a wrapper around the Windows Beep API
>
> The frequency argument specifies frequency, in hertz, of the sound.
> This parameter must be in the range 37 through 32,767.
> The duration argument specifies the number of milliseconds.
> On WinNT and 2000, the platform Beep API is used directly. Else funky
> code doing direct port manipulation is used; it's unknown whether that
> will work on all systems.
>
> MessageBeep(...)
> MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.
>
> PlaySound(...)
> PlaySound(sound, flags) - a wrapper around the Windows PlaySound API
>
> The sound argument can be a filename, data, or None.
> For flag values, ored together, see module documentation.
>
> DATA
> MB_ICONASTERISK = 64L
> MB_ICONEXCLAMATION = 48L
> MB_ICONHAND = 16L
> MB_ICONQUESTION = 32L
> MB_OK = 0L
> SND_ALIAS = 65536L
> SND_APPLICATION = 128L
> SND_ASYNC = 1L
> SND_FILENAME = 131072L
> SND_LOOP = 8L
> SND_MEMORY = 4L
> SND_NODEFAULT = 2L
> SND_NOSTOP = 16L
> SND_NOWAIT = 8192L
> SND_PURGE = 64L
>
> </F>


 
Reply With Quote
 
Ben Sizer
Guest
Posts: n/a
 
      09-04-2006
Jay wrote:
> So, are you saying this would be possible to do with the PlaySound
> function?


Fredrik is often terse. I think what he's saying is that when I
said you could pass a .wav file to an external application, he showed
that you could pass it to a Python module instead. I think you still
need to get it into .wav format first, though this can apparently be in
memory rather than on disk.

--
Ben Sizer

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RAW Viewer for wide range of RAW formats greymfm Digital Photography 0 06-14-2006 09:12 PM
[Maxxum 7D] Dimage RAW Viewer v. Adobe Raw Plugin Alan Browne Digital Photography 3 03-12-2005 04:17 AM
Adobe PS RAW convertor vs Nikon RAW convertor Vlad Gunko Digital Photography 8 01-25-2005 07:43 PM
raw audio input on Windows Noah Python 1 01-28-2004 02:33 PM
How raw is RAW format? Editor www.nutritionsoftware.org Digital Photography 4 12-22-2003 07:33 PM



Advertisments