GNU Octave duplex audio

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
there was a complete measurement suite for octave. i tried it out some years ago but it all lacked a bit of the playing and recording functionality because of some integrated tool named TestTone that would not work as expected on linux. in the meantime octave itself integrated a function for that but i cant rename it. you might simply use these tools and take a look at its current state. maye they already fixed this issue.

MATAA (Mat’s Audio Analyzer) | audioroot

looking at github it seems to be active in developement these days:
GitHub - mbrennwa/mataa
 
urks, thats bad news about holm. when using windows i almost always use holm, the live filter update and curve manipulation functions of holm are worth gold.

i use rew only if i have to because the functions are so enormous and asking too much of me.
rew is nice to have as something for linux. i really have to learn more about it.
 
Is it possible to use record at the same time as soundsc?

I am thinking how to use GNU Octave as a speaker impedance measurement tool and want to play out a sweep or chirp while reading in for level and phase measurement

Have you tried Python? There is a package sounddevice that does what you want.

Simultaneous Playback and Recording
To play back an array and record at the same time, use sounddevice.playrec():

myrecording = sd.playrec(myarray, fs, channels=2)
The number of output channels is obtained from myarray, but the number of input channels still has to be specified.

Again, default values can be used:

sd.default.samplerate = fs
sd.default.channels = 2
myrecording = sd.playrec(myarray)
In this case the number of output channels is still taken from myarray (which may or may not have 2 channels), but the number of input channels is taken from sounddevice.default.channels.

I don't know if any of the tools support 24bit or greater, the most basic built-ins don't.
 
I was thinking about a very straightforward and reasonably accurate impedance measurement system. 16 bit is plenty for this and no point struggling for 24 bit.

Logarithmic impedance and frequency scales and calibration with 0R, 10R and 100R resistors to remove the effects of soundcard output impedance and fixture resistances
 
I am thinking how to use GNU Octave as a speaker impedance measurement tool and want to play out a sweep or chirp while reading in for level and phase measurement



No idea, but you can with the Matlab Audio System Toolbox. Note there is a Home license for non professional use for about ~£60.


Code:
% gen 1khz and output to audio device and measure thd / thd+n of input
Fs=44100;
f=997;
A=.998; 
harmonics=11;
dut = 'Lynx E22';
playRec = audioPlayerRecorder('SampleRate',Fs,'BitDepth','32-bit float');
playRec.Device = 'ASIO Lynx';
t=0:1/Fs:1-(1/Fs);
audioOut = A*sin(f*2*pi*t);
for i=1:3
    [audioIn,numUnderrun,numOverrun]  = playRec(audioOut');
end
figure
thd(audioIn, Fs, harmonics);
figure
sinad(audioIn,Fs);
 
I really want to figure out an opensource method, just because it can be done.

I might be able to use playrec or this is supposed to work:

p = audioplayer (original, fs, ...)
r = audiorecorder (fs, nbits, ...)
play (p);
recordblocking (r, number_of_seconds);
y = getaudiodata (r);
 
I might be able to use playrec or this is supposed to work:

p = audioplayer (original, fs, ...)
r = audiorecorder (fs, nbits, ...)
play (p);
recordblocking (r, number_of_seconds);
y = getaudiodata (r);

Did you try this? The only problem I see is that there is no guarantee of the delay between play and getaudiodata whereas the playrec functions on various systems are intended to be simultaneous. There is probably not enough delay to matter and you could figure it out in any case.

I tried the Octave functions anything but 16 bit returns garbage (for me), so just ask for 16 bits no matter what your card says.

We went through this a while back, the PortAudio code that most of the free/open source software uses is compiled without ASIO or other advanced features.
 
there was a complete measurement suite for octave. i tried it out some years ago but it all lacked a bit of the playing and recording functionality because of some integrated tool named TestTone that would not work as expected on linux. in the meantime octave itself integrated a function for that but i cant rename it. you might simply use these tools and take a look at its current state. maye they already fixed this issue.

MATAA (Mat’s Audio Analyzer) | audioroot

looking at github it seems to be active in developement these days:
GitHub - mbrennwa/mataa

Yes, I still maintain MATAA, and I use it for most of my own work (both on Linux and a Mac). What was your problem with TestTone?

If you want to go another route, I'd recommend PlayRec, which has become relatively mature. It allows full-duplex sound in/out with Octave. If I would start over with MATAA today, I would use PlayRec instead of writing my own tool for sound in/out (TestTone), but PlayRec was not as mature back then. That said, PlayRec and TestTone both rely on PortAudio, so the the sound in/out engine is the same.
 
Why are the PortAudio binaries that are generally available for Python and Octave, etc. compiled without ASIO, etc.? I just went through this with kevin k. this weekend, the file info just ends up being nonsense (talking about Win).

Uhm, why do you think so? What do you mean by "binaries that are generally available for Python and Octave"? The Windows version of the TestTone binary for MATAA does use ASIO.

Edit: I guess you are referring to this: ASIO Audio Interface - Audacity Wiki . There's always ASIO4ALL as a way out.
 
Last edited:
I am struggling with making MATAA use ASIO on Windows 7&10 PCs, the TestDevice command is working and detecting ASIO, but then the script fails to use it.

I don't want to go too far off topic here -- please PM me or send a message to the mataa mailing list. Make sure to include the command you used and the error message you get.
 
Edit: I guess you are referring to this: ASIO Audio Interface - Audacity Wiki . There's always ASIO4ALL as a way out.

I read that Audacity still has to be recompiled from source for asio4all to work, I was not trying to help users that are comfortable with this.

I was trying to find a turnkey solution for some folks. Out of the box Octave does not do >16bits (at least with a Scarlett 2i2 which works fine with ARTA).

The pyaudio readme has this.

Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6. For those versions, both 32-bit and 64-bit wheels are available. These binaries include PortAudio v19 v190600_20161030, built with MinGW. They support only the Windows MME API and do not include support for DirectX, .
 
I read that Audacity still has to be recompiled from source for asio4all to work, I was not trying to help users that are comfortable with this.

I was trying to find a turnkey solution for some folks. Out of the box Octave does not do >16bits (at least with a Scarlett 2i2 which works fine with ARTA).

The pyaudio readme has this.

Maybe they are dealing with the same license issues as Audacity that stop them from offering a binary with ASIO support.

PortAudio certainly does support >16 bit. Both PlayRec and MATAA/TestTone work with >16 bit.
 
Yes, I still maintain MATAA, and I use it for most of my own work (both on Linux and a Mac). What was your problem with TestTone?

If you want to go another route, I'd recommend PlayRec, which has become relatively mature. It allows full-duplex sound in/out with Octave. If I would start over with MATAA today, I would use PlayRec instead of writing my own tool for sound in/out (TestTone), but PlayRec was not as mature back then. That said, PlayRec and TestTone both rely on PortAudio, so the the sound in/out engine is the same.

grützi, thx for jumping right in the discussion mbrennwa,

i think it had to do with the working directory of octave not finding Testone. i somehow remember that octave could start the scripts. which version of octave do you recommend? on the weekend i'll probably take some time and try it again. its been years since i looked at it.
for me the 16bit limit is not so bad at the moment, maybe in the future someone will start working on the 24bit feature.
also -if it works, TestTone might be good enough for me and there is no reason atm to change to PlayRec. first i want to get it up and running. anyway, octave is killer in functional range and it might take years to understand things there :)
 
Maybe they are dealing with the same license issues as Audacity that stop them from offering a binary with ASIO support.

PortAudio certainly does support >16 bit. Both PlayRec and MATAA/TestTone work with >16 bit.

To be clear I have not tried the Python version but digging deeper the Audacity developers have a comment that they do not want to support the odd byte unwrapping of packed 24 bit data, so it's possible it's their problem. They have stated in the past "who needs 24bits". My apologies, I just assumed MME support only would preclude >16 bits. I will look further.

If one does a search a LOT of people have these problems and to compound it there are often no warning messages. Sometimes you simply need to dump the raw audio samples and see that the 8 LSB's or MSB's (I forget which) are 0. Several times I've downloaded people's files which opened as 24/96 and demonstrated to them that they weren't sometimes to much surprise on their part (they sound great).

I only tried Octave's built-in audiorecorder and could not get real 24bit data from it. My apologies again I will try MATAA and see what I find.
 
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.