Author Topic: How to convert .wav to .ogg ?  (Read 559 times)


  • Posts: 1
How to convert .wav to .ogg ?
« on: 8 Aug '14 - 08:28 »

I'm use to making a program in Delphi about capturing voice of microphone, Program capturing voice of microphone to .wav now,

This is my codes:
Code: [Select]
unit Unit1;
  Form9: TForm9;


{$R *.dfm}

    // Record
    procedure TForm9.Button1Click(Sender: TObject);

    Label2.Caption:='0';                     //Sets label2 to 0 duh

    Timer1.Enabled:=true;                    //Turns timer1 on so you know
                                             //how long you'v been recording

    mciSendString('OPEN NEW TYPE WAVEAUDIO ALIAS MicSound', nil, 0, Handle);

    // MicSound is what the WaveAudio is asigned to.
    // It is used in all the mciSendString so if you
    // rename it to a diffrent name then you need to
    // make sure you change it on all of them.
    // If you dont know what I just said..
    // hell I dont think I know what i just said
    // then leave it the way it is, it will work ether way.
    // The Following is pritty much self explanatory but I put
    // the Notes out for those who dont follow.

    mciSendString('SET MicSound TIME FORMAT MS ' +      // set the time format

        'BITSPERSAMPLE 8 ' +                            // 8 Bit
        'CHANNELS 1 ' +                                 // MONO
        'SAMPLESPERSEC 8000 ' +                         // 8 KHz
        'BYTESPERSEC 8000',                             // 8000 Bytes/s
        nil, 0, Handle);

    mciSendString('RECORD MicSound', nil, 0, Handle);

    // Stop Record
    procedure TForm9.Button2Click(Sender: TObject);
    Timer1.Enabled:=false;   //Stops the timer
    mciSendString('STOP MicSound', nil, 0, Handle);
    mciSendString(PChar('SAVE MicSound ' + 'C:\FileName.wav'), nil, 0, Handle);
    mciSendString('CLOSE MicSound', nil, 0, Handle);



I want to converting .wav to .ogg (For compressing file and lessen size file) with using BASS libraries?
How to convert .wav to .ogg or .amr using delphi and using BASS libraries?

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: How to convert .wav to .ogg ?
« Reply #1 on: 8 Aug '14 - 15:53 »
To record in OGG (or other encoded) format, you can use the BASSenc add-on (along with the main BASS library). Please see the BASS_Encode_Start documentation for details. Also take a look at the RECTEST example that is included in the BASSenc package for a demonstration of recording in OGG format.

If you would also like to encode existing files, that can be done in much the same way. Instead of setting the encoder on a recording channel, you set it on a decoder. You could do something like this (in C/C++)...

Code: [Select]
HSTREAM decoder=BASS_StreamCreateFile(FALSE, infile, 0, 0, BASS_STREAM_DECODE); // create decoder for source file
HENCODE encoder=BASS_Encode_Start(decoder, "oggenc -o out.ogg -", BASS_ENCODE_AUTOFREE, 0, 0); // set an OGG encoder on it
while (BASS_ChannelIsActive(decoder) && BASS_Encode_IsActive(encoder)) { // decoder and encoder are still going
BYTE buf[20000]; // decoding buffer
BASS_ChannelGetData(decoder, buf, sizeof(buf)); // decode some data (and encode it)
BASS_StreamFree(decoder); // free decoder (and encoder due to AUTOFREE)