Add audio signal output example (#94)

This commit is contained in:
Jeff Fessler 2022-02-13 22:19:12 -05:00 committed by GitHub
parent f6cd300ec8
commit 9c701415c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -100,3 +100,15 @@ julia> buf = read(stream, 10s)
julia> close(stream)
julia> save(joinpath(homedir(), "Desktop", "myvoice.ogg"), buf)
```
### Play an audio signal through the default sound output device
```julia
using PortAudio, SampledSignals
S = 8192 # sampling rate (samples / second)
x = cos.(2pi*(1:2S)*440/S) # A440 tone for 2 seconds
PortAudioStream(0, 2; samplerate=Float64(S)) do stream
write(stream, x)
end
```