Link to home
Start Free TrialLog in
Avatar of kimling
kimling

asked on

Record in WMA format

Hi, I am using Delphi 7
and need some code to record a sound file in WMA format
1:Start recording
2:Stop recording
3 Save recording

i dont want combo boxes or anything just hard code that will record a sound file and save it as 123test.wma
thanks Kim
Avatar of jimyX
jimyX

Avatar of kimling

ASKER

I tried and downloaded the install package but it requires a user name and serial number to install
so i cant install that.
Which one you are talking about?
Avatar of kimling

ASKER

Hi The lake soft components
Never had to enter anything.
After download, went to "Common" directory and installed "vc2.dpk" and everything went smooth.
Avatar of kimling

ASKER

no i didnt get that, i just downloaded what was suppose to be a free version? but instead i got a personal version which requires username and serial number to install
Unless we are on different pages. Here is what I did and got everything running without requiring anything extra:
1. Click here. It is the download link.
2. Extract.
3. Go to "Common".
4. Double click "vc2.dpk".

That's all.
Avatar of kimling

ASKER

Hi Thanks for the download
i tried running a few samples but had errors, Couldnt find some files so the samples would not run,
but ii had a quick look through the code and its not what i am looking for,
See, why i am need hard code is that i have to put it in a plugin so it works in the background,
The plugin would be full of procedures that initialise the WMA codec and prepare buffers ect ready for recording

the i just have to place the code to StartRecord, StopRecord, and Save Record as 123.WAM

Years ago i did get someone from here to give me code for recording in GSM 6.10  Format using the codec, that was good
Problem Now Windows 7 and future versions are no longer sopporting this codec, so my plugin is useless today
hence why i need the WMA one....

I have software i write which requires very small Voice files
Thanks
>   "i tried running a few samples but had errors, Couldnt find some files so the samples would not run,"
Add the "..Path\common" directory path to the Delphi library path (Tools->Environment Options->Library Tab)

>  "...StartRecord, StopRecord, and Save Record as 123.WAM"
Have you seen vcSampler & vcSoundRec in demos directory?

Now I realized it will produce WAV and not WMA
Avatar of kimling

ASKER

Ok Thanks for all your help, But looks like i am stuck with this. may have to look into record and play VOX files
Ok, here is a set of components from Torry with WMA recording capability.

After download, install, and add the src path to the Delphi library.

You can go to the demos-> Recorders-rippers -> DirectSoundRecorder.
It supports recording Ogg, Flac, and Wav, so to add WMA support:
1. Drop "WMAOut", set its input property to "DXAudioIn1".
2. Add the extension "WMA" to the "SaveDialoge1".
3. Finally update the following code at Button "Record":
Instead of:
  if Ext = '' then
    raise EAuException.Create('Cannot determine the input file format');
  if Ext = '.ogg' then
  begin
    Output := VorbisOut1;
    VorbisOut1.Compression := SpinEdit1.Value/10;
  end else
  if Ext = '.flac' then
  begin
    Output := FLACOut1;
  end else
  if Ext = '.wav' then
    Output := WaveOut1;

Open in new window

It becomes:
  if Ext = '' then
    raise EAuException.Create('Cannot determine the input file format');
  if Ext = '.ogg' then
  begin
    Output := VorbisOut1;
    VorbisOut1.Compression := SpinEdit1.Value/10;
  end else
  if Ext = '.flac' then
  begin
    Output := FLACOut1;
  end else
  if Ext = '.wav' then
  begin
    Output := WaveOut1;
  end else
  if Ext = '.wma' then
  begin
    Output := WMAOut1;
  end;

Open in new window

Avatar of kimling

ASKER

OK done that, it executed without errors, but could not find 123.wma file,  but this looks promissing lol
Avatar of kimling

ASKER

I am running the code and tried to make changes without selecting the File Save Dialog
insted i am writing the filename as 888.wam
but when i run it i get  "Input Not Assigned"

but i cant see whats wrong anyway i keep trying i know its not far away from working
thanks
> but when i run it i get  "Input Not Assigned"
The input property of the "WMAOut" is not set.

Have you done all the steps thoroughly?
1. Drop "WMAOut", set its input property to "DXAudioIn1".
Avatar of kimling

ASKER

I couldnt add The Extention to SaveDialog1
because its everywhere at the start record button
i changed
EXT := ExtractFileExtention := SaveDialog1.Filename;
to
EXT := ExtractFileExtention := '.wma';
Then the program wont run gives me error messages, so when i change it back then it runs
ALso I have to Select A Wave file first so it can record over it and then save it as another name


Instead of using the open File Dialog can i type the name of the file in code
the file i am using is TEST.WAV
Thanks
Avatar of kimling

ASKER

Hi, I got it all working Now
But strange thing the file size is small as i expected but the sound quality is not good

What i dont understand when i use a WAVE to WMA convertor the reult is small file and very good sound quality

could these components be too old and the updated ones produce better results??
Thanks Kim
WMAOut component has properties that you need to set. Have you changed any of the following properties?
DesiredBitRate
LossLess
VBR
VBRQuality

Also the DXAudioIn.

What you need to do is Ctrl-Click on the TWMAOut declaration, in the demo project, which will take you to the source file "ACS_WinMedia.pas" where you can read how to best adjust the above properties, I copy here:
    (* Property: DesiredBitrate
       Set the desired bitrate for an output file (in the constant bitrate
       lossy mode). The component will search for the best configuration
       matching your parameters, so the actual bitrate may be less than this
       value. *)
    property DesiredBitrate : LongWord read FBitrate write FBitrate;
    (* Property: Lossless
       Use this property to switch between the lossless and lossy compression modes.
       In the lossless mode the <DesiredBitrate> and <VBRQuality> values are ignored.
       Lossless encoding is always VBR. *)
    property Lossless : Boolean read FLossless write FLossless;
    (* Property: VBR
       Use this property to switch between constant bitrate and variable
       bitrate lossy encoding modes. In VBR mode <DesiredBitrate> value is
       ignored. The quality of the output sound is defined by the <VBRQuality>
       property. If you encode data by directly selecting the codec and
       format, note that the VBR setting affects <Formats> and <FormatsCount>
       values for every codec. In the lossless mode the this property's value
       is ignored. *)
    property VBR : Boolean read FVBR write FVBR;
    (* Property: VBRQuality
       Use this property to set the output audio quality in VBR mode. The
       valid values range from 1 to 99. This property only has an effect if
       <VBR> is set to True and <Lossless> to False. *)
    property VBRQuality : Byte read FVBRQuality write FVBRQuality;
    (* Property: OnOutputError
       This event is raised if an error occurs during the output. If the event handler is not set, the error is ignored.
       The best way to handle this event is to call
       > Sender.Stop(True);
       from the handler.
       When this event is called the ExceptionMessage property returns 'Windows Media output error' string. *)

Open in new window


Do the same for the TDXAudioIn where you find and know what to set to get best result.
Avatar of kimling

ASKER

Hi
I tried making some changes qulity is good but it plays back much faster than when i speaked
7 seconds recording produced 500klbyts
trying to get good quality, normal speed talking and small file size
if you can do this for me i can give you $100
but i have to pay by paypal thats all i use for ebay ect...
let me know, hope i am not breaking any rules here, sorry if i am
> trying to get good quality, normal speed talking and small file size
As you know, quality and size have connected relation. More quality means more size.
Only what we can do is finding a suitable balance.
Here am attaching a modified sample, that can get you 60 Sec @ 161KB.

if you can do this for me i can give you $100
You do not have to make payment.
Unless you are happy with the result and you want to make a payment.
Sample.zip
Avatar of kimling

ASKER

Hi, I tried to run it but when i pressed the Record Button
the CPU windows came up with a heap of numbers?
thanks
Avatar of kimling

ASKER

I tried again but it said Invalid Pointer
thanks
Did you change anything?
Because that works just fine here, and I can't see why not with you, unless HW incompatibility for the parameters I set.
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kimling

ASKER

Hi yes its working good now many thanks
can you send to me your email or paypal info
i want to pay you $100 for your kind and patient help in solving my problem i am very happy as this has been annoying me for 2 weeks
kind regards Kim and Marie
Avatar of kimling

ASKER

Yes JimmyX was very patient and most helpful, i am very happy with his work and his help, he was helping me for sometime, and he got me excellent results...I highly recommend him, again Many Thanks JimmyX from Kim Neil And Marie x
Avatar of kimling

ASKER

Just want to add, he did not accept any payment from me, although i offered it as i was extremely grateful for his help, he is kind honest man.