{"id":118,"date":"2021-02-09T11:02:00","date_gmt":"2021-02-09T16:02:00","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/?p=118"},"modified":"2021-04-06T10:52:50","modified_gmt":"2021-04-06T14:52:50","slug":"project-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/project-2\/","title":{"rendered":"Project 2"},"content":{"rendered":"<p><strong>Deadlines:<br \/>\nDue 11:59 pm Eastern on February 22 2021.<br \/>\nPeer grading due 11:59 pm Eastern on March 1, 2021.<\/strong><\/p>\n<h1>Download<\/h1>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-content\/uploads\/2017\/09\/P2.zip\"><code>P2.zip<\/code><\/a><\/p>\n<h1>Envelopes<\/h1>\n<p>Envelopes are very important in sound synthesis. Envelopes are the primary way to &#8220;shape&#8221; sounds from various sound sources so that the sounds do not suddenly pop on and off or blast at a constant level.<\/p>\n<p>You should have learned to use both &#8220;pwl&#8221; and &#8220;env&#8221; for envelopes in the on-line lessons. Hint: Look up &#8220;pwl&#8221; and &#8220;env&#8221; in the Nyquist Reference Manual and pay attention to their behaviors under different stretch environments.<\/p>\n<h1>Composition Programming<\/h1>\n<p>The following code creates a short score and plays it when you click the &#8220;F2&#8221; button in the Nyquist IDE (maybe your keyboard F2 key will work too):<\/p>\n<pre>variable *ascore* =\n      {{0 1 {note pitch: c2 vel: 50}}\n       {1 0.3 {note pitch: d2 vel: 70}}\n       {1.2 0.3 {note pitch: f2 vel: 90}}\n       {1.4 0.3 {note pitch: g2 vel: 110}}\n       {1.6 0.3 {note pitch: a2 vel: 127}}\n       {1.8 2 {note pitch: g2 vel: 100}}\n       {3.5 2 {note pitch: d2 vel: 30}}\n       {3.7 2 {note pitch: d4 vel: 70}}\n       {3.9 2 {note pitch: d5 vel: 70}}\n       {4.1 2 {note pitch: d6 vel: 50}}\n       {4.9 0.5 {note pitch: g4 vel: 40}}\n       {5.2 2.5 {note pitch: a4 vel: 30}}}\n    \nfunction f2() play timed-seq(*ascore*)\n\nvariable *bscore* ; to be initialized from *ascore*\n\nfunction f3() play timed-seq(*bscore*)\n<\/pre>\n<p>Create a file named <code>instr.sal<\/code>, paste this code in, and try it.<\/p>\n<h2>Define an Instrument<\/h2>\n<p>Your first task is to define a new instrument, also in the file <code>instr.sal<\/code>, that multiplies the output of a table-lookup oscillator by an envelope. The instrument should consist of<\/p>\n<ol>\n<li>a table created as shown in the lectures using the <code>build-harmonic<\/code> function and containing at least 8 harmonics,<\/li>\n<li>an oscillator (use <code>osc<\/code>), and<\/li>\n<li>an envelope.<\/li>\n<\/ol>\n<p>The instrument should be encapsulated in a function named <b><code>simple-note<\/code><\/b> that at least has the two keyword parameters seen in <code>*ascore*<\/code> (<code>pitch:<\/code> and <code>vel:<\/code>). The <code>vel:<\/code> parameter represents velocity, a loudness control based on MIDI key velocity which ranges from 1 to 127. Convert MIDI key velocity to amplitude using the <code>vel-to-linear<\/code> function (see the Nyquist Reference Manual). Your <code>simple-note<\/code> instrument function should satisfy these requirements:<\/p>\n<ul>\n<li>starting time is of course the default start time from the environment,<\/li>\n<li>duration is determined by the stretch factor in the environment, e.g. <code>simple-note(pitch: c2, vel: 100) ~ 2.6<\/code> should have a duration of 2.6s,<\/li>\n<li>maximum amplitude is proportional to <code>vel-to-linear(vel)<\/code>, where <code>vel<\/code> is the value of the <code>vel<\/code> keyword parameter,<\/li>\n<li>pitch is controlled by the <code>pitch<\/code> keyword parameter, which gives pitch in &#8220;steps&#8221;, e.g. C4 produces middle-C.<\/li>\n<li>Any &#8220;instrument&#8221; function should return a sound (and not play the sound).<\/li>\n<\/ul>\n<h2>Play <code>*ascore*<\/code> with your instrument<\/h2>\n<p>To show off your instrument, transform <code>*ascore*<\/code> using one of the <code>score-*<\/code> functions to use your instrument rather than note. (It is your task to become familiar with the <code>score-*<\/code> functions and find the one that replaces function names.) Assign the transformed score to <code>*bscore*<\/code> at the top level of <code>instr.sal<\/code>; for example, you might have something like the following in your code:<\/p>\n<pre>set *bscore* = function-to-transform-a-score(*ascore*, perhaps-other-parameters)<\/pre>\n<p>You may add one or more additional functions to <code>instr.sal<\/code> as needed.<\/p>\n<p>Now, F3 (as defined above) should play the altered score, and it should use your <code>simple-note<\/code> instead of the built-in piano note function <code>note<\/code>. The resulting sound should demonstrate your instrument playing different pitches, durations, and velocities.<\/p>\n<h2>Record Tapping<\/h2>\n<p>Record a short period of rhythmic tapping sound (&lt;10 sec) and save as <code>tapping.wav<\/code>. This can be your own tapping or some other source.<\/p>\n<h2>Tap Detection<\/h2>\n<p>Download the <a href=\"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-content\/uploads\/2017\/09\/P2.zip\"><code>P2.zip<\/code><\/a> file, which contains code, a test sound, and some documentation.<\/p>\n<p>You will now create a <b>new file<\/b> named <code>tapcomp.sal<\/code>, which will use the <code>tapping.wav<\/code> data to create a composition. In <code>tapcomp.sal<\/code>, load the given code <code>tap-detect.sal<\/code> to detect a list of tap times and tap amplitudes of <code>tapping.wav<\/code>. You must use load <code>tap-detect.sal<\/code>, e.g. do not specify any path such as load <code>P2\/tap-detect.sal<\/code>. Refer to the HTML documentation for <code>tap-detect<\/code> and inspect the <code>tap-detect<\/code> code to get an idea of how you can generate a score based on this code.<\/p>\n<h2>Convert Taps to Score<\/h2>\n<p>Add your own functions to <code>tapcomp.sal<\/code> to map the list of tap times and amplitudes into a Nyquist score named <code>*tapscore*<\/code> that plays your instrument from <code>instr.sal<\/code> (so of course, you should have the statement <code>load \"instr.sal\"<\/code> to define your instrument). When you are done, loading <code>tapcomp.sal<\/code> should immediately run your code and produce <code>*tapscore*<\/code>, which should be a direct 1-to-1 translation of the taps to a score.<\/p>\n<p>NOTE 1: Do NOT use <code>score-gen<\/code>. Instead, you must use loop and list primitives to construct a score. You may use the <code>linear-to-vel<\/code> function to convert tap strength to a velocity parameter.<\/p>\n<p>NOTE 2: Note duration is up to you. It fixed, random, or related to the tap inter-onset times.<\/p>\n<h2>Make Music<\/h2>\n<p>Create between 20 and 40 seconds of music using your code. You can create new scores based on your <em>tapscore<\/em> (but please do not modify <code>*tapscore*<\/code>), mix multiple sounds or \u201ctracks,\u201d you can create sounds by other means (as long as at least one &#8220;track&#8221; is derived according to the recipe above), and you can manipulate your results in an audio editor (again, as long as the tap-driven instrument is clearly heard). Keep all the code for your piece in <code>tapcomp.sal<\/code>, but do not compute your piece immediately when the code is loaded (at least not in the version you hand in). It may be convenient to use <code>F4<\/code> and other buttons in the IDE to run different pieces of your code. E.g. you could add something like this to <code>tapcomp.sal<\/code>:<\/p>\n<pre>function F4() play compute-my-tap-piece(*tapscore*)<\/pre>\n<p>Do NOT write any <code>play<\/code> command or commands to compute your piece at the top-level. E.g. do NOT write something like<\/p>\n<pre>play compute-my-tap-piece(*tapscore*)<\/pre>\n<p>unless it is inside a function (like F4 above), and the function does not get called when the file is loaded.<\/p>\n<p>Name your composition sound file <code>p2comp.wav<\/code> (AIFF format is acceptable too.)<\/p>\n<h2>Describe Your Intentions<\/h2>\n<p>Create a simple ASCII text file <code>p2comp_README.txt<\/code> or pdf file <code>p2comp_README.pdf<\/code> with a sentence or two describing your goals or musical intentions in creating <code>p2comp.wav<\/code>.<\/p>\n<h2>Submission<\/h2>\n<p>Submit files in a zip file to ATutor. The following files should be at the top level in your zip file (you may use .aiff sound files instead of .wav sound files):<br \/>\n<strong>instr.sal<\/strong>: A SAL program implementing your table-lookup instrument,<br \/>\n<strong>tapping.wav<\/strong>: The recorded taps used as input to <code>tap-detect.sal<\/code>,<br \/>\n<strong>tapcomp.sal<\/strong>: A SAL program to convert tap times to a Nyquist score.<br \/>\n<strong>p2comp.wav<\/strong>: Your project 2 composition (at least 20 seconds).<br \/>\n<strong>p2comp_README.txt<\/strong>: Optional additional info on your composition.<\/p>\n<h2>Decibels<\/h2>\n<p>Read &#8220;The Bell Scale&#8221;, &#8220;The Decibel Scale (dB),&#8221; and &#8220;Decibels for Comparing Amplitude Levels&#8221; in <a href=\"http:\/\/www.cs.cmu.edu\/~music\/icm-online\/readings\/panlaws\/\"><em>Loudness Concepts and Panning Laws<\/em><\/a>, but to summarize some important points:<\/p>\n<ul>\n<li>Decibels are a unit-less measure of the ratio of power. Each Bel represents a factor of 10.<\/li>\n<li>Since power increases with the <em>square<\/em> of amplitude, a factor of 10 change in amplitude gives a factor of 100 in power, which is 2 Bels (log10(100) = 2), which is 20dB.<\/li>\n<li>A very useful number is: A factor of 2 in amplitude is very nearly 6dB.<\/li>\n<\/ul>\n<p>Remember that 6 dB represents a factor of 2 in amplitude!<\/p>\n<h2>Grading Criteria<\/h2>\n<p>Here are some things you might want to check before your final submission. Some criteria will be checked automatically. Some will be the basis of peer grading:<\/p>\n<ul>\n<li>Your <code>simple-note<\/code> is as directed, accepts 2 keyword parameters, and has proper pitch, amplitude, time and duration control.<\/li>\n<li>You define and convert <code>*ascore*<\/code> to <code>*bscore*<\/code> that calls <code>simple-note<\/code> when <code>instr.sal<\/code> is loaded.<\/li>\n<li><code>tapping.wav<\/code> contains at least 10 taps.<\/li>\n<li><code>*tapscore*<\/code>, generated by loading <code>tapcomp.sal<\/code>, should be a valid Nyquist score. (You can use <code>score-print<\/code> to see it nicely formatted.)<\/li>\n<li>Your submission should be complete and anonymous.<\/li>\n<li>The audio should have acceptable quality (no clipping or unintended distortion, no bad splices, adequate overall level, etc.)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Deadlines: Due 11:59 pm Eastern on February 22 2021. Peer grading due 11:59 pm Eastern on March 1, 2021. Download P2.zip Envelopes Envelopes are very &hellip; <\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/posts\/118"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":47,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":555,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/posts\/118\/revisions\/555"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-322\/s2021\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}