🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #49

mmioDescend() / mmioAscend()

#49
From: TMBTC
Date: Sun, 16 Jul 2006 01:23
81 lines
4042 bytes
Can anyone help me understand how to use the mmioDescend() / mmioAscend() 
API functions for a read operation. I have searched the Web and Help files 
but am still having problems. I need to write an app that will add the CART 
(www.cartchunk.org) chunk information to a WAVE file.

I have a test.wav file that contains the CART chunk. When I read it all is 
fine. When I read a WAVE file that does not contain it, I also can't find 
the 'data' chunk.

//Code --------------------------------------------------------------------
void __fastcall TForm1::OpenButtonClick(TObject *Sender)
{
   //
   MMCKINFO mmckInfoWave = {0};
   HMMIO mmioFileHandle = NULL;
   WAVEFORMATEX WaveFormat = {0};
   MMCKINFO mmckInfoSubChunk = {0};
   CartChunkTagURL cartTag = {0};
   AnsiString asTemp = "";

   mmioFileHandle = mmioOpen("test.wav", 0, MMIO_READ);
   if (mmioFileHandle) {
      mmckInfoWave.fccType = mmioFOURCC('W','A','V','E');
      if (mmioDescend(mmioFileHandle, (LPMMCKINFO)&mmckInfoWave, 0, 
MMIO_FINDRIFF)
          == MMIOERR_CHUNKNOTFOUND) {
         mmioClose(mmioFileHandle, 0);
         return;
      } //EndIf (mmioDescend(...))
      //
      mmckInfoSubChunk.ckid = mmioFOURCC('f','m','t',' ');
      if(mmioDescend(mmioFileHandle, &mmckInfoSubChunk, &mmckInfoWave, 
MMIO_FINDCHUNK)
         == MMIOERR_CHUNKNOTFOUND) {
         mmioClose(mmioFileHandle, 0);
         return;
      } //EndIf (mmioDescend(..))
   } //EndIf (mmioFileHandle)

   mmioRead(mmioFileHandle, (HPSTR)&WaveFormat, mmckInfoSubChunk.cksize);
   Memo1->Lines->Clear();
   asTemp.sprintf("Number of Channels: %d", WaveFormat.nChannels);
   Memo1->Lines->Add(asTemp);
   asTemp.sprintf("Sample Per Second: %d", WaveFormat.nSamplesPerSec);
   Memo1->Lines->Add(asTemp);
   asTemp.sprintf("Avg. Bytes Per Second: %d", WaveFormat.nAvgBytesPerSec);
   Memo1->Lines->Add(asTemp);
   asTemp.sprintf("Block Alignment: %d", WaveFormat.nBlockAlign);
   Memo1->Lines->Add(asTemp);
   //
   // Get CART Info
   mmioAscend(mmioFileHandle, &mmckInfoSubChunk, 0);
   mmckInfoSubChunk.ckid = mmioFOURCC('C','A','R','T');
   if(mmioDescend(mmioFileHandle, &mmckInfoSubChunk, &mmckInfoWave, 
MMIO_FINDCHUNK)
      == MMIOERR_CHUNKNOTFOUND) {
      Memo1->Lines->Add("No 'CART' chunk found.");
      mmioSeek(mmioFileHandle, mmckInfoWave.dwDataOffset, SEEK_SET);
      mmckInfoSubChunk.dwDataOffset = mmckInfoWave.dwDataOffset;
      mmckInfoSubChunk.fccType = 0;
   } else {
      mmioRead(mmioFileHandle, (HPSTR)&cartTag, mmckInfoSubChunk.cksize);
      asTemp.sprintf("Size of CART: %d", mmckInfoSubChunk.cksize);
      Memo1->Lines->Add(asTemp);
   }


   // get data info
      mmioAscend(mmioFileHandle, &mmckInfoSubChunk, 0);
   mmckInfoSubChunk.ckid = mmioFOURCC('d','a','t','a');
   if(mmioDescend(mmioFileHandle, &mmckInfoSubChunk, &mmckInfoWave, 
MMIO_FINDCHUNK)
      == MMIOERR_CHUNKNOTFOUND) {
      Memo1->Lines->Add("No 'data' chunk found.");
   } else {
      asTemp.sprintf("Size of Data: %d", mmckInfoSubChunk.cksize);
      Memo1->Lines->Add(asTemp);
   }

   mmioClose(mmioFileHandle, 0);
} //End OpenButtonClick()
Technical Details
Message-ID: <44b994f9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,1c42c7cbd941d437,start
X-Google-Attributes: gid10d0fc,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "TMBTC" <jkofsky@bellsouth.net>
Newsgroups: borland.public.cppbuilder.multimedia
Subject: mmioDescend() / mmioAscend()
Date: Sat, 15 Jul 2006 20:23:04 -0500
Lines: 83
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
NNTP-Posting-Host: 65.6.192.60
Message-ID: <44b994f9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1153012985 65.6.192.60 (15 Jul 2006 18:23:05 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail