Building Synthetic Voices | ||
---|---|---|
<<< Previous | Chapter 24. Festival's Scheme Programming Language | Next >>> |
There a number of basic data types in this Scheme, new ones may also be added but only through C++ functions. This basic types are
symbols atoms starting with an alphabetic character. Unlike numbers and strings, they may be used as variables. Examples are
Symbols may be created from strings by using the function interna bcd f6 myfunc
plus cond
In this version of scheme all numbers are doubles, there is no distinction between floats, doubles and ints. Examples are
Numbers evaluate to themselves, that is the value of the atom 2 is the number 2.1
1.4
3.14
345
3456756.4345476
Strings are bounded by the double quote characters ". For example
Strings evaluate to themselves. They may be converted to symbols with the function intern. If they are strings of characaters that represent numbers you can convert a string to a number with the function parse-number. For example"a"
"abc"
"This is a string"
Although you can make symbols from numbers you should not do that.(intern "abc") => abc
(parse-number "3.14") => 3.14
Double quotes may be specified within a string by escaping it with a backslash. Backslashes therefore also require an escape backslash. That is, "ab\"c" contains four characters, a, b, " and c. "ab\\c" also contains four characters, a, b, \ and c. And "ab\\\"c" contains five characters a, b, \, " and c.
Lists start with a left parenthesis and end with a right parenthesis with zero or more s-expression between them. For example
Lists can be made by various functions most notably cons and list. cons returns a list whose first item is the first item in the list, standardly called its car, and whose remainder, standardly called its cdr, is the second argument of cons.(a b c)
()
(b (b d) e)
((the boy) saw (the girl (in (the park))))
(cons 'a '(b c)) => (a b c)
(cons '(a b) '(c d)) => ((a b) c d)
Functions may be applied explicity bu the function apply or more normally as when the appear as the first item in a list to be evaluated. The normal way to define function is using the define function. For example
This binds the function to the variable ftoc. Functions can also be defined anonymously which sometimes is convinient.(define (ftoc temp)
(/ (* (- temp 32) 5) 9))
returns a function.(lambda (temp)
(/ (* (- temp 32) 5) 9))
other internal types are support by Festival's scheme including some inportant object types use for synthesis such as utterances, waveforms, items etc. The are normally printed as in the form
The rpint form is a convinience form only. Enter that string of characters will not allow a reference to that object. The number is unique to that object instance (it is actually the internal address of the object), and can be used visually to note if objects are the same or not.#<Utterance 6234>
#%lt;Wave 1294>
<<< Previous | Home | Next >>> |
Festival's Scheme Programming Language | Up | Functions |