forked from grame-cncm/faust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportaudio.jl
89 lines (73 loc) · 3 KB
/
portaudio.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# ************************************************************************
# FAUST Architecture File
# Copyright (C) 2021 GRAME, Centre National de Creation Musicale
# ---------------------------------------------------------------------
# This is sample code. This file is provided as an example of minimal
# FAUST architecture file. Redistribution and use in source and binary
# forms, with or without modification, in part or in full are permitted.
# In particular you can create a derived work of this FAUST architecture
# and distribute that work under terms of your choice.
# This sample code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ************************************************************************
const FAUSTFLOAT = Float32
# Architecture
abstract type UI end
# One can override the behavior by defining another set of function that takes a different concrete UI type
# -- widget's layouts
function openTabBox(label::String)
end
function openHorizontalBox(label::String)
end
function openVerticalBox(label::String)
end
function closeBox()
end
# -- active widgets
function addButton(ui_interface::UI, label::String, param::Symbol)
end
function addCheckButton(ui_interface::UI, label::String, param::Symbol)
end
function addHorizontalSlider(ui_interface::UI, label::String, param::Symbol, init::FAUSTFLOAT, min::FAUSTFLOAT, max::FAUSTFLOAT, step::FAUSTFLOAT)
end
function addVerticalSlider(ui_interface::UI, label::String, param::Symbol, init::FAUSTFLOAT, min::FAUSTFLOAT, max::FAUSTFLOAT, step::FAUSTFLOAT)
end
function addNumEntry(ui_interface::UI, label::String, param::Symbol, init::FAUSTFLOAT, min::FAUSTFLOAT, max::FAUSTFLOAT, step::FAUSTFLOAT)
end
# -- passive widgets
function addHorizontalBargraph(ui_interface::UI, label::String, param::Symbol, min::FAUSTFLOAT, max::FAUSTFLOAT)
end
function addVerticalBargraph(ui_interface::UI, label::String, param::Symbol, min::FAUSTFLOAT, max::FAUSTFLOAT)
end
# -- soundfiles
function addSoundfile(ui_interface::UI, label::String, filename::String, soundfile::Symbol)
end
# -- metadata declarations
function declare(ui_interface::UI, key::String, val::String)
end
# Generated code
<<includeIntrinsic>>
<<includeclass>>
# Testing
samplerate = Int32(44100)
block_size = Int32(512)
# Using PortAudio
# import Pkg; Pkg.add("PortAudio")
using PortAudio
devices = PortAudio.devices()
#dev = filter(x -> x.maxinchans == 2 && x.maxoutchans == 2, devices)[1]
# Selecting a Duplex device here
dev = devices[10]
PortAudioStream(dev, dev) do stream
dsp = mydsp{Float32}()
println("getNumInputsmydsp ", getNumInputsmydsp(dsp))
println("getNumOutputsmydsp ", getNumOutputsmydsp(dsp))
initmydsp(dsp, samplerate)
outputs = zeros(Float32, block_size, getNumOutputsmydsp(dsp))
while true
inputs = convert(Matrix{Float32}, read(stream, block_size))
computemydsp(dsp, block_size, inputs, outputs)
write(stream, outputs)
end
end