Permalink
Browse files

add method fomus-add-tenor to the sequence class (talea)

  • Loading branch information...
1 parent be4734d commit 8600963663a2082959c11246cdb50c5dbcfac723 @k7f committed Nov 14, 2011
Showing with 24 additions and 12 deletions.
  1. +14 −7 work/fomus/demo/demo.factor
  2. +10 −5 work/fomus/fomus.factor
View
21 work/fomus/demo/demo.factor
@@ -7,15 +7,22 @@ IN: fomus.demo
<PRIVATE
: (a-chord) ( staff base-pitch -- )
- 1. fomus-set-dyn .5 fomus-set-dur { 0 4 7 } n+v fomus-add-chord ;
+ 4. fomus-set-dyn { 4 11 12 15 } n+v .25 fomus-add-chord ;
+
+: (an-arpeggio) ( staff base-pitch -- )
+ 4. fomus-set-dyn { 0 4 8 } n+v .3 fomus-add-tenor ;
: (a-scale) ( staff base-pitch -- )
- 2. fomus-set-dyn [ 12 + ] [ 3 + ] bi [a,b] .25 fomus-add-tenor ;
+ 1. fomus-set-dyn [ 12 + ] [ 3 + ] bi
+ pick 2 = [ swap ] when
+ [a,b] { .5 .25 .25 } fomus-add-tenor ;
: (a-figure) ( staff base-pitch start -- )
- [ dup fomus-set-voice ] 2dip
- [ fomus-set-time (a-chord) ]
- [ 1. + fomus-set-time (a-scale) ] 3bi ;
+ [ dup fomus-set-voice ] 2dip [
+ fomus-set-time over 1 = [ (an-arpeggio) ] [
+ 2dup (a-chord) .5 fomus-inc-time (a-chord)
+ ] if
+ ] [ 1. + fomus-set-time (a-scale) ] 3bi ;
: (demo) ( -- )
fomus-start <fomus> [
@@ -31,8 +38,8 @@ IN: fomus.demo
"pf" fomus-set-part
{ { 1 58 1 }
{ 2 36 .5 }
- { 1 60 5. }
- { 2 38 4.5 } } [ first3 (a-figure) ] each
+ { 1 60 6. }
+ { 2 38 5.5 } } [ first3 (a-figure) ] each
"fomus-demo" fomus-render&play
] with-fomus ;
View
15 work/fomus/fomus.factor
@@ -2,8 +2,8 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators debugger fomus.ffi fry io io.backend
- io.pathnames kernel math math.parser namespaces sequences strings
- timidity ;
+ io.pathnames kernel math math.parser namespaces sequences
+ sequences.repeating strings timidity prettyprint ;
IN: fomus
<PRIVATE
@@ -221,10 +221,15 @@ M: number fomus-add-tenor
dup fomus-set-dur
'[ fomus-set-pitch fomus-set-staff fomus-add-note _ fomus-inc-time ] with each ;
-! FIXME
-! M: sequence fomus-add-tenor
+M: sequence fomus-add-tenor
+ 2dup shorter? [ [ length repeated ] keep ] [ over length repeated ] if
+ rot [
+ fomus-set-staff [ fomus-set-dur fomus-set-pitch ] keep
+ fomus-add-note fomus-inc-time
+ ] curry 2each ;
-: fomus-add-chord ( staff chord -- ) f fomus-add-tenor ; inline
+: fomus-add-chord ( staff chord duration -- )
+ [ fomus-set-dur f fomus-add-tenor ] keep fomus-inc-time ; inline
! ___________________
! rendering interface

0 comments on commit 8600963

Please sign in to comment.