Which API to use for simple clients?
I have two Audio related projects that need updating.
1. "rsynth" formant based text-to-speech synthesis
2. Audio::* Perl modules.
Both have existing /dev/dsp style backends at present, which have been working fine. But recently (SuSE 9.0 install?) when run under ALSA emulation of /dev/dsp they both started producing segfaults - "after program had exited", (neither valgrind nor gdb can give any info on the fault).
So I decided it was time to do a native ALSA backend(s). I have rsynth backend working, and perl Audio:: one almost working. But before going forward I would like to solicit opinions on what is the "right" API to use.
The Linux audio world seems to be in a state of flux with these options (please tell me if I missed any):
1. Venerable OSS stuff
- Widely available :-)
- Some cards have quasi or truely commecial drivers rather than
free / opensource ones :-(
- emulation via ALSA (at least as shipped by SuSE) seems broken :-(
2. ALSA
- Reasonably widely available :-|, and improving
- Opensource :-)
- Documentation is lacking :-(
Everything hinges on the
"Configuration Space" concept, but I can't find an explanation of how that works. This is the sticking point with perl code - I can't find how to change the sample rate / channels, so _seems_ I need to close and re-open.
3. JACK
- Gets lots of excited "this is cool" kind of coverage :-)
- realtime :-)
- Callback style not ideal for speech synthesis or play-from-file
of my simple apps. complex :-(
4. Enlightenment Sound Demon
- Seems to be used by KDE etc.
- haven't looked into it further.
5. Network Audio System
- Works on many platforms Linux/Solaris/X Terminals :-)
- X-like "imake" style rather than configure :-(
- Linux version still seems to be based on OSS - so recurse ;-)
6. Presumably there is some kind of telephony API as well, for sending sound to incomming phone calls via modem / ISDN
Complexity and callbacks don't scare me - I do perl/Tk after all! But this is a 2nd-string project so I don't want to do a lot of complex stuff for an API that is vanishing - I would rather either use a simple stable interface, or pitch in and help on the "comming" complex API.
Suggestions anyone? (I just subscribed to both lists - so reply to your favourite list.)
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
How about PortAudio? It currently supports OSS, and should support ALSA and JACK in the next release.
- Steve
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Hi Nick
Since you're looking into different alternatives, have you considered PortAudio (www.portaudio.com)? The ALSA implementation of v19 (development branch) is well developed, and fairly stable from what I can see (being one of the developers). There hasn't been a lot of feedback, but my own testing hasn't turned up any bugs in a while. PortAudio also offers two different interfaces to the programmer, both blocking and callback interfaces are completed for the ALSA implementation. So you can choose whichever suits your application the best. At the same time, should you wish to write cross-platform programs, PortAudio supports different platforms. I don't know the current state of all the implementations, but Windows MME and ASIO should be well functional and SGI IRIX seems to be coming along.
Hope this helps
Arve Knudsen
Quoted 70 lines · Nick Ing-Simmons
I have two Audio related projects that need updating.
1. "rsynth" formant based text-to-speech synthesis
2. Audio::* Perl modules.
Both have existing
/dev/dspstyle backends at present, which have been working fine. But recently (SuSE 9.0 install?) when run under ALSA emulation of/dev/dspthey both started producing segfaults - "after program had exited", (neither valgrind nor gdb can give any info on the fault).So I decided it was time to do a native ALSA backend(s). I have rsynth backend working, and perl Audio:: one almost working. But before going forward I would like to solicit opinions on what is the "right" API to use.
The Linux audio world seems to be in a state of flux with these options (please tell me if I missed any):
1. Venerable OSS stuff
- Widely available :-)
- Some cards have quasi or truely commecial drivers rather thanfree / opensource ones :-(- emulation via ALSA (at least as shipped by SuSE) seems broken :-(
2. ALSA
- Reasonably widely available :-|, and improving
- Opensource :-)
- Documentation is lacking :-(
Everything hinges on the
"Configuration Space" concept, but I can't find an explanation of how that works. This is the sticking point with perl code - I can't
find
how to change the sample rate / channels, so _seems_ I need to close and re-open.3. JACK
- Gets lots of excited "this is cool" kind of coverage :-)
- realtime :-)
- Callback style not ideal for speech synthesis or play-from-fileof my simple apps. complex :-(4. Enlightenment Sound Demon
- Seems to be used by KDE etc.
- haven't looked into it further.5. Network Audio System
- Works on many platforms Linux/Solaris/X Terminals :-)
- X-like "imake" style rather than configure :-(
- Linux version still seems to be based on OSS - so recurse ;-)6. Presumably there is some kind of telephony API as well, for sending sound to incomming phone calls via modem / ISDN
Complexity and callbacks don't scare me - I do perl/Tk after all! But this is a 2nd-string project so I don't want to do a lot of complex stuff for an API that is vanishing - I would rather either use a simple stable interface, or pitch in and help on the "comming" complex API.
Suggestions anyone? (I just subscribed to both lists - so reply to your favourite list.)
Quoted 9 lines
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
Quoted 4 lines · Arve Knudsen
Hi Nick
Since you're looking into different alternatives, have you considered PortAudio (www.portaudio.com)?
Had not heard of it before.
Looks interesting.
Quoted 4 lines
The ALSA implementation of v19 (development
branch) is well developed, and fairly stable from what I can see (being one of the developers). There hasn't been a lot of feedback, but my own testing hasn't turned up any bugs in a while.
I few clicks but nothing too horrible.
Quoted 4 lines
PortAudio also offers two
different interfaces to the programmer, both blocking and callback interfaces are completed for the ALSA implementation. So you can choose whichever suits your application the best.
patest_write_sine produces a noise but it isn't a sine wave (by ear there are some "sharp edges" in the waveform).
patest_sine_formats hangs apparently forever.
Quoted 7 lines
At the same time, should you
wish to write cross-platform programs, PortAudio supports different platforms. I don't know the current state of all the implementations, but Windows MME and ASIO should be well functional and SGI IRIX seems to be coming along.Hope this helps
If nothing else it serves as example code for oss/alsa/jack setup. Will not rule it out.
Quoted 89 lines
Arve Knudsen
Quoted 72 lines · Nick Ing-Simmons
I have two Audio related projects that need updating.
1. "rsynth" formant based text-to-speech synthesis
2. Audio::* Perl modules.
Both have existing
/dev/dspstyle backends at present, which have been working
fine. But recently (SuSE 9.0 install?) when run under ALSA emulation of/dev/dspthey both started producing segfaults - "after program had exited",
(neither valgrind nor gdb can give any info on the fault).So I decided it was time to do a native ALSA backend(s). I have rsynth backend working, and perl Audio:: one almost working. But before going forward I would like to solicit opinions on what is the "right" API to use.
The Linux audio world seems to be in a state of flux with these options (please tell me if I missed any):
1. Venerable OSS stuff
- Widely available :-)
- Some cards have quasi or truely commecial drivers rather thanfree / opensource ones :-(- emulation via ALSA (at least as shipped by SuSE) seems broken :-(
2. ALSA
- Reasonably widely available :-|, and improving
- Opensource :-)
- Documentation is lacking :-(
Everything hinges on the
"Configuration Space" concept, but I can't find an explanation of how that works. This is the sticking point with perl code - I can't
find
how to change the sample rate / channels, so _seems_ I need to close and re-open.3. JACK
- Gets lots of excited "this is cool" kind of coverage :-)
- realtime :-)
- Callback style not ideal for speech synthesis or play-from-fileof my simple apps. complex :-(4. Enlightenment Sound Demon
- Seems to be used by KDE etc.
- haven't looked into it further.5. Network Audio System
- Works on many platforms Linux/Solaris/X Terminals :-)
- X-like "imake" style rather than configure :-(
- Linux version still seems to be based on OSS - so recurse ;-)6. Presumably there is some kind of telephony API as well, for sending sound to incomming phone calls via modem / ISDN
Complexity and callbacks don't scare me - I do perl/Tk after all! But this is a 2nd-string project so I don't want to do a lot of complex stuff for an API that is vanishing - I would rather either use a simple stable interface, or pitch in and help on the "comming" complex API.
Suggestions anyone? (I just subscribed to both lists - so reply to your favourite list.)
Quoted 9 lines
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Quoted 9 lines
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
Quoted 6 lines · Nick Ing-Simmons
Quoted 4 lines
The ALSA implementation of v19 (development
branch) is well developed, and fairly stable from what I can see (being one of the developers). There hasn't been a lot of feedback, but my own testing hasn't turned up any bugs in a while.I few clicks but nothing too horrible.
Clicks as in audio glitches? I experience no glitches in daily use (blocking API), unless I set the buffer size too low.
Quoted 9 lines
Quoted 4 lines
PortAudio also offers two
different interfaces to the programmer, both blocking and callback interfaces are completed for the ALSA implementation. So you can choose whichever suits your application the best.
patest_write_sineproduces a noise but it isn't a sine wave (by ear there are some "sharp edges" in the waveform).
patest_sine_formatshangs apparently forever.
Sounds weird. Works perfectly with my setup. Can you tell me which one of the underlying host APIs (JACK/OSS/ALSA) is being used? I just tested the OSS implementation for the first time, and it behaves as you describe. I cannot help you with OSS or JACK I'm afraid, as I concentrate on the ALSA bit. I don't know what the current state of OSS and JACK support is, but I don't think they've been as regularly updated as the ALSA one. My recommendation, for now, would be to configure PortAudio to compile with only ALSA support. Then the ALSA host API should be used by default, and things should work better I think.
Quoted 11 lines
Quoted 7 lines
At the same time, should you
wish to write cross-platform programs, PortAudio supports different platforms. I don't know the current state of all the implementations, but Windows MME and ASIO should be well functional and SGI IRIX seems to be coming along.Hope this helps
If nothing else it serves as example code for oss/alsa/jack setup. Will not rule it out.
Appreciate the feedback
Arve Knudsen
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Nick Ing-Simmons
Quoted 3 lines · Arve Knudsen
Quoted 3 lines
patest_write_sineproduces a noise but it isn't a sine wave (by ear there are some "sharp edges" in the waveform).That is the potential killer ... remember one advantage of portaudio was the option to use a
write()interface...
The blocking interface is fully implemented with the ALSA implementation, and I use it daily. It would seem there are problems with the OSS one, but its development branch after all :)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
patest_sine_formatshangs apparently forever.Sounds weird. Works perfectly with my setup. Can you tell me which one of the underlying host APIs (JACK/OSS/ALSA) is being used?
Can you tell me how to tell?
You can use something like this to print the API name:printf("Host API: %s\n", Pa_GetHostApiInfo(Pa_GetDefaultHostApi())->name); Unless I explicitly disable it, OSS shows up as default.
Quoted 19 lines
Quoted 8 lines
I just tested the
OSS implementation for the first time, and it behaves as you describe. I cannot help you with OSS or JACK I'm afraid, as I concentrate on the ALSA bit. I don't know what the current state of OSS and JACK support is, but I don't think they've been as regularly updated as the ALSA one. My recommendation, for now, would be to configure PortAudio to compile with only ALSA support. Then the ALSA host API should be used by default, and things should work better I think.Worse:
1019 make clean 1020 make distclean 1021 rm config.cache 1022 rm config.status 1023 ./configure --without-jack --without-oss 1024 make 1025 bin/patest_sine_formats
Quoted 9 lines
nick@llama:~/portaudio> !1025
bin/patest_sine_formats
PortAudio Test: output Signed 16 Bit
An error occured while using the portaudio stream
Error number: -9997
Error message: Invalid sample rateMy ALSA card is quite capable of doing 44100
Can you verify that the ALSA API is in use, after configuring out OSS and JACK? I cannot see why this test should fail, granted your card supports the given samplerate. If you could be bothered, perhaps you could add some debug output to function SetApproximateSampleRate at pa_linux_alsa/pa_linux_alsa.c: 1575? Ie. you could verify that the correct samplerate is indeed passed to ALSA-lib, and that ALSA-lib rejects it.
Quoted 6 lines
This is using a v19 snapshot:
-rw-rw-r-- 1 nick users 486933 2004-01-04 11:25/home/nick/tgzs/pa_snapshot_v19.tar.gzTime/date are GMT.
Quoted 8 lines
Adding jack back in makes no difference.
Adding oss back in gives same fail.So it seems that it is using oss and it is broken, can't say I am surprised - if you recall the original message was prompted as I was moving to native ALSA 'cos OSS emulation was flakey.
I think v19 PortAudio OSS still needs some work, I'm experiencing similar problems.
Regards
Arve Knudsen
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · On Mon, 05 Jan 2004 13:36:33 +0000, <[email protected]> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
patest_sine_formatshangs apparently forever.Sounds weird. Works perfectly with my setup. Can you tell me which one of
the underlying host APIs (JACK/OSS/ALSA) is being used?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can you tell me how to tell?
You can use something like this to print the API name:
printf("Host API: %s\n", Pa_GetHostApiInfo(Pa_GetDefaultHostApi())->name); Unless I explicitly disable it, OSS shows up as default.That segfaulted 1st place I put it. Putting it after the open works
Oh yeah, sorry, I forgot to mention it has to come after the Pa_Initialize call. My bad :|
Quoted 54 lines
Quoted 7 lines
Quoted 7 lines
nick@llama:~/portaudio> !1025
bin/patest_sine_formats
PortAudio Test: output Signed 16 Bit
An error occured while using the portaudio stream
Error number: -9997
Error message: Invalid sample rateQuoted 8 lines
Quoted 2 lines
My ALSA card is quite capable of doing 44100
Can you verify that the ALSA API is in use, after configuring out OSS and JACK? I cannot see why this test should fail, granted your card supports the given samplerate. If you could be bothered, perhaps you could add some debug output to function SetApproximateSampleRate at
pa_linux_alsa/pa_linux_alsa.c: 1575? Ie. you could verify that the correct samplerate is indeed passed to ALSA-lib, and that ALSA-lib rejects it.SetApproximateSampleRate is @ line 1583 in my copy:
Making that :err = snd_pcm_hw_params_set_rate( pcm, hwParams, approx, dir ); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=44100 rate=-22 dir=0 Host API: ALSA
An error occured while using the portaudio stream Error number: -9997
Error message: Invalid sample rate nick@llama:~/portaudio>Which seems sane. Changing it to:
err = snd_pcm_hw_params_set_rate_near( pcm, hwParams, &approx, &dir
); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=48000 rate=0 dir=0 Host API: ALSA
Waiting 10 seconds for sound to finish. PortAudio Test Finished: Signed 16 Bit
Quoted 5 lines
So perhaps my card does _NOT_ support 44100Hz after all. This is the card as autodetected/configured by SuSE9.0's YaST. Seems there are options to play with including the clock rate but I don't know what I am doing ...
It looks like you got PortAudio working at least :) You can also look up the PaDeviceInfo struct for any device, to check out the default sample rate. I think the ALSA plughw device will convert the samplerate to a hardware supported one for you, so that might be your best bet? I have never used the PCM plugin myself, but its possible to specify a custom device string with pa_linux_alsa. If you look in the pa_linux_alsa.h file, you'll see a custom stream structure, PaAlsaStreamInfo, which basically can be used like this:
PaAlsaStreamInfo alsaStreamInfo;
PaStreamParameters outputParameters;
PaAlsa_InitializeStreamInfo(&alsaStreamInfo);
alsaStreamInfo.deviceString = "plughw:0,0";
outputParameters.device = paUseHostApiSpecificDeviceSpecification; outputParameters.hostApiSpecificStreamInfo = &alsaStreamInfo;
It's device string will then be used when opening the output device.
Hope this helps
Arve Knudsen
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
Quoted 51 lines · Arve Knudsen
Quoted 51 lines
Quoted 12 lines
Quoted 3 lines
My ALSA card is quite capable of doing 44100
Can you verify that the ALSA API is in use, after configuring out OSS and
JACK? I cannot see why this test should fail, granted your card supports the given samplerate. If you could be bothered, perhaps you could add some
debug output to function SetApproximateSampleRate atpa_linux_alsa/pa_linux_alsa.c: 1575? Ie. you could verify that the correct
samplerate is indeed passed to ALSA-lib, and that ALSA-lib rejects it.SetApproximateSampleRate is @ line 1583 in my copy:
Making that :err = snd_pcm_hw_params_set_rate( pcm, hwParams, approx, dir ); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=44100 rate=-22 dir=0 Host API: ALSA
An error occured while using the portaudio stream Error number: -9997
Error message: Invalid sample rate nick@llama:~/portaudio>Which seems sane. Changing it to:
err = snd_pcm_hw_params_set_rate_near( pcm, hwParams, &approx, &dir
); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=48000 rate=0 dir=0 Host API: ALSA
Waiting 10 seconds for sound to finish. PortAudio Test Finished: Signed 16 Bit
Quoted 6 lines
Quoted 5 lines
So perhaps my card does _NOT_ support 44100Hz after all. This is the card as autodetected/configured by SuSE9.0's YaST. Seems there are options to play with including the clock rate but I don't know what I am doing ...
It looks like you got PortAudio working at least :)
Well if you consider 48000 "near" 44100 ...
Quoted 4 lines
You can also look up
the PaDeviceInfo struct for any device, to check out the default sample rate. I think the ALSA plughw device will convert the samplerate to a hardware supported one for you, so that might be your best bet?
I think so - googling for 8235 and 44100 shows I am not the 1st to have this kind of problem...
Quoted 8 lines
I have
never used the PCM plugin myself, but its possible to specify a custom device string withpa_linux_alsa. If you look in thepa_linux_alsa.hfile, you'll see a custom stream structure, PaAlsaStreamInfo, which basically can be used like this:
PaAlsaStreamInfo alsaStreamInfo;
PaStreamParameters outputParameters;
Quoted 7 lines
PaAlsa_InitializeStreamInfo(&alsaStreamInfo);
alsaStreamInfo.deviceString = "plughw:0,0";outputParameters.device = paUseHostApiSpecificDeviceSpecification; outputParameters.hostApiSpecificStreamInfo = &alsaStreamInfo;
It's device string will then be used when opening the output device.
But having a custom string then means I need to know that
A. PortAudio is using ALSA
B. This user's ALSA hw device cannot do my rate
C. Which magic custom string to use.
If I need to know that much I might as well use native ALSA code...
Surely the whole point of PortAudio is that app says "open sound card for 44100Hz, 16-bit, 2 channels" and the PortAudio layer figures out how to do that?
Quoted 6 lines
Hope this helps
Arve Knudsen
Quoted 9 lines
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
Quoted 52 lines · On Mon, 05 Jan 2004 15:55:46 +0000, <[email protected]> wrote:
Quoted 51 lines · Arve Knudsen
Quoted 51 lines
Quoted 12 lines
Quoted 3 lines
My ALSA card is quite capable of doing 44100
Can you verify that the ALSA API is in use, after configuring out OSS and
JACK? I cannot see why this test should fail, granted your card supports the given samplerate. If you could be bothered, perhaps you could add some
debug output to function SetApproximateSampleRate atpa_linux_alsa/pa_linux_alsa.c: 1575? Ie. you could verify that the correct
samplerate is indeed passed to ALSA-lib, and that ALSA-lib rejects it.SetApproximateSampleRate is @ line 1583 in my copy:
Making that :err = snd_pcm_hw_params_set_rate( pcm, hwParams, approx, dir ); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=44100 rate=-22 dir=0 Host API: ALSA
An error occured while using the portaudio stream Error number: -9997
Error message: Invalid sample rate nick@llama:~/portaudio>Which seems sane. Changing it to:
err = snd_pcm_hw_params_set_rate_near( pcm, hwParams, &approx, &dir
); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=48000 rate=0 dir=0 Host API: ALSA
Waiting 10 seconds for sound to finish. PortAudio Test Finished: Signed 16 Bit
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
So perhaps my card does _NOT_ support 44100Hz after all. This is the card as autodetected/configured by SuSE9.0's YaST. Seems there are options to play with including the clock rate but I don't know what I am doing ...
It looks like you got PortAudio working at least :)
Well if you consider 48000 "near" 44100 ...
This doesn't have to do with PortAudio, frankly. PortAudio does not convert samplerates, it will be constrained by the host device.
Quoted 19 lines
Quoted 4 lines
You can also look up
the PaDeviceInfo struct for any device, to check out the default sample rate. I think the ALSA plughw device will convert the samplerate to a hardware supported one for you, so that might be your best bet?I think so - googling for 8235 and 44100 shows I am not the 1st to have this kind of problem...
Quoted 11 lines
I have
never used the PCM plugin myself, but its possible to specify a custom device string withpa_linux_alsa. If you look in thepa_linux_alsa.hfile, you'll see a custom stream structure, PaAlsaStreamInfo, which basically can be used like this:
PaAlsaStreamInfo alsaStreamInfo;
PaStreamParameters outputParameters;
PaAlsa_InitializeStreamInfo(&alsaStreamInfo);
alsaStreamInfo.deviceString = "plughw:0,0";
Quoted 8 lines
Quoted 4 lines
outputParameters.device = paUseHostApiSpecificDeviceSpecification; outputParameters.hostApiSpecificStreamInfo = &alsaStreamInfo;
It's device string will then be used when opening the output device.
But having a custom string then means I need to know that
A. PortAudio is using ALSA
B. This user's ALSA hw device cannot do my rate
PortAudio allows you to test a given configuration, which is not particular to ALSA.
Quoted 1 line
C. Which magic custom string to use.
Some devices (software) are not enumerated by ALSA, so there is no way for PortAudio to know.
Quoted 1 line
If I need to know that much I might as well use native ALSA code...
The only reason I mentioned plughw is you might want to convert from 44100 to 48000, since your hardware device doesn't support 44k. This is particular to ALSA. Regular hardware devices will be available through PortAudio, requiring no specialized knowledge.
Quoted 4 lines
Surely the whole point of PortAudio is that app says "open sound card for 44100Hz, 16-bit, 2 channels" and the PortAudio layer figures out how to do that?
Like I pointed out earlier, PortAudio performs no samplerate conversion (nor will it provide more or less channels than the device supports). The point, as I see it, is cross platform abstraction (with benefits such as buffer adaption and bitdepth conversion). Wether a card supports a specific configuration can be tested, or you can go with the defaults. However, certain API's have their own ways of doing things. ALSA offers software devices, such as plughw, which are not currently enumerated along with the other devices. So in order to use plughw, you will have to pass a custom device string. This requires specialized knowledge in the client app of course, but its the best solution I've come up with. This is getting entirely offtopic though, maybe we best discuss this on the PortAudio list? If you're still interested in the API that is.
Regards
Arve Knudsen
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
Quoted 5 lines · On Mon, 05 Jan 2004 13:36:33 +0000, <[email protected]> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
patest_sine_formatshangs apparently forever.Sounds weird. Works perfectly with my setup. Can you tell me which one of
the underlying host APIs (JACK/OSS/ALSA) is being used?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can you tell me how to tell?
You can use something like this to print the API name:
printf("Host API: %s\n", Pa_GetHostApiInfo(Pa_GetDefaultHostApi())->name); Unless I explicitly disable it, OSS shows up as default.That segfaulted 1st place I put it. Putting it after the open works
Oh yeah, sorry, I forgot to mention it has to come after the Pa_Initialize call. My bad :|
Quoted 54 lines
Quoted 7 lines
Quoted 7 lines
nick@llama:~/portaudio> !1025
bin/patest_sine_formats
PortAudio Test: output Signed 16 Bit
An error occured while using the portaudio stream
Error number: -9997
Error message: Invalid sample rateQuoted 8 lines
Quoted 2 lines
My ALSA card is quite capable of doing 44100
Can you verify that the ALSA API is in use, after configuring out OSS and JACK? I cannot see why this test should fail, granted your card supports the given samplerate. If you could be bothered, perhaps you could add some debug output to function SetApproximateSampleRate at
pa_linux_alsa/pa_linux_alsa.c: 1575? Ie. you could verify that the correct samplerate is indeed passed to ALSA-lib, and that ALSA-lib rejects it.SetApproximateSampleRate is @ line 1583 in my copy:
Making that :err = snd_pcm_hw_params_set_rate( pcm, hwParams, approx, dir ); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=44100 rate=-22 dir=0 Host API: ALSA
An error occured while using the portaudio stream Error number: -9997
Error message: Invalid sample rate nick@llama:~/portaudio>Which seems sane. Changing it to:
err = snd_pcm_hw_params_set_rate_near( pcm, hwParams, &approx, &dir
); printf("%s approx=%lu rate=%d dir=%d\n", __FUNCTION__,approx, err, dir); return err;Yields:
nick@llama:~/portaudio> bin/patest_sine_formats PortAudio Test: output Signed 16 Bit SetApproximateSampleRate approx=48000 rate=0 dir=0 Host API: ALSA
Waiting 10 seconds for sound to finish. PortAudio Test Finished: Signed 16 Bit
Quoted 5 lines
So perhaps my card does _NOT_ support 44100Hz after all. This is the card as autodetected/configured by SuSE9.0's YaST. Seems there are options to play with including the clock rate but I don't know what I am doing ...
It looks like you got PortAudio working at least :) You can also look up the PaDeviceInfo struct for any device, to check out the default sample rate. I think the ALSA plughw device will convert the samplerate to a hardware supported one for you, so that might be your best bet? I have never used the PCM plugin myself, but its possible to specify a custom device string with pa_linux_alsa. If you look in the pa_linux_alsa.h file, you'll see a custom stream structure, PaAlsaStreamInfo, which basically can be used like this:
PaAlsaStreamInfo alsaStreamInfo;
PaStreamParameters outputParameters;
PaAlsa_InitializeStreamInfo(&alsaStreamInfo);
alsaStreamInfo.deviceString = "plughw:0,0";
outputParameters.device = paUseHostApiSpecificDeviceSpecification; outputParameters.hostApiSpecificStreamInfo = &alsaStreamInfo;
It's device string will then be used when opening the output device.
Hope this helps
Arve Knudsen
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click