• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

Audio compression

how to implement audio compression in delphi .what units and dll s that i need
0
rihab
Asked:
rihab
1 Solution
 
ITugayCommented:
Which of compression methods do you like?
----
Igor.
0
 
MathiasIT SpecialistCommented:
Which compression do you want? Wave, Midi or MP3...
0
 
l8knightCommented:
Try 'Audio Compression Manager' available from http://www.rtfm.be/fpiette/acm.htm

hope this helps

l8knight
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
rowisoftCommented:
Hello!

I use Delphi 5! I tryed to open a mp3-file with the TMediaPlayer!! It was running!

Try it out, open a mp3-file with TMediaPlayer! It does work!

bye

Robert
0
 
PhrAtoRCommented:
Hello!

if you want to compress audiofiles (wav-> mp3) then have a look on following site http://bladeenc.mp3.no/

bye
PhrAtoR
0
 
scifibeau67Commented:
Do you want it for playback or recording?

Playback is easy. Just use TMediaPlayer to open and play it. But the necessary codecs must be available on your system for it to do that.

Also, if MP3 is unchecked in Windows Media Player, TMediaPlayer won't play an mp3 file even if you have the codecs. You have to do some trudging around in the registry to re-enable it. I have included source for doing this (from my own audio player) at end of message.

As for recording, implementing it is a very low level affair in Windows. For mp3, you will probably have to use the freeware Blade encoder DLL, because Windows limits mp3 recording bitrate to 58Kbs, which sounds like frap. Playback of mp3 has no such limits.

Have you tried .asf? Microsoft improved the codecs so that sound quality is equal to mp3, but at much lower bitrates. I was really surprised at the quality of the .asf files. Also, since it is an MS product, you don't have worry about patent hassles and lawsuits.

160Kbs mp3 => 96Kbs asf
128Kbs mp3 => 64Kbs asf

To encode asf, download the Windows Media Tools (~4MB), and use them as is. If you want to distribute them in your own app, use OLE to access the encoder. But, the end user has to have the encoder installed on their system.




-----------------------
MP3 Enabling code


procedure TForm1.EnableMP3();
var   winini: TIniFile;
 winreg: TRegistry;
begin
  // enables mp3 Playback, even if media Player
  // cannot be set to it. Requires Windows Media Player 6.1 or higher.
  //
  // enable win.ini settings
  winini := TIniFile.Create('c:\Windows\win.ini');
  tmpstring := winini.ReadString('mci extensions','mp3','x');
  if tmpstring = 'x' then
    begin
//      MessageDlg('Enabling mp3. Please wait while I trudge around in the registry.', mtInformation,[mbOk], 0);
      winini.WriteString('mci extensions','mp3','MPEGVideo');
      winini.WriteString('mci extensions','m3u','MPEGVideo');
      winini.WriteString('MCI Extensions.BAK','mp3','MPEGVideo');
      winini.WriteString('MCI Extensions.BAK','m3u','MPEGVideo');
//      MessageDlg('MP3 enabled!', mtInformation,[mbOk], 0);
    end;
  winini.free;
  //
  //enable mp3
  winreg := TRegistry.Create;
  try
    winreg.RootKey := HKEY_LOCAL_MACHINE;
    winreg.OpenKey('Software\Microsoft\MediaPlayer\PlayerUpgrade', False);
    // get MediaPlayer version, must be 6.4 or higher
    tmpstring := winreg.ReadString('PlayerVersion');
    winreg.CloseKey;
    if tmpstring[1] <> '6' then
      begin
        if MessageDlg('Windows Media Player must be upgraded to the latest version.'+
          'Click YES to visit the Microsoft site. Or, NO to exit.', mtConfirmation,
          [mbYes, mbNo], 0) = mrYes then
            begin
              Form1.Visible := False;
              ShellExecute(0,nil,'http://www.microsoft.com/windows/windowsmedia/',nil,nil,0);
              MessageDlg('After downloading Windows Media Player, run setup. When it finishes installing, restart Aurika. Thanks.',
               mtInformation, [mbOK], 0);
              Application.Terminate;
            end
        else
          MessageDlg('Aurika will now terminate. Please remember to download the latest version of Windows Media Player. Thanks.',
            mtInformation, [mbOK], 0);
          Application.Terminate;
      end;
    if tmpstring[3] < '4' then
      begin
        if MessageDlg('Windows Media Player must be upgraded to the latest version.'+
          'Click YES to visit the Microsoft site. Or, NO to exit.', mtConfirmation,
          [mbYes, mbNo], 0) = mrYes then
            begin
              Form1.Visible := False;
              ShellExecute(0,nil,'http://www.microsoft.com/windows/windowsmedia/',nil,nil,0);
              MessageDlg('After downloading Windows Media Player, run setup. When it finishes installing, restart Aurika. Thanks.',
               mtInformation, [mbOK], 0);
              Application.Terminate;
            end
        else
          MessageDlg('Aurika will now terminate. Please remember to download the latest version of Windows Media Player. Thanks.',
            mtInformation, [mbOK], 0);
          Application.Terminate;
      end;
    // enable mp3 registry settings
    winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions', True);
    winreg.WriteString('MP3 file (*.mp3;*.m3u)','*.mp3;*.m3u');
    winreg.CloseKey;
    winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions\Descriptions', True);
    winreg.WriteString('1','Audio file (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3)');
    winreg.WriteString('3','Movie File (MPEG) (*.mpeg;*.mpg;*.m1v;*.mp2;*.mpa;*.mpe)');
    winreg.WriteString('4','Media playlist (*.asx;*.wax;*.m3u;*.wvx)');
    winreg.CloseKey;
    winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions\Types', True);
    winreg.WriteString('1','*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3');
    winreg.WriteString('3','*.mpeg;*.mpg;*.m1v;*.mp2;*.mpa;*.mpe');
    winreg.WriteString('4','*.asx;*.wax;*.m3u;*.wvx');
    winreg.CloseKey;
    // get
  finally
    winreg.Free;
  end;
end;
0
 
rihabAuthor Commented:
hi my master,
i am glad some body answer me :).
i need to compress buffers(not files) recorded in the PCM format and pass these buf to another pc in the network. some thing like voice chatting .in real time compression is applied and buf pass to the end point in which decomp is made .i made it with PCM but buf are so BIG  putting in mind the traffic in the network.what is your opinion ?.what proper format is useful ( ex GSM  )?.what about asf this is the first time i hear about it.
0
 
scifibeau67Commented:
I have only had experience using asf.

In regards to compressing buffers, the easiest would be to use the ASF encoder. It supports real-time compression and broadcast of streaming  audio across a network. It supprts audio bitrates from 6.5Kbs up to 128Kbs. The 128Kbs is slightly higher quality than 196KBs mp3 audio.

What you can broadcast is limited to either live audio coming into your sound card from some source, or a wav/mp3 file on your hard drive. To actually pass buffers of PCM data, you would probably have to either save the chunks as files and have the encoder send those in succesion (requires use of OLE Automation), or playback the audio and let the encoder compress and send it over the network (no OLE required).

On your end, you will have to have the encoder. On the receiving end, the person will need to have Windows Media Player 6.1 or higher installed.


Hope this helps.
0
 
scifibeau67Commented:
Forgot to mention it. More info about ASF and downloads can be found at...

http://www.microsoft.com/windows/windowsmedia
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now