Give the demo a real tune: the Anachronaut Labs theme
The composition is the user's - a leitmotif they already have variants of, written into the note table by hand. It replaces the eight note scale that was there to prove a note could be played at all, and it is a better demo for the obvious reason and one less obvious one: it is long enough to hear whether the machine keeps time, which a run of eight notes is not. Forty five notes, 567 frames, 9.45 seconds, peaking at 19,461 of 32,767. The test budget goes to twelve million cycles, which is a duration rather than a guess: at 16,667 cycles a frame the music is 9.45 million, so there is room to add bars before anybody has to come back here. Also records what borrowing the screen's frame actually costs, which came out of writing music rather than out of theory. The frame is not too slow, it is FIXED: every duration is a whole number of 16.67 ms, so a note worth a third of a beat cannot be written, and the way round it is choosing a tempo whose subdivisions land on whole frames - making the tune fit the machine. That is the argument for the timer peripheral wanting an arbitrary tick rather than a faster fixed one, and for the screen not being the clock: a display refresh and a music routine have no reason to share a rate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
85329f13c3
commit
2f22807458
@@ -17,6 +17,18 @@
|
|||||||
; Borrowing the screen's frame costs nothing and works, which is the whole reason to notice
|
; Borrowing the screen's frame costs nothing and works, which is the whole reason to notice
|
||||||
; that a beat is a beat wherever it comes from.
|
; that a beat is a beat wherever it comes from.
|
||||||
;
|
;
|
||||||
|
; ---- What borrowing it costs ----
|
||||||
|
;
|
||||||
|
; The frame is not slow. It is FIXED, and that is the different complaint. Every duration here
|
||||||
|
; is a whole number of 16.67 ms, so a note worth a third of a beat cannot be written at all -
|
||||||
|
; and the way round it is to pick a tempo whose subdivisions happen to land on whole frames,
|
||||||
|
; which is making the tune fit the machine rather than the other way round. The theme below
|
||||||
|
; was written to the frame and is a few cents of tempo away from what it wants to be.
|
||||||
|
;
|
||||||
|
; So what the timer wants is an ARBITRARY tick rather than a faster fixed one, and the reason
|
||||||
|
; the screen should not be the clock is that a display refresh and a music routine have no
|
||||||
|
; reason to share a rate.
|
||||||
|
;
|
||||||
; ---- What a patch costs and what a note costs ----
|
; ---- What a patch costs and what a note costs ----
|
||||||
;
|
;
|
||||||
; Setting the sound up is twenty-odd writes, done once before a single note is played. After
|
; Setting the sound up is twenty-odd writes, done once before a single note is played. After
|
||||||
@@ -137,7 +149,7 @@ start:
|
|||||||
;
|
;
|
||||||
; Data Pointer 0 walks the table, and nothing in this loop is a CALL, so it stays where it
|
; Data Pointer 0 walks the table, and nothing in this loop is a CALL, so it stays where it
|
||||||
; was left without being saved anywhere.
|
; was left without being saved anywhere.
|
||||||
SETD.0 Tune
|
SETD.0 Theme
|
||||||
|
|
||||||
nextNote:
|
nextNote:
|
||||||
LDA.0 ; The note. Zero is the end of the tune.
|
LDA.0 ; The note. Zero is the end of the tune.
|
||||||
@@ -197,6 +209,69 @@ Tune:
|
|||||||
0d60 0d45 ; and home
|
0d60 0d45 ; and home
|
||||||
0x00
|
0x00
|
||||||
|
|
||||||
|
Theme:
|
||||||
|
0x30 0d15 ; C
|
||||||
|
0x35 0d15 ; F
|
||||||
|
0x3C 0d15 ; C+
|
||||||
|
0x40 0d30 ; E+
|
||||||
|
0x48 0d30 ; C++
|
||||||
|
0x45 0d30 ; A+
|
||||||
|
0x47 0d30 ; B+
|
||||||
|
0x43 0d45 ; G+
|
||||||
|
; repeat four times.
|
||||||
|
0x2A 0d7 ; Gs
|
||||||
|
0x33 0d7 ; Ef
|
||||||
|
0x3C 0d7 ; C+
|
||||||
|
;
|
||||||
|
0x2A 0d7 ; Gs
|
||||||
|
0x33 0d7 ; Ef
|
||||||
|
0x3C 0d7 ; C+
|
||||||
|
;
|
||||||
|
0x2A 0d7 ; Gs
|
||||||
|
0x33 0d7 ; Ef
|
||||||
|
0x3C 0d7 ; C+
|
||||||
|
;
|
||||||
|
0x2A 0d7 ; Gs
|
||||||
|
0x33 0d7 ; Ef
|
||||||
|
0x3C 0d7 ; C+
|
||||||
|
; next chord
|
||||||
|
0x2E 0d7 ; Bf
|
||||||
|
0x35 0d7 ; F
|
||||||
|
0x3E 0d7 ; D+
|
||||||
|
; next chord
|
||||||
|
0x2E 0d7 ; Bf
|
||||||
|
0x35 0d7 ; F
|
||||||
|
0x3E 0d7 ; D+
|
||||||
|
;
|
||||||
|
; next chord
|
||||||
|
0x2E 0d7 ; Bf
|
||||||
|
0x35 0d7 ; F
|
||||||
|
0x3E 0d7 ; D+
|
||||||
|
;
|
||||||
|
; next chord
|
||||||
|
0x2E 0d7 ; Bf
|
||||||
|
0x35 0d7 ; F
|
||||||
|
0x3E 0d7 ; D+
|
||||||
|
; Finally on the C major
|
||||||
|
0x30 0d7 ; C
|
||||||
|
0x37 0d7 ; G
|
||||||
|
0x40 0d7 ; E+
|
||||||
|
;
|
||||||
|
0x30 0d7 ; C
|
||||||
|
0x37 0d7 ; G
|
||||||
|
0x40 0d7 ; E+
|
||||||
|
;
|
||||||
|
0x30 0d7 ; C
|
||||||
|
0x37 0d7 ; G
|
||||||
|
0x40 0d7 ; E+
|
||||||
|
;
|
||||||
|
0x30 0d7 ; C
|
||||||
|
0x37 0d7 ; G
|
||||||
|
0x40 0d7 ; E+
|
||||||
|
;
|
||||||
|
0x18 0d60 ; C bass
|
||||||
|
0x00
|
||||||
|
|
||||||
#Vectors
|
#Vectors
|
||||||
|
|
||||||
Boot start
|
Boot start
|
||||||
|
|||||||
+10
-5
@@ -52,11 +52,16 @@ frames | Examples/frames.asm | run | -
|
|||||||
# picture draws a whole 320 by 200 bitmap and prints nothing, so what is recorded is only
|
# picture draws a whole 320 by 200 bitmap and prints nothing, so what is recorded is only
|
||||||
# that it ran and what it cost. Tests/video.sh is where the pixels are checked.
|
# that it ran and what it cost. Tests/video.sh is where the pixels are checked.
|
||||||
picture | Examples/picture.asm | run | - | -
|
picture | Examples/picture.asm | run | - | -
|
||||||
# tune plays eight notes and prints nothing, so what is recorded is that it ran, that it
|
# tune plays the Anachronaut Labs theme and prints nothing, so what is recorded is that it
|
||||||
# finished on its own, and how much of its time it spent asleep - which is nearly all of it,
|
# ran, that it finished on its own, and how much of its time it spent asleep - which is
|
||||||
# because the tempo is the screen's frame and a program waiting on a frame is not using the
|
# 99.8% of it, because the tempo is the screen's frame and a program waiting on a frame is
|
||||||
# bus. Tests/sound.sh is where the samples are checked.
|
# not using the bus. Tests/sound.sh is where the samples are checked.
|
||||||
tune | Examples/tune.asm | run | - | 5000000
|
#
|
||||||
|
# THE BUDGET IS A DURATION, and that is the thing to know if this ever fails. 567 frames of
|
||||||
|
# music at 16,667 cycles a frame is 9.45 million, so twelve leaves room to lengthen the tune
|
||||||
|
# without coming back here - and a failure saying "cycle limit reached" means somebody added
|
||||||
|
# bars, not that anything broke.
|
||||||
|
tune | Examples/tune.asm | run | - | 12000000
|
||||||
8bitSieve | Examples/primeSieve/8bitSieve.asm | run | - | -
|
8bitSieve | Examples/primeSieve/8bitSieve.asm | run | - | -
|
||||||
16bitSegmentedSieve | Examples/primeSieve/16bitSieve.asm | run | - | -
|
16bitSegmentedSieve | Examples/primeSieve/16bitSieve.asm | run | - | -
|
||||||
# The four pointer rewrite. It emits exactly the same primes as the line above, which
|
# The four pointer rewrite. It emits exactly the same primes as the line above, which
|
||||||
|
|||||||
Reference in New Issue
Block a user