Graphical Design of Physical Models for Real-Time Sound Synthesis
Total Page:16
File Type:pdf, Size:1020Kb
peter vasil GRAPHICALDESIGNOFPHYSICALMODELSFOR REAL-TIMESOUNDSYNTHESIS Masterarbeit Audiokommunikation und -technologie GRAPHICALDESIGNOFPHYSICALMODELS FORREAL-TIMESOUNDSYNTHESIS Implementation of a Graphical User Interface for the Synth-A-Modeler compiler vorgelegt von peter vasil Matr.-Nr.: 328493 Technische Universität Berlin Fakultät 1: Fachgebiet Audiokommunikation Abgabe: 25. Juli 2013 Peter Vasil: Graphical Design of Physical Models for Real-Time Sound Synthesis, Implementation of a Graphical User Interface for the Synth- A-Modeler compiler, © July 2013 supervisors: Prof. Dr. Stefan Weinzierl Dr. Edgar Berdahl ABSTRACT The goal of this Master of Science thesis in Audio Communication and Technology at Technical University Berlin, is to develop a Graph- ical User Interface (GUI) for the Synth-A-Modeler compiler, a text-based tool for converting physical model specification files into DSP exter- nal modules. The GUI should enable composers, artists and students to use physical modeling intuitively, without having to employ com- plex mathematical equations normally necessary for physical model- ing. The GUI that will be developed in the course of this thesis allows the creation of physical models with graphical objects for physical masses, links, resonators, waveguides, terminations, and audioout objects. In addition, this tool will be used to create a model for an Arabic oud to demonstrate its functionality. ZUSAMMENFASSUNG Das Ziel dieser Master Arbeit am Fachgebiet Audiokommunikation der TU Berlin, ist die Entwicklung einer graphischen Umgebung für die textbasierte Software, Synth-A-Modeler compiler, welche es erlaubt, ein speziell dafür entwickeltes Datei Format für physikalische Mod- elle, in externe DSP Module umzuwandeln. Die Software macht es Komponisten, Künstlern und Studenten möglich, physikalische Modellierung intuitiv zu anzuwenden, ohne die komplexen mathe- matischen Formeln, welche normalerweise für physikalische Model- lierung nötig sind, anwenden zu müssen. Die graphische Umgebung, die im Zuge dieser Arbeit entwickelt wird, erlaubt es dem Benutzer physikalische Modelle mithilfe von graphischen Bausteinen, welche physikalische Elemente, wie z. B. Masse, Federn, Resonatoren oder Wellenleiter representieren, selbst zu erstellen. Im Rahmen der Ar- beit wird die graphische Umgebung ausserdem dazu verwendet, eine arabische Laute zu modellieren, um die Funktionalität der Software zu demonstrieren. iv ACKNOWLEDGMENTS I would like to thank my partner Kathleen Reinhardt and my parents Ilona and Stefan Vasil. I would also like to thank Tobias Preuss for his valuable input and discussions regarding the implementation of the application for this thesis. Last but not least I would like to thank my supervisors Stefan Weinzierl and especially Edgar Behrdahl, for his feedback and sup- port during my work on the thesis. v CONTENTS i introduction1 1 introduction2 1.1 Goals/Objectives . 2 1.2 Motivation . 3 1.3 Thesis outline . 3 ii fundamentals5 2 fundamentals6 2.1 Physical Modeling . 6 2.1.1 Digital Waveguide Synthesis . 6 2.1.2 Mass-Interaction Synthesis . 8 2.1.3 Modal Synthesis . 8 2.2 Prior work . 9 2.2.1 GENESIS . 9 2.2.2 Modalys . 10 3 synth-a-modeler compiler 12 3.1 Technical background . 12 3.1.1 Requirements . 12 3.1.2 Overview . 13 3.1.3 Faust . 13 3.1.4 Dataflow . 14 3.2 Modeling . 16 3.2.1 The model specification file . 16 3.2.2 Abstractions . 17 3.3 Compilation result . 19 3.4 Creating externals . 19 3.4.1 Pure Data . 19 3.4.2 SuperCollider . 21 3.4.3 Qt/GTK . 23 iii synth-a-modeler designer 24 4 design 25 4.1 Specification . 25 4.1.1 Visual specification . 25 4.1.2 Technical specification . 29 4.2 Software Architecture . 30 5 technology selected 32 5.1 JUCE C++ Library . 32 5.2 Regular Expressions . 35 5.3 Git................................. 36 5.4 Github . 37 6 implementation 38 vi contents vii 6.1 Application components . 39 6.1.1 Core components . 39 6.1.2 Internal MDL representation . 43 6.1.3 MDL parsing and writing . 46 6.1.4 Views.............................. 48 6.1.5 Controllers . 54 6.1.6 Executing external commands . 59 6.1.7 Command-line support . 61 6.1.8 Unit testing . 62 6.2 Automatic positioning of objects . 63 6.2.1 Force-directed algorithm . 64 6.2.2 Graph drawing components . 66 6.2.3 Graph drawing examples . 67 6.3 Extending Synth-A-Modeler Designer with a new object . 71 6.4 Problems and limitations . 81 7 modeling the oud 83 7.1 The Oud . 83 7.1.1 History . 83 7.1.2 Principle of operation . 84 7.2 Modeling the oud in Synth-A-Modeler . 85 7.2.1 The modeling . 85 7.2.2 Commuted Synthesis . 87 8 conclusions 89 8.1 Conclusion . 89 8.2 Future work . 90 iv appendix 91 a appendix 92 a.1 Example .mdl file . 92 a.2 Oud model . 93 a.3 Emacs support . 97 a.4 Vim support . 98 a.5 Building Synth-A-Modeler on a Beagle-Board ......... 100 a.6 Class hierarchy . 101 bibliography 103 LISTOFFIGURES Figure 1 Schematic relationship between physical mod- eling synthesis paradigms in Synth-A-Modeler . 6 Figure 2 Digital waveguide model of a simple string . 7 Figure 3 FAUST dataflow diagram . 14 Figure 4 Block diagram of a spring generated by FAUST 15 Figure 5 Synth-A-Modeler internal dataflow diagram . 15 Figure 6 Synth-A-Modeler dataflow diagram . 16 Figure 7 “touch a resonator” PureData patch . 21 Figure 8 Standalone applications . 23 Figure 9 Mockup of the main Synth-A-Modeler Designer interface . 26 Figure 10 Mockup of Synth-A-Modeler pull-down menus 27 Figure 11 Mass-like object icons . 28 Figure 12 Link-like object icons . 28 Figure 13 Waveguide and audioout object icons . 28 Figure 14 Comparison, unsegmented and segmented con- nections . 29 Figure 15 Collaboration of Model View Controller (MVC) components . 31 Figure 16 Synth-A-Modeler Designer user interface . 48 Figure 17 Object component inheritance . 50 Figure 18 Window for editing object parameters . 51 Figure 19 Setting font color of a CommentComponent ... 53 Figure 20 FAUST code input and edit window . 53 Figure 21 Misc tab in preferences window . 54 Figure 22 Exporter tab in preferences window . 55 Figure 23 Window for setting redraw options . 67 Figure 24 An unordered guiro model . 67 Figure 25 The guiro model after applying CircleFlowAlgorithm 68 Figure 26 The guiro model after applying ForceBasedAlgorithm 68 Figure 27 Cube model layout comparison . 69 Figure 28 Big cube model layout comparison . 69 Figure 29 Percussion model layout comparison . 69 Figure 30 Random mass interaction model layout com- parison . 70 Figure 31 Another random mass interaction model lay- out comparison . 70 Figure 32 Random model layout comparison . 70 Figure 33 Icon of the pulsetouch object . 71 Figure 34 Oud front and rear view . 84 Figure 35 Simple schematic of a guitar . 85 viii Figure 36 A string in Synth-A-Modeler ........... 86 Figure 37 The oud model in Synth-A-Modeler ....... 86 Figure 38 Class hierarchy diagram . 102 LISTOFTABLES Table 1 MDL object types and their parameters . 18 LISTINGS Listing 1 A simple spring represented in FAUST ..... 14 Listing 2 A simple model specification . 16 Listing 3 ”touch a resonator” FAUST file . 19 Listing 4 “touch a resonator” SuperCollider class . 22 Listing 5 Example CommandIDs ............... 41 Listing 6 Example usage of CommandIDs .......... 41 Listing 7 Synth-A-Modeler Designer user settings file . 42 Listing 8 Pseudo code for an UndoableAction to add an object . 43 Listing 9 Internal representation of an MDL file . 44 Listing 10 Example assembling an MDL file structure . 45 Listing 11 Class for parsing an MDL file . 47 Listing 12 Class for writing an MDL file to disk . 47 Listing 13 Function for fixing parameter value if not for- matted properly . 51 Listing 14 Function for adding a new object . 56 Listing 15 Representation of a mass object when copied to the clipboard . 58 Listing 16 SAMCmd class . 59 Listing 17 Default exporter commands . 61 Listing 18 Help text of the Synth-A-Modeler Designer command- line interface . 62 Listing 19 Pseudo code of the force-based graph drawing algorithm . 65 Listing 20 New code in ObjectFactory.cpp ........ 71 Listing 21 New code in ObjectsHolder.cpp ........ 73 Listing 22 New code in LinkComponent.cpp ........ 74 Listing 23 New code in ResourceLoader.cpp ....... 75 Listing 24 New code in Application.cpp ......... 76 ix Listing 25 New code in CommandIDs.cpp .......... 76 Listing 26 New code in ContentComponent.cpp ...... 76 Listing 27 New code in ObjectPropertiesPanel.cpp ... 77 Listing 28 New code in ObjectComponent.cpp ....... 79 Listing 29 New code in MDLParser.cpp ........... 79 Listing 30 New code in SAMRegex.cpp ........... 80 Listing 31 New code in MiscUtilities.cpp ........ 80 Listing 32 New default values . 80 Listing 33 New values in SAMLookAndFeel.cpp ...... 81 Listing 34 A complete mdl file . 92 Listing 35 The model of an oud . 93 Listing 36 Source of sam-mode for Emacs . 97 Listing 37 Vim support source . 98 ACRONYMS API Application Programming Interface DSP Digital Signal Processing GUI Graphical User Interface RE Regular Expression SCM source code management MVC Model View Controller x Part I INTRODUCTION INTRODUCTION 1 Physical modeling is a well-known and extensively developed tech- nique to virtually create instruments as well as sounds. It is using mathematical models consisting of a set of equations and algorithms to simulate a physical source of sound. The parameters can be con- stants, which describe physical material and dimension of a real in- strument, as well as time-dependent parameters, which describe the interaction of a player with the instrument. It has been an established research topic for decades, and many scientific texts have been pub- lished on the topic. However, creating physical models of instruments is a difficult process involving the creation of highly complex equa- tions.