Instructions for wavesynthTune

(produced at 02:56 a.m. UTC on 2024-01-24)

This task is part of project01 which is due at 23:00 EST on 2024-01-30.

You have the option to work with a partner on this task if you wish. Working with a partner requires more work to coordinate schedules, but if you work together and make sure that you are both understanding the code you write, you will make progress faster and learn more.

You can download the starter code for this task using this link.

You can submit this task using this link.

Put all of your work for this task into the file tune.py
(you will create this file from scratch)

This task will help you practice writing basic code and will help you get familiar with the wavesynth library for creating music with Python.

The requirements are very simple, and in fact, there are no restrictions on what notes you create: the only rules are that you must make use of certain functions.

To start, you need to create a new file, named tune.py. This file must be in a folder where wavesynth.py is also present. To create that file, you should:

  1. Download the starter code for this task from Potluck.
  2. Unzip the downloaded file to create a folder to work in. This folder will include a file called wavesynth.py.
  3. In Thonny, create a new file. Immediately use "save" or "save as" and then pick the folder you just created as the destination, with "tune.py" as the filename.

Now you're ready to write code. Your tune.py file must satisfy the following criteria:

  1. Your file must start with a triple-quoted string at the top, identifying the names of each author, which classmates and/or tutors and/or instructors you consulted for help, the last date you modified the file, and a brief description of the purpose of the file. We will do this for all files that you submit in this class. Here is an example:

    """
    Authors: Anon & Ymous
    Consulted: T. A.
    Date: 2022-1-21
    Purpose: Wavesynth tune task
    """
    
  2. Your file must import the wavesynth module so that you can use functions from it.

  3. You must use each of the following basic functions for creating sounds (reference) at least once:
  4. You must use at least one of the functions climbUp, climbDown, halfStepUp, or halfStepDown to change the current pitch between notes. For full credit, you must both use at least one of climbUp or climbDown and use at least one of halfStepUp or halfStepDown, and you must also use setPitch.
  5. You must use at least one of the setVolume, quieter, and/or louder functions to manipulate the volume of one or more notes or beats.
  6. You must use at least one of the setTime, rewind, and/or fastforward functions to alter the time at which some notes or beats are created.
  7. You must use the saveTack function so that your program saves the music to a file. You may name your saved file whatever you wish. As an extra goal, you may also use the printTrack function to print out a record of the notes you created. Calling playTrack is not required, but if simpleaudio can be installed on your system, it's a faster way to hear the audio than opening up the saved file each time.
  8. For full credit, you must use at least one of the setDrum and/or setInstrument functions to specify the instrument or drum used to create notes. You can see the list of available beat and note instruments in our quick reference.

You are welcome to use other wavesynth features in addition to the ones listed above, but only the above features are required.

If you want to challenge yourself and read ahead a little bit, consider defining a custom function and using it as part of your tune (but you will not receive any extra credit for this, so don't do it if you're short on time).

Reminder: If you want to hear sounds using playTrack, you must install the simpleaudio module using the Package manager in the Thonny Tools menu (search for simpleaudio, select the result with that name, and then click "install"). This may not work on some machines. If simpleaudio and thus playTrack doesn't work for you, just use saveTrack to save as a .wav file and then open that file after you run your program.

Examples

Using wavesynth

Here's a brief reminder of how to use the wavesynth functions. This code creates a tune with three notes going up in pitch.

In []:
from wavesynth import * addNote(0.2) climbUp(1) addNote(0.2) climbUp(1) addNote(0.2) saveTrack('threeUp.wav') # playTrack() # Use this only if simpleaudio is working on your system
Audio

Layering sounds

Here's an example of how to use rewind to layer sounds on top of each other. This tune has two 1/2-second notes and two 1/4-second beats play during each note. Remember that a quick reference guide is available that covers all of the wavesynth functions we will use in this class.

In []:
from wavesynth import * addNote(0.5) climbUp(2) addNote(0.5) rewind(1) addBeat(0.25) addBeat(0.25) addBeat(0.25) addBeat(0.25) saveTrack('layered.wav') # playTrack() # Use this only if simpleaudio is working on your system
Audio

Rubric

Group goals:
 
unknown No errors loading code
Your code should be able to be loaded without errors. Run your code before submitting it to make sure this is true.
 
unknown Call addNote
Call addNote in at least one place.
 
unknown Call addBeat
Call addBeat in at least one place.
 
unknown Call climbUp
Call climbUp, climbDown, halfStepUp, or halfStepDown in at least one place.
 
unknown Call setVolume
Call setVolume, quieter, or louder in at least one place.
 
unknown Call setTime
Call setTime, rewind, or fastforward in at least one place.
 
unknown Call saveTrack
Call saveTrack in at least one place.
 
unknown Call addRest
Call addRest in at least one place.
 
unknown Call setPitch
Call setPitch in at least one place.
 
unknown Call climbUp
Call climbUp or climbDown in at least one place.
 
unknown Call halfStepUp
Call halfStepUp or halfStepDown in at least one place.
 
unknown Call setDrum
Call setDrum or setInstrument in at least one place.
 
unknown Call printTrack
Call printTrack in at least one place.