## 4. Actively Augmenting Mobile Devices
### Active Augmentation Framework
Bidirectional blocks are connected to each other using the chain primitive which is part of physmodels.lib. For example, an open waveguide (no terminations) expressed as:

waveguide(nMax,n) = par(i,2,de.fdelay4(nMax,n)),_;

where nMax is the maximum length of the waveguide and n its current length, could be connected to our emptyBlock:

foo = chain(emptyBlock : waveguide(256,n) : emptyBlock) ;

Figure 13: Bidirectional construction in Faust using the tilde diagram composition operation. Note the use of fdelay4 in waveguide, which is a fourth order fractional delay line [60]. The Faust compiler is not able yet to generate the block diagram corresponding to the previous expression in an organized bidirectional way (see Section 5.3). However, a \"hand-made\" diagram can be seen in Figure 14.

The placement of elements in a chain matters and corresponds to their order in the physical world. For example, for a set of hypothetical functions implementing the different parts of a violin, we could write:

violin = chain(nuts : string : bridge : body);

The main limitation of this system is that it introduces a one sample delay in both directions for each block in the chain due to the internal use of \(\sim\)[49]. This has to be taken into account when implementing certain types of elements such as a string or a tube. Terminations can be added on both sides of a chain using lTermination(A,B) for a left-side termination and rTerminations(B,C) for a right-side termination where B can be any bidirectional block, including a chain, and A and C are functions that can be put between left and right-going signals (see Figure 15). A signal \(x\) can be fed anywhere in a chain by using the in(x) primitive. Similarly, left and right-going waves can be summed and extracted from a chain using the out primitive (see Code Listing 4). Finally, a chain of blocks A can be \"terminated\" using endChain(A) which essentially removes the three inputs and the first two outputs of A. Assembling a simple waveguide string model with \"ideal\" rigid terminations is simple using this framework:

string(length,pluckPosition,excitation) = endChain(wg) with{ maxStringLength = 3; // in meters lengthTuning = 0.08; // adjusted \"by hand\" tunedLength = length-lengthTuning; nUp = tunedLength*pluckPosition; // upper string segment length nDown = tunedLength*(1-pluckPosition); // lower string segment length lTerm = lTermination(*(-1),basicBlock); // phase inversion rTerm = rTermination(basicBlock,*(-1)); // phase inversion

Figure 14: Bidirectional construction in Faust using the chain primitive. Figure 15: lTermination(A,B) and rTermination(B,C) in the Faust Physical Modeling Library. stringSegment(maxLength,length) = waveguide(nMax,n) with{  nMax=maxLength:12s;//meterstosamples  n=length:12s/2;//meterstosamples  };  wg=chain(lTerm:stringSegment(maxStringLength,nUp):  in(excitation):out:stringSegment(maxStringLength,nDown):  rTerm);//waveguidechain }; ```
Listing 4: \"Ideal\" string model with rigid terminations. In this case, since in and out are placed next to each other in the chain, the position of excitation and the position of the pickup are the same as well. #### 5.2.2 Assembling High Level Parts: Violin Example

FPML contains a wide range of ready-to-use instrument parts and pre-assembled models. An overview of the content of the library is provided in the Faust libraries documentation [60]. Detailing the implementation of each function of the library would be interesting, however this section focuses on one of its models: violinModel (see Code Listing 5) which implements a simple bowed string connected to a body through a bridge. ``` violinModel(stringLength,bowPressure,bowVelocity,bowPosition)=endChain(modelChain)with{ stringTuning=0.08; stringL=stringLength-stringTuning; modelChain=chain( violinNuts: violinBowedString(stringL,bowPressure,bowVelocity,bowPosition): violinBridge:violinBody:out ); }; ```
Listing 5: violinModel: a simple violin physical model from the Faust Physical Modeling Library.