|
To resolve those linkage errors you need to add 'winmm.lib' to your project. Possibly, with mingw32 the name of the lib is different, i have never used mingw32, but idea is you need to provide the proper lib to the linker.
Regards,
Ruslan
|
|
|
|
|
i dont know what is this winmm.lib
beyond that linker errors
a "sizeof type", without sizeof(type), easy to fix
and [Warning] `packed' attribute ignored
on line } BE_CONFIG, *PBE_CONFIG ATTRIBUTE_PACKED;
i really need a lib to record sound
since the last day i'm trying to find one.. but is hard
most of they need visual c
and i dont have the vc sdk.. just the bins..
pls help me
=/
|
|
|
|
|
Why don't you try using Visual Studio Express edition? Free to download from Microsoft and free of charge for home and academic usage.
Regarding
>>i dont know what is this 'winmm.lib'
It's not about coding this time. I guess you know what static linking means. So
- at the first step, development environment compiles the code and produces object files (.obj),
- at the second step, development environment links the obtained object files with the provided static libraries (.lib) and produces the final executable.
As you see, I wrote 'provided' which means you have to provide this, if you know how to use 'mingw32'. You need to understand and know these details and be able to apply them with the development environment you are using. As so, even if I provide you the simple code, you won't succeed building the .exe without this knowledge about 'mingw32'.
So, in this case you need to provide 'winmm.lib' for proper linking. Windows Media API (winmm.lib/WINMM.DLL) was introduced many years ago, it's a standard in Windows. I don't believe 'mingw32' doesn't have this static library (somewhere in the 'LIB' folder where 'mingw32' is installed). Even LCC (lightest C compiler) has it.
Regards,
Ruslan
|
|
|
|
|
ok, i downloaded the visual studio
set lots of lib, and its compiling
but, its hard to create my own code
your example use argc.. argv, is hard to understand
then, i tried it:
int main() {
const vector<cwaveinsimple*>& wInDevices = CWaveINSimple::GetDevices();
CWaveINSimple& WaveInDevice = CWaveINSimple::GetDevice(wInDevices[0]->GetName());
CHAR szName[MIXER_LONG_NAME_CHARS];
UINT j;
CMixer& mixer = WaveInDevice.OpenMixer();
const vector<cmixerline*>& mLines = mixer.GetLines();
for (j = 0; j < mLines.size(); j++) {
::CharToOem(mLines[j]->GetName(), szName);
printf("%s\n", szName);
}
mixer.Close();
CWaveINSimple& device = CWaveINSimple::GetDevice(wInDevices[0]->GetName());
CMixer& _mixer = device.OpenMixer();
::CharToOem(mLines[6]->GetName(), szName); //get Microphone
CMixerLine& mixerline = _mixer.GetLine(szName);
mixerline.UnMute();
mixerline.SetVolume(0);
mixerline.Select();
_mixer.Close();
mp3Writer *mp3Wr = new mp3Writer(); //here crashes
device.Start((IReceiver *) mp3Wr);
while( !_kbhit() ) ::Sleep(100);
device.Stop();
delete mp3Wr;
CWaveINSimple::CleanUp();
}
and get this error:
"This aplication has request the Runtime to terminate it in a unusual way.
Please contact the application's support team for more information"
=/
and i get this fopen warning:
'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
|
|
|
|
|
You forgot about 'try {...} catch(...)'. Also don't forget that 'lame_enc.dll' must be in the same folder with the final '.exe' file. It looks like application is trying to load 'lame_enc.dll' and it can't find it. As so application is throwing an exception which is not caught and you get runtime error.
Try this code:
#include "stdafx.h"
#include "INCLUDE/mp3_simple.h"
#include "INCLUDE/waveIN_simple.h"
#include <conio.h>
class mp3Writer: public IReceiver {
private:
CMP3Simple m_mp3Enc;
FILE *f;
public:
mp3Writer(unsigned int bitrate = 128, unsigned int finalSimpleRate = 0):
m_mp3Enc(bitrate, 44100, finalSimpleRate) {
f = fopen("music.mp3", "wb");
if (f == NULL) throw "Can't create MP3 file.";
};
~mp3Writer() {
fclose(f);
};
virtual void ReceiveBuffer(LPSTR lpData, DWORD dwBytesRecorded) {
BYTE mp3Out[44100 * 4];
DWORD dwOut;
m_mp3Enc.Encode((PSHORT) lpData, dwBytesRecorded/2, mp3Out, &dwOut);
fwrite(mp3Out, dwOut, 1, f);
};
};
int main() {
char strLineName[] = "Microphone";
const UINT volume = 15;
try {
const vector<CWaveINSimple*>& wInDevices = CWaveINSimple::GetDevices();
CWaveINSimple& device = CWaveINSimple::GetDevice(wInDevices[0]->GetName());
CMixer& mixer = device.OpenMixer();
CMixerLine& mixerline = mixer.GetLine(strLineName);
mixerline.UnMute();
mixerline.SetVolume(volume);
mixerline.Select();
mixer.Close();
mp3Writer *mp3Wr = new mp3Writer();
device.Start((IReceiver *) mp3Wr);
while( !_kbhit() ) ::Sleep(100);
device.Stop();
delete mp3Wr;
}
catch (const char *err) { printf("%s\n",err); }
CWaveINSimple::CleanUp();
return(0);
}
|
|
|
|
|
very tks!!!
this sample work
and i get the lame_enc.dll
i had forget
very tks
|
|
|
|
|
Hi,
I wish you make the dialog base app. example to use mp3 class as,I have tried to make it several times but it did not success.
If possible,please show me the dialog base sample.
I'm a novice.
Thank you.
Arun
|
|
|
|
|
Hi Arun,
Unfortunately I can't. Dialog based version is a commercial project:
http://mp3r.send2.me.uk/
Regards,
Ruslan Ciurca
|
|
|
|
|
Hi Ruslan,
OK,I understand but,I want to implement some point like mp3 recording with microphone or other into my learning project.
If you can suggest a little guide to do this,please suggest too.
Thank you.
Arun
|
|
|
|
|
Hi Arun,
Well, it depends on what are you novice to:
- programming in general
- C++
- MFC
- MP3 encoding
This also depends on what and how you plan to implement, general application's approach/design. You can also have a look at what/how other people implemented similar things.
Application's approach is important. Anything else is just technical solution(s) (well, sometimes difficult to implement, but at least you know what you want to achieve). And, due to the lack of time, I can help you only just by answering specific technical questions.
Regards,
Ruslan Ciurca
|
|
|
|
|
Hi Ruslan,
Thank you for your suggestion.I would be spending the time for this surely but,at least like you said i know what i want to achive.
Thank you.
Regards,
Arun
|
|
|
|
|
Hi,
Let me first congratulate you for writing such a useful tool. I was wondering if the lame_enc.dll can be included in an installer of a freeware tool?
Thanks,
Sumit
Sumit
|
|
|
|
|
Hi Sumit,
Lame project is an open source one. The only restriction is the Light GPL (LGPL) license.
More details here:
http://lame.sourceforge.net/license.txt
Skip the decoding part, because the classes in this article do only encoding.
Regards,
Ruslan Ciurca
|
|
|
|
|
HI Ruslan,
This is Mujeeb Again, Once again Thanks for your excellent comment on "Recording from Simultanious Sources"
Now I am trying to use your Mp3_stream for realtime mp3 recording in my application, As I am really new to C++ i just can;t change ur code to meet my requirement.
My Request is quite simple.
1.How can i use default audio device (with out specifying name) for recording.
2. "From where i will get a C# sample for implimentation of lame.exe for Real-Time mp3 encoding", Do you have any idea?
Thanks
Mujeeb
|
|
|
|
|
Hello Mujeeb,
Regarding request 1, I haven't implemented this feature. Low level Wave API doesn't have the notion of the default device (within the API), so, as far as I know, this is resolved a bit different. I have posted an answer to this, see topic related to 'windows default mixer' ... so you can find default device by querying registry, path:
HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Record
Following this path, you will extract the name (string) of the system's default recording device. With that name ... use CWaveINSimple::GetDevice(...) next.
Regarding request 2, ... well, first I suggest googling. By the way, few month ago I found a Lame wrapper for Java (tritonus) which I used for a voice chat, so, I am 99% sure there should be one for C#. You can start with sourceforge. If not, check this FAQ for the very first posts, you will see 'play File' topic with few links. I mean guys maintaining madxlib, they have few applications in C#. One application they have done allows re-coding sound from WAV to MP3 (and I think vice-versa). That application is coming with sources and uses lame API as well (as far as I remember ).
Regards,
Ruslan
|
|
|
|
|
Thank you for this contribution.
I have a question:
Is it possible to detect silence?
Thanks again,
Where there is a WISH, there is a WILL.
|
|
|
|
|
Hi,
Yes it is possible, though I have studied this subject thoroughly. I was googling couple of months ago regarding this and find couple of useful articles, but nothing more. You may do the same, however, I still have one issue with this; since record is from soundcard's waveOut it's not quite clear how to determine if silence is due to music switch or just a silence as a part of the music's composition.
Regards,
Ruslan
|
|
|
|
|
Thank you again Ruslan.
I spent 2/3 of the night surfing on the web to study this matter and just find that your are right.
I'll have to personalize your code so that the file can be written chunk by chunk.
A way for me to be able to submit my different pieces to a commercial application that accept a couple of parameters to cut blanks: e.g. cut all records of least than 2DB during 3 min.
Regards,
Gaby.
Where there is a WISH, there is a WILL.
|
|
|
|
|
Is there any method to select default Mixer(checked) of Windows?
|
|
|
|
|
Hi,
Probably you mean identifying the default mixer device. If so, check the registry for:
HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Playback
HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Record
I am not sure this is the only way though.
Regards,
Ruslan
|
|
|
|
|
thanks! but i want default(checked) mixer line(ex, Stereo mixer, Mic)
http://crazy.einsbiz.com/temptemp.jpg
|
|
|
|
|
I see
Well, there is no notion of the default mixer's line, it is selected. To be honest, I haven't investigated the problem of identifying currently selected mixer's line, but, in sources you will find how to select a line you need. Same you can find at this link
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B159753
See the code for "void SelectMic()" function. That code is a bit huge and maybe not quite descriptive but see the bottom of the code:
for (DWORD j=0; j
|
|
|
|
|
Problems with text formatting ... sorry about that. Here is what to check for:
for (DWORD j=0; j < cMultipleItems; j = j + cChannels)
........if (0 == strcmp(plisttext[j].szName, "Microphone"))
................// Select it for both left and right channels
................plistbool[j].fValue = plistbool[j+ cChannels - 1].fValue = 1;
........else if (bOneItemOnly)
................// Mux or Single-select allows only one item to be selected
................// so clear other items as necessary
................plistbool[j].fValue = plistbool[j+ cChannels - 1].fValue = 0;
|
|
|
|
|
im new to mp3, very new....
i downloaded the code, add the lame....dll
and run it..
and it does not create exe file..
here is the output..
////////////////////////////////////////////////////
'mp3_stream.exe': Loaded 'C:\Documents and Settings\lyeaos\Desktop\mp3_stream_src\Debug\mp3_stream.exe', Symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\Program Files\TuneUp Utilities 2006\WinStylerThemeHelper.dll', Binary was not built with debug information.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'mp3_stream.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
The program '[2308] mp3_stream.exe: Native' has exited with code 0 (0x0).
////////////////////////////////////////////////////////////////////////////////
pls help me
leoren_tm
|
|
|
|
|
Hi,
Added lame_enc.dll? You shouldn't add lame_enc.dll anywhere, the link is done dynamically (invoked from code).
Are you using VS.NET (2003 or 2005) to compile? Or?
Top of the article says VS 6.0 in fact. So, I am not sure VS.NET (C++) compiler will compile VS 6.0 project without changes. I would recommend to create VS.NET solution from scratch and just copy/paste existing code.
Regards,
Ruslan Ciurca
|
|
|
|
|