By Van Bucsko May 7, 2008. Intro – What is SAOL? SAOL is a standard programming language that specifies sound as a computer program that generates audio.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Simulation executable (simv)
Intermediate Code Generation
Unit Generators and V.I.s Patches are configurations of V.I.s Both Patches & Virtual Instruments can be broken down into separate components called Unit.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Compiler Construction
True or false A variable of type char can hold the value 301. ( F )
Spring 2002EECS150 - Lec13-proj Page 1 EECS150 - Digital Design Lecture 13 - Final Project Description March 7, 2002 John Wawrzynek.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Customizable Audio Kaleidoscope Agustya Mehta, Dennis Ramdass, Tony Hwang Final Project Spring 2007.
Music Processing Roger B. Dannenberg. Overview  Music Representation  MIDI and Synthesizers  Synthesis Techniques  Music Understanding.
JavaScript, Third Edition
Introduction to C Programming
Games and Simulations O-O Programming in Java The Walker School
Synthesis Basics (1) Analog Synthesis Intro to Digital Oscillators.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
1 Week 12 Arrays, vectors, matrices and cubes. Introduction to Scientific & Engineering Computing 2 Array subscript expressions n Each subscript in an.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Chapter 3: Data Types and Operators JavaScript - Introductory.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT3: Conditional Statements CS2311 Computer Programming.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
Compiler Chapter# 5 Intermediate code generation.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
CARDIAC ELECTROPHYSIOLOGY WEB LAB Developing your own protocol descriptions.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Execution of an instruction
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Types of C Variables:  The following are some types of C variables on the basis of constants values it has. For example: ○ An integer variable can hold.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Digital Oscillators. Everything is a Table A table is an indexed list of elements (or values) A digital oscillator or soundfile is no different.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1 CS 177 Week 7 Recitation Slides Modifying Sounds using Loops + Discussion of some Exam Questions.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 5: Control Structures II (Repetition)
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Variables, Operators, and Expressions
ARITHMETIC IN C Operators.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
MATLAB: Structures and File I/O
Chapter 2 - Introduction to C Programming
CSCE Fall 2013 Prof. Jennifer L. Welch.
Chapter 2 - Introduction to C Programming
Introduction to Csound 5.
Chapter 6 Control Statements: Part 2
Chapter 2 - Introduction to C Programming
CSCE Fall 2012 Prof. Jennifer L. Welch.
Chapter 2 - Introduction to C Programming
Matlab Basics.
Chap 7. Advanced Control Statements in Java
Introduction to C Programming
Presentation transcript:

By Van Bucsko May 7, 2008

Intro – What is SAOL? SAOL is a standard programming language that specifies sound as a computer program that generates audio when it is executed, as opposed to just audio data. It is pretty similar to C++ as far as logic, expressions, and math go, but there are several differences in variables, the kinds of files each can play and so on.

Numbers and Names Numbers Names- reserved words Declarations Instr Parameters & Variables Scalars Arrays Global variables – must be imported or exported global blocks Standard Names Global Parameters: 5 kinds difference between global and instr

Expressions and Statements Arithmetic Expressions Unary (-) takes precedence over both the binary classes (+, - and *, /) All binary and unary operations in SAOL follow a rate rule – the rate of an expression is the rate of its fastest subexpression. i-rate is the slowest, k-rate is faster and a-rate is the fastest rate Arrays and Other Expressions declared exactly like in C++; use the same syntax and numbering indexed arrays in SAOL are scalars – the array takes on the fastest rate possible Ex. ivar i[2]; ksig k; asig a[3]; SAOL basically uses the same operators for less than, greater than, less than/equal to, greater than/equal to, and not equal exceptions – if both operands are scalar width (1), with &&, the right subexpression is only evaluated if the left one is true - opposite for || - right subexpression is evaluated only if the left one is false Switch – switch operator takes the logical value of the first non-zero operand (there are 3 operands with switch) if at least one subexpression has width greater than 1, all three subexpressions are evaluated

More Statements and a Loop Assigment Statements the syntax for these statements is lval (a instr parameter or signal variable that receives the new value) = expr (an expression evaluated to generate the value to assign). these statements also have rules about width because an lval can be a scalar or array variable – both the lval and expression have to be scalar width If & If – Else these statements work basically the same as in C+ + if (note > 5) // expr i-rate { decay = 0.8; // k-rate } else { decay = 0.9; // k-rate } While Statement only loop used in SAOL; executed basically exactly like in C++ statement in parentheses must be scalar width, and (along with all the statements in the set), must run at the same rate

Core opcodes What are they? Core Opcodes basically serve the same function as library functions do in C++. Opcode calls basically act like parameters or variables in expressions. Transcendentals : Trigonometric Opcodes - forward trig opcodes take angle parameters in units of radians, and inverse trig opcodes return angle values in radians The trig opcodes are asin, acos and atan. there are no tan or hyperbolic functions in the opcode library, so there are replacements in the Slib library. There are also log, log10 and sqrt opcodes.

Loudness, Tempo and Pitch opcodes Loudness -Waveform amplitude is often converted to the decibel (dB) scale to express loudness. Ex. opcode dbamp(xsig x) computes log10(x) for x > 0 SAOL has two rate-polymorphic core opcodes that handle conversion between amplitude and dB units: the dbamp and ampdb. Pitch – a set of 12 rate-polymorphic core opcodes handles conversions between three note name encodings and cycles per second. the opcodes are named by the abbreviations for the four kinds of pitches, cps, midi, pch and oct. the oct and pch types are octave-fraction and pitch class notation respectively, which use float numbers; the integer part of the number for both types is the octave number from a full keyboard. Also oct opcodes may return values between the 12 note steps. The pch opcodes give values rounded to the nearest semitone (in.01 increments). Tempo – the global tempo can be changed in SAOL from the default 60 beats per minute through the k-rate core opcode settempo. Ex. kopcode settempo(ksig x) opcode gettempo([xsig dummy])

SAOL Wavetables Declarations: First you have to declare a table (and follow the naming rules). To import tables, an instr parameter accesses a global wavetable by declaring an instr wavetable with the same name as the global wavetable. SAOL has a special data type called the tablemap which is an array of wavetables to support some wavetable applications that create a set of sample buffers.

More Wavetables Periodic Waveforms – 3 wavetable generators produce a single cycle of a periodic waveform harm, the simplest generator, specifies a waveform as a harmonic series of N zero-phase sine waves; can be used to generate a pure tone harm_phase generator specifies an amplitude parameter and a phase parameter to each sinusoid (or curve of the sine function), and the periodic generator also adds a frequency parameter buzz generator specifies an algorithm for generating a family of pulse- like waveforms using only a few parameters. Envelope Waveforms – 5 generators (step, lineseg, expseg, spline, cubicseg) produce wavetables useful for signal envelopes For each one, the envelope is specified as a piece-wise waveform, and the generators interpolate between the break points to create a waveform the cubic equations should not be too complex, they are way too complex to calculate manually, so it’s best to use a computer program

Sound Files 2 nd parameter of generator sample specifies the name of the audio file to be read into the table. 1 st parameter specifies the size of the wavetable. Only certain types of AIFF (the kind of music file on a CD) or WAV files are supported by sfront, a translator that converts MP4-SA files into efficient C programs. The opcode speedt shrinks the size of the wavetable without changing the pitch in the sample.

Table Playback 4 core opcodes play back wavetables. Each core opcode has an internal pointer to the wavetable that always starts at the first sample. 2 of them, koscil and doscil are specialized for creating signals by repeating a cycle of a waveform stored in a table.

Table Playback (cont’d.) The doscil opcode plays back the wavetable t once and then returns 0. It also considers the the wavetable to be a recording of a pitched sound. The loscil opcode enhances doscil by playing back the wavetable at a set pitch. Ex. aopcode oscil(table t, asig freq [,ivar loops]) kopcode koscil(table t, ksig freq [,ivar loops])

Low-Level Opcodes 9 opcodes produce settings for the wavetable t: fsetsr and fsetbase set the sampling rate and base frequency, respectively. ftsetloop and ftsetend change the loop start and ending points respectively. ftlen, ftsr, ftbasecps, ftloop and ftloopend return the values of the length, sampling rate, base frequency, and loop start and end points. Tableread and tablewrite read and write values into the wavetables.

Low-level Generators empty fills a wavetable with zero values. data fills a wavetable with parameter values. polynomial fills a wavetable with nth order polynomial values. concat takes a list of wavetables as parameters, joins them together and then initializes its own wavetabl Random fills a wavetable with pseudorandom values, and a distribution number of 1-5 tells the distribution type. Window produces a wavetable to one of a set of windowing functions.

Output Statement SAOL instruments have one audio output port each, and each one holds the instrument’s audio output. Every SAOL program includes an output_bus, the width of which is set by the global parameter outchannels. After all instances of execute, the output_bus is summed onto the system’s final audio output, which usually falls into the range of -1 and 1, and is sent to a file to be stored or to a converter, so one can listen to it.

Effects Instruments An instrument that processes audio output is called an effects instrument. An effects instrument usually processes the value held by the standard input name, and writes a modified version to the audio output port. i = 0; while (i < inchan) { w[i] = sfactor; i = i + 1; }

Send Statements Create instances of effects instruments; these statements can only appear in global blocks. Have three sections: 1 st specifies the name of instrument to be created. 2 nd is an expression list, whose values initialize the instrument parameters of the instance. 3 rd specifies the audio input port for the instrument as a list of at least one bus.

Route Statements By default, an instrument sends its audio input port to output_bus, but route statements can change it to go to a user-defined bus. A statement consists of a bus name and a list of instruments. Several route statements can target the same bus.

Signal Flow Graphs A set of send and route statements act together to form a diagram. Send statements create the boxes in the diagram, connected by lines to and from the boxes that represent the route statements.

Determining Execution Order of Instruments 1 st rule – instruments that produce a signal should run before instruments that use the signal. 2 nd rule – if loops are created by the send and route statements, the order of the send statements creates the order of the instances. By default, the instruments run in any order. Any of the above rules can be overriden by the sequence statement, which has a list of instruments as parameters and these instruments are executed in the order listed.

System buses The input_bus – a system bus that lets SAOl programs process external audio streams, like WAV files or live mikes. The output_bus – holds the final output of the SAOL decoder. Ex. send(rvb; inchan + outchan; input_bus); // output_bus in a send statement send(scale; 0.5 ; output_bus);

SASL Scores SASL score – a list of commands that trigger actions relative to the clock time the SAOL programs run by. SASL commands are one line long and are a list of elements.

Instr command Starts with an optional label 1 st required element is the trigger time, which is a float value in units of beats that says when to create the instance. 2 nd – the name of the SAOL instrument to be instantiated. Then a float duration value that says how long it should execute.

Control command Changes the value of a SAOL variable. Begins with the trigger time, which tells when to change the value. Then an optional label element is next, and then the keyword control is the name of the variable you want to change.

Tempo and End commands When the tempo command executes, it changes the global tempo value. Ex tempo tempo 4 When end executes, the simulation ends, and no more audio is produced. Ex end

Table command The table command creates wavetables in a SAOL program. Keyword table follows the table you want to create. globals { table orig(data, 3, 1,2,3); }

Streaming and SASL The MP4 binary file format has provisions for certain SASL commands. If these commands have timestamps, they follow the trigger semantics; if not, they are executed at the next possible opportunity. A “*” can be added to each command to indicate that it’s higher priority.

MIDI Basics What exactly is MIDI in reference to computers and music? MIDI commands for start and end notes use integers for the notes on the keyboard (0-127, with 60 as Middle C). These commands specify a key number, the note value that was pressed or released, and a channel number (between 0-15). Many electronic keyboards have a pitch wheel on the side of the keyboard to bend a note. MIDI Files can include tempo commands, which change the value of the global SAOL tempo value.

More MIDI NoteOn command creates an instance of the instrument that has the same number as the command channel. An instance created on a specific channel executes until a NoteOff executes with that instance. However, the instance can be delayed with either a Sustain Pedal on the keyboard, or through the SAOL extend statement to delay the end of the instance.

Standard Names in MIDI There are five accepted names that contain info about MIDI: channel, preset, MIDIbend, MIDItouch, and MIDIctrl. Channel holds the extended channel number of the command that created the instance, and preset holds the value of the preset extended channel value. MIDIbend, MIDItouch, and MIDIctrl all have to do with the extended channels associated with the instance, along with certain commands they are also associated with.

SAOL Dynamic Instruments The SAOL instr statement performs dynamic instrument instantiation, so that a child instrument can be copied several times from its parent. 5 SAOL standard names (time, itime, released, dur and cpuload) let an instance monitor its execution status. An instance can delay its termination time with the extend statement, which works the same as in MIDI. Turnoff statement can force a program to terminate.

Execution of a SAOL program 1 st – all the instruments and wavetables are initialized, and the instances are also produced with the send statements. 2 nd – all SASL or dynamically generated instruments are initialized, all SASL table, tempo and control and MIDI events and tempo commands that are ready to execute are run, and instruments that are supposed to be terminated end. 3 rd – like the first step, except all imports variables and table wavetables are set to an initial value. 4 th – all local variables are set to the values of their corresponding global variables, and all imports exports wavetables are linked to their associated global wavetables.

Questions? Comments?

Bibliography Lazzaro, John and Wawrznek, John. The MP4 – Structured Audio Book. CS Division, UC Berkeley: 1999.

The End. Yay!