diff options
author | Anthony Wang | 2023-03-12 00:18:58 -0500 |
---|---|---|
committer | Anthony Wang | 2023-03-12 00:18:58 -0500 |
commit | 60267b5aa7f7350895ebbdbeed6d06d48bdbad71 (patch) | |
tree | c93d5da7ad7abae7b50d50a1988447b48af88ad7 | |
parent | 902286833b2ed018454eea8bec425e1a7d24f2ff (diff) |
32-bit audio because why not
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | example.ogg | bin | 422704 -> 433074 bytes | |||
-rw-r--r-- | music.py | 6 |
3 files changed, 4 insertions, 4 deletions
@@ -4,4 +4,4 @@ Lambeat is a new way to make music using functional programming. It's heavily in ## Get started First, install [Sox](https://sox.sourceforge.net/) and clone this repo. Write some music in `music.scm`. Enjoy your music with `guile --fresh-auto-compile lambeat.scm | play -r 8000 -t s16 -`! -For the Python version, use `pypy3 music.py | play -r 44100 -t s16 -` to listen and `pypy3 music.py | sox -r 44100 -t s16 - example.ogg` to save to a file. +For the Python version, use `pypy3 music.py | play -r 44100 -t s32 -` to listen and `pypy3 music.py | sox -r 44100 -t s32 - example.ogg` to save to a file. diff --git a/example.ogg b/example.ogg Binary files differindex b89a0d8..fcf9198 100644 --- a/example.ogg +++ b/example.ogg @@ -314,7 +314,7 @@ def at(t): """ Returns the total intensity of music sampled at time t """ - i = bisect.bisect(music, (t, 10**9)) + i = bisect.bisect(music, (t, 2**31)) # This is actually pretty efficient ngl # Because people usually don't have that many overlapping notes ret = 0 @@ -322,9 +322,9 @@ def at(t): m = music[j] # if m[0] + m[1] > t: ret += m[4] * tone(freq(m[2], m[3]), t - m[0]) - return int(2**12 * ret) + return int(2**28 * ret) # Print out music encoded in s16 to standard output for i in range(0 * bitrate, 84 * bitrate): - sys.stdout.buffer.write(struct.pack("h", at(i / bitrate))) + sys.stdout.buffer.write(struct.pack("i", at(i / bitrate))) |