Add new bytebeat in Scheme implementation
This commit is contained in:
parent
9b62eed93c
commit
92e83efd95
7 changed files with 21 additions and 49 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,9 +0,0 @@
|
|||
# ---> Scheme
|
||||
*.ss~
|
||||
*.ss#*
|
||||
.#*.ss
|
||||
|
||||
*.scm~
|
||||
*.scm#*
|
||||
.#*.scm
|
||||
|
26
README.md
26
README.md
|
@ -1,24 +1,2 @@
|
|||
# M
|
||||
|
||||
A minimal and ergonomic music programming language, inspired by Lisp
|
||||
|
||||
## Design
|
||||
|
||||
A M source code file has the extension `.m` and is basically a Scheme program with some extra spice. All lines that start with an open parenthesis, space, or tab are treated as lines of a normal Scheme program. Lines that do not start with those characters correspond to generating a music tone at a certain time. These lines have the following format:
|
||||
```
|
||||
401/2A 441/2A 471/2A
|
||||
```
|
||||
|
||||
Each line consists of multiple notes separated by tab characters. You can use any Scheme variables in for these notes instead of actual numbers. It's recommended to set your tab size to 8 so the notes in different lines are aligned.
|
||||
|
||||
Each note consists of multiple characters:
|
||||
1. The first character is the octave.
|
||||
2. The second is the step of the scale it's on in base 12, so 0 is equivalent to the traditional A, A is equivalent to the traditional G, and B is equivlanet to the traditional G sharp.
|
||||
3. The next few characters are the length of the note. This can be a fraction.
|
||||
4. The final character is a modifier that changes some property of the note, such as its volume.
|
||||
|
||||
## Toolchain
|
||||
|
||||
The M compiler `mc` will first interpret the Scheme program and generate an M intermediate format file with file extension `.min`. This file consists of all the music tone lines that the compiler ran into while interpreting the Scheme program. This can be then played by the `mplay` tool or converted to formats like `.mp3` with `mconv`.
|
||||
|
||||
The `m` wrapper tool automates this process and will compile and play an M file if no output is specified, or convert it to the desired output format if specified.
|
||||
# Lambeat
|
||||
Bytebeat in Scheme
|
||||
|
|
4
m
4
m
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/guile -s
|
||||
!#
|
||||
|
||||
(display "hello world")
|
19
main.scm
Normal file
19
main.scm
Normal file
|
@ -0,0 +1,19 @@
|
|||
(define (note freq start len) (
|
||||
lambda (t) (
|
||||
if (or (< t start) (> t (+ start len)))
|
||||
0
|
||||
freq
|
||||
)
|
||||
))
|
||||
|
||||
(define (music t) (
|
||||
(note 440 0 10) t
|
||||
))
|
||||
|
||||
(define (play t) (
|
||||
if (< t 100)
|
||||
(cons (music t) (play (+ t 1)))
|
||||
(music t)
|
||||
))
|
||||
|
||||
(display (play 0))
|
4
mc
4
mc
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/guile -s
|
||||
!#
|
||||
|
||||
(display "hello world")
|
4
mconv
4
mconv
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/guile -s
|
||||
!#
|
||||
|
||||
(display "hello world")
|
4
mplay
4
mplay
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/guile -s
|
||||
!#
|
||||
|
||||
(display "hello world")
|
Loading…
Reference in a new issue