Hi,
As I'm sure you've noticed, you are running out of memory ;)
In general you want to avoid large lists in Scheme. You are creating a very large list when you define melody. So your problems aren't really with the string, but instead are with the creation of the list 'melody'. A better approach is to simply read the characters straight out of the string and avoid making the melody list. Like this example, which assumes that you have a string defined as 'sequence'.
(define sequence "taatcacacctggtttgt") ;; but much longer
; cycle through the string directly
(define loop_better
(lambda (time dna idx end)
(println 'playing idx)
(if (< idx end)
(let* ((c (string-ref dna idx))
(pitch (- (char->integer c) 24)))
(play-note time fmsynth pitch 80 1000)
(callback (+ time (* *second* 0.02)) 'loop_better
(+ time (* *second* 0.02)) dna (+ idx 1) end))
(println 'done))))
(loop_better (now) sequence 0 (length sequence))
Now FYI this will still cause problems with very large strings, because extempore's scheme interpreter doesn't handle very large string literals particularly well - and they (large string literals) are not a great idea in any case. What you really want is to read the data straight out of an ascii text file. Like this:
;; cycle through an ascii text file
(define loop_best
(lambda (time dnafile idx)
(println 'playing idx dnafile)
(set-input-port dnafile)
(let ((c (read-char)))
(if (eof-object? c)
(begin (println 'done)
(close-input-port dnafile))
(begin
(play-note time fmsynth (- (char->integer c) 24) 80 1000)
(callback (+ time (* *second* 0.02)) 'loop_best
(+ time (* *second* 0.02)) dnafile (+ idx 1)))))))
(loop_best (now) (open-input-file "/tmp/dna.txt") 0)
Now you should be able to make the file "/tmp/dna.txt" as large as you like - fmsynth sonification of the human genome anyone? Remember when you create the txt file that you don't want the start and end quotes (i.e. leave out the ") - just the characters. And no carriage returns, new lines etc., just the sequence characters.
A couple of side notes:
If you want to keep using extempore you are definitely going to want to get precomp working. Maybe send another new email to this list to get some help with that.
Your smaller string example "~900" should work just fine, but is crashing due to a syntax error in your code. What you want is either (println melody) or maybe (println (length melody)). (println (melody)) is a syntax error (note that 'melody' is not a function that you can call). Obviously it would be nicer for extempore to provide a nice friendly error message rather than crashing in flames, so maybe you could add a bug report to github for that one ;)
Just submit the bug with the following example, which is all that is required to reproduce it.
(define sequence "taatcacacctggtttgtttcagagccacatcacaaagatagagaacaacctaggtctccgaagggagcaagggcatcagtgtgctcagttgaaaatcccttgtcaacacctaggtcttatcacatcacaagttccacctcagactctgcagggtgatccaacaaccttaatagaaacattattgttaaaggacagcattagttcacagtcaaacaagcaagattgagaattaaccttggttttgaacttgaacacttaggggattgaagattcaacaaccctaaagcttggggtaaaacattggaaatagttaaaagactaatcacacctggtttgtttcagagccacatcacaaagatagagaacaacctaggtctccgaagggagcaagggcatcagtgtgctcagttgaaaatcccttgtcaacacctaggtcttatcacatcacaagttccacctcagactctgcagggtgatccaacaaccttaatagaaacattattgttaaaggacagcattagttcacagtcaaacaagcaagattgagaattaaccttggttttgaacttgaacacttaggggattgaagattcaacaaccctaaagcttggggtaaaacattggaaatagttaaaagactaatcacacctggtttgtttcagagccacatcacaaagatagagaacaacctaggtctccgaagggagcaagggcatcagtgtgctcagttgaaaatcccttgtcaacacctaggtcttatcacatcacaagttccacctcagactctgcagggtgatccaacaaccttaatagaaacattattgttaaaggacagcattagttcacagtcaaacaagcaagattgagaattaaccttggttttgaacttgaacacttaggggattgaagattcaacaaccctaaagcttggggtaaaacattggaaatagttaaaa")