# Music for my game!

**URL:** https://forum.makecode.com/t/music-for-my-game/4818
**Category:** Collaboration
**Created:** [December 6, 2020, 7:29pm UTC](https://forum.makecode.com/t/music-for-my-game/4818 "2020-12-06T19:29:04Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)
#### Post date: [December 7, 2020, 8:34pm UTC](https://forum.makecode.com/t/music-for-my-game/4818/5 "2020-12-07T20:34:26Z")

</div>

Haha thanks for the compliment 😃

This is how I make the songs in Arcade:

1. First I find some sheet music and download it. I usually use the [Musescore](https://musescore.com/dashboard) website to browse for sheet music.
2. Then I open it in the [Musescore](https://musescore.org/en) software, make song adjustments as necessary, and export to the MIDI format. I usually check the `.mid` file in [Audacity](https://www.audacityteam.org/).
3. After, I adjust my Python scripts to use the MIDI file I just exported. The first script opens and parses the MIDI with [Mido](https://pypi.org/project/mido/) and generates a JSON file that looks like this:

```json
{
    "midi": [
        [
            {
                "note": 72,
                "name": "C5",
                "velocity": 80,
                "time": 0.24895833333333334
            },
            {
                "note": 48,
                "name": "C3",
                "velocity": 80,
                "time": 0.24895833333333334
            }
        ],
        [
            {
                "note": 67,
                "name": "G4",
                "velocity": 80,
                "time": 0.24895833333333334
            },
            {
                "note": 55,
                "name": "G3",
                "velocity": 80,
                "time": 0.24895833333333334
            }
        ],
        [
            {
                "note": 72,
                "name": "C5",
                "velocity": 80,
                "time": 0.4739583333333333
            },
            {
                "note": 48,
                "name": "C3",
                "velocity": 80,
                "time": 0.4739583333333333
            }
        ],
        // More notes
    ]
}

```

1. I then run my second script to use this JSON and it produces a `.ts` file that looks like this: (I changed the speed to be I think 1.5x slower.)

```auto
function play_song() {
    // ['C5', 'C3']
    {
        music.setVolume(80)
        // C5
        timer.background(function() {
            music.playTone(523, 372.0)
        })
        // C3
        music.playTone(130, 373)
    }
    // ['G4', 'G3']
    {
        // G4
        timer.background(function() {
            music.playTone(391, 372.0)
        })
        // G3
        music.playTone(195, 373)
    }
    // ['C5', 'C3']
    {
        // C5
        timer.background(function() {
            music.playTone(523, 709.5)
        })
        // C3
        music.playTone(130, 710)
    }
    // More notes
}

play_song()

```

So I don’t do the songs by hand (I would have gone insane) but writing the scripts to generate the typescript took ages…

---

_[View the full topic](https://forum.makecode.com/t/music-for-my-game/4818)._
