Ok cool people! I got the first prototype working:

# sinegen.jl

#=
  Just a simple generator of sine waves. It even records stuff!
=#

using WAV

# User defined stuff:

# Define Sample Frequency:
Fs = 96000# Hz
# Define Frequency of Wave:
f = 440 # Hz
# Define Duration:
T = 10 #s

# Define Audio File variables:
nbits = 32
# Format:
fformat = "wav"

# Define Audio Driver and AudioDevice for playback
adriver = "alsa"
adev = "hw:1"

# Execute:

# Time window:
t = (1/Fs) * collect(0:(T*Fs - 1)) #s
# Signal:
y = sin(2π*f*t)

# File Name:
fname = "Sine $f.$fformat"
# Save the sine wave:
wavwrite(y,Fs,nbits,fname)

# Set Driver and device for sox:
ENV["AUDIODRIVER"] = adriver
ENV["AUDIODEV"] = adev

# And now, play it with sox from command line.
# run(`play -b $nbits -r $Fs $fname`)

# To record for a lenght of time T:
# run(`rec -b $nbits -r $Fs Output.wav trim 0 $T `)

# To play and record simultaneously:
run(`play -b $nbits -r $Fs $fname` & `rec -b $nbits -r $Fs Output.wav trim 
0 $T `)

It is using sox as suggested above. Do you have any particular suggestion 
about calling these two commands simultaneously in the last line?


On Wednesday, 20 January 2016 00:15:45 UTC, CrocoDuck O'Ducks wrote:
>
> Wow! Sounds amazing! Can't wait for that!
>
> On Monday, 18 January 2016 23:42:30 UTC, Spencer Russell wrote:
>>
>> AudioIO is going to be going deprecated soon in favor of a family of 
>> packages that are each a bit more focused and simpler to interface with. 
>> They’re not quite release-ready but have been making a lot of progress 
>> lately, and I wanted folks to know what’s coming before you sink a bunch of 
>> time into working with the AudioIO implementation. Currently there’s a 
>> mostly working JACK library, and I’ll probably port over the PortAudio 
>> support from AudioIO after that.
>>
>> -s
>>
>> On Jan 17, 2016, at 1:30 PM, CrocoDuck O'Ducks <[email protected]> 
>> wrote:
>>
>> Hi there!
>>
>> I have a number MATLAB scripts that I use for electro-acoustic 
>> measurements (mainly impulse responses) and I would like to port them to 
>> JULIA. I also written the data acquisition in MATLAB. It works by streaming 
>> the test signal to the soundcard outputs while recording from the soundcard 
>> inputs. I would like to implement that as well. I was looking at AudioIO 
>> but there are few issues:
>>
>>
>>    - I cannot find documentation/examples on how to record from 
>>    soundcard input.
>>    - I cannot find documentation/examples on selecting the audio device 
>>    to use.
>>    - I cannot find documentation/examples on setting sampling variables 
>>    (it is in my best interest to use the highest sample rate available).
>>
>> Are these things possible with JULIA? I think I can use aplayer and 
>> arecord through JULIA (I am on Linux), but I was wishing to have all the 
>> code contained within JULIA.
>>
>> Many thanks, I hope you can point me in the right direction.
>>
>>
>>

Reply via email to