Article View: borland.public.cppbuilder.multimedia
Article #413Re: Compressing audio - formats supported by XP
From: Mark Jacobs
Date: Sun, 25 Jul 2004 01:32
Date: Sun, 25 Jul 2004 01:32
60 lines
4335 bytes
4335 bytes
The reason is that the WAVEFORMATEX structure members have to be derived from
actual inspection of the audio codecs using the Microsoft ACM library. Have a
look for acmDriverEnum in the Windows SDK help file. Each codec has a number of
formats. For example, MPEG3 has 41, and OGG Mode 3 has 88 on my PC. Most have
fewer formats than these, for example PCM (uncompressed data) which has 16
formats and GSM 6.10 (mobile phone compression) with 4. Each of these formats
has a unique WAVEFORMATEX encoding and a variable number of extra bytes tacked
on to the end of the WAVEFORMATEX structure, the exact number denoted in the
cbSize member. Supply one of these correct structures to waveInOpen, and it
usually works. The number of extra bytes is usually no greater than 32, however,
OGG codecs use up to 3,096 extra bytes, so you have to declare a generic
WAVEFORMATEX structure to hold the extra info, like this :-
typedef struct mywvfmt { WAVEFORMATEX wfx; WORD xinf[32768];} MJWVFMT;
Remember, a WORD is 2 bytes, so I have plenty of space for future absurdities
with 32,768!
The ACM is really hard to program, unless you are used to the MFC way of
programming, with structs, callback routines and pointers. Success is very
rewarding though. On my website at http://www.jacobsm.com/index.htm#sft is a
program called MJ Calculator ... (mathspenknife.exe) which will produce a report
for any PC it is run on, listing all the audio codecs and possible formats for
the WAVEFORMATEX structures. For my PC this report is 5 MBytes and is produced
in under 5 seconds. Right-click the little globe button on the right-hand side
of the window.
--
Mark Jacobs
(I answer my own questions to let you know)
"Mark Jacobs" <markj atty critical dotty co dotty uk> wrote in message
news:40fe9d52$1@newsgroups.borland.com...
| I have been dabbling with direct handling of audio buffers, and I have been
| able to open PCM and GSM6.10 formats by specifying the correct WAVEFORMATEX
| and GSM610WAVEFORMAT structures. As I delved deeper, I found loads of other
| compression algorithms, including MPEGLAYER3 and TRUESPEECH. The problem I am
| getting is that none of these other codecs open correctly with
|
| waveInOpen(&phwo,WAVE_MAPPER,&ptsp.wfx,(DWORD)WaveInProc,
| (DWORD)this,CALLBACK_FUNCTION);
|
| where I set up TRUESPEECHWAVEFORMAT ptsp structure as follows :-
|
| ptsp.wfx.cbSize=32; ptsp.wfx.wFormatTag=WAVE_FORMAT_DSPGROUP_TRUESPEECH;
| ptsp.wfx.nChannels=1; ptsp.wfx.nSamplesPerSec=8000;
| ptsp.wfx.wBitsPerSample=0;
| ptsp.wfx.nAvgBytesPerSec=1067; ptsp.wfx.nBlockAlign=32;
| ptsp.nSamplesPerBlock=240;
|
| This is in accordance with the document at
| http://www.csdn.net/dev/format/windows/wavec.htm
|
| Why will this not open for input or output? I have checked that I have all of
| these codecs enabled under Windows Multimedia system properties. Am I correct
| in thinking that you can only waveInOpen codecs that can handle real-time
| encoding?
|
| If I use MPEGLAYER3, I can, under Windows XP SP1, open it with waveOutOpen,
| but not waveInOpen. Why only for decoding MP3 audio, and not for encoding? Is
| there some kind of copyright issue here? TIA,
Technical Details
Message-ID:
<41030db0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40fe9d52$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,3ab497c67f89962f X-Google-Attributes: gid10d0fc,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Jacobs" <mark@losethisbitjacobsm.com> Newsgroups: borland.public.cppbuilder.multimedia References: <40fe9d52$1@newsgroups.borland.com> Subject: Re: Compressing audio - formats supported by XP Date: Sun, 25 Jul 2004 02:32:31 +0100 Lines: 61 Organization: DK Computing MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 81.86.186.94 Message-ID: <41030db0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1090719152 81.86.186.94 (24 Jul 2004 18:32:32 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail