# `Mx.Song`
[🔗](https://github.com/mx-music/mx/blob/main/lib/mx/song.ex#L1)

A song loaded from a file: its tempo and its parts, each played as a loop, in the order of the song.
`tempos` holds the tempo changes its music writes, each section's as `Mx.Tempo` takes them, or nil when it writes none.

A song file is either a script that ends with `Mx.song/1`, or a module that uses `Mx.Song`:

    defmodule Paredao do
      @moduledoc "A kick and an 808 bass at 92 beats a minute."

      use Mx.Song, tempo: 92

      part :kick, synth: :kick, fx: [level: [amp: 0.6]]
      part :bass, synth: :sub808

      def song, do: together([part(:kick, steps("x...", 1)), part(:bass, note(:g1, 4))])
    end

`use Mx.Song` imports `Mx` and takes the options of `Mx.song/1` but `music:`, which is what the module's `song/0` returns.
`part/2` written in the module's body declares a part with its options, once, and written in a function it is that part playing some music, with those options.
A part that is not declared does not compile.

# `check_fx`

Checks an fx: option, an effect or a list of effects with their options, as `:ok` or `{:error, message}`.

# `load`

Loads a song file, and returns `{:ok, song}` or `{:error, message}` naming the file and line.

# `part`
*macro* 

In a module's body, declares a part with its options; in a function, that part playing music with the options it was declared with.

# `put_live`

Records a live audio input of the song being loaded.

# `put_music_loop`

Records a part of the song being loaded as a loop that replays its music, ending after a number of passes, or never with nil.

# `put_osc_from`

Records the port the song being loaded takes OSC from.

# `put_osc_to`

Records where the song being loaded sends OSC.

# `put_played`

Records a sample the song being loaded plays, and whether it plays normalized, so a silent or quiet file is named once it has loaded.

# `put_tempo`

Records the tempo of the song being loaded.

# `put_tempos`

Records the tempo changes the music of the song being loaded writes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
