Music 147 assignment for Tuesday June 10, 2014

“Final Exam”: Presentation of completed programs

The final meeting of this class will take place in the scheduled final exam time:
Tuesday June 10, 10:30-12:30 in CAC 3006
(N.B. Starting time is 10:30, not 11:00.]

1) Plan a 10-minute presentation of your program (one presentation per project). Think of it as a) a concise report on what your program is intended to do, b) a brief demonstration of its use, c) a mention of key features of interest and/or particular challenges for which you had to devise a solution. Because of the limited time of the entire session and the number of programs to be demonstrated, your presentation will have to be finely tuned to that amount of time. (Ten minutes is not much.) You should rehearse your presentation to check that it’s feasible within the allotted time. If it’s a group project, it might not be practical for all members of the group to speak in the presentation, but at least two members of the group should share the speaking duties.

2) Deposit your complete project in the EEE DropBox called “CompleteProject” by the end of the day, Tuesday June 10, 11:59pm. Your project should be accompanied by whatever documentation is necessary for every detail of your program to be understood. That might include a User’s Manual, a “Read Me” file, and/or a prose description (and/or flow chart) describing how the program works. It should certainly include extensive commenting of the code itself. Assume that the reader of your code needs to have just about everything explained or clarified in plain English. (You’ll be glad you did that when you look at your code six months later!)

Music 147 assignment for Thursday June 5, 2014

Solve the following problem in the form of a computer program in Max, Java or C.

Given a sensor input that goes linearly from 0.0 to 1.0, what is the expression that will convert that into a linear change from -100 dB to 0 dB (i.e. an exponential change from 0.00001 to 1.0)?

And three “extra credit questions”:

1) An exponential curve will only truly reach 0 when the dB reaches -infinity. What should we do about that?
2) Is -100 dB the best value to use as the minimum nonzero amplitude? Why or why not? If not, what might be better? Explain.
3) Ideally, we should interpolate to each new amplitude value to avoid clicks. How should that be implemented?

The patch provided here gives the pertinent formula, and creates a template for making and testing your solution in Max.

Deposit your solution in the EEE DropBox called, “DecibelControl”.


In class we will work together to solve any problems we’re encountering with our programming projects. Come to class ready to work on your own project—either by bringing your own computer or by bringing the files you need to work on your project on one of the lab computers—as well as to help others with their project. If you are struggling with any aspect of your program, be prepared to explain it succinctly to others so that they can suggest improvements. If you’re not struggling with any aspect of your program, that’s great, and you should therefore make yourself available to help others. (And if nobody needs help, then you’ll have plenty of time to continue working on your own project.)

Music 147 assignment for Tuesday June 3, 2014

The topic in class will be inter-application communication—be it within one computer, via network, or wirelessly. You should inform yourself about the principles involved and some of the methods that have been established for accomplishing such communication, and be prepare to explain and discuss those topics in class.

Learn about ReWire by reading its general description and some technical details.

Learn about Jack and the Jack API.

Learn about JackTrip, by reading about how it works and what the JackTrip library contains.

Learn about the Open Sound Control (OSC) protocol, and the TouchOSC application for wireless handheld devices.

 

Music 147 assignment for Thursday May 29, 2014

Read the first part of the chapter on “Filters” in Miller Puckette’s The Theory and Technique of Electronic Music, at least through the section called “Taxonomy of Filters”.

If you haven’t yet done so, study the MSP Tutorial chapters from the previous assignment:

MSP Tutorials 27-31.
27. Delay Lines
28. Delay Lines with Feedback
29. Flanging
30. Chorus
31. Comb Filter

 

Ocarina iPhone app article in CMJ

The Summer 2014 issue of the Computer Music Journal (which you can read for free by accessing it from the UCI LAN or via VPN tunnel to UCI) has several articles of relevance to this course, including “Ocarina: Designing the iPhone’s Magic Flute” written by Ge Wang, author of Ocarina, the most popular music app for iOS to date and one of the top 20 downloaded apps of all time.

Wang, Ge. “Ocarina: Designing the iPhone’s Magic Flute”. Computer Music Journal, Volume 38, Number 2, Summer 2014, pp. 8-21 (Article). Cambridge, MA: The MIT Press, 2014.

iOS Oscillator app

I have posted an Xcode project for a bare-bones iOS app called Oscillator. It plays a sine tone and allows the user to adjust the amplitude and the frequency (exponentially from -40 dB to 0 dB and from A-110 Hz to A-1760 Hz). It’s not very sophisticated conceptually, technically, or aesthetically, but it does demonstrate the basics of a) mapping user interface objects to methods, b) writing an audio callback function, and c) implementing wavetable synthesis. There’s a fair bit of commentary in the .h and .m files.

Music 147 assignment for Tuesday May 27, 2014

Come to class prepared to do a very brief demonstration of your programming project in progress. It should be a demonstration of what you’ve accomplished so far, the decisions you’ve made, the problems you’ve solved, and the problems that you have not yet solved (to solicit ideas from your classmates).


In preparation for the upcoming discussion of delay-based effects, read the Wikipedia article about the “Circular buffer“. Many interesting audio effects are achieved by combining a sound with a delayed (and possibly altered) version of itself. To delay a sound, one needs to store it for a certain amount of time till (a delayed copy of) it is needed. That storage has to be constantly ongoing when we’re dealing with realtime audio processing, yet we usually also want to dispose of the delayed audio data once it’s no longer needed. Realtime delay of audio is therefore most often achieved by storing the sound in what’s commonly called a ring buffer or a circular buffer.

Study MSP Tutorials 27-31.
27. Delay Lines
28. Delay Lines with Feedback
29. Flanging
30. Chorus
31. Comb Filter

 

Probability distribution vector

A computer can make a choice between different alternatives based on assigned statistical “likelihoods”—relative probabilities assigned to each possible alternative. This is accomplished most easily by storing all of the probabilities in a single vector (array), calculating the sum of all those probabilities, dividing the range (0 to the sum) into “quantiles” (subranges) proportional to the different probabilities, choosing a random number within that range, and determining which quantile the random number falls into.

The article “Probability distribution” describes this process and shows how to accomplish it, both conceptually (in a prose description that could be implemented as a program) and with an example written in Max using the table object. That article also discusses the implications and limitations of making decisions in this way.

What follows is an example of how to implement a probabilistic decision making program in JavaScript, and a simple Max patch for testing it. I chose to write the example in JavaScript for two reasons. One reason is that JavaScript is an easy-to-understand language, comprehensible to people who already know Java or C; the other reason is just to demonstrate how easy it is to write and use JavaScript code inside Max.

First, let’s recap the process we’ll follow, as stated in that article.
1. Construct a probability vector.
2. Calculate the sum of all probabilities.
3. Choose a random (nonnegative) number less than the sum.
4. Begin cumulatively adding individual probability values, checking after each addition to see if it has resulted in a value greater than the randomly chosen number.
5. When the randomly chosen value has been exceeded, choose the event that corresponds to the most recently added probability.

To see an implementation of this in JavaScript for use in the Max js object, download the file “probabilisticchoice.js” and save it with that name somewhere in the Max file search path. The comments in that file explain what’s being done. In this implementation, though, we use a reverse procedure from the one described in step 4 above. We start by subtracting the value of the last probability in the array from the total sum, and checking to see if that value is less than the random number we chose. If not, we proceed to the next-to-last probability, subtract that, and see if it’s less than the random number, and so on. The principle is the same, we’re just checking downward from the maximum rather than upward from the minimum.

You can try out the program using the example Max patch shown below.


probabilitiestester.maxpat

The JavaScript program accommodates the six input messages shown in the patch. To set the array of probabilities, one can use the setprobabilities message or simply a list. One can query the contents of the variables probabilities, choices, and sum variables, which are sent out the right outlet. The message bang makes a probabilistic choice based on the specified probabilities, and sends the choice (some number from 0 to choices-1) out the left outlet. Note that this is nearly identical to the probabilistic choice capabilities of the table object. It’s shown here as a JavaScript to demonstrate the calculation explicitly.