WAV saving?

November 27th, 2003 - 12:52 pm ET by w3r3w0lf | Report spam
Hi!

thanks to Chris P., I managed to convert streams via acm* API, and now would
like to save that :)
I realize I need to use mmio to do that, and I manage to create header, but
do not know how to write data.
this is how i write my headers:

HMMIO hmmio;
hmmio = mmioOpen("C:\\dest.wav",
NULL,
MMIO_CREATE | MMIO_WRITE | MMIO_EXCLUSIVE |
MMIO_ALLOCBUF);

MMCKINFO ckRIFF;

ckRIFF.fccType = mmioFOURCC('W', 'A', 'V', 'E');
ckRIFF.cksize = 0;
mmioCreateChunk(hmmio, &ckRIFF, MMIO_CREATERIFF);

MMCKINFO ck;

ck.ckid = mmioFOURCC('f', 'm', 't', ' ');
ck.cksize = 0L;
mmioCreateChunk(hmmio, &ck, 0);

mmioWrite(hmmio, (HPSTR)&wfSrc, sizeof(wfSrc));
mmioAscend(hmmio, &ck, 0);

ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
ck.cksize = dwSrcSamples;

mmioCreateChunk(hmmio, &ck, 0);
mmioAscend(hmmio, &ck, 0);

mmioAscend(hmmio, &ckRIFF, 0);

mmioClose(hmmio, 0);


I get it that my data chunk is actuall blank, but how to fill it up? ACM
fills pbDst member of ACMSTREAMHEADER with converted data, but I do not know
how to write it to data chunk.

any help much appreciated!
email Follow the discussionReplies 4 repliesReplies Make a reply

Similar topics

Replies

#1 Chris P.
November 27th, 2003 - 09:33 pm ET | Report spam
"w3r3w0lf" !> wrote in message news:bq5dso$49m$
Hi!

thanks to Chris P., I managed to convert streams via acm* API, and now


would
like to save that :)
I realize I need to use mmio to do that, and I manage to create header,


but
do not know how to write data.
this is how i write my headers:

HMMIO hmmio;
hmmio = mmioOpen("C:\\dest.wav",
NULL,
MMIO_CREATE | MMIO_WRITE | MMIO_EXCLUSIVE |
MMIO_ALLOCBUF);

MMCKINFO ckRIFF;

ckRIFF.fccType = mmioFOURCC('W', 'A', 'V', 'E');
ckRIFF.cksize = 0;
mmioCreateChunk(hmmio, &ckRIFF, MMIO_CREATERIFF);

MMCKINFO ck;

ck.ckid = mmioFOURCC('f', 'm', 't', ' ');
ck.cksize = 0L;
mmioCreateChunk(hmmio, &ck, 0);

mmioWrite(hmmio, (HPSTR)&wfSrc, sizeof(wfSrc));
mmioAscend(hmmio, &ck, 0);

ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
ck.cksize = dwSrcSamples;

mmioCreateChunk(hmmio, &ck, 0);
mmioAscend(hmmio, &ck, 0);

mmioAscend(hmmio, &ckRIFF, 0);

mmioClose(hmmio, 0);


I get it that my data chunk is actuall blank, but how to fill it up? ACM
fills pbDst member of ACMSTREAMHEADER with converted data, but I do not


know
how to write it to data chunk.

any help much appreciated!



It's just a chunk of data, so just write it with mmioWrite. The code you
show also assumes that you know the size of the destination data before
actually writing the data which is not always the case.

To verify that your files are being made correctly start of by only doing
minor format conversions (PCM to another PCM format) and then open the files
in binary mode inside Visual Studio checking the length specified after the
'data' chunk.
Replies Reply to this message
#2 w3r3w0lf
November 28th, 2003 - 06:01 am ET | Report spam
"Chris P." wrote in message
news:
"w3r3w0lf" !> wrote in message news:bq5dso$49m$



<cut>

It's just a chunk of data, so just write it with mmioWrite. The code you
show also assumes that you know the size of the destination data before
actually writing the data which is not always the case.

To verify that your files are being made correctly start of by only doing
minor format conversions (PCM to another PCM format) and then open the


files
in binary mode inside Visual Studio checking the length specified after


the
'data' chunk.



thanks, but i don't know how to write the data with mmioWrite. can you
please give me a short snip on how to do that?
do I have to do this:
mmioWrite(hmmio, (HPSTR)&bData,dwSrcSamples);

bData is an array of BYTE data type.
Replies Reply to this message
#3 Chris P.
November 28th, 2003 - 12:02 pm ET | Report spam
"w3r3w0lf" wrote

"Chris P." wrote
> "w3r3w0lf" wrote

<cut>

> It's just a chunk of data, so just write it with mmioWrite. The code


you
> show also assumes that you know the size of the destination data before
> actually writing the data which is not always the case.
>
> To verify that your files are being made correctly start of by only


doing
> minor format conversions (PCM to another PCM format) and then open the
files
> in binary mode inside Visual Studio checking the length specified after
the
> 'data' chunk.

thanks, but i don't know how to write the data with mmioWrite. can you
please give me a short snip on how to do that?
do I have to do this:
mmioWrite(hmmio, (HPSTR)&bData,dwSrcSamples);

bData is an array of BYTE data type.



Correct, where dwSrcSamples is the size of your BYTE array. More
technically your samples aren't really bytes at all but it just makes the
math easier.

However if bData is an array or a pointer you do not want to take the
address of that or you will be writing the wrong memory space.

mmioWrite(hmmio, bData, dwSrcSamples);

Typecast bData if necessary to HPSTR. Call the function repetively as
required to write all the data.

Call mmioAscend when all the data is written to update the data chunk size
value.
Replies Reply to this message
#4 w3r3w0lf
November 28th, 2003 - 02:27 pm ET | Report spam
"Chris P." wrote in message
news:
<cut>
Correct, where dwSrcSamples is the size of your BYTE array. More
technically your samples aren't really bytes at all but it just makes the
math easier.

However if bData is an array or a pointer you do not want to take the
address of that or you will be writing the wrong memory space.

mmioWrite(hmmio, bData, dwSrcSamples);

Typecast bData if necessary to HPSTR. Call the function repetively as
required to write all the data.

Call mmioAscend when all the data is written to update the data chunk size
value.




thanks, it worked! but I have one more question...
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search