0
0

Hi I tried the CD ripping executable and it worked.

I’m trying to make a simple Win32 app that does the same thing. I more or less lifted a lot of the code from the example. Here is the key bit

[code:16qqnpy6]
FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND_NONREALTIME);
if (convertList[i]==false) continue;
char buf[50];
sprintf(buf, "%d.wav", i+1);
fp = fopen(buf, "wb");

    fseek(fp, sizeof(FileHeader) + sizeof(FmtChunk) + sizeof(DataChunk), SEEK_SET);

    FSOUND_STREAM *stream;
    FSOUND_DSPUNIT *rawwrite_dsp;

    rawwrite_dsp = FSOUND_DSP_Create(&DSP_RawWriteCallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0);

    FSOUND_DSP_SetActive(rawwrite_dsp, TRUE);

    FSOUND_Stream_SetBufferSize(2000);

    stream = FSOUND_Stream_Open("f:*j", FSOUND_NORMAL, 0, 0);

    if ( !stream )

    {
        MessageBox("stream didn't work.");
        return;
    }

    FSOUND_Stream_SetEndCallback(stream, endcallback, 0);
    FSOUND_Stream_SetSubStream(stream, i);
    if ( FSOUND_Stream_Play(FSOUND_FREE, stream) == -1)
    {
        MessageBox("not streaming.");
        return;
    }

    ofstream working("working.txt");

    do
    {

        int percentage = (int)(((float)FSOUND_Stream_GetTime(stream) / (float)FSOUND_Stream_GetLengthMs(stream)) * 100.0f);

        progress.SetPos(percentage);

        FSOUND_Update();
    }
    while (stream_ended==FALSE);

    FSOUND_Stream_Close(stream);
    FSOUND_DSP_SetActive(rawwrite_dsp, FALSE);
    FSOUND_DSP_Free(rawwrite_dsp);

    FileHeader.RIFFHeader.length = sizeof(FmtChunk) + sizeof(WAVEChunk) + byteswritten;

    DataChunk.DataChunkHeader.length = byteswritten;

    fseek(fp, 0, SEEK_SET);
    fwrite(&FileHeader, sizeof(FileHeader), 1, fp);
    fwrite(&FmtChunk, sizeof(FmtChunk), 1, fp);
    fwrite(&DataChunk, sizeof(DataChunk), 1, fp);
    fclose(fp);

    byteswritten=0;
    stream_ended=FALSE;
}

FSOUND_Close();

[/code:16qqnpy6]

for some reason my code outputs .wav files that are a) silent and b) exactly 6 seconds long. I find this puzzling.

since the sample program worked i’m guessing it must be my code that is wrong and not my CD-drive?

  • You must to post comments
0
0

[quote="brett":metivjts]hm,
did you make sure the wav headers are packed / aligned properly? (ie #pragma pack)[/quote:metivjts]

yes i did that.

i have actually timed the idle while loop that runs whilst the stream is playing using timeGetTime() and the streams always last 6 seconds (irrespective of the actual track length) and are always silent…

first i thought it was because i didn’t init fmod but i do that and it still doesn’t make a difference. weird.

  • You must to post comments
0
0

I dumped some stats to a textfile…maybe they will give some clues

[code:23lijd34]is thing on?
Converting track 6
Seeking 44 bytes into wave file.
Return value of FSOUND_Stream_Play = 4097
Open state of stream: 0
Stream closed in :0:6s
Number of bytes streamed for this track 1130496
Writing Wave File Header, Size : 12
Writing FMT chunk header, Size: 24
Writing Data Chunk header, Size: 8
[/code:23lijd34]

What worries me is the “stream closed in 0:6s” line. a real head scratcher this one…

  • You must to post comments
0
0

so..um..any ideas? 😕

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.