Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Audio compression

Posted on 2000-04-30
9
Medium Priority
?
512 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 

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 400 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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