Writing the implementation
In this case, the implementation would be the modules used to define a note struct and play a note, using the aplay
command.
Note for non-Linux readers
The aplay
command only works for Linux machines with ALSA. If you’re using a Mac or a Windows machine, you can try looking for alternatives to play a note as part of this project. Even if you cannot get a note to play on your machine, it would still be very useful to learn how to build this interface.
Since the goal of this project is to learn how to use metaprogramming, we will focus more of our attention on building the interface. Therefore, I will be glossing over some of the details of the implementation.
Let’s start by creating a new mix project:
$ mix new mix_music
Now, inside our new mix project, let’s define a MixMusic.Note
module, which also defines a struct. This module will also be responsible for converting a note to a final frequency with a MixMusic.Note...