Wave file properties

49 views
Skip to first unread message

Molochnik

unread,
Sep 13, 2012, 7:58:26 AM9/13/12
to newac...@googlegroups.com
Hello,
i want to know the wave file properties such as BitsPerSample, SampleRate etc. So I just create TWaveIn object and try to get these properties from it:
 
var
  WaveIn1: TWaveIn;
  i:integer;
begin
  WaveIn1 := TWaveIn.Create(nil);
  WaveIn1.FileName := 'c:\chimes.wav';
  i:=WaveIn1.BitsPerSample;//range check error
....
end;
 
This code always results "range check error" while opening the file. Maybe I do not make it right, but in any case the "range check error" is not a good style

Ross Levis

unread,
Sep 13, 2012, 8:16:56 AM9/13/12
to newac...@googlegroups.com

I think you may need a WaveIn1.Init;

--
You are recieving this message because you are subscribed to "NewAC users" Google group.
To post message to this group send it to
newac...@googlegroups.com
To unsubscribe from the group send a mail to: newac-users...@googlegroups.com
Additional variants are available at the groups page http://groups.google.com/group/newac-users?hl=en

Ross Levis

unread,
Sep 13, 2012, 8:20:51 AM9/13/12
to newac...@googlegroups.com

And don’t forget the WaveIn1.Flush afterwards.

Hunter1972

unread,
Sep 13, 2012, 10:02:04 AM9/13/12
to Ross Levis
1)I added these "init" and "flush" methods and now it works fine, thank you.
2)Immediately I got another situation that I cannot understand.
I am concatenating two files in one, so I placed on the form two TWaveIns, one TAudioMixer and one TWaveOut.
This code works fine (the file is created):

with WaveOut1 do
begin
FileName := 'c:\a.wav';
OnDone := WaveOut1Done;
Input := AudioMixer1;
Run;
end;

this code works without errors but without the resulted file either

with TWaveOut.Create(Self) do
begin
FileName := 'c:\a.wav';
OnDone := WaveOut1Done;
Input := AudioMixer1;
Run;
end;

I tried to change this code in different ways but could not make it work properly
--
С уважением,
Hunter1972 mailto:Hunte...@mail.ru

Sergey Tkachenko

unread,
Sep 13, 2012, 10:09:33 AM9/13/12
to newac...@googlegroups.com
Did you tried to use Cardinal instead Integer for i ?

13.09.2012 14:58, Molochnik написав(ла):

Hunter1972

unread,
Sep 13, 2012, 10:33:14 AM9/13/12
to Sergey Tkachenko
> Did you tried to use Cardinal instead Integer for i ?
This error is gone after I added the Init function. But now
even when I remove "Init" the code works properly and I cannot
reproduce the error. That makes me feel a little confused.

Hunter1972

unread,
Sep 13, 2012, 10:43:33 AM9/13/12
to Hunter1972
But the second question remains, why the TWaveOut object doesn't work
being created at runtime.
Reply all
Reply to author
Forward
0 new messages