From: Alex Chapman Date: Thu, 16 Apr 2009 03:36:21 +0000 (+1000) Subject: Moving synth and morse from unmaintained to extra X-Git-Tag: 0.94~2132^2~9^2~1 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=4934c49f0880c53ce8381c6620d1b2b62484678b Moving synth and morse from unmaintained to extra --- diff --git a/extra/morse/authors.txt b/extra/morse/authors.txt new file mode 100644 index 0000000000..e9c193bac7 --- /dev/null +++ b/extra/morse/authors.txt @@ -0,0 +1 @@ +Alex Chapman diff --git a/extra/morse/morse-docs.factor b/extra/morse/morse-docs.factor new file mode 100644 index 0000000000..e35967d3e9 --- /dev/null +++ b/extra/morse/morse-docs.factor @@ -0,0 +1,33 @@ +! Copyright (C) 2007 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: morse + +HELP: ch>morse +{ $values + { "ch" "A character that has a morse code translation" } { "str" "A string consisting of zero or more dots and dashes" } } +{ $description "If the given character has a morse code translation, then return that translation, otherwise return an empty string." } ; + +HELP: morse>ch +{ $values + { "str" "A string of dots and dashes that represents a single character in morse code" } { "ch" "The translated character" } } +{ $description "If the given string represents a morse code character, then return that character, otherwise return f" } ; + +HELP: >morse +{ $values + { "str" "A string of ASCII characters which can be translated into morse code" } { "str" "A string in morse code" } } +{ $description "Translates ASCII text into morse code, represented by a series of dots, dashes, and slashes." } +{ $see-also morse> ch>morse } ; + +HELP: morse> +{ $values { "str" "A string of morse code, in which the character '.' represents dots, '-' dashes, ' ' spaces between letters, and ' / ' spaces between words." } { "str" "The ASCII translation of the given string" } } +{ $description "Translates morse code into ASCII text" } +{ $see-also >morse morse>ch } ; + +HELP: play-as-morse* +{ $values { "str" "A string of ascii characters which can be translated into morse code" } { "unit-length" "The length of a dot" } } +{ $description "Plays a string as morse code" } ; + +HELP: play-as-morse +{ $values { "str" "A string of ascii characters which can be translated into morse code" } } +{ $description "Plays a string as morse code" } ; diff --git a/extra/morse/morse-tests.factor b/extra/morse/morse-tests.factor new file mode 100644 index 0000000000..144448917f --- /dev/null +++ b/extra/morse/morse-tests.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2007 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: arrays morse strings tools.test ; + +[ "" ] [ CHAR: \\ ch>morse ] unit-test +[ "..." ] [ CHAR: s ch>morse ] unit-test +[ CHAR: s ] [ "..." morse>ch ] unit-test +[ f ] [ "..--..--.." morse>ch ] unit-test +[ "-- --- .-. ... . / -.-. --- -.. ." ] [ "morse code" >morse ] unit-test +[ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test +[ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test +! [ ] [ "sos" 0.075 play-as-morse* ] unit-test +! [ ] [ "Factor rocks!" play-as-morse ] unit-test diff --git a/extra/morse/morse.factor b/extra/morse/morse.factor new file mode 100644 index 0000000000..2951c96077 --- /dev/null +++ b/extra/morse/morse.factor @@ -0,0 +1,182 @@ +! Copyright (C) 2007, 2008 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs combinators hashtables kernel lists math +namespaces make openal parser-combinators promises sequences +strings symbols synth synth.buffers unicode.case ; +IN: morse + +morse-assoc ( -- assoc ) + morse-codes >hashtable ; + +: morse>ch-assoc ( -- assoc ) + morse-codes [ reverse ] map >hashtable ; + +PRIVATE> + +: ch>morse ( ch -- str ) + ch>lower ch>morse-assoc at* swap "" ? ; + +: morse>ch ( str -- ch ) + morse>ch-assoc at* swap f ? ; + +: >morse ( str -- str ) + [ + [ CHAR: \s , ] [ ch>morse % ] interleave + ] "" make ; + + <+> ; + +LAZY: 'morse-word' ( -- parser ) + 'morse-char' 'char-gap' list-of ; + +LAZY: 'morse-words' ( -- parser ) + 'morse-word' 'word-gap' list-of ; + +PRIVATE> + +: morse> ( str -- str ) + 'morse-words' parse car parsed>> [ + [ + >string morse>ch + ] map >string + ] map [ [ CHAR: \s , ] [ % ] interleave ] "" make ; + + ( -- buffer ) + half-sample-freq <8bit-mono-buffer> ; + +: sine-buffer ( seconds -- id ) + beep-freq swap >sine-wave-buffer + send-buffer id>> ; + +: silent-buffer ( seconds -- id ) + >silent-buffer send-buffer id>> ; + +: make-buffers ( unit-length -- ) + { + [ sine-buffer dot-buffer set ] + [ 3 * sine-buffer dash-buffer set ] + [ silent-buffer intra-char-gap-buffer set ] + [ 3 * silent-buffer letter-gap-buffer set ] + } cleave ; + +: playing-morse ( quot unit-length -- ) + [ + init-openal 1 gen-sources first source set make-buffers + call + source get source-play + ] with-scope ; + +: play-char ( ch -- ) + [ intra-char-gap ] [ + { + { dot-char [ dot ] } + { dash-char [ dash ] } + { word-gap-char [ intra-char-gap ] } + } case + ] interleave ; + +PRIVATE> + +: play-as-morse* ( str unit-length -- ) + [ + [ letter-gap ] [ ch>morse play-char ] interleave + ] swap playing-morse ; + +: play-as-morse ( str -- ) + 0.05 play-as-morse* ; diff --git a/extra/morse/summary.txt b/extra/morse/summary.txt new file mode 100644 index 0000000000..2c1f091a9a --- /dev/null +++ b/extra/morse/summary.txt @@ -0,0 +1 @@ +Converts between text and morse code, and plays morse code. diff --git a/extra/morse/tags.txt b/extra/morse/tags.txt new file mode 100644 index 0000000000..1e107f52e4 --- /dev/null +++ b/extra/morse/tags.txt @@ -0,0 +1 @@ +examples diff --git a/extra/synth/authors.txt b/extra/synth/authors.txt new file mode 100644 index 0000000000..e9c193bac7 --- /dev/null +++ b/extra/synth/authors.txt @@ -0,0 +1 @@ +Alex Chapman diff --git a/extra/synth/buffers/authors.txt b/extra/synth/buffers/authors.txt new file mode 100644 index 0000000000..e9c193bac7 --- /dev/null +++ b/extra/synth/buffers/authors.txt @@ -0,0 +1 @@ +Alex Chapman diff --git a/extra/synth/buffers/buffers.factor b/extra/synth/buffers/buffers.factor new file mode 100644 index 0000000000..b0128ca52a --- /dev/null +++ b/extra/synth/buffers/buffers.factor @@ -0,0 +1,76 @@ +! Copyright (C) 2008 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types combinators kernel locals math math.ranges openal sequences sequences.merged ; +IN: synth.buffers + +TUPLE: buffer sample-freq 8bit? id ; + +: ( sample-freq 8bit? -- buffer ) + f buffer boa ; + +TUPLE: mono-buffer < buffer data ; + +: ( sample-freq 8bit? -- buffer ) + f f mono-buffer boa ; + +: <8bit-mono-buffer> ( sample-freq -- buffer ) t ; +: <16bit-mono-buffer> ( sample-freq -- buffer ) f ; + +TUPLE: stereo-buffer < buffer left-data right-data ; + +: ( sample-freq 8bit? -- buffer ) + f f f stereo-buffer boa ; + +: <8bit-stereo-buffer> ( sample-freq -- buffer ) t ; +: <16bit-stereo-buffer> ( sample-freq -- buffer ) f ; + +PREDICATE: 8bit-buffer < buffer 8bit?>> ; +PREDICATE: 16bit-buffer < buffer 8bit?>> not ; +INTERSECTION: 8bit-mono-buffer 8bit-buffer mono-buffer ; +INTERSECTION: 16bit-mono-buffer 16bit-buffer mono-buffer ; +INTERSECTION: 8bit-stereo-buffer 8bit-buffer stereo-buffer ; +INTERSECTION: 16bit-stereo-buffer 16bit-buffer stereo-buffer ; + +GENERIC: buffer-format ( buffer -- format ) +M: 8bit-mono-buffer buffer-format drop AL_FORMAT_MONO8 ; +M: 16bit-mono-buffer buffer-format drop AL_FORMAT_MONO16 ; +M: 8bit-stereo-buffer buffer-format drop AL_FORMAT_STEREO8 ; +M: 16bit-stereo-buffer buffer-format drop AL_FORMAT_STEREO16 ; + +: 8bit-buffer-data ( seq -- data size ) + [ 128 * >integer 128 + ] uchar-array{ } map-as [ underlying>> ] [ length ] bi ; + +: 16bit-buffer-data ( seq -- data size ) + [ 32768 * >integer ] short-array{ } map-as [ underlying>> ] [ byte-length ] bi ; + +: stereo-data ( stereo-buffer -- left right ) + [ left-data>> ] [ right-data>> ] bi@ ; + +: interleaved-stereo-data ( stereo-buffer -- data ) + stereo-data <2merged> ; + +GENERIC: buffer-data ( buffer -- data size ) +M: 8bit-mono-buffer buffer-data data>> 8bit-buffer-data ; +M: 16bit-mono-buffer buffer-data data>> 16bit-buffer-data ; +M: 8bit-stereo-buffer buffer-data + interleaved-stereo-data 8bit-buffer-data ; +M: 16bit-stereo-buffer buffer-data + interleaved-stereo-data 16bit-buffer-data ; + +: telephone-sample-freq 8000 ; +: half-sample-freq 22050 ; +: cd-sample-freq 44100 ; +: digital-sample-freq 48000 ; +: professional-sample-freq 88200 ; + +: send-buffer ( buffer -- buffer ) + { + [ gen-buffer dup [ >>id ] dip ] + [ buffer-format ] + [ buffer-data ] + [ sample-freq>> alBufferData ] + } cleave ; + +: ?send-buffer ( buffer -- buffer ) + dup id>> [ send-buffer ] unless ; + diff --git a/extra/synth/example/authors.txt b/extra/synth/example/authors.txt new file mode 100644 index 0000000000..e9c193bac7 --- /dev/null +++ b/extra/synth/example/authors.txt @@ -0,0 +1 @@ +Alex Chapman diff --git a/extra/synth/example/example.factor b/extra/synth/example/example.factor new file mode 100644 index 0000000000..747cfb9c86 --- /dev/null +++ b/extra/synth/example/example.factor @@ -0,0 +1,38 @@ +! Copyright (C) 2008 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays kernel namespaces make openal sequences +synth synth.buffers ; +IN: synth.example + +: play-sine-wave ( freq seconds sample-freq -- ) + init-openal + <16bit-mono-buffer> >sine-wave-buffer send-buffer id>> + 1 gen-sources first + [ AL_BUFFER rot set-source-param ] [ source-play ] bi + check-error ; + +: test-instrument1 ( -- harmonics ) + [ + 1 0.5 , + 2 0.125 , + 3 0.0625 , + 4 0.03125 , + ] { } make ; + +: test-instrument2 ( -- harmonics ) + [ + 1 0.25 , + 2 0.25 , + 3 0.25 , + 4 0.25 , + ] { } make ; + +: sine-instrument ( -- harmonics ) + 1 1 1array ; + +: test-note-buffer ( note -- ) + init-openal + test-instrument2 swap cd-sample-freq <16bit-mono-buffer> + >note send-buffer id>> + 1 gen-sources first [ swap queue-buffer ] [ source-play ] bi + check-error ; diff --git a/extra/synth/summary.txt b/extra/synth/summary.txt new file mode 100644 index 0000000000..ece589350d --- /dev/null +++ b/extra/synth/summary.txt @@ -0,0 +1 @@ +Simple sound synthesis using OpenAL. diff --git a/extra/synth/synth.factor b/extra/synth/synth.factor new file mode 100644 index 0000000000..be1e5943af --- /dev/null +++ b/extra/synth/synth.factor @@ -0,0 +1,36 @@ +! Copyright (C) 2008 Alex Chapman +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel locals math math.constants math.functions memoize openal synth.buffers sequences sequences.modified sequences.repeating ; +IN: synth + +MEMO: single-sine-wave ( samples/wave -- seq ) + pi 2 * over / [ * sin ] curry map ; + +: (sine-wave) ( samples/wave n-samples -- seq ) + [ single-sine-wave ] dip ; + +: sine-wave ( sample-freq freq seconds -- seq ) + pick * >integer [ /i ] dip (sine-wave) ; + +: >sine-wave-buffer ( freq seconds buffer -- buffer ) + [ sample-freq>> -rot sine-wave ] keep swap >>data ; + +: >silent-buffer ( seconds buffer -- buffer ) + tuck sample-freq>> * >integer 0 >>data ; + +TUPLE: harmonic n amplitude ; +C: harmonic + +TUPLE: note hz secs ; +C: note + +: harmonic-freq ( note harmonic -- freq ) + n>> swap hz>> * ; + +:: note-harmonic-data ( harmonic note buffer -- data ) + buffer sample-freq>> note harmonic harmonic-freq note secs>> sine-wave + harmonic amplitude>> ; + +: >note ( harmonics note buffer -- buffer ) + dup -roll [ note-harmonic-data ] 2curry map >>data ; + diff --git a/unmaintained/morse/authors.txt b/unmaintained/morse/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/morse/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/morse/morse-docs.factor b/unmaintained/morse/morse-docs.factor deleted file mode 100644 index e35967d3e9..0000000000 --- a/unmaintained/morse/morse-docs.factor +++ /dev/null @@ -1,33 +0,0 @@ -! Copyright (C) 2007 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax ; -IN: morse - -HELP: ch>morse -{ $values - { "ch" "A character that has a morse code translation" } { "str" "A string consisting of zero or more dots and dashes" } } -{ $description "If the given character has a morse code translation, then return that translation, otherwise return an empty string." } ; - -HELP: morse>ch -{ $values - { "str" "A string of dots and dashes that represents a single character in morse code" } { "ch" "The translated character" } } -{ $description "If the given string represents a morse code character, then return that character, otherwise return f" } ; - -HELP: >morse -{ $values - { "str" "A string of ASCII characters which can be translated into morse code" } { "str" "A string in morse code" } } -{ $description "Translates ASCII text into morse code, represented by a series of dots, dashes, and slashes." } -{ $see-also morse> ch>morse } ; - -HELP: morse> -{ $values { "str" "A string of morse code, in which the character '.' represents dots, '-' dashes, ' ' spaces between letters, and ' / ' spaces between words." } { "str" "The ASCII translation of the given string" } } -{ $description "Translates morse code into ASCII text" } -{ $see-also >morse morse>ch } ; - -HELP: play-as-morse* -{ $values { "str" "A string of ascii characters which can be translated into morse code" } { "unit-length" "The length of a dot" } } -{ $description "Plays a string as morse code" } ; - -HELP: play-as-morse -{ $values { "str" "A string of ascii characters which can be translated into morse code" } } -{ $description "Plays a string as morse code" } ; diff --git a/unmaintained/morse/morse-tests.factor b/unmaintained/morse/morse-tests.factor deleted file mode 100644 index 144448917f..0000000000 --- a/unmaintained/morse/morse-tests.factor +++ /dev/null @@ -1,13 +0,0 @@ -! Copyright (C) 2007 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: arrays morse strings tools.test ; - -[ "" ] [ CHAR: \\ ch>morse ] unit-test -[ "..." ] [ CHAR: s ch>morse ] unit-test -[ CHAR: s ] [ "..." morse>ch ] unit-test -[ f ] [ "..--..--.." morse>ch ] unit-test -[ "-- --- .-. ... . / -.-. --- -.. ." ] [ "morse code" >morse ] unit-test -[ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test -[ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test -! [ ] [ "sos" 0.075 play-as-morse* ] unit-test -! [ ] [ "Factor rocks!" play-as-morse ] unit-test diff --git a/unmaintained/morse/morse.factor b/unmaintained/morse/morse.factor deleted file mode 100644 index 2951c96077..0000000000 --- a/unmaintained/morse/morse.factor +++ /dev/null @@ -1,182 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs combinators hashtables kernel lists math -namespaces make openal parser-combinators promises sequences -strings symbols synth synth.buffers unicode.case ; -IN: morse - -morse-assoc ( -- assoc ) - morse-codes >hashtable ; - -: morse>ch-assoc ( -- assoc ) - morse-codes [ reverse ] map >hashtable ; - -PRIVATE> - -: ch>morse ( ch -- str ) - ch>lower ch>morse-assoc at* swap "" ? ; - -: morse>ch ( str -- ch ) - morse>ch-assoc at* swap f ? ; - -: >morse ( str -- str ) - [ - [ CHAR: \s , ] [ ch>morse % ] interleave - ] "" make ; - - <+> ; - -LAZY: 'morse-word' ( -- parser ) - 'morse-char' 'char-gap' list-of ; - -LAZY: 'morse-words' ( -- parser ) - 'morse-word' 'word-gap' list-of ; - -PRIVATE> - -: morse> ( str -- str ) - 'morse-words' parse car parsed>> [ - [ - >string morse>ch - ] map >string - ] map [ [ CHAR: \s , ] [ % ] interleave ] "" make ; - - ( -- buffer ) - half-sample-freq <8bit-mono-buffer> ; - -: sine-buffer ( seconds -- id ) - beep-freq swap >sine-wave-buffer - send-buffer id>> ; - -: silent-buffer ( seconds -- id ) - >silent-buffer send-buffer id>> ; - -: make-buffers ( unit-length -- ) - { - [ sine-buffer dot-buffer set ] - [ 3 * sine-buffer dash-buffer set ] - [ silent-buffer intra-char-gap-buffer set ] - [ 3 * silent-buffer letter-gap-buffer set ] - } cleave ; - -: playing-morse ( quot unit-length -- ) - [ - init-openal 1 gen-sources first source set make-buffers - call - source get source-play - ] with-scope ; - -: play-char ( ch -- ) - [ intra-char-gap ] [ - { - { dot-char [ dot ] } - { dash-char [ dash ] } - { word-gap-char [ intra-char-gap ] } - } case - ] interleave ; - -PRIVATE> - -: play-as-morse* ( str unit-length -- ) - [ - [ letter-gap ] [ ch>morse play-char ] interleave - ] swap playing-morse ; - -: play-as-morse ( str -- ) - 0.05 play-as-morse* ; diff --git a/unmaintained/morse/summary.txt b/unmaintained/morse/summary.txt deleted file mode 100644 index 2c1f091a9a..0000000000 --- a/unmaintained/morse/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Converts between text and morse code, and plays morse code. diff --git a/unmaintained/morse/tags.txt b/unmaintained/morse/tags.txt deleted file mode 100644 index 1e107f52e4..0000000000 --- a/unmaintained/morse/tags.txt +++ /dev/null @@ -1 +0,0 @@ -examples diff --git a/unmaintained/synth/authors.txt b/unmaintained/synth/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/synth/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/synth/buffers/authors.txt b/unmaintained/synth/buffers/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/synth/buffers/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/synth/buffers/buffers.factor b/unmaintained/synth/buffers/buffers.factor deleted file mode 100644 index b0128ca52a..0000000000 --- a/unmaintained/synth/buffers/buffers.factor +++ /dev/null @@ -1,76 +0,0 @@ -! Copyright (C) 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types combinators kernel locals math math.ranges openal sequences sequences.merged ; -IN: synth.buffers - -TUPLE: buffer sample-freq 8bit? id ; - -: ( sample-freq 8bit? -- buffer ) - f buffer boa ; - -TUPLE: mono-buffer < buffer data ; - -: ( sample-freq 8bit? -- buffer ) - f f mono-buffer boa ; - -: <8bit-mono-buffer> ( sample-freq -- buffer ) t ; -: <16bit-mono-buffer> ( sample-freq -- buffer ) f ; - -TUPLE: stereo-buffer < buffer left-data right-data ; - -: ( sample-freq 8bit? -- buffer ) - f f f stereo-buffer boa ; - -: <8bit-stereo-buffer> ( sample-freq -- buffer ) t ; -: <16bit-stereo-buffer> ( sample-freq -- buffer ) f ; - -PREDICATE: 8bit-buffer < buffer 8bit?>> ; -PREDICATE: 16bit-buffer < buffer 8bit?>> not ; -INTERSECTION: 8bit-mono-buffer 8bit-buffer mono-buffer ; -INTERSECTION: 16bit-mono-buffer 16bit-buffer mono-buffer ; -INTERSECTION: 8bit-stereo-buffer 8bit-buffer stereo-buffer ; -INTERSECTION: 16bit-stereo-buffer 16bit-buffer stereo-buffer ; - -GENERIC: buffer-format ( buffer -- format ) -M: 8bit-mono-buffer buffer-format drop AL_FORMAT_MONO8 ; -M: 16bit-mono-buffer buffer-format drop AL_FORMAT_MONO16 ; -M: 8bit-stereo-buffer buffer-format drop AL_FORMAT_STEREO8 ; -M: 16bit-stereo-buffer buffer-format drop AL_FORMAT_STEREO16 ; - -: 8bit-buffer-data ( seq -- data size ) - [ 128 * >integer 128 + ] uchar-array{ } map-as [ underlying>> ] [ length ] bi ; - -: 16bit-buffer-data ( seq -- data size ) - [ 32768 * >integer ] short-array{ } map-as [ underlying>> ] [ byte-length ] bi ; - -: stereo-data ( stereo-buffer -- left right ) - [ left-data>> ] [ right-data>> ] bi@ ; - -: interleaved-stereo-data ( stereo-buffer -- data ) - stereo-data <2merged> ; - -GENERIC: buffer-data ( buffer -- data size ) -M: 8bit-mono-buffer buffer-data data>> 8bit-buffer-data ; -M: 16bit-mono-buffer buffer-data data>> 16bit-buffer-data ; -M: 8bit-stereo-buffer buffer-data - interleaved-stereo-data 8bit-buffer-data ; -M: 16bit-stereo-buffer buffer-data - interleaved-stereo-data 16bit-buffer-data ; - -: telephone-sample-freq 8000 ; -: half-sample-freq 22050 ; -: cd-sample-freq 44100 ; -: digital-sample-freq 48000 ; -: professional-sample-freq 88200 ; - -: send-buffer ( buffer -- buffer ) - { - [ gen-buffer dup [ >>id ] dip ] - [ buffer-format ] - [ buffer-data ] - [ sample-freq>> alBufferData ] - } cleave ; - -: ?send-buffer ( buffer -- buffer ) - dup id>> [ send-buffer ] unless ; - diff --git a/unmaintained/synth/example/authors.txt b/unmaintained/synth/example/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/synth/example/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/synth/example/example.factor b/unmaintained/synth/example/example.factor deleted file mode 100644 index 747cfb9c86..0000000000 --- a/unmaintained/synth/example/example.factor +++ /dev/null @@ -1,38 +0,0 @@ -! Copyright (C) 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays kernel namespaces make openal sequences -synth synth.buffers ; -IN: synth.example - -: play-sine-wave ( freq seconds sample-freq -- ) - init-openal - <16bit-mono-buffer> >sine-wave-buffer send-buffer id>> - 1 gen-sources first - [ AL_BUFFER rot set-source-param ] [ source-play ] bi - check-error ; - -: test-instrument1 ( -- harmonics ) - [ - 1 0.5 , - 2 0.125 , - 3 0.0625 , - 4 0.03125 , - ] { } make ; - -: test-instrument2 ( -- harmonics ) - [ - 1 0.25 , - 2 0.25 , - 3 0.25 , - 4 0.25 , - ] { } make ; - -: sine-instrument ( -- harmonics ) - 1 1 1array ; - -: test-note-buffer ( note -- ) - init-openal - test-instrument2 swap cd-sample-freq <16bit-mono-buffer> - >note send-buffer id>> - 1 gen-sources first [ swap queue-buffer ] [ source-play ] bi - check-error ; diff --git a/unmaintained/synth/summary.txt b/unmaintained/synth/summary.txt deleted file mode 100644 index ece589350d..0000000000 --- a/unmaintained/synth/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Simple sound synthesis using OpenAL. diff --git a/unmaintained/synth/synth.factor b/unmaintained/synth/synth.factor deleted file mode 100644 index be1e5943af..0000000000 --- a/unmaintained/synth/synth.factor +++ /dev/null @@ -1,36 +0,0 @@ -! Copyright (C) 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel locals math math.constants math.functions memoize openal synth.buffers sequences sequences.modified sequences.repeating ; -IN: synth - -MEMO: single-sine-wave ( samples/wave -- seq ) - pi 2 * over / [ * sin ] curry map ; - -: (sine-wave) ( samples/wave n-samples -- seq ) - [ single-sine-wave ] dip ; - -: sine-wave ( sample-freq freq seconds -- seq ) - pick * >integer [ /i ] dip (sine-wave) ; - -: >sine-wave-buffer ( freq seconds buffer -- buffer ) - [ sample-freq>> -rot sine-wave ] keep swap >>data ; - -: >silent-buffer ( seconds buffer -- buffer ) - tuck sample-freq>> * >integer 0 >>data ; - -TUPLE: harmonic n amplitude ; -C: harmonic - -TUPLE: note hz secs ; -C: note - -: harmonic-freq ( note harmonic -- freq ) - n>> swap hz>> * ; - -:: note-harmonic-data ( harmonic note buffer -- data ) - buffer sample-freq>> note harmonic harmonic-freq note secs>> sine-wave - harmonic amplitude>> ; - -: >note ( harmonics note buffer -- buffer ) - dup -roll [ note-harmonic-data ] 2curry map >>data ; -