|
Hi Ayman,
The answer is yes and no ... you can always take the sources and force a mobile version compilation, but yes, it will take a while to make it compile and run properly (for instance you will have to replace MMX instructions with appropriate API, depending on whether CPU supports float point instructions or not). I have seen few attempts to port LAME for ARM CPU, which technically says that it may run on Android or BusyBox Linux (or any other Linux platform that supports ARM) platforms, but I am not sure how far they went with this ... CPU power is still the major issue.
Regards,
Ruslan
|
|
|
|
|
Hi Ruslan,
And thank you for your reply.
As a matter of fact a friend of mine has compiled LAME for Windows Mobile, but it was not efficient, it took a long time to convert a small wave file to mp3, a time that can make an application freezes, which is something not welcomed by end users. But as you said, if I want to complete my friend's work, I have to replace those instruction you were talking about, plus make appropriate optimizations so that the application can use the library in an efficient way.
Regards,
Ayman
|
|
|
|
|
the demo wont run it opens and then exits
|
|
|
|
|
Could you please provide more details of what are you doing? E.g. command line paramaters, OS version.
|
|
|
|
|
Hi
I am trying to use the "Lame API" that you warped in the mp3Writer class, but with data that is not a captured from a stream, instead the data is loaded from a file, the audio format of the data is: nBits = 8, nChannels = 1, SPS = 8000, please notice that this is not an audio file format (not a *.wav), but just data that been recorded from a mic and stored in a binary file, and that was tested and all ok, but when encoding the output file is ... strange (I really can't explain it), something is wrong with the both sampling frequency and bits per samples (I can see that in matlab)
I used this:
mp3Wr->ReceiveBuffer(buffer, 8000); //buffer is one second length = 8000 samples
note: when making an instance of mp3Writer (mp2Wr in this case) with nBitRate = 128 and nFSampleRate = 8000 there will be an error opening the *.mp3 file...
Any idea what could be wrong?
Thanks
Jalal A. H. Sela
|
|
|
|
|
Hi,
You will need to do few adjustments to your code:
1. First of all "mp3Writer" class, presented in this article, was written from the perspective that input simple rate is 44100. In your case input simple rate is 8000. So you need to adjust the constructor:
mp3Writer(unsigned int bitrate = 128,
unsigned int finalSimpleRate = 0):
m_mp3Enc(bitrate, 8000, finalSimpleRate)
2.Regarding
mp3Wr->ReceiveBuffer(buffer, 8000);
In fact, the second argument is the buffer size. I understand your code is reading data from file, so you need to pass the number of bytes that were read. Don't assume they are exactly 8000.
3. Regarding nBits = 8, nChannels = 1.
Lame API (Blade interface) expects as an input 16 bits based array (SHORT, 1st byte is for left channel, 2nd for the right).
m_mp3Enc.Encode((PSHORT) lpData, dwBytesRecorded/2, mp3Out, &dwOut);
You have only one channel (and just 1 byte) so you need to make it 2 by duplicating each byte you read from the file (thus simulating left channel == right channel).
Regards,
Ruslan
|
|
|
|
|
Thanks for your answer
Yes, I thought it would have to do with the audio format, thanks again for your help.
Regards
Jalal A. H. Sela
|
|
|
|
|
Hi,
before starting, let me thank you for your source code. It's very helpful, and the article is great!
I have a little problem:
when i run the program, it works very well, with no errors.
When I have finished recording and the program exits, of course it stops to recording music.mp3, but I noticed I still have the microphone "linked" to the speakers... I mean, if I continue to talking to microphone, I can hear my voice from the speakers, and I don't understand why.
I'll hope you can solve this mistery..
Best wishes, Marco
|
|
|
|
|
Hi,
Application selects the device and line to record from. Once application exits, the line remains selected, thus the problem as far as I understand it. You have to manually reset the line or adjust the application so that it will restore the lines when exiting.
Regards,
Ruslan
|
|
|
|
|
mp3Wr = new mp3Writer(nBitRate, nFSimpleRate);<br />
device.Start((IReceiver *) mp3Wr);<br />
printf("hit <ENTER> to stop ...\n");<br />
DWORD dwTimeStart = GetTickCount();<br />
DWORD dwTimeEnd = dwTimeStart+60000;<br />
while( GetTickCount() < dwTimeEnd ) ::Sleep(1);<br />
<br />
device.Stop();<br />
delete mp3Wr;<br />
why recording 57 sec ?...
i'm 1 min recording..
plz.....
|
|
|
|
|
Hi,
Nope, it's not time related ... it's driver specific, as it was discussed here many comments ago
Try modifying the code like:
1.
mp3Wr = new mp3Writer(nBitRate, nFSimpleRate);
printf("hit <ENTER> to stop ...\n");
DWORD dwTimeStart = GetTickCount();
DWORD dwTimeEnd = dwTimeStart+60000;
device.Start((IReceiver *) mp3Wr);
while( GetTickCount() <= dwTimeEnd ) ::Sleep(1);
device.Stop();
delete mp3Wr;
2. Reduce the size of the buffers for recording, in the constructor of the CWaveINSimple class, e.g. from (2 seconds recording time):
this->m_WaveHeader[1].dwBufferLength = this->m_WaveHeader[0].dwBufferLength = this->m_waveFormat.nAvgBytesPerSec << 1;
to (1 second recording time):
this->m_WaveHeader[1].dwBufferLength = this->m_WaveHeader[0].dwBufferLength = this->m_waveFormat.nAvgBytesPerSec;
Regards,
Ruslan
|
|
|
|
|
|
Hi,
I am in very much need of your code.
However, my C is very,very rusty.
I don't need all the code.
All I need is to detect sound comming from the sound card.
Any sound. Not especially something that I play.
Can you help me ?
Thank you,
Anomis
|
|
|
|
|
Hi,
I am not doing VB or C#, I am sorry about this. But, I am sure there should be a .NET based API for dealing with sound (there is one for Java, sure there should be one for .NET). Alternatively, you can do a search on codeproject, I have seen good .NET based articles related to sound recording.
Regards,
Ruslan
|
|
|
|
|
How to record Muti-line at one time ?
hello
Currently I'm trying to use your code to record two lines of device. Such as: stereo mix and microphone volume of device. Currently it can record voices of Stereo Mix to write a file, and record voices of Microphone to write another. How can record the two lines of device at the same time and write it to one file.
Sorry, My English is very poor. Hope you can understand what means I say. thank you very much.
|
|
|
|
|
Hi,
This requires little of math (Fourier series), physics (composition of two waves) and knowledge of what PCM is. Good topic for another article by the way.
But, if you have a sound card allowing mixing, it should be easier then. Or you could google for other tricks.
Regards,
Ruslan
|
|
|
|
|
had the same question some days ago and found this virtual sound card tool may work for the purpose of recording both stereomix and microphone.
|
|
|
|
|
Hello
Currently I´m trying to use your code to record Right and Left channels separatly. I´m using a Delta1010LT sound card which show its devices like that:
Delta1010LT 1/2
It's a stereo line where 1/2 means Rigth and Left channels.
I have debugged your application and the property cChannels of the MixerLine structure always is set to 1.
I suppose that property ought to be set to 2 because there are 2 channels in that divice. But it not happened.
Should I use other kind of structure?
I wonder if you can suggest me what can I to do?
|
|
|
|
|
Hi,
"cChannels" is set to 1 as a result of:
if (MIXERCONTROL_CONTROLF_UNIFORM & pmxctrl[i].fdwControl) cChannels = 1;
Just one question, in order to understand properly the problem; "Delta1010LT 1/2" - does this mean that when listing lines of the sound card (wave in device) you have two different lines like "Delta1010LT 1" and "Delta1010LT 2"?
Alternatively, have a look at:
http://www.microsoft.com/whdc/device/audio/multichaud.mspx
Regards,
Ruslan Ciurca
|
|
|
|
|
Hello,
First I appreciate your response.
Acording to the conditional sentence during the debug I could realize that it never reach that line because the property Controls of the "MIXERLINE mxl" structure always is set to 0 and
there is a conditional at that line 246 of the wavein_simple.h file that makes an evaluation of the property.
In the other hand I have two fisical lines "Delta1010LT 1" and "Delta1010LT 2" but the program identify them like only one, "Delta1010LT 1/2". It´s like a stereo line.
If it´s helpful, I´m using this card:
http://www.m-audio.com/products/en_us/Delta1010LT.html
Finally I'll review the link. Thanks for your suggestions.
Regards
|
|
|
|
|
Hi,
Just one more question; how is Windows OS indentifying the line? I am pretty sure it is still "Delta1010LT 1/2".
The other drawback is ... LAME API works with 16bits PCM only (only if they didn't update the API). As a result, recording from two lines, each producing 16bits PCM will require a little of math to mix them, though it is always a good idea to rely on sound card drive mixing (if it supports such mixing and in your case "Delta1010LT 1/2" is exactly this sort of mixing I guess ).
Regards,
Ruslan Ciurca
|
|
|
|
|
LAME sucks it is just open source. Have you dealt with any other encoders out there.
|
|
|
|
|
Hi,
No I didn't. For the purpose of streaming MP3 content over the internet (aka internet radio) it is just fine. In fact, I don't know any other open source MP3 library better than LAME. Have a look at this list:
http://lame.sourceforge.net/links.php#Contents
Or look at this:
http://lame.sourceforge.net/open_letter_sony_bmg.html
So, it isn't that bad at all
Regards,
Ruslan
|
|
|
|
|
I am also in need of same code.which can record the channels seperately in two different files. . I am using following code to record.. Please help me
using...VB 2008
Public Class Form1
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' record from microphone
Label1.Text = "Recording Input Sound..."
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
mciSendString("record recsound", "", 0, 0)
ProgressBar1.PerformStep()
i = Second(Now) + 1
For i = 1 To 100
ProgressBar1.Increment(i)
ProgressBar1.Increment(i - 2)
Next i
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' stop and save
SaveFileDialog1.InitialDirectory = "c:\"
SaveFileDialog1.DefaultExt = ".wav"
SaveFileDialog1.Filter = "Wave Files|*.wav"
SaveFileDialog1.FilterIndex = 1
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Filetosave As String = "save recsound " & SaveFileDialog1.FileName
mciSendString(Filetosave, "", 0, 0)
Else
MsgBox("Saving Cancelled!!!")
End If
mciSendString("close recsound", "", 0, 0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
OpenFileDialog1.InitialDirectory = "c:\"
OpenFileDialog1.DefaultExt = ".wav"
'OpenFileDialog1.Filter = "Wave Files|*.wav"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim FiletoOpen As String = OpenFileDialog1.FileName
My.Computer.Audio.Play(FiletoOpen, AudioPlayMode.Background)
Label1.Text = "Playing Audio File..." & OpenFileDialog1.FileName
Else
Exit Sub
End If
End Sub
End Class
Ravi
|
|
|
|
|
Dear rtybase
Is it possible to use lame_enc.dll form more than one channel.
Suppose that we want to encode the voice of serveral channels.
Is it possible to load lame_enc.dll for several times and then use it for separate channels?
Regards
Mahdi
|
|
|
|
|