Rick,
Something went wrong when I tried to reply using my cell phone so
here is it again (+ some more info)
First check that you are using the correct card with ainfo. This is
how it looks on a Macbook Pro:
octave:1> ainfo
No ALSA device was given. Listing the devices:
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: Cirrus Analog [Cirrus Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: Cirrus Digital [Cirrus Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: Cirrus Analog [Cirrus Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: Cirrus Digital [Cirrus Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
If you for example want to use the HDA Intel card then
octave:2>aplay(randn(44100*2,2),44100,'hw:0,0',[512 2])
should work (plays 2 seconds of noise). If you get this message:
error: Playback open error: Device or resource busy
then try, for example, to start jackd:
fl-mac ~ # jackd -dalsa -r44100 -p512
jackd 0.121.3
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben
Hohn and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK compiled with System V SHM support.
loading driver ..
apparent rate = 44100
creating alsa driver ...
hw:0|hw:0|512|2|44100|0|0|nomon|swmeter|-|32bit
control device hw:0
ATTENTION: The playback device "hw:0" is already in use. The
following applications are using your soundcard(s) so you should
check them and stop them as necessary before trying to start JACK
again:
knotify4 (process ID 4190)
cannot load driver module alsa
Here knotify4 is using the HDA card so a
fl-mac ~ # kill -9 4190
will let you use the sound card.
Regarding aplayrec, calling it using
Y = aplayrec(A,2,44100,'hw:0,0',[512 2]);
will record 2 cannels (put in the actual number of capture channels
that your card has) at 44100 Hz and the number of columns in Y is
the same as in the A matrix.
/Fredrik
On 10/29/11 21:19, Fredrik Lingvall wrote:
---------- Forwarded message ----------
From: "Fredrik Lingvall" <address@hidden>
Date: Oct 29, 2011 6:32 PM
Subject: Re: Playing an array as sound and recording
it's output in parallel
To: "Rick T" <address@hidden>
Rick,
Try to specify the ALSA device, eg., hw:0,X
Where X is 0 or 1 (if you have two cards. Find out which with
ainfo.
There may also be something else using the soundcard, such as
KDE. You can try to start jackd from the command line. If
something is using the card then jackd will complain too.
On Oct 29, 2011 2:32 AM, "Rick T" <address@hidden>
wrote:
>
> Thanks Fredrik
>
> I downloaded and installed your package I'm getting an
error message
> "Unable to set the PCM access type: Invalid argument
> >>>error: Unable to set hardware parameters.
Bailing out!" This is the test code I tried it with
>
> clear all
> t=linspace(0,1,44100);
> A = 1; % amplitude
> Fs = 44100
>
> for ii=1:1:10
> freq=ii; %how many in 1 sec
> T = 1/freq; % period of the signal
> vertoffset=0.5;
> % square
> square = mod(t * A / T, A) > A / 2;
> square = square - vertoffset;
> %sound(square,Fs);
> aplay(square,Fs,'default',[512 2])
> end;
>
> I also was trying to test your aplayrec function but got a
little confused with the [Y] variable in the help it says
> Loadable Function: [Y] =
> aplayrec(A,rec_channels,fs,dev_name,hw_pars)
> APLAYREC Plays audio data from the input matrix A, on the
PCM
> device given by dev_name, and records audio data to
the output
> matrix Y
>
> The [Y] variable looks like it's just going to record the
'A' variable/matrix.
> I'm trying to play a matrix/array on the output of a
channel
> and record the input from the mic channel into an
array/matrix.
>
> thanks
>
> On Fri, Oct 28, 2011 at 6:44 AM, Fredrik Lingvall <address@hidden>
wrote:
>>
>> Rick,
>>
>> You can try two packages found here:
>>
>> http://folk.uio.no/fl/aaudio.shtml
>>
>> One is using the ALSA API and one is using JACK. Both
can do full duplex. At least on the RME cards that I used when
writing the code.
>>
>> HTH,
>>
>> /Fredrik
>>
>>
>> On 10/28/11 17:02, Rick T wrote:
>>>
>>> Wow thanks I do have a full duplex sound card and
I'm using ubuntu 10.04 64bit. This looks like what I'm looking
for hopefully it will allow me to create my own test signals to
use.
>>> Thanks again
>>>
>>> On Fri, Oct 28, 2011 at 3:21 AM, William Krekeler
<address@hidden>
wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> From: address@hidden
[mailto:address@hidden]
On Behalf Of Rick T
>>>> Sent: Thursday, October 27, 2011 5:17 PM
>>>> To: address@hidden
>>>> Subject: Playing an array as sound and
recording it's output in parallel
>>>>
>>>>
>>>>
>>>> Greetings All
>>>>
>>>>
>>>>
>>>> I know octave can play arrays as sound but, I
was wondering if Octave can do this. I would like to cycle
through a range of frequencies and have octave play them using
the speaker out on my computer, and have octave also record the
sound using the mic input to get the max value. I'm trying to
automate a way to have octave cycle through frequencies and
record the data received so I can go back latter and look at the
resonant frequencies. Can Octave do this type of operation in
parallel?
>>>>
>>>>
>>>>
>>>> Example:
>>>>
>>>> clear all
>>>>
>>>> t=linspace(0,1,44100);
>>>>
>>>> A = 1; % amplitude
>>>>
>>>> Fs = 44100
>>>>
>>>>
>>>>
>>>> for ii=1:1:10
>>>>
>>>> freq=ii; %how many in 1 sec
>>>>
>>>> T = 1/freq; % period of the signal
>>>>
>>>> vertoffset=0.5;
>>>>
>>>> % square
>>>>
>>>> square = mod(t * A / T, A) > A / 2;
>>>>
>>>> square = square - vertoffset;
>>>>
>>>> sound(square,Fs);
>>>>
>>>> end;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Playing sound and recording sound at the same
time requires a full-duplex soundcard. This is not the default
configuration so from a hardware standpoint your computer may
not be able to do this. Next you need a low-latency driver like
ASIO, there are others I just can't remember then right now. For
code look at MATAA (Mat's Audio Analyzer) for examples of how to
input and output sound at the same time along with analysis.
>>>>
>>>>
>>>>
>>>> http://sourceforge.net/projects/mataa/
>>>>
>>>> http://www.audioroot.net/index.html?analysis/mataa.html
>>>>
>>>>
>>>>
>>>> Hope that helps.
>>>>
>>>>
>>>>
>>>> William Krekeler
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Help-octave mailing list
>>> address@hidden
>>> https://mailman.cae.wisc.edu/listinfo/help-octave
>>
>>
>
>
>
> --
>
|