Signal Rate Inference for Dimensional Faust Multi-Dimensional - - PowerPoint PPT Presentation

signal rate inference for
SMART_READER_LITE
LIVE PREVIEW

Signal Rate Inference for Dimensional Faust Multi-Dimensional - - PowerPoint PPT Presentation

Signal Rate Inference for Multi- Signal Rate Inference for Dimensional Faust Multi-Dimensional Faust Y. Orlarey P. Jouvelot Signals Yann Orlarey 1 Pierre Jouvelot 2 Types/rates Inference 1 Grame, France Correctness Algorithm 2 MINES


slide-1
SLIDE 1

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Signal Rate Inference for Multi-Dimensional Faust

Yann Orlarey1 Pierre Jouvelot2

1Grame, France 2MINES ParisTech, PSL Research University, France

IFL’16 – Leuven, August, 31, 2016

1 / 15

slide-2
SLIDE 2

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Towards Multirate Faust

Faust (Functional Audio Stream) key features: Real-time (audio) signal processing DSL Two layers: lambda-calculus macros and signal processors High-level, functional paradigm for signals (timed samples) Efficient, multiplatform implementations ... but need for multiple rates: Control vs. audio rates Efficient spectral processing (FFT, wavelets,

  • versampling...)

Multi-dimensional data structures (arrays)

2 / 15

slide-3
SLIDE 3

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Core Faust

+ abs process

process = + : abs ;

+ process

process = + ~ _ ;

3 / 15

slide-4
SLIDE 4

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Example: Organ

1 // organ.dsp 2 // http :// faust.grame.fr 3 4 voice(gate , gain , freq) = envelop(gate , gain) * timbre(freq ); 5 6 // Envelop 7 envelop(gate , gain) = gate * gain : smooth (0.9995) 8 with { smooth(c) = * (1-c) : + ~ * (c); }; 9 10 // Timbre 11 phasor(f) = f/fconstant(int fSamplingFreq , <math.h>) : (+ ,1.0: fmod) ~ _; 12

  • sc(f)

= phasor(f) * 6.28318530718 : sin; 13 14 timbre(freq) = osc(freq) + 0.5* osc (2.0* freq) + 0.25* osc (3.0* freq ); 15 16 // Organ 17 process = voice(midigate , midigain , midifreq) * 18 hslider (" volume", 0, 0, 1, 0.01) 19 with { midigate = button (" gate "); 20 midifreq = hslider (" freq[unit:Hz]", 440, 20, 8000 , 1); 21 midigain = hslider (" gain", 0.5, 0, 10, 0.01); }; 4 / 15

slide-5
SLIDE 5

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Agenda

1

Signals

2

Types/rates

3

Inference

4

Correctness

5

Algorithm

6

Related Work

7

Conclusion

5 / 15

slide-6
SLIDE 6

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Signal Examples

+ abs process

abs(I0 + I1)

+ process

X0, with D(X) = ⟨X0@1 + I0⟩ X = ⟨X0⟩

6 / 15

slide-7
SLIDE 7

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Signal Definition

Step-wise approximation of continuous functions... ... from sampled times in Tr (r ∈ Q∗) to values in V ∪ {0V} Tr = 1

r Z = { i r | i ∈ Z}

Examples : T1 = {. . . , −2, −1, 0, 1, 2, . . . } ; T2 = {. . . , −1, −0.5, 0, 0.5, 1, . . . } ; T1/3 = {. . . , −6, −3, 0, 3, 6, . . . } . Negative times always yield 0V

7 / 15

slide-8
SLIDE 8

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Syntax and Dynamic Semantics

Signal expressions E ∈ S: E ::= k | f | In | Xi | E1 ⋆ E2 E ↑n | E ↓n | v(E, n) | s(E) | E1#E2 | E1[E2] ... and D(⟨X0, ..., Xn−1⟩) ∈ S∗ Denotational semantics: Sa(In)t = a(In)t , Sa(Xi, D)t = Sa(πi(D(X)))t . Multidimensional constructs (with si(t) = Sa(E (ri)

i

)t): Sa(v(E1, n))t = [s1(t − (n − 1)/r1), ..., s1(t − 1/r1), s1(t)] , Sa(s(E1))t = s1(⌊tr1⌋/r1)[mod(rt, n)], if |s1(t)| = n .

8 / 15

slide-9
SLIDE 9

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Static Semantics

Domain types as rates r in Q∗ Codomain types T ::= int[l, h] | float[l, h] | [n]T Signal types: Tr Typing rules, with Γ(In) = float[−∞, +∞]r:

Γ⊢In:Γ(In) Γ⊢(Ei,D):Γ(Xi) D(X)=⟨E0,E1...En−1⟩ Γ⊢(Xi,D):Γ(Xi) Γ⊢E:[n]Tr Γ⊢s(E):Tnr Γ⊢E:Tnr Γ⊢v(E,n):[n]Tr

Subject Reduction theorem

9 / 15

slide-10
SLIDE 10

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Rate Inference Algorithm

Predefined typing environment Ω Possibly-scalable (v ∈ {0, 1}) rate environments ∆v, with ∆v(In) = r (idem for Xi) Set of confluent rewrite rules (E, Ω) → (∆v, r):

k→(⊥0,1) Xi→(⊥[Xi→1]1,1) Ω⊢E:[n]T E→(∆v,r) s(E)→(∆v,nr) E→(∆1,r) m=lcm(n,r) v(E,n)→(( m

r ∆)1,m/n)

Composition ∆v1

1 + ∆v2 2 of rate environments for E1 ⋆ E2:

ri = ∆i(x) m = lcm(r1, r2) ( m

r1)v1∆1 ≃ ( m r2)v2∆2

∆v1

1 + ∆v2 2 → (( m r1)v1∆1 ∪ ( m r2)v2∆2)v1v2

10 / 15

slide-11
SLIDE 11

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Local Rate Inference Correctness

Theorem (Soundness (simplified)) For all integers p, if we have (E, Ω) → (∆v, r) and (Ω, pv∆) ⊏ Γ, then, Γ ⊢ (E, D) : Tpvr. Theorem (Integer Completeness (simplified)) If Γ ⊢N E : TR, then there exist ∆, v, r and k such that: (E, Ω(Γ)) → (∆v, r) and R = rkv.

11 / 15

slide-12
SLIDE 12

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Global Rate Inference Algorithm (1/2)

rates(L, D) : % Input: List L of n signal

  • utputs Ei

% Function D for recursive signal definitions % Output: Typing environment Γ (Γ(oi) = type/rate of Ei ) % Infer types and local rates for each Ei in L (Ωi, Ti) = sample_type ((Ei, D)); (∆vi

i , ri) = local_rate ((Ei, Ωi));

% Compute the global sample type environment Ω = ∪n−1

i=0 Ωi[oi → Ti]; 12 / 15

slide-13
SLIDE 13

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Global Rate Inference Algorithm (2/2)

% Compute the global rate environment Rs = ∪n−1

i=0 {∆i[oi → ri]vi };

while ∃ intersecting R1 and R2 in Rs Rs = Rs ∪ {R1 + R2} − {R1, R2}; ∆ = ∪

R∈Rs R;

% Build the global signal type environment Γ = []; for each x in Dom(∆) Γ = Γ[x → Ω(x)∆(x)]; % Check recursive signals for each X in Dom(D) for each i from 0 to length(D(X)) − 1 Ti ri = type/rate(Γ, (πi(D(X)), D)); check (Ti ri == Γ(πi(X))); return Γ; end

13 / 15

slide-14
SLIDE 14

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Related Work

Functional languages Music languages (Csound) Synchronous languages: Synchronous Dataflow Model, SDF (Lee and Messerschmitt, 87) Lustre (Caspi et al, 87), Signal (Benveniste et al, 91), Lucid synchrone (Caspi et al, 07) “Clocks as abstract types” (Colaço and Pouzet, 03) Clock inference (Talpin and Shulka, 05) Array primitives as clock mechanisms (Jouvelot and Orlarey, 11)

14 / 15

slide-15
SLIDE 15

Signal Rate Inference for Multi- Dimensional Faust

  • Y. Orlarey
  • P. Jouvelot

Signals Types/rates Inference Correctness Algorithm Related Work Conclusion

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Conclusion

Faust (signal) language extended with array and sampling primitives Multirate inference algorithm Correctness theorems and proofs (for a DSL) Existing prototype in C++ (Grame) Future work: relaxed type/rate constraints, explicit rates

  • rgan.dsp

15 / 15