🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #171

Re: waveIn/waveOut API

#171
From: Jason Cipriani
Date: Mon, 30 Jun 2008 20:25
35 lines
2748 bytes
"Carl Danley" <cdanley@codebyter.com> wrote in message 
news:48690f45$1@newsgroups.borland.com...
> Anyone able to write me some sample coding for creating a stream to record 
> audio to using the waveIn, waveOut API?

You'll be using the waveIn* functions to open and read from an audio input 
device. The waveOut functions are for writing sounds to audio hardware, not 
for writing WAV files.

Start with waveInOpen:
http://msdn.microsoft.com/en-us/library/ms713735(VS.85).aspx

I don't know what you are recording audio -to-, so I'm assuming to disk. As 
you capture samples, it's straightforward just to write to WAV files 
directly with stdio or iostreams or whatever your preferred API is. Here is 
the WAV file format, they are much easier to write than they are to read::
http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

You only need to write the "data" and "fmt " subchunks. Just write the 
header with the appropriate values then write all the samples, nothing to 
it.

You could also consider using DirectSound, or DirectShow. It's trivial with 
both, assuming familiarity with DirectX and COM. I believe there is a sample 
class CWaveFile that comes with DirectSound that can also handle writing WAV 
files:
http://msdn.microsoft.com/en-us/library/bb206370(VS.85).aspx

See the TOC on the left of that link for more DirectSound links. One 
advantage of DirectSound, or DirectShow, is that it becomes extremely easy 
to use other codecs, such as MP3, to record audio, and also to use files on 
disk as well as hardware as audio sources (or any source with a DirectSound 
driver) without modifying much application code.

Jason
Technical Details
Message-ID: <48694148$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!feed.xsnews.nl!border-3.ams.xsnews.nl!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <48690f45$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9763bae5c3c1546f
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Jason Cipriani" <jason.cipriani@nospam-gmail.com>
From: "Jason Cipriani" <jason.cipriani@nospam-gmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <48690f45$1@newsgroups.borland.com>
Subject: Re: waveIn/waveOut API
Date: Mon, 30 Jun 2008 16:25:43 -0400
Lines: 37
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 24.189.102.41
Message-ID: <48694148$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1214857544 24.189.102.41 (30 Jun 2008 13:25:44 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!feed.xsnews.nl!border-3.ams.xsnews.nl!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail