ChucK => A Concurrent, On-the-fly Audio Programming Language Ge Wang *Perry R. Cook Department of Computer Science (*Also Music) Princeton University ICMC.

Slides:



Advertisements
Similar presentations
A Dataflow Programming Language and Its Compiler for Streaming Systems
Advertisements

CS 5204 – Operating Systems 1 Scheduler Activations.
Chapter 13 Embedded Systems Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Programming Language Semantics Java Threads and Locks Informal Introduction The Java Specification Language Chapter 17.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
February 21, 2008 Center for Hybrid and Embedded Software Systems Mapping A Timed Functional Specification to a Precision.
1 Java Grande Introduction  Grande Application: a GA is any application, scientific or industrial, that requires a large number of computing resources(CPUs,
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
CS884 (Prasad)Java Goals1 “Perfect Quote” You know you've achieved perfection in design, Not when you have nothing more to add, But when you have nothing.
2  Problem Definition  Project Purpose – Building Obfuscator  Obfuscation Quality  Obfuscation Using Opaque Predicates  Future Planning.
Scheduling Parallel Task
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
What is Concurrent Programming? Maram Bani Younes.
SEC(R) 2008 Intel® Concurrent Collections for C++ - a model for parallel programming Nikolay Kurtov Software and Services.
CS 153 Design of Operating Systems Spring 2015
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Lecture 2 Foundations and Definitions Processes/Threads.
Invitation to Computer Science 5 th Edition Chapter 6 An Introduction to System Software and Virtual Machine s.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
GPU Architecture and Programming
PRET-OS for Biomedical Devices A Part IV Project.
Design Issues. How to parallelize  Task decomposition  Data decomposition  Dataflow decomposition Jaruloj Chongstitvatana 2 Parallel Programming: Parallelization.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Getting started with Programming using IDE. JAVA JAVA IS A PROGRAMMING LANGUAGE AND A PLATFORM. IT CAN BE USED TO DELIVER AND RUN HIGHLY INTERACTIVE DYNAMIC.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
ECE291 Computer Engineering II Lecture 15 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
ISE-575 Presentation 1 Designing Smule’s iPhone Ocarina By Ge Wang Huihui Cheng 3/20/2011.
0 The old computing is about what computers can do… the new computing is about what people can do. - Ben Shneiderman.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
Software Development Introduction
Published in ACM SIGPLAN, 2010 Heidi Pan MassachusettsInstitute of Technology Benjamin Hindman UC Berkeley Krste Asanovi´c UC Berkeley 1.
Martin Kruliš by Martin Kruliš (v1.0)1.
Harvestworks Part 1: ChucK basics Rebecca Fiebrink Princeton University 1.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
CompSci 143A1 1. Introduction 1.1 The Role of Operating Systems - Bridge the “Semantic Gap” between Hardware and Application - Three Views of Operating.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
Chapter 4 – Thread Concepts
Applications Active Web Documents Active Web Documents.
Information Science and Engineering
SOFTWARE DESIGN AND ARCHITECTURE
Simple Concurrent Object-Oriented Programming
Chapter 4 – Thread Concepts
Representation, Syntax, Paradigms, Types
Chapter 26 Concurrency and Thread
CSCI1600: Embedded and Real Time Software
Representation, Syntax, Paradigms, Types
Threads Chapter 4.
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
Java History, Editions, Version Features
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 19
Foundations and Definitions
Presentation transcript:

ChucK => A Concurrent, On-the-fly Audio Programming Language Ge Wang *Perry R. Cook Department of Computer Science (*Also Music) Princeton University ICMC 2003

What is ChucK? General-purpose Audio Programming Language –Strongly typed and strongly timed –Object oriented –Platform independent –Designed from the ground up Not based on a single existing language A new programming model Solves a number of problems

Audio Programming Considerations –Development Flexibility & Programmability Elegant mapping of audio concepts to language Levels of abstraction Timing (and Concurrency?)

Audio Programming Considerations –Development Flexibility & Programmability Elegant mapping of audio concepts to language Levels of abstraction Timing (and Concurrency?) –Run-time Real-time Usability / Control Performance

Audio Programming Considerations –Development Flexibility & Programmability Elegant mapping of audio concepts to language Levels of abstraction Timing (and Concurrency?) –Run-time Real-time Usability / Control Performance Problem: Difficult to incorporate into a single language

Question: Can we design one language that supports: Representation of audio concepts –Reason about flow from code Both high and low levels of abstraction –Data and time –Reason about time directly from code Concurrency –Can be useful (but hard!) Timing Synchronization Performance

Problem 1: Representation White Noise A D S R BiQuad Filter DAC MIDI Input center freq note on dacOut.tick(biQuad.tick(adsr.tick() * noise.tick())); if( timeCount % 44 == 0 ) { if( midi.nextMessage() == __SK_NoteOn_ ) { (midi.getByteThree() ? adsr.noteOn() : adsr.noteOff()); biQuad.setFreq( MD2Freq(midi.getByteTwo()) ); }

Solution 1: Representation White Noise A D S R BiQuad Filter DAC MIDI Input center freq note on noise3 => ADSR=> biquad1 => dac; midi => ( ADSR, biquad1 );

Solution 1: Representation =>

=> Syntax Simple chuck: x => y; Chain chuck: w => x => y => z; Nested chuck: w => ( x => y ) => z; Cross chuck: w => (x, y); (w, v) => (x, y, z); Un-chuck: x =< y =< z; Re-chuck: x =<> y;

=> Semantics Action-oriented Overloaded on types –Defined for primitives –Unit generators –System mechanisms Chuck operator helps represent flow

Problem 2: Level of Control What is the appropriate level of control for… –Data? (bits, bytes, objects, …) –Time & control rate? (sample, ms, …) Solution: provide many levels of control! –Work at multiple levels of abstraction for both data and time

Problem 2: Level of Control while( true ) { (300 * sin(now*FC)) => biQuad.freq; 100:ms => now; } noise => env => biQuad => dac; Demo 1

ChucK Timing Constructs dur is a native type –Units: samp, ms, second, minute, hour, day, week –Arithmetic: 3:second + 100:ms => dur quarter; time is a native type –now keyword holds current chuck time –Arithmetic: 5:second + now => time later;

Time Example 4:second + now => time later; while( now < later ) { now => stdout; 1:second => now; } > chuck foo.ck

Advancing Time Time stands still until you “advance” it Two semantics for advancing time –Chuck to now 1:second => now; –Wait on event midi_event => midi_handler; You are responsible for keeping up with time Timing embedded in program flow

How It Works Audio Engine Scheduler Execution Unit future DAC now Process (waiting) Process (running)

How It Works Audio Engine Scheduler Execution Unit future now Process (running) DAC

Dynamic Control Rate "snare" => sndbuf sbuf => dac; 50 => int r; 0 => float a; while( true ) { 0 => sbuf; 70 + (30 * sin(a)) => r;.1 +=> a; r::ms => now; } Demo 2

Consequences of Timing Mechanism Consistent, deterministic notion of time Strong correspondence of program flow and timing Control rate –Arbitrary –Dynamic –Sample-Synchronous Timing model makes chuck more powerful by allowing deterministic concurrency…

0.0 => float v; while( true ) { sin(v*FC) => biQuad.freq; 1.0 +=> v; 100:ms => now; } while( true ) { if( midiin.noteOn() ) midiin.vel => env; 13:ms => now; } noise => env => biQuad => dac; Problem 3: Concurrent audio programming

Concurrency is hard! Synchronization and timing Overhead Programming model –expressing concurrency in code

Programming with Shreds Threads –Preemptive / non-deterministic –Use a fork() –No timing guarantees Shreds –Deterministic shred of computation –Use a spork() –Sample-synchronous precision

Properties of Shreds Resemble non-preemptive threads User-level constructs (no kernel interaction) –High-performance Context switch Synchronization / shreduling Automatically synchronized by time! Managed by the ChucK shreduler Deterministic execution

How it Works Audio Engine Shreduler DAC Execution Unit future now Shred (running) Shred (waiting) Shred (waiting) …

CONTROL RATES and SHREDS Determined by programmer per shred ChucK control rates are: –Arbitrary –Dynamic –Simultaneous 500::ms => now; "bass" => sndbuf sb => dac; while( 1 ) { 0 => sb; 500::ms => now; } 750::ms => now; "snare" => sndbuf sb => dac; while( 1 ) { 0 => sb; 500::ms => now; } 625::ms => now; "hatcl" => sndbuf sb => dac; while( 1 ) { 0 => sb; 250::ms => now; } 3-shred example: Demo 3

Consequences of Concurrency with timing Possible to write truly parallel, sample- synchronous audio code Can work at low and high level –Fine granularity == power and control –Arbitrary granularity == flexibility and efficiency Program on-the-fly…

On-the-fly Programming Goal: add/modify/remove parts of the program as it is running Experimentation & performance possibilities Use the shred mechanism –Add and remove shreds from the virtual machine –Use networking, GUI, or command line

ChucK Virtual Machine Code (“foo.ck”) On-the-fly compiler Process shred Shreduler Chuck Virtual Machine Audio Engine I/O Manager Execution Unit Code (“foo.ck”, “bar.ck”)

Acknowledgements Thanks => ( Andrew Appel, David August, Brian Kernighan, Kai Li, David Walker, Dan Trueman, Amal Ahmed, Lujo Bauer, Limin Jia, Jared Ligatti, Kedar Swadi, Spyros Triantafyllis, Ari Lazier ); ChucK is free from the authors:

Questions?