Playing/recording signals with PortAudio.jl

Hi again,

Found some information here :

Seems that synced play/record is not fully implemented in PortAudio.jl (as far as I can understand…).
Couldn’t get the PortAudio.jl solution working, but a PyCall workaround works like a charm !
If anyone is interested :

using PyCall

sampleRate = 44100 
signal     = sin.(2pi*440*(1:sampleRate*2)/sampleRate)

py"""
import sounddevice as sd
def record(testsignal, fs):
    sd.default.samplerate = fs
    sd.default.dtype      = 'float64'
    # Start the recording
    recorded = sd.playrec(testsignal, samplerate=fs, channels=1)
    sd.wait()

    return recorded
"""

recorded = py"record"(signal, 44100) ;

Cheers!

3 Likes