Square Wave: Np.Where(X/Np.Pi % 2 > 1,-1,1)

Square Wave: Np.Where(X/Np.Pi % 2 > 1,-1,1)

Python As in Monty Python What is Python? • Prototyping language • Structured as pseudocode • Easy to write • Garbage collection • Dynamic typing • Fast and flexible development time Why it's perfect for sound design Or, our Agenda for today • Less DAW overhead • Numpy, Scipy, Numba • More accessible math • Fast, iterative development • Jupyter • Live compiling • Machine learning, simulation, etc Details of Python • Interpreted Language • Dictionary / BST backend • Add / remove variables • Built-in data structures • Dynamically typed Numpy • Corollary to python • Math / Array handling library • Vectorized • C++ backend • Basis for machine learning Python Advantages • Development time • Access to Scientific Libraries • Overlap with Machine Learning and research fields • Magenta: Google's Sound Design Library Disadvantages • Slower runtime • No access to DAW • Will not port into VST format • No access to existing libraries like JUCE Flying Without the DAW • Longer computations • Iterative design process • Play it fast and loose Avoid Real-time • Envelopes based on length • Note lead time • Guitars, theremins Numpy Math Library Numpy • Python math library • Array manipulation • Vectorized - Array operations • C++ backend Numpy 10 Lines of C++ = 1 Line of Numpy C++ Numpy Some Oneliners in Numpy Sine Wave: np.sin(x) Saw Wave: -((x/np.pi) % 2) + 1 Square Wave: np.where(x/np.pi % 2 > 1,-1,1) Triangle Wave: np.abs((x/np.pi-.5)% 2 -1) *2 - 1 Compressor: np.where(sound > thresh, (sound - thresh) * ratio + thresh, np.where(sound < -thresh, (sound + thresh) * ratio - thresh, sound)) Distortion: np.arcsin(np.clip(sound, -1, 1)) Numpy Extensions SciPy • Filter design, analysis • Chebyshev, elliptical, butterworth • Filter response, poles & zeros analysis, processing • Convolutions for Reverb • Interpolation • Envelope creation • Pooling • Envelope Detection Numba • Just-in-time Compiling • Decorator • Speed up non-vectorized code Slow Python Code With Numba Numba • Repeated function calls • Any place with a for loop • Non-object oriented - move to static function • Not compatible with everything Jupyter Programming in Jupyter Long function Listen to output • Run cells individually • Variables are stored betweenTry lowpassing it runs • Iterate on code, iterate on Graph it process • Graphs, audio output, print statements What is Jupyter? • Interface to the Python terminal • HTML Frontend - Hosted in browser • Runs over localhost Using Jupyter for Sound Design • ipywebrtc AudioRecorder for input • IPython.display.Audio(audio, rate=sr) for output • autoplay=True • Store parameters in dictionary • Write utility file and include it in every notebook • Typesafe array functions • Envelopes & Oscillators • Midi lookup Math Frequency over Time Summation • Changing frequency • Array of frequencies • Cumulative sum • Exponential Decay Percussive Sounds • Function that loses percentage of its energy each step • Good for percussive envelopes Logistic Curve Transition • Carrying capacity • In sound, good for smooth transitions • Affects only critical section • Pitch bend, volume change, etc More math • sin(tan(x)) - Alien sfx • Random numbers - white noise • Saturation - stacking powers of waves • Intervals: f + 2f + 3f ... • Note intervals: 5th, 7th Bugs Bugs can be good • Bugs can be good in sound design • Interesting, unique • Work for one-off sounds • Moug's overdriven filter • (always test production!) • My reverb glitch Python Real-Time Applications Python Applications • Real-time guarantee • Block safety checks • Less multithreading because of garbage collection • Try block to catch exceptions Libraries for Python Applications • PyQT • PyAudio on PortAudio • RTMidi • Soundfile • Importlib for Live Compiling Live Compiling "Syntax Error on line 1" Live Compiling Demo Live Compiling • Write code - reload code • A/B Testing • Flow • Iterative process Live Compiling Basic Steps • Step 1: • Wrap instruments with decorator • Decorator - a function that accepts a class as an argument and returns another class • Step 2: • Reload function in decorator Live Compiling Things to Remember • Python uses a dictionary backend • Decorators are zealous • Python uses __getattr__ to handle variable access and function calls Decorator Code @decorator • instrument_decorator function • Create new object • Forward calls with getattr • Create metatype • Store classtype • Forward static calls Reload Step def reload: • Get module • Try/Catch compilation errors • Re-compile module • Get new class • Reinstantiate class with original arguments • Transfer object data • Replace stored object Usage instr.play_regular() • @instrument_decorator on every parent and child object • Dereference inheritance with .O • Use object normally • Reload as a function call • Isinstance no longer works • use type(i).__name__ Advanced Topics Future Development Rendering • More unisons, more intervals • More reverb • Advanced note controls • Finer control over song • Lead-time Simulation • Air fluid flow simulations • Instrument body simulations • Create realistic yet impossible instruments Machine Learning It's all if statements • Python is the ML standard • Frequency domain • Advanced forms Auto-Encoders Latent Space Compression • Compresses data along patterns • Results unpredictable while following standard patterns • Can be used to save disk space on massive multisamplers • Most likely to create something cool Style Transfer Layer mixing • Mixes and matches detail levels • Can be used on several levels, each from different inputs • Fuse sounds • Style transfer FX • Most likely to work GANs Generative Adversarial Networks • Imposter / Art Critic Paradigm • Best for machine creativity • Most likely to create realistic sounds That's it! Algorithmic Design AlgorithmicSounds.com IsaacRoberts.tech Thank you for coming! I will now be taking questions!.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    53 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us