|
ok, I have found the reason for the Mixer's line not found.
It only has "Master Volume" as the only mixer line which works well.
still, is there a way to get the full name of the devices?
|
|
|
|
|
Good question and ... I still don't have an answer, unless there is some other API (e.g. Direct Sound) allowing that.
Please let me know if you find the answer.
Regards,
Ruslan
|
|
|
|
|
I try to embed your code to a mfc dialog based application. i add these code in a button function:
void CTransBtnDlg::OnBnClickedBtnRecord()
{
// TODO: Add your control notification handler code here
mp3Writer *mp3Wr;
CWaveINSimple& device = CWaveINSimple::GetDevice("SB Live! Wave Device");
CMixer& mixer = device.OpenMixer();
CMixerLine& mixerline = mixer.GetLine("Line-In");
mixerline.UnMute();
mixerline.SetVolume(50);
mixerline.Select();
mixer.Close();
mp3Wr = new mp3Writer(128, 0);
device.Start((IReceiver *) mp3Wr);
Sleep(1000);
device.Stop();
delete mp3Wr;
CWaveINSimple::CleanUp();
}
in CWaveINSimple::CleanUp(), it throw a Unhandled exception. why?
|
|
|
|
|
Hi,
What is the exact line throwing exception within CWaveINSimple::CleanUp()? Could you debug please?
Regards,
Ruslan
|
|
|
|
|
vector<CWaveINSimple*>::iterator itPos = m_arrWaveINDevices.begin();
for (; itPos < m_arrWaveINDevices.end(); itPos++) {
delete *itPos;
}
when it delete *itPos, it throw an unhandled exception. i guess maybe itPos point to an empty object.
so it can not delete the pointer. it's strange. why in a console application. the CleanUp() function works well,
in a dialog application it didn't work, although the main recording function works well both.
|
|
|
|
|
Indeed it's very odd ... i have also used these classes in an MFC project and this was working fine.
Try adding a check like:
if (*itPos != NULL) delete *itPos;
Also, add a check when adding object to the collection:
const vector<CWaveINSimple*>& CWaveINSimple::GetDevices() {
...
pWaveIn = new CWaveINSimple(i, &wic);
if (pWaveIn != NULL) m_arrWaveINDevices.push_back(pWaveIn);
...
}
Please tell me if this doesn't help.
Regards,
Ruslan Ciurca
|
|
|
|
|
Thanks for the previous(lame_enc.dll) fix, and for the awesome project.
Is there a way that i can record from the mic and stereo mix at the same time to one file?
So i might apply it to record a conversation, like a conversion from googletalk?
|
|
|
|
|
As far as I remember you are the third person asking this question
Microphone routing is the answer and ... more details if you search/look through posts of this forum.
Regards,
Ruslan Ciurca
|
|
|
|
|
"Recording at 128Kbps, 44100Hz
from Stereo Mix (SoundMAX Digital Audio).
Volume 0%.
Error loading lame_enc.DLL"
can someone one help me on how to fix this run time error?
|
|
|
|
|
Hi,
Make sure "lame_enc.dll" is in the same folder with the .EXE you are starting or in the folder included in PATH environment, or in one of the system's folders.
Regards,
Ruslan
|
|
|
|
|
I am getting the following error,when I try to implement the function in a voice chat app I am developing :
chat\sync_simple.h(15) : error C2039: 'TryEnterCriticalSection' : is not a member of '`global namespace''
chat\sync_simple.h(15) : error C2065: 'TryEnterCriticalSection' : undeclared identifier
Please help.
|
|
|
|
|
Hi,
You need to include the following:
#define _WIN32_WINNT 0x0400
as per "StdAfx.h" from attached sources.
Regards,
Ruslan
P.S. I am sorry i am slow with answering these days, pretty busy with moving to UK.
|
|
|
|
|
Hi,
Thanks for this wonderful piece of code.
I am building a voice chat client.I record data from Microphone and then would like to pipe the output to my chat class instead of saving as a file.Can you give me some tips or some code samples on doing this.
Thank you for the code.
|
|
|
|
|
I fail to download them .How can I get them and try them?
help....
|
|
|
|
|
Hi,
Works fine, i have just tested. Did you login before downloading?
Regards,
Ruslan
|
|
|
|
|
Hi Ruslan Ciurca, thanks for a neat little program. Works like a charm. Is it possible to record from the windows default audio device instead of taking the input from the user? This is useful in recording from most Instant Messengers and VOIP tools.
So, instead of -device=XXX and -line=yyy, could we just record form the default soundcard?
Thanks in advance
Nitin
|
|
|
|
|
Yep, possible. I have received two similar questions on this forum and answered them, but ... it seems that codeproject is doing some re-works and i can't access those posts. In any case:
1. if the sound-mixer is one, then you know the default one.
2. if more sound-mixers are installed, then you need to check registry settings for the default. Check:
HKU,"\.Default\Software\Microsoft\Multimedia\Sound Mapper"
or
HKCU,"\Software\Microsoft\Multimedia\Sound Mapper"
Regards,
Ruslan
|
|
|
|
|
Hi Ruslan,
Again, thanks for your reply! I did search through the forum before I asked, but apologies if I should have found it somewhere else.
Three questions - Two technical and one general:
a) By reading Playback or Record key from Registry, I will get the name of the sound card. Is there a safe mechanism to select the "line" from the sound card device that will record the audio stream (Wave Out). I know you said "Almost every sound card supports Wave Out Mix or Stereo Mix", so is it safe, in your experience, to assume "Stereo Mix" as the default line for the device?
b) Do you know if the registry key method is Vista ready? I dont have a Vista box to test on, but I will pretty soon.
c) This is the general question - I have adapted your code and tied it to Skype API to create a Skype VOIP recorder. I am planning to create an open source project on Google. First, is it ok to give you credit and have your code as part of the open source project? Second, since I am not a C++ programmer, I have done mostly a hack job by looking at code from multiple places for the recording and C++ ATL/COM code. So while my code works and my Skype API knowledge is upto scracth and the exe has been thoroughly tested by a team of testers it definitely needs someone who knows C++ to lead the project. Since your code is the most critical component of this recorder, I would like to invite you to take the lead on this project, if you want to!
I personally think a lot of people will benefit by this open source VOIP recorder. Sorry for the longish post! Please do let me know what you think.
Thanks
Nitin
|
|
|
|
|
Hi Nitin,
No problems ... back to your questions:
(a) - Most of the soundcards do have those ('Wave Out Mix' or 'Stereo Mix') lines, but ... it is not safe to use them. Unfortunately, this is absolutely true with regards to Windows Vista. I didn't use Vista hardly, but i have mentioned that sounding 'stuff' is completely different in Vista comparing with other Windows versions. However, it is safe to use "Microphone" as the default line.
(b) - Most probably not, but i haven't tested this as well.
>>(c) - "First, is it ok to give you credit and have your code as part of the open source project?"
Yep, that is absolutely fine.
>>(c) - "I would like to invite you to take the lead on this project, if you want to!"
Do you mean lead or help? ... With "help" and "code adjust/bug fixing" yes, i am ok. By the way, have you thought about doing all this stuff in Java (will be good for Linux/Mac OS users as well)?
Regards,
Ruslan
|
|
|
|
|
Hi Ruslan,
Again, thanks for your replies!
<ruslan>However, it is safe to use "Microphone" as the default line.
That will not work because we need both the incoming sound and the outgoing sound from most VOIP tools. So, I made a list of all the Wave Out mixer devices I could find, from your article and google i.e. "Stereo Mix", "Wave Out Mix", "Mono Mix", "What U Hear", "Wave".
Please let me know if you know of any more.
For Vista, I am not sure what will work. This (solution [^]seems work for most people! But, since there are commercial products in the market that do not require this work around I think there should be some way to record from the soundcard in Vista as well
As for the open source project, I meant lead and not contribute. I will dedicate resources from my organization for testing and the Skype integration. But this really need someone to take the lead for C++ standards, unicode support, logging framework etc for the project
I do not mind doing it in Java, in fact that would reduce my headaches a lot! But, the Skype Java API typically lags the COM API. I will take a look at Javasound and Java Media Framework once this solution is stable.
The thing I like most about the VC++ version is
a) You did a lot of the work
b) The footprint is amazingly small
Thanks
Nitin
|
|
|
|
|
Hi Nitin,
Yes, having a predefined list of 'Wave Out Mix' lines sounds like a good approach. Unfortunately i don't know other names for such lines.
For Vista, i don't see other approaches, at the moment, other than testing & investigating.
Regarding leading; the list of projects, i am currently involved in, doesn't allow me to take the risk of leading another one. And, by the way, this is a reason why can't finish (yet) the last article from the "MP3 broadcasting" series. So, i better say "no" for the leading and "yes" for contribution, at least in this scenario i am confident that i can keep my promises.
Regarding Java; i have succeeded to do the same (what is covered in this article) using Java. By the way, starting with J2SE 5.0, Java sound is part of the standard. So, with J2SE and Tritonus (open source Java wrapper of the LAME API) it costs nothing to implement similar functionality with Java. Java Media Framework is useless when MP3 encoding is required. I am not familiar with Skype API, but if Java version isn't 'good enough' then it should be easy to implement a wrapper to the standard API with JNI.
Regards,
Ruslan
|
|
|
|
|
Hi Ruslan,
Sorry for the absence, work & travel called
Ok, I think the project is ready to be released to open source though its not as standard in code base etc as I want it to be, but then there is no end to how much better it can be made before releasing it.
Any thoughts about license? I was thinking Apache License 2.0 or Mozilla Public License. Do you have any specific OSI license in mind? The more open the better, what do you think?
As for Java, If you share the code for Tritonous, I will code the Skype aspects pretty quick. We can leave the choice to people about which one they use.
Also, if you have any specific credits etc that you want in the header of your source code, could you please email it to me at nitin dot shenoy at gmail dot com?
I will be putting in my company name in the code that I have written unless you have objections.
Thanks
Nitin
|
|
|
|
|
I'd like to know how I could
record from device GN 2100 USB LINE Mikrofon on (for example) left channel
and record voice stream (VOIP) or Headset speaker on right channel in mp3-file.
I think it's possible.
But I need a hint (or help) how i could solve this problem.
But may be my way is wrong.
Thanks.
T-O
|
|
|
|
|
So, you want to mix sounds from two different sources, something like you hear yourself and what others are speaking.
I am not sure if using right/left channels idea will work fine, but have a try. In any case, when recording 16 bits PCM from any WaiveIn, it should be easy to take 8 bits (from 16) of the one of the channels (left or right). Then compute 8 bits of the left channel from one source and 8 bits of the right channel from other source in order to obtain a mixed 16 bits sample again (8bitsLeft*16 + 8bitsRight = 16 bits mixed PCM). As an input to MP3 encoder you will pass a buffer of such 16 bits mixed samples.
Alternatively, you can try recoding 8 bits PCM from both sources and mix those bits in the same way as explained above.
However, if driver(s) allow that, I would relay on hardware mixing if possible (redirect both WaveIn sources to a WaveOut device which allows recording).
Another solution (in case hardware mixing is not supported/possible) would be to compute waves (a bit of math) of the 16 bits PCM from both sources into another wave (16 bits as well). I haven't checked the google yet, but I am sure you should find few good, ready to use classes, to compute two waves.
Regards,
Ruslan
|
|
|
|
|
Hi RtyBase,
thanks for your work.
I would like to advice you about a bug on the m_BuffersDone variable that you use in the while loop inside "_Stop" function. m_BuffersDone is never initialized thus having an undefined value when "_Stop" function is called, inside the while loop which is right after waveInReset() call. I put the statement m_BuffersDone=0 in the "_Start" function right before the second call to waveInAddBuffer(): in this way no more problems arises stopping the recording.
But there is another trouble that I don't think is a bug. This is the behavior:
my application, start and stop to record automatically, based on the amount of noice the mic reaches: if it reaches noise over a pre-set level, it start to record; if it reaches noise below the same level, it stops recording. Now it happens that randomly the "++_this->m_BuffersDone;" under MM_WIM_DATA case, will not be reached even though the "waveInReset(this->m_WaveInHandle)" has been called (and m_SIG is set to EXIT_SIG). In this way the "while (this->m_BuffersDone < 2)" inside "_Stop" function will become an infinite loop. (Consider that I put a lot of TRACE in those two involved functions). I do not understand why this happens.
Furthermore, can you explain me why have I to expect that "_this->m_BuffersDone" have to reach the value of 2? Means that have I to expect one MM_WIM_DATA for each buffer built with waveInPrepareHeader()/waveInAddBuffer()? (Sorry, I do not found this explanation inside VC2003).
Last question: when I play what I have recorded thanks to your work, I would like to have a parametric equalizer. Any link, any idea, any articles somewhere in the web?
Thanks and regards, GianniGP
|
|
|
|
|