Solved

Low Level Audio API question

Posted on 2000-02-28
15
416 Views
Last Modified: 2010-05-18
Does anyone know how to alter the sample rate of a wave once it has been opened with WaveOutOpen? I can alter it if I change the nsamplespersec entry in my WAVEFORMATEX structure but can I alter it once I have opened the wave? Where is this info stored. Anyone have any better ideas on how to speed up and slow down a wave by any other means?

This one is hard guys!!

Dave
0
Comment
Question by:davegreen
15 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2567865
I found this:

http://www.cs.cornell.edu/dali/api/wave-c.html

If it is a complete description of this particular API I would say the answer is you can't :-(

Cheers,

Raymond.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2567951
hi dave,

maybe you can also find something at simonets athenas place

http://www.bhnet.com.br/~simonet/howtoprojs.htm

there is also a howtoproj with wave-files

meikl
0
 

Author Comment

by:davegreen
ID: 2568005
Adjusted points to 1000
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:davegreen
ID: 2568006
Thanks guys.. Raymond.. That looks like a api for their own application..not the Win API.
meikl.. already checked this out.. he is not using the low level wave api
Thanks...

Upped the points... I REALLY need an answer for this one!

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2568283
Is DirectSound (DirectX) an option?
0
 

Author Comment

by:davegreen
ID: 2568303
Adjusted points to 1500
0
 

Author Comment

by:davegreen
ID: 2568304
Epsylon
I didn't want to use DirectSound, although I know that it has a pitch function that would work.
0
 

Author Comment

by:davegreen
ID: 2568308
1500 point should be enough I think for an answer :O)
0
 

Expert Comment

by:ellessar
ID: 2568338
Have you tried the waveOutSetPlaybackRate function to speed up or slow down your playback?


0
 

Author Comment

by:davegreen
ID: 2568357
I'm not sure this is available on all soundcards, if at all. I tried it on mine and it didn't work. I need something that will work on every wave  playing capable computer.
0
 

Expert Comment

by:ellessar
ID: 2568445
From the MSDN:
=========================
Changing Pitch and Playback Rate
Some waveform-audio output devices can vary the pitch and the playback rate of waveform-audio data. Not all waveform-audio devices support pitch and playback-rate changes. To determine whether a device supports playback rate changes, use the WAVECAPS_PLAYBACKRATE flag to test the dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).

The differences between changing pitch and playback rate are as follows:

Changing the playback rate is performed by the device driver and does not require specialized hardware. The sample rate is not changed, but the driver interpolates by skipping or synthesizing samples. For example, if the playback rate is changed by a factor of two, the driver skips every other sample.
Changing the pitch requires specialized hardware. The playback rate and sample rate are not changed.
Windows provides the following functions to query and set waveform-audio pitch and playback rates.

waveOutGetPitch Retrieves the pitch for the specified waveform-audio output device.

waveOutGetPlaybackRate Retrieves the playback rate for the specified waveform-audio output device.

waveOutSetPitch Sets the pitch for the specified waveform-audio output device.

waveOutSetPlaybackRate Sets the playback rate for the specified waveform-audio output device.


The pitch and playback rates are changed by a factor specified with a fixed-point number packed into a doubleword value. The upper 16 bits specify the integer part of the number; the lower 16 bits specify the fractional part. For example, the value 1.5 is represented as 0x00018000L. The value 0.75 is represented as 0x0000C000L. A value of 1.0 (0x00010000) means the pitch or playback rate is unchanged.
==========================


So, if your sound card is not working, then determine what the cause is from the returned error message. It looks like these are the only methods that the windows API supports. Unfortunately we live in an imperfect world and hardware does not always support what we require. Just look at printers to see an example..

Anyway, that's all I can help with unfortunately..
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2569057
hi dave!

you can do whatever you want with that .WAV file while you opened it as normal file (without API), so:

- open .WAV file as usual AssignFile( F, 'mywav.wav' );
- read it all (or by chunks) to memory
- analyze .WAV header to find out sampling rate, 8 or 16 bit etc...
- now CONVERT it by yourself to another sampling rate... this is called stretching or squeezing algorythm. You better to use Brezenhaim (spelling is wrong, I know ;) approach to get it changed to another frequence. Easy example: if you need it faster two times, just throw out every second byte (or word if 16bit)... But, to make it 'good' conversion you have to apply some dithering.
- now add new .WAV header to that converted data and send it it multimedia API

this is the only way I think....
0
 
LVL 1

Accepted Solution

by:
Horus earned 1500 total points
ID: 2570869
Have you looked at MMTools from swiftsoft www.swiftsoft.de. Their wave components do almost anything that can be done with wave audio. There is a pitch component in the audio pack.
0
 

Author Comment

by:davegreen
ID: 2571410
These look great! although a little expensive to buy the source. The pitch component looks like it will do the trick.
Thanks again guys!
0
 

Expert Comment

by:mombino
ID: 2722384
davegreen.....
I need your help strongly......realy strongly....please if you have some tiny spare time just send me an e-mail with a single word "ok".

I am working on a project on the low level wave recording, and I am trying to use the wave\in, wave\out functions....

just a little help from you will lead me out.....

yours daniel mondi.....
danielmondi@hotmail.com

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 2 69
Why can't I create any project with my delphi EXE file? 6 39
Installshield for Embarcadero EX 10.1 Berlin 4 60
Tidtcpserver listening on multiports? 1 35
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question