maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Solved] How to record sound with pulseaudio from optional device? (https://talk.maemo.org/showthread.php?t=65122)

Laethnes 2010-11-05 14:22

[Solved] How to record sound with pulseaudio from optional device?
 
I need write application recording sounds and it's needed to choose device. So, what I did so far:
- Wrote recorder with QtMultimedia. It's working for default device, but list provided by Qt is really short and choosing device from it doesn't work. From both reasons, this is no right way.
- Wrote recorder with PulseAudio. It's working for default device, but I can not use any other. I founded this http://pulseaudio.org/wiki/SampleAsyncDeviceList code to find out all devices (I couldn't find it anywhere else) and when I try any of them, it doesn't works. Sometimes error is "Invalid argument" and sometimes "No such entity".

My recorder uses simple API of pulseaudio, not the asynchronous one.

So, please, is there any tutorial how to record sound from non-default device with pa?

Language: C++
Project: I can not use existing application nor other language (like Python).

mr id 2010-11-05 14:30

Re: How to record sound with pulseaudio from optional device?
 
Hi,
What do you mean by non-default device?

Typically the mic or mixer can easily be exposed, even bluetooth mic (although naturally very laggy).

I have not worked with QtMultimedia in the past, as it hasn't proved flexible enough for my needs when I've looked at it. GStreamer is available on the device and may well be an easier route to go for development. It's not a natural fit with Qt but Gtk/GStreamer is fine with C++.

Laethnes 2010-11-05 14:38

Re: How to record sound with pulseaudio from optional device?
 
Thank you for reply.

I mean, I create input with pa_simple_new(NULL, "MyApp", PA_STREAM_RECORD, NULL, device, "record", &m_format, NULL, NULL, &error), where m_format and error are some variables and device (type: const char*) is THE device. If it is NULL, it is default and all works, if it is string identifying device (for example "source.hw1.monitor"), it doesn't work like I described above. That was mine point.

GStreamer - ok, that is next library I'll try if this won't work, thank you for suggesting. (But first I'll try to figure out how to do it with PA, because I'm really running out of time and I have not so much time to learn yet another library :3.)

mr id 2010-11-05 14:52

Re: How to record sound with pulseaudio from optional device?
 
Thanks for the clarification, wasn't quite sure where the problem was.

http://talk.maemo.org/showthread.php?p=441501 looks like it may offer some insight into some additional tools you can use at the terminal (pulseaudio-utils) to help you verify your set up. There may be other insightful postings elsewhere on this forum as well.

A quick read of that posting suggests you may want to be attatching to sink.hw1.monitor and not source.hw1.monitor but as I say using parec from the utils package should help you get up and running with this and verify the correct device setup.

If you end up going the GStreamer route I may be able to be more helpful.

Laethnes 2010-11-05 14:54

Re: How to record sound with pulseaudio from optional device?
 
Thank you very much, I'm going to check it. (If it's about source.../sink... I tryied both :3.)

mr id 2010-11-05 14:56

Re: How to record sound with pulseaudio from optional device?
 
Hmm, hopefully the utils will really help. Is it a stupid question to ask if you actually had something connected to hw1 (bluetooth I believe) when you tried testing it?

Laethnes 2010-11-05 15:09

Re: How to record sound with pulseaudio from optional device?
 
I don't test such devices - for now. I just want to record from normal mic - but with right device name and not NULL. For now.

Well, the utils tells me I do something terribly wrong, because they work, but when I use same device name - "sink.hw0.monitor" or "source.hw0" in my app, it doesn't work. But NULL does.

mr id 2010-11-05 15:19

Re: How to record sound with pulseaudio from optional device?
 
Are you able to post your code (or ideally the smallest compilable snippet) that illustrates this? Could be something simple in the code that is wrong rather than with the set-up.

I wouldn't be able to compile and run it until this evening, but someone else viewing the thread may be better placed to before then.

Laethnes 2010-11-05 18:54

Re: How to record sound with pulseaudio from optional device?
 
I'm so dumb! All it was problem wrong retyping from QString to classic C string (const char*). (I just tested it with std::cout and it looked ok...)

Anyway, thank you very much for your effort and help, I really appreciate it.

And I apologize for late answer, I ran out of time...

mr id 2010-11-05 19:35

Re: How to record sound with pulseaudio from optional device?
 
good news. happy coding.


All times are GMT. The time now is 01:59.

vBulletin® Version 3.8.8