Skip to content

Commit

Permalink
Support just intonation in score entry
Browse files Browse the repository at this point in the history
Using MPE style channel rotation.
Add TRAT piano experiment.
Add BPM>TPW
Set default TPW based on 120 BPM.
  • Loading branch information
philburk committed Aug 5, 2019
1 parent 02c198c commit 7bbd796
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 7 deletions.
168 changes: 168 additions & 0 deletions hmsl/pieces/trat.fth
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
\ Test dynamic intonation using PitchBend on multiple channels.

include? ratio>pbend tools/bend_tuning.fth
include? par{ tools/score_entry
include? task-bend_score tools/bend_score.fth

anew TASK-TRAT

\ simple piece using ratio scoring
: TRAT1
1 1 PR 3 2 PR 4 3 PR
;

: TRAT2
trat1
5 4 rat{ trat1 }RAT
trat1
;

: TRAT.CH1
chord{ 1 1 PR 3 2 PR 4 3 PR }chord
;
: TRAT.CH2
chord{ 1 1 PR 4 3 >>PR 4 3 >>PR }chord
;
: TRAT.CH3
chord{ 4 5 >>PR 4 3 >>PR 4 3 >>PR }chord
;

: TRAT3
par{ 1/8 4 0 DO 1 1 PR 7 5 PR 3 4 PR 5 4 PR LOOP
}par{
1/4 4 0 DO 4 1 RAT{ 1 1 PR 3 2 PR }RAT LOOP
}par
;
: TRAT4
par{ trat3
}par{ 1/16 5 4 RAT{
8 0 DO 1 1 PR 9 8 PR 8 5 PR 7 4 PR LOOP
}RAT
}par
;

: TRAT5
1/8
4 0
DO
2 1 PR 5 4 PR 1 1 PR 1 1 PR
1 1 PR 3 2 >>PR 3 4 >>PR 4 5 >>PR!
LOOP
;

: TRAT.SCALE { numer denom num -- , play a series of just intervals }
num 0
DO
numer denom >>PR
LOOP
;

: TRAT.SCALES ( -- , perform up and down scales )
8 0
DO
4 i + 3 i + 2dup 8 trat.scale swap 8 trat.scale
LOOP
;
: TRAT.DIVERGE ( -- , perform up and down scales, diverging and rejoining )
8 0
DO
par{
4 i + 3 i + 2dup 8 trat.scale swap 8 trat.scale
}par{
4 i + 3 i + SWAP 2dup 8 trat.scale swap 8 trat.scale
}par
LOOP
;

: TRAT6 { n1 n2 -- , play chords with sliding fundamental }
1 1 PR 2 3 >>PR n1 n2 >>PR n1 n2 >>PR n2 n1 >>PR n2 n1 >>PR
8 0
DO
CHORD{ n2 n1 >>PR! n1 n2 PR 3 2 PR }CHORD
LOOP
;

: TRAT7
par{
1/12 4 0 DO 1 1 PR 3 4 PR 4 5 PR LOOP
}par{
1/4 1 2 PR 3 8 PR 9 16 PR 4 6 PR
}par
1/12 4 0
DO chord{ 5 6 PR! 2 3 PR }chord
3 4 PR! 3 2 PR!
LOOP
1/12 4 0 DO 2 1 PR 6 5 PR 4 3 >>PR LOOP
;

: TRAT8
1/4 1 1 pr 6 5 >>pr 4 5 >>pr 3 2 >>pr
1/2 4 5 >>pr 1 1 >>pr!
;

: TRAT9
1/4 1 1 pr 5 3 >>pr 5 6 >>pr 5 4 >>pr
1/2 3 2 >>pr 1 2 >>pr!
;

: TRAT10 \ play chords with a single internal fundamental
chord{ 1 1 pr 3 4 >>pr 2 3 >>pr }chord
chord{ 4 3 pr! 3 4 >>pr 2 3 >>pr }chord
chord{ 2 3 pr! 3 5 >>pr 5 6 >>pr }chord
chord{ 3 2 pr! 2 3 >>pr 3 4 >>pr }chord
chord{ 5 3 pr! 3 5 >>pr 2 3 >>pr }chord
chord{ 4 5 pr! 3 4 >>pr 5 6 >>pr }chord
;

: TRAT11 \ play bass chords plus high ornamentation
par{ chord{ 1/2 1 1 pr 3 4 >>pr 2 3 >>pr }chord
}par{ 1/8 4 1 rat{ 1 1 pr 3 4 pr 4 3 pr 2 3 pr }rat
}par
par{ chord{ 1/2 4 3 pr! 3 4 >>pr 2 3 >>pr }chord
}par{ 1/8 4 1 pr 3 4 >>pr 5 4 >>pr 6 5 >>pr
}par
par{ chord{ 1/2 2 3 pr! 3 5 >>pr 5 6 >>pr }chord
}par{ 1/8 4 1 pr 3 5 >>pr 5 3 >>pr 6 5 >>pr
}par
par{ chord{ 1/2 3 2 pr! 2 3 >>pr 3 4 >>pr }chord
}par{ 1/8 4 1 pr 3 4 >>pr 5 4 >>pr 6 5 >>pr
}par
par{ chord{ 1/2 5 3 pr! 3 5 >>pr 2 3 >>pr }chord
}par{ 1/8 4 1 rat{ 1 1 pr 3 4 pr 4 3 pr 2 3 pr }rat
}par
par{ chord{ 1/2 4 5 pr! 3 4 >>pr 5 6 >>pr }chord
}par{ 1/8 4 1 pr 3 4 >>pr 5 4 >>pr 6 5 >>pr
}par
;

: TRAT12 ( -- , pound steady chord )
1/8 4 0 DO chord{ 1 1 pr 3 4 >>pr 4 5 >>pr }chord LOOP
4 3 rat!
1/8 4 0 DO chord{ 1 1 pr! 4 5 >>pr 5 6 >>pr }chord LOOP
;

: TRAT
1 bsc.set.program
pr.reset
1/4
\ trat3 trat4
\ 4 3 RAT{ trat4 trat3 }RAT
1 2 rat!
1/16 4 3 trat6 5 4 trat6 6 5 trat6
1/2 1 2 >>PR 2 3 >>PR 2 3 >>PR!
trat7
1/16 trat.scales trat.diverge
trat8 trat8
trat9 trat9
1/4 _ff 1 2 rat! trat10 1 2 rat! trat10
_mf 1 2 rat! trat11 trat12
1/4 1 2 rat! trat10
1/16 1 2 rat! trat.scales trat.diverge
1/4 1 2 rat! trat10
;

." To listen, enter: playnow trat" cr

\ playnow 1 bsc.set.program pr.reset 1/16 4 3 trat6 5 4 trat6 6 5 trat6


13 changes: 7 additions & 6 deletions hmsl/tools/bend_score.fth
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
\ By Phil Burk
\ Copyright 1995

include? par{ ht:score_entry
include? par{ score_entry.fth
include? ratio>pbend bend_tuning.fth

ANEW TASK-BEND_SCORE


: MIDI.SET.RPN { val rpn -- , set registered parameter number }
101 0 midi.control
100 rpn midi.control
Expand Down Expand Up @@ -88,6 +87,7 @@ pr.reset
;

\ move this to EVENT_BUFFER !!!
0 [if]
: EB.CATCHUP ( -- , wait for free nodes silently )
eb-free-nodes eb.next 0=
IF
Expand All @@ -99,15 +99,16 @@ pr.reset
drop
THEN
;
[then]

: (PR) { numer denom pbend -- }
bsc.next.channel
numer denom ratio>pbend \ convert the ratio to a relative pitch bend
pbend + \ convert the ratio to an absolute pitch bend
dup bsc-last-pbend !
eb.catchup
\ eb.catchup
pbend>note+pb midi.pitch.bend
eb.catchup
\ eb.catchup
note
;

Expand All @@ -127,8 +128,8 @@ pr.reset
: >>PR ( numer denom -- , play ratio based on previous note)
bsc-last-pbend @ (pr)
;
: >>PR! ( numer denom -- , play ratio based on previous note, update fundamental

: >>PR! ( numer denom -- , play ratio based on previous note, update fundamental )
>>pr
bsc-last-pbend @ bsc-fundamental ! \ update fundamental
;

13 changes: 12 additions & 1 deletion hmsl/tools/score_entry.fth
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,18 @@ variable HUMANIZE-OFFSET
DOES> w@ ns.velocity!
;

40 value DEFAULT_TPW
\ Base default ticks per whole note on clock rate when compiled.
: BPM>TPW { bpm -- tpw , convert beats per minute to ticks per whole note }
rtc.rate@ \ ticks per second
60 \ seconds per minute
* \ ticks per minute
bpm \ beats per minute, default tempo
/ \ ticks per beat
4 \ beats per whole note
* \ ticks per whole note
;

120 bpm>tpw value DEFAULT_TPW

: NS.RESET ( -- )
80 ns-cur-velocity ! ( forte )
Expand Down

0 comments on commit 7bbd796

Please sign in to comment.