comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » reading wav files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
reading wav files [message #23347] Mon, 15 January 2001 17:38 Go to next message
jnettle1 is currently offline  jnettle1
Messages: 27
Registered: January 2001
Junior Member
Does anyone have a routine/set of routines to read *.wav files in IDL? And if
so, do you feel like sharing it?? :)

Thanks for your time!
Jeff Nettles
(jnettle1@utk.edu)
Re: Reading Wav files [message #31837 is a reply to message #23347] Thu, 22 August 2002 01:21 Go to previous messageGo to next message
Mike Alport is currently offline  Mike Alport
Messages: 8
Registered: December 1998
Junior Member
Thanks guys - both your suggestions have worked. When I was first playing
around with read_wav, I must have inavertently made it a variable. An
explicit ".compile read_wav" then seems overide that earlier definition. I
have now also learnt about STRICTARR.
Thanks again,
Mike

PS - now I just need to play .wav files from IDL - I see that Matt Feinstein
asked the same question a few days ago wrt IDL_Tools.


"JD Smith" <jdsmith@as.arizona.edu> wrote in message
news:pan.2002.08.21.20.24.41.192394.2937@as.arizona.edu...
> On Wed, 21 Aug 2002 09:08:35 -0700, Mike Alport wrote:
>
>> This seems a trivial problem: the IDL 5.5 documentation gives the
>> following syntax for reading sound .wav files: Result = READ_WAV (
>> Filename [, Rate] ) So, when I try it, I get: IDL> Result = READ_WAV(
>> "ramsay0150.wav" ) % Variable is undefined: READ_WAV.
>>
>> Have they switched the calling procedure name on us? Thanks, Mike Alport
>
> This is probably related to the ()/[] degeneracy in IDL array indexing.
> I can replicate your error:
>
> IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
> % Compiled module: READ_WAV.
> IDL> read_wav=2
> IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
> IDL> help,result
> RESULT BYTE = Array[5400]
>
> No problem thus far.. but what if I start IDL again with:
>
> IDL> read_wav=1
> IDL> r=temporary(read_wav)
> IDL> help
> % At $MAIN$
> I INT = 167
> R INT = 1
> READ_WAV UNDEFINED = <Undefined>
>
> Uh, oh, an "undefined variable" READ_WAV exists. You can imagine what
> will happen now:
>
> IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
> % Variable is undefined: READ_WAV.
> % Execution halted at: $MAIN$
>
> IDL thinks you're trying to index an undefined variable! The problem
> is, variables sometimes exists as "undefined" zombies, even after you
> think they're gone. In this state, that can still "shadow" or overlap
> with function calls. A few options for solving the problem:
>
> 1. Find out where the undefined variable READ_WAV is getting created,
> and eliminate that.
>
> 2. Use "compile_opt STRICTARR" at the beginning of your procedure, or
> at the main level:
>
> IDL> compile_opt STRICTARR
> IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
> % Compiled module: READ_WAV.
>
> 3. Use "forward_function READ_WAV" to declare it a function.
>
> 4. Clamor for RSI to make STRICTARR the default (though duck as Craig
> throws an eraser at your head.)
>
> You could also just put "compile_opt STRICTARR" in your startup file,
> and I think it then applies to all routines and interactive commands
> (anybody know for sure?).
>
> Good luck,
>
> JD
Re: Reading Wav files [message #31848 is a reply to message #23347] Wed, 21 August 2002 13:24 Go to previous messageGo to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 21 Aug 2002 09:08:35 -0700, Mike Alport wrote:

> This seems a trivial problem: the IDL 5.5 documentation gives the
> following syntax for reading sound .wav files: Result = READ_WAV (
> Filename [, Rate] ) So, when I try it, I get: IDL> Result = READ_WAV(
> "ramsay0150.wav" ) % Variable is undefined: READ_WAV.
>
> Have they switched the calling procedure name on us? Thanks, Mike Alport

This is probably related to the ()/[] degeneracy in IDL array indexing.
I can replicate your error:

IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
% Compiled module: READ_WAV.
IDL> read_wav=2
IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
IDL> help,result
RESULT BYTE = Array[5400]

No problem thus far.. but what if I start IDL again with:

IDL> read_wav=1
IDL> r=temporary(read_wav)
IDL> help
% At $MAIN$
I INT = 167
R INT = 1
READ_WAV UNDEFINED = <Undefined>

Uh, oh, an "undefined variable" READ_WAV exists. You can imagine what
will happen now:

IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
% Variable is undefined: READ_WAV.
% Execution halted at: $MAIN$

IDL thinks you're trying to index an undefined variable! The problem
is, variables sometimes exists as "undefined" zombies, even after you
think they're gone. In this state, that can still "shadow" or overlap
with function calls. A few options for solving the problem:

1. Find out where the undefined variable READ_WAV is getting created,
and eliminate that.

2. Use "compile_opt STRICTARR" at the beginning of your procedure, or
at the main level:

IDL> compile_opt STRICTARR
IDL> result = read_wav('/usr/share/licq/sounds/fun/Auth.wav')
% Compiled module: READ_WAV.

3. Use "forward_function READ_WAV" to declare it a function.

4. Clamor for RSI to make STRICTARR the default (though duck as Craig
throws an eraser at your head.)

You could also just put "compile_opt STRICTARR" in your startup file,
and I think it then applies to all routines and interactive commands
(anybody know for sure?).

Good luck,

JD
Re: Reading Wav files [message #31851 is a reply to message #23347] Wed, 21 August 2002 09:59 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mike Alport (alport@nu.ac.za) writes:

> This seems a trivial problem: the IDL 5.5 documentation gives the following
> syntax for reading sound .wav files:
> Result = READ_WAV ( Filename [, Rate] )
> So, when I try it, I get:
> IDL> Result = READ_WAV( "ramsay0150.wav" )
> % Variable is undefined: READ_WAV.
>
> Have they switched the calling procedure name on us?

No, it is definitely a function. Try this:

IDL> .compile read_wav
IDL> Result = READ_WAV( "ramsay0150.wav" )

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: reading wav files [message #46075 is a reply to message #23347] Thu, 03 November 2005 02:51 Go to previous message
wem is currently offline  wem
Messages: 6
Registered: October 2005
Junior Member
rlayberry@hotmail.com wrote:
> I want to be able to read .wav audio files in IDL, such that after
> stripping the header I can look at the actual values. I can't find a
> website with the actual binary format of wav files explained. I
> remember doing something like this years ago. I read wav files and
> then displayed them and processed them etc (I was comparing wav files
> before and after being sent VOIP) - just cant remember how I did it. I
> was also using PV-WZVE before which may have had a wav file reader?
>
> thanks
>
> russ
>

You want something like this?:
http://www.borg.com/~jglatt/tech/wave.htm
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Extracting arrays into txt files
Next Topic: Extracting the resultant angles from the Hough transform

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 06:25:28 PDT 2025

Total time taken to generate the page: 1.59551 seconds