In this assignment, you give a new meaning to the word RecordPlayer. You’ll build something which can record and playback sound-files.
The intended setup is as follows.
- There are two modes, a record and a playback mode. You can switch between the modes by pressing the spacebar. Indicate in which mode is active by using visual feedback of your choice. For example, use a [panel] which changes it’s color from red (recording) to green (playback). Any other way of informing the user about the mode is also fine. For example:
When in record mode:
- the press of a key will record a file as long as the key is pressed. When the key is released, the recording stops. Detect the keypress with [key] and keyreleases with [keyup].
- the name of the file should correspond with the keynumber. E.g., pressing h (which has the key-number 104) for four seconds should produce a file called 104.wav (or 104.aif) which is four seconds long. Use a replaceable argument to create that name. Tipp: have a look at the “new msp object section”. We have a made recording patch which automatically named files with ascending numbers and started recordings.
When in playback mode:
- the press of a key will play back the file that was recorded pressing the same key. When the key is released, the playback stops. E.g., pressing h for two seconds should play back the first two seconds of the file called 104.aif (or 104.wav).
Use [ezadc~] to start audio and get the signal from the build in microfone. Use [ezdac~] for the sound output.
You can only make one recording at a time and also play back one recording at a time. Therefor, you can assume that any key-release (keyup) should stop the recording/playback. However, it’s nice, to filter out the spacebar keyups, just to be clean about it.
This should get you started:
Now, with the recording and a stop functionality added, it should look a bit like this…
Make sure it works. You could for example put your recorder into a subpatch to clean up a bit. It could look like this:
The rec subpatch of this patch looks like this:
Finish the assignment by adding the playback functionality.
After this works, put the play back mechanism in an abstraction (a separate file called simpleplayer.maxpat), put this file in the same folder as your patch and load it in your patch by making a new object and typing in [simpleplayer]. Make sure you add inlets to the abstraction so you can send the keynumber into the [simpleplayer].
Make a presentation mode version of the patch which only shows the necessary elements.
Try to export you patch as an application by going to the menu and choose File-> Export as Collective/Application. In the following export-dialogue, choose format: application, not collective . Test the application.
Send the max patch and your abstraction to Bernd, not the application.