Created
October 25, 2017 09:57
-
-
Save olligobber/d39f27dc16e5b8d91bfa03b8c4863032 to your computer and use it in GitHub Desktop.
Demonstration of basic chiptune waves in Mathematica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ToPitch[x_] := 440 2^((x - 9)/12) | |
Song[t_] := Piecewise[{{ToPitch[2], 0 <= t <= 2.5},{ToPitch[5], 3 <= t <= 5.5},{ToPitch[2], 6 <= t <= 7.5},{ToPitch[2], 8 <= t <= 8.5},{ToPitch[5], 9 <= t <= 10.5},{ToPitch[7], 11 <= t <= 11.5},{ToPitch[9], 12 <= t <= 13.5},{ToPitch[12], 14 <= t <= 14.5},{ToPitch[9], 15 <= t <= 16.5},{ToPitch[5], 17 <= t <= 17.5},{ToPitch[2], 18 <= t <= 19.5},{ToPitch[0], 20 <= t <= 20.5},{ToPitch[2], 21 <= t <= 22.5},{ToPitch[2], 24 <= t <= 31.5}}, 0] | |
Play[SquareWave[Song[6 t] t], {t, -0.1, 5.5}] | |
Play[2 SawtoothWave[Song[6 t] t] - 1, {t, -0.1, 5.5}] | |
Play[TriangleWave[Song[6 t] t], {t, -0.1, 5.5}] | |
Play[Sin[Song[6 t] t 2 Pi], {t, -0.1, 5.5}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment