Solved

Audio compression

Posted on 2000-04-30
9
464 Views
Last Modified: 2010-05-18
how to implement audio compression in delphi .what units and dll s that i need
0
Comment
Question by:rihab
9 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2763775
Which of compression methods do you like?
----
Igor.
0
 
LVL 3

Expert Comment

by:Mathias
ID: 2763973
Which compression do you want? Wave, Midi or MP3...
0
 
LVL 1

Expert Comment

by:l8knight
ID: 2764349
Try 'Audio Compression Manager' available from http://www.rtfm.be/fpiette/acm.htm

hope this helps

l8knight
0
 
LVL 1

Expert Comment

by:rowisoft
ID: 2765304
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:PhrAtoR
ID: 2765908
Hello!

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

bye
PhrAtoR
0
 

Accepted Solution

by:
scifibeau67 earned 100 total points
ID: 2785755
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
 

Author Comment

by:rihab
ID: 2787230
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
 

Expert Comment

by:scifibeau67
ID: 2788155
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
 

Expert Comment

by:scifibeau67
ID: 2788164
Forgot to mention it. More info about ASF and downloads can be found at...

http://www.microsoft.com/windows/windowsmedia
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now