# Music studies

While music itself is pleasant to listen to, the theory behind it, along with maths for processing or synthesizing it, as well as the process of performing it, can be quite fun.

## Music theory

Music theory for nerds is a great starting point. "What Makes Music Sound Good?" is another overview and introduction, though perhaps more opinionated.

Some of the related and interesting research areas are those of music origin and purpose, such as evolutionary musicology, and how it's perceived by humans: psychoacoustics, music psychology, music and emotion.

The Ask HN: Tools to learn music theory? discussion contains a few more relevant links.

Open Music Theory looks like a nice textbook.

As with computing and maths, it is useful to study history of the subject as well, so that more of it will make sense, and it will be easier to put into a perspective. Videos on history of music can be found on YouTube, as well as on PeerTube, where some of the PianoTV videos are available.

## Generation and processing

The PCM format is to audio basically what netpbm/PPM/PGM/PBM/PNM is to graphics: very simple and straightforward, can be played with ffplay and others, easy to generate programmatically and write into a file without any encoder libraries, as well as to read without a special decoder. Audio I/O libraries (e.g., PortAudio) and codec libraries (e.g., libopus) tend to work with it.

DCT/DFT are often involved in processing (and in compression, also similarly to graphics), Mel-frequency cepstrum can be useful and/or interesting to look into.

## Analysis

Audacity is handy for checking the spectrum and notes in it, for music transcription and other checks.

## MIDI keyboard

To practice playing piano using a MIDI keyboard, one needs at least a software synthesizer and some music scores.

The keyboard in this case is M-Audio Keystation 88 MK3, which worked easily with Linux (5.10, Debian), Windows 10, and an Android tablet (Samsung Galaxy Tab A8, connected with a USB-A-to-USB-C adapter). For a synthesizer, I've used Yoshimi on Linux, LMMS (mostly with its sf2/soundfont plugin) on Linux and Windows, and Synthesia (not in F-Droid repositories, and I don't have a Google account, but grabbed an apk from their website) on Android.

MuseScore allows to compose sheet music and export it into MIDI rather quickly and easily, and there are more editors and converters of that kind available from Debian repositories.

PianoBooster looks like a nice trainer, akin to GNU Typist, but I found it quite annoying that it counts it as a mistake if you press a key too soon, so switched back to just reading scores and playing from those.

I use my computer screen to read sheet music, with the keyboard stand placed behind my computer chair, so it has to be zoomed in (Xfce's zooming in is quite handy when software can't zoom in on its own), and scrolling is needed for larger compositions, but the regular computer keyboard and mouse are out of reach. The MIDI keyboard has directional keys, messages from which come from a separate MIDI port; I haven't found readily available software (possibly LMMS plugins) helping to scroll the notes from a MIDI keyboard, but it took just a small script to achieve:

    import mido
    from xdo import xdo

    # apt install python3-mido python3-xdo libportmidi-dev python3-rtmidi

    # perhaps can be done in bash, with something like amidi + xdotool

    # https://gitlab.com/dkg/python-xdo/-/blob/main/xdo/__init__.py
    # https://gitlab.com/cunidev/gestures/-/wikis/xdotool-list-of-key-codes

    # print(mido.get_input_names())

    mapping = {
        96: 'Page_Up',
        97: 'Page_Down',
        98: 'Left',
        99: 'Right',
        100: 'space'
    }

    x = xdo()

    with mido.open_input('Keystation 88 MK3:Keystation 88 MK3 MIDI 2 24:1') as port:
        for msg in port:
            # print(msg)
            if msg.note in mapping and msg.velocity == 127:
                x.send_keysequence_window(mapping[msg.note])

## Scores

IMSLP.org is a nice source of public domain or otherwise freely available scores (including solo piano arrangements). Additionally, there are MIDI music collections around, which are lightweight, but encode melodies, which can then be viewed as scores (e.g., with MuseScore 2).

## Composition

Music composition seems to be rather similar to poetry, and to arts in general: a creative process, but one can reuse a musical form, learn and use a variety of approaches and tricks (by analyzing existing works, in addition to just reading about techniques), experiment and try things out.

Music appreciation seems useful to study as well; "Inside the Score" is one of the YouTube channels focusing on that.

Ryan Leach on YouTube makes nice videos explaining the composition process. David Bennett Piano brings up plenty of interesting subjects and analyzes songs.

## On singing

While I don't sing, a brief look into it suggests that as with most of other skills, it's primarily about learning and practicing, exercising.

Yet even without singing, it is interesting to learn about vocal registers and related topics.

Possibly it is a wrong way to learn and practice, but I found it fun to set a tuner program on a phone (e.g., Tuner from F-Droid repositories), and try hitting notes.

## Ear training

For Android, there is the Open Ear program, available from Android: seems to be a little buggy (making noises), but allows to practice recognition of scale degrees.

The musictheory.net website also provides exercises, including those for ear training.

And I composed a shell script using SoX for practice of identification of scale degrees and intervals.

## Motivation

Sometimes I find myself questioning the usefulness of these amateur music studies, particularly of playing instruments (while the theory and composition may conceivably be applied somehow), but it helps to view it as a recreational activity, quite similar to a game: the process itself should be enjoyable.