[SCM] csound/master: Imported Upstream version 5.17.6~dfsg
fsateler at users.alioth.debian.org
fsateler at users.alioth.debian.org
Thu Apr 19 12:52:36 UTC 2012
The following commit has been merged in the master branch:
commit 5a6d920cdd789ca82b7b52c896e43ae19d79e85d
Author: Felipe Sateler <fsateler at debian.org>
Date: Wed Apr 18 18:47:52 2012 -0300
Imported Upstream version 5.17.6~dfsg
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4837a61..29cdb31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -263,6 +263,11 @@ find_package(OpenMP)
# First, required stuff
find_library(LIBSNDFILE_LIBRARY sndfile)
+
+if(NOT LIBSNDFILE_LIBRARY AND WIN32)
+find_library(LIBSNDFILE_LIBRARY sndfile-1)
+endif()
+
if(NOT LIBSNDFILE_LIBRARY)
message(FATAL_ERROR "Csound requires the sndfile library")
endif()
@@ -339,8 +344,12 @@ endif()
check_deps(USE_OPEN_MP OPENMP_FOUND PTHREAD_BARRIER_INIT_EXISTS)
if(USE_OPEN_MP)
list(APPEND libcsound_CFLAGS -DUSE_OPENMP)
- list(APPEND CMAKE_C_FLAGS ${OpenMP_C_FLAGS})
- list(APPEND CMAKE_CXX_FLAGS ${OpenMP_CXX_FLAGS})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
+
endif()
diff --git a/Doxyfile b/Doxyfile
index e4e25fd..b1789bd 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -1,1522 +1,1522 @@
-# Doxyfile 1.5.8
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = "Csound and CsoundAC API"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER = 5.14
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = doc
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
-# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
-# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
-# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene,
-# Spanish, Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF = NO
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = YES
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
-
-JAVADOC_AUTOBRIEF = YES
-
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
-
-QT_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 4
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
-
-OPTIMIZE_FOR_FORTRAN = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
-
-OPTIMIZE_OUTPUT_VHDL = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it parses.
-# With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this tag.
-# The format is ext=language, where ext is a file extension, and language is one of
-# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
-# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
-# use: inc=Fortran f=C
-
-EXTENSION_MAPPING = YES
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = YES
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
-
-SIP_SUPPORT = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate getter
-# and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
-# documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
-
-IDL_PROPERTY_SUPPORT = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-TYPEDEF_HIDES_STRUCT = NO
-
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
-
-SYMBOL_CACHE_SIZE = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
-
-EXTRACT_ANON_NSPACES = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = YES
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
-
-SORT_GROUP_NAMES = YES
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = YES
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = NO
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = YES
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
-
-SHOW_FILES = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page.
-# This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
-
-SHOW_NAMESPACES = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
-# doxygen. The layout file controls the global structure of the generated output files
-# in an output format independent way. The create the layout file that represents
-# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
-# file name after the option, if omitted DoxygenLayout.xml will be used as the name
-# of the layout file.
-
-LAYOUT_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = H \
- interfaces \
- frontends/CsoundVST \
- frontends/CsoundAC \
- frontends/tclcsound
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS = *.h \
- *.hh \
- *.hxx \
- *.hpp \
- *.h++
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS = AEff* \
- aeff* \
- AudioEff* \
- audioeff* \
- *wrap*
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output.
-# If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis.
-# Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match.
-# The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.
-# Otherwise they will link to the documentation.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = YES
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS = YES
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
-
-GENERATE_DOCSET = NO
-
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
-
-DOCSET_FEEDNAME = "Doxygen generated docs"
-
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
-
-DOCSET_BUNDLE_ID = org.doxygen.Project
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
-
-CHM_INDEX_ENCODING =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
-# are set, an additional index file will be generated that can be used as input for
-# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
-# HTML documentation.
-
-GENERATE_QHP = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
-
-QCH_FILE =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
-
-QHP_NAMESPACE =
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
-
-QHP_VIRTUAL_FOLDER = doc
-
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
-# For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
-
-QHP_CUST_FILTER_NAME =
-
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
-
-QHP_CUST_FILTER_ATTRS =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
-# filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
-
-QHP_SECT_FILTER_ATTRS =
-
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
-
-QHG_LOCATION =
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to FRAME, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature. Other possible values
-# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list;
-# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
-# disables this behavior completely. For backwards compatibility with previous
-# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
-# respectively.
-
-GENERATE_TREEVIEW = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
-
-FORMULA_FONTSIZE = 10
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = pdflatex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = letter
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER = refman_header.tex
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = YES
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader.
-# This is useful
-# if you want to understand what is going on.
-# On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-#
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-#
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = NO
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = YES
-
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
-
-DOT_FONTNAME = FreeSans
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
-
-DOT_FONTSIZE = 10
-
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
-
-DOT_FONTPATH =
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = NO
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = NO
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = NO
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH = D:\utah\opt\ATT\Graphviz\bin
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
-
-DOT_TRANSPARENT = YES
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = YES
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = NO
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Options related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
+# Doxyfile 1.5.8
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "Csound and CsoundAC API"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = 5.17
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
+# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene,
+# Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = NO
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = YES
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C
+
+EXTENSION_MAPPING = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = YES
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = YES
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = YES
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = NO
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = H \
+ interfaces \
+ frontends/CsoundVST \
+ frontends/CsoundAC \
+ frontends/tclcsound
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS = *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS = AEff* \
+ aeff* \
+ AudioEff* \
+ audioeff* \
+ *wrap*
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = YES
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to FRAME, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature. Other possible values
+# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list;
+# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
+# disables this behavior completely. For backwards compatibility with previous
+# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
+# respectively.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = pdflatex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = letter
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER = refman_header.tex
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = YES
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = NO
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = NO
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = NO
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH = D:\utah\opt\ATT\Graphviz\bin
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = NO
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Options related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
diff --git a/Engine/corfiles.c b/Engine/corfiles.c
index f4d2447..5fc130b 100644
--- a/Engine/corfiles.c
+++ b/Engine/corfiles.c
@@ -24,6 +24,7 @@
#include "csoundCore.h" /* CORFILES.C */
#include <string.h>
#include <stdio.h>
+#include <ctype.h>
extern int csoundFileClose(CSOUND*, void*);
@@ -48,19 +49,33 @@ CORFIL *corfile_create_r(const char *text)
void corfile_putc(int c, CORFIL *f)
{
- if (f->p+1 >= f->len)
+ f->body[f->p++] = c;
+ if (f->p >= f->len)
f->body = (char*) realloc(f->body, f->len+=100);
- f->body[f->p] = c;
- f->body[++f->p] = '\0';
+ f->body[f->p] = '\0';
}
void corfile_puts(char *s, CORFIL *f)
{
- int slen = strlen(s);
- while (f->p+slen+1>=f->len)
- f->body = (char*) realloc(f->body, f->len+=100);
- strcat(f->body, s);
- f->p += slen;
+ char *c;
+ int n;
+ /* skip and count the NUL chars to the end */
+ for (n=0; f->p > 0 && f->body[f->p-1] == '\0'; n++, f->p--);
+ /* append the string */
+ for (c = s; *c != '\0'; c++) {
+ f->body[f->p++] = *c;
+ if (f->p >= f->len)
+ f->body = (char*) realloc(f->body, f->len+=100);
+ }
+ if (n > 0) {
+ /* put the extra NUL chars to the end */
+ while (--n >= 0) {
+ f->body[f->p++] = '\0';
+ if (f->p >= f->len)
+ f->body = (char*) realloc(f->body, f->len+=100);
+ }
+ }
+ f->body[f->p] = '\0';
}
void corfile_flush(CORFIL *f)
@@ -102,14 +117,10 @@ void corfile_ungetc(CORFIL *f)
MYFLT corfile_get_flt(CORFIL *f)
{
- int n;
+ int n = f->p;
MYFLT ans;
-#ifdef USE_DOUBLE
- sscanf(&f->body[f->p], "%lf%n", &ans, &n);
-#else
- sscanf(&f->body[f->p], "%f%n", &ans, &n);
-#endif
- f->p += n;
+ while (!isspace(f->body[++f->p]));
+ ans = (MYFLT) atof(&f->body[n]);
return ans;
}
diff --git a/Engine/cs_par_base.c b/Engine/cs_par_base.c
index c2e2773..27dec6f 100644
--- a/Engine/cs_par_base.c
+++ b/Engine/cs_par_base.c
@@ -215,7 +215,7 @@ void csp_barrier_dealloc(CSOUND *csound, pthread_barrier_t **barrier)
//{
// /* int val, res; */
// /* res = sem_getvalue(sem, &val); */
-// /* csound->DebugMsg(csound, "before sem_grow: %d %i\t",
+// /* csound->DebugMsg(csound, "before sem_grow: %d %i\t",
// val, csp_thread_index_get(csound)); */
// sem_post(sem);
// /* res = sem_getvalue(sem, &val); */
@@ -249,7 +249,7 @@ void csp_barrier_dealloc(CSOUND *csound, pthread_barrier_t **barrier)
//void csp_semaphore_release_print(CSOUND *csound, sem_t *sem)
//{
// int val, res;
-// if (UNLIKELY(sem == NULL))
+// if (UNLIKELY(sem == NULL))
// csound->Die(csound, "Invalid NULL Parameter sem");
// res = sem_getvalue(sem, &val);
// csound->DebugMsg(csound, "sem_release_print: %d %p\n",
@@ -260,18 +260,16 @@ void csp_barrier_dealloc(CSOUND *csound, pthread_barrier_t **barrier)
/***********************************************************************
* set data structure
*/
-#pragma mark -
-#pragma mark Set
/* static prototypes */
-static int set_element_delloc(CSOUND *csound,
+static int set_element_delloc(CSOUND *csound,
struct set_element_t **set_element);
static int set_element_alloc(CSOUND *csound,
- struct set_element_t **set_element,
+ struct set_element_t **set_element,
char *data);
static int set_is_set(CSOUND *csound, struct set_t *set);
#if 0
-static int
+static int
set_element_is_set_element(CSOUND *csound,
struct set_element_t *set_element);
#endif
@@ -358,7 +356,7 @@ static int set_is_set(CSOUND *csound, struct set_t *set)
}
#if 0
-static int
+static int
set_element_is_set_element(CSOUND *csound,
struct set_element_t *set_element)
{
@@ -410,7 +408,7 @@ static int set_update_cache(CSOUND *csound, struct set_t *set)
if (set->count > 0) {
struct set_element_t *ele;
int ctr = 0;
- set->cache =
+ set->cache =
csound->Malloc(csound,
sizeof(struct set_element_t *) * set->count);
ele = set->head;
diff --git a/Engine/cs_par_dispatch.c b/Engine/cs_par_dispatch.c
index ecd8b2d..eeba3c6 100644
--- a/Engine/cs_par_dispatch.c
+++ b/Engine/cs_par_dispatch.c
@@ -91,8 +91,6 @@ static uint32_t hash_string(char *str, uint32_t hash_size)
/***********************************************************************
* Global Var Lock Inserts
*/
-#pragma mark -
-#pragma mark Global Var Lock Inserts
/* global variables lock support */
struct global_var_lock_t {
@@ -154,7 +152,7 @@ static struct global_var_lock_t *global_var_lock_alloc(CSOUND *csound,
return ret;
}
-static struct global_var_lock_t
+static struct global_var_lock_t
*global_var_lock_find(CSOUND *csound, char *name)
{
if (UNLIKELY(name == NULL))
@@ -328,7 +326,7 @@ void csp_locks_cache_build(CSOUND *csound)
/* csound->Message(csound, "Global Locks Cache\n");
ctr = 0;
while (ctr < csound->global_var_lock_count) {
- csound->Message(csound, "[%i] %s\n",
+ csound->Message(csound, "[%i] %s\n",
csound->global_var_lock_cache[ctr]->index,
csound->global_var_lock_cache[ctr]->name);
ctr++;
@@ -353,10 +351,8 @@ int globalunlock(CSOUND *csound, GLOBAL_LOCK_UNLOCK *p)
/***********************************************************************
* weighting
*/
-#pragma mark -
-#pragma mark Instr weightings
-/* static struct instr_weight_info_t
+/* static struct instr_weight_info_t
*instr_weight_info_alloc(CSOUND *csound)
{
struct instr_weight_info_t *ret =
@@ -379,10 +375,10 @@ static void csp_weights_calculate_instr(CSOUND *csound, TREE *root,
TREE *current = root;
INSTR_SEMANTICS *nested_instr = NULL;
- while(current != NULL) {
+ while (current != NULL) {
switch(current->type) {
case INSTR_TOKEN:
- nested_instr =
+ nested_instr =
csp_orc_sa_instr_get_by_name(csound,
current->left->value->lexeme);
/* if (nested_instr->weight == NULL) {
@@ -430,7 +426,7 @@ void csp_weights_calculate(CSOUND *csound, TREE *root)
TREE *current = root;
INSTR_SEMANTICS *instr = NULL;
- while(current != NULL) {
+ while (current != NULL) {
switch(current->type) {
case INSTR_TOKEN:
if (current->left->type == T_INSTLIST) {
@@ -475,7 +471,7 @@ static void csp_orc_sa_opcode_dump_instr(CSOUND *csound, TREE *root)
{
TREE *current = root;
- while(current != NULL) {
+ while (current != NULL) {
switch(current->type) {
case INSTR_TOKEN:
break;
@@ -504,8 +500,8 @@ void csp_orc_sa_opcode_dump(CSOUND *csound, TREE *root)
TREE *current = root;
- while(current != NULL) {
- switch(current->type) {
+ while (current != NULL) {
+ switch (current->type) {
case INSTR_TOKEN:
csp_orc_sa_opcode_dump_instr(csound, current->right);
break;
@@ -524,8 +520,6 @@ void csp_orc_sa_opcode_dump(CSOUND *csound, TREE *root)
/***********************************************************************
* weights structure
*/
-#pragma mark -
-#pragma mark weights structure
struct opcode_weight_cache_entry_t {
uint32_t hash_val;
@@ -547,7 +541,7 @@ struct opcode_weight_cache_entry_t {
static void opcode_weight_entry_add(CSOUND *csound,
char *name, uint32_t weight);
-static int
+static int
opcode_weight_entry_alloc(CSOUND *csound,
struct opcode_weight_cache_entry_t **entry,
char *name, uint32_t weight, uint32_t hash_val)
@@ -575,7 +569,7 @@ static int
}
#if 0
-static int
+static int
opcode_weight_entry_dealloc(CSOUND *csound,
struct opcode_weight_cache_entry_t **entry)
{
@@ -915,8 +909,6 @@ void csp_weights_load(CSOUND *csound)
/***********************************************************************
* weighting decision
*/
-#pragma mark -
-#pragma mark dag weighting decision
/* static struct instr_weight_info_t *weight_info; */
@@ -996,8 +988,6 @@ int inline csp_parallel_compute_should(CSOUND *csound, DAG *dag)
/***********************************************************************
* dag2 data structure
*/
-#pragma mark -
-#pragma mark Dag2
/* prototypes for dag2 */
static void dag_node_2_alloc(CSOUND *csound, DAG_NODE **dag_node,
@@ -1155,7 +1145,7 @@ void csp_dag_add(CSOUND *csound, DAG *dag,
dag_node_2_alloc(csound, &dag_node, instr, insds);
TRACE_1("dag->count = %d\n", dag->count);
- // dag->all =
+ // dag->all =
// (DAG_NODE **)csound->Malloc(csound,
// sizeof(DAG_NODE *) * (dag->count + 1));
/* Can not this be done with memcpy or Realloc */
@@ -1305,7 +1295,7 @@ inline static void csp_dag_build_edges(CSOUND *csound, DAG *dag)
}
csp_set_dealloc(csound, &write_intersection);
- /* csound->Message(csound,
+ /* csound->Message(csound,
"write_intersection depends: %i\n", depends);
csp_set_print(csound, dag->all[dag_root_ctr]->instr->write);
csp_set_print(csound, dag->all[dag_curr_ctr]->instr->read); */
@@ -1348,14 +1338,14 @@ inline static void csp_dag_build_edges(CSOUND *csound, DAG *dag)
}
csp_set_dealloc(csound, &readwrite_write_intersection);
- /* csound->Message(csound,
+ /* csound->Message(csound,
"readwrite_write_intersection depends: %i\n",
depends);
csp_set_print(csound, dag->all[dag_root_ctr]->instr->read_write);
csp_set_print(csound, dag->all[dag_curr_ctr]->instr->write); */
struct set_t *readwrite_read_intersection = NULL;
- csp_set_intersection(csound,
+ csp_set_intersection(csound,
dag->all[dag_root_ctr]->instr->read_write,
dag->all[dag_curr_ctr]->instr->read,
&readwrite_read_intersection);
@@ -1367,7 +1357,7 @@ inline static void csp_dag_build_edges(CSOUND *csound, DAG *dag)
/* csound->Message(csound,
"readwrite_read_intersection depends: %i\n",
depends);
- csp_set_print(csound,
+ csp_set_print(csound,
dag->all[dag_root_ctr]->instr->read_write);
csp_set_print(csound, dag->all[dag_curr_ctr]->instr->write); */
@@ -1380,11 +1370,11 @@ inline static void csp_dag_build_edges(CSOUND *csound, DAG *dag)
}
csp_set_dealloc(csound, &read_readwrite_intersection);
- /* csound->Message(csound,
+ /* csound->Message(csound,
"read_readwrite_intersection depends: %i\n",
depends);
csp_set_print(csound, dag->all[dag_root_ctr]->instr->read);
- csp_set_print(csound,
+ csp_set_print(csound,
dag->all[dag_curr_ctr]->instr->read_write); */
struct set_t *write_readwrite_intersection = NULL;
@@ -1418,7 +1408,7 @@ inline static void csp_dag_build_edges(CSOUND *csound, DAG *dag)
"readwrite_readwrite_intersection depends: %i\n",
depends);
csp_set_print(csound, dag->all[dag_root_ctr]->instr->read_write);
- csp_set_print(csound,
+ csp_set_print(csound,
dag->all[dag_curr_ctr]->instr->read_write); */
if (depends & DAG_STRONG_LINK) {
@@ -1863,8 +1853,6 @@ void csp_dag_print(CSOUND *csound, DAG *dag)
/**********************************************************************************************
* dag2 optimization structure
*/
-#pragma mark -
-#pragma mark Dag2 optimization
static uint64_t dag_opt_counter;
@@ -2189,8 +2177,6 @@ void csp_dag_optimization(CSOUND *csound, DAG *dag)
/**********************************************************************************************
* dag2 cache structure
*/
-#pragma mark -
-#pragma mark Dag2 Cache
/* #ifdef LINEAR_CACHE */
diff --git a/Engine/csound_orc.l b/Engine/csound_orc.l
index 1f78d28..eebaa1c 100644
--- a/Engine/csound_orc.l
+++ b/Engine/csound_orc.l
@@ -81,14 +81,14 @@ LABEL ^[ \t]*[a-zA-Z0-9_][a-zA-Z0-9_]*:
IDENT [a-zA-Z_][a-zA-Z0-9_]*
IDENTN [a-zA-Z0-9_]+
INTGR [0-9]+
-NUMBER [0-9]+\.?[0-9]*(e[-+]?[0-9]+)?|\.[0-9]+(e[-+]?[0-9]+)?
+NUMBER [0-9]+\.?[0-9]*(e[-+]?[0-9]+)?|\.[0-9]+(e[-+]?[0-9]+)?|0[xX][0-9a-fA-F]+
WHITE [ \t]+
OPTWHITE [ \t]*
CONT \\[ \t]*(;.*)?\n
XSTR "{{"
EXSTR "}}"
-LINE ^"#line"
-FILE ^"#source"
+LINE ^[ \t]*"#line"
+FILE ^[ \t]*"#source"
FNAME [a-zA-Z0-9/:.+-_]+
%x line
%x src
@@ -237,17 +237,18 @@ FNAME [a-zA-Z0-9/:.+-_]+
PARM->xstrmax+=80);
csound->DebugMsg(csound,"Extending xstr buffer\n");
}
-// csound->DebugMsg(csound,"Adding newline (%.2x)\n", yytext[0]);
+ //csound->DebugMsg(csound,"Adding newline (%.2x)\n", yytext[0]);
PARM->xstrbuff[PARM->xstrptr++] = yytext[0];
PARM->xstrbuff[PARM->xstrptr] = '\0';
}
-<xstr>. { if (PARM->xstrptr+2==PARM->xstrmax) {
+<xstr>"\r" { }
+<xstr>. { if (PARM->xstrptr+2==PARM->xstrmax) {
PARM->xstrbuff = (char *)realloc(PARM->xstrbuff,
PARM->xstrmax+=80);
csound->DebugMsg(csound,"Extending xstr buffer\n");
}
-// csound->DebugMsg(csound,"Adding (%.2x)\n", yytext[0]);
+ //csound->DebugMsg(csound,"Adding (%.2x)\n", yytext[0]);
PARM->xstrbuff[PARM->xstrptr++] = yytext[0];
PARM->xstrbuff[PARM->xstrptr] = '\0';
}
@@ -478,6 +479,6 @@ char *csound_orcget_current_pointer(void *yyscanner)
int csound_orcget_locn(void *yyscanner)
{
- struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
+// struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
return PARM->locn;
}
diff --git a/Engine/csound_orc.y b/Engine/csound_orc.y
index 045abbc..259a4cb 100644
--- a/Engine/csound_orc.y
+++ b/Engine/csound_orc.y
@@ -178,7 +178,8 @@ extern int csound_orcget_lineno(void *);
orcfile : rootstatement
{
- *astTree = *((TREE *)$1);
+ if ($1 != NULL)
+ *astTree = *((TREE *)$1);
csound->synterrcnt = csound_orcnerrs;
//print_tree(csound, "ALL", $1);
}
@@ -600,7 +601,7 @@ bexpr : '(' bexpr ')' { $$ = $2; }
| bexpr S_OR error
| '!' bexpr %prec S_UNOT { $$ = make_node(csound, LINE,LOCN,
S_UNOT, $2, NULL); }
- | '!' error { $$ = NULL }
+ | '!' error { $$ = NULL; }
;
expr : bexpr '?' expr ':' expr %prec '?'
@@ -620,12 +621,12 @@ iexp : iexp '+' iexp { $$ = make_node(csound, LINE,LOCN, '+', $1, $3); }
{
$$ = make_node(csound,LINE,LOCN, S_UMINUS, NULL, $2);
}
- | '-' error { $$ = NULL }
+ | '-' error { $$ = NULL; }
| '+' iexp %prec S_UMINUS
{
$$ = $2;
}
- | '+' error { $$ = NULL }
+ | '+' error { $$ = NULL; }
| iterm { $$ = $1; }
;
@@ -662,10 +663,10 @@ ifac : ident { $$ = $1; }
| iexp S_BITSHIFT_RIGHT error
| '~' iexp %prec S_UMINUS
{ $$ = make_node(csound, LINE,LOCN, '~', NULL, $2);}
- | '~' error { $$ = NULL }
+ | '~' error { $$ = NULL; }
| '(' expr ')' { $$ = $2; }
- | '(' expr error { $$ = NULL }
- | '(' error { $$ = NULL }
+ | '(' expr error { $$ = NULL; }
+ | '(' error { $$ = NULL; }
| function '(' exprlist ')'
{
$1->left = NULL;
diff --git a/Engine/csound_orc_compile.c b/Engine/csound_orc_compile.c
index e71f426..f68152a 100644
--- a/Engine/csound_orc_compile.c
+++ b/Engine/csound_orc_compile.c
@@ -162,7 +162,7 @@ static void lblrequest(CSOUND *csound, char *s)
static inline void resetouts(CSOUND *csound)
{
- csound->acount = csound->kcount = csound->icount =
+ csound->acount = csound->kcount = csound->icount =
csound->Bcount = csound->bcount = 0;
}
@@ -489,9 +489,9 @@ OPTXT *create_opcode(CSOUND *csound, TREE *root, INSTRTXT *ip)
}
/* VL 14/12/11 : calling lgbuild here seems to be problematic for
undef arg checks */
- else {
- lgbuild(csound, arg, 1);
- }
+ else {
+ lgbuild(csound, arg, 1);
+ }
}
@@ -533,7 +533,7 @@ OPTXT *create_opcode(CSOUND *csound, TREE *root, INSTRTXT *ip)
// csound->Message(csound, "Opcode InTypes: %s\n", ep->intypes);
// csound->Message(csound, "Opcode OutTypes: %s\n", ep->outypes);
-
+
set_xincod(csound, tp, ep, root->line);
set_xoutcod(csound, tp, ep, root->line);
@@ -842,7 +842,7 @@ void close_instrument(CSOUND *csound, INSTRTXT * ip)
ip->lclkcnt = (ip->lclkcnt + 1) & (~1);
}
- ip->lclfixed = ip->lclkcnt +
+ ip->lclfixed = ip->lclkcnt +
ip->lclwcnt * Wfloats * ip->lclpcnt * Pfloats;*/
ip->mdepends = ip->mdepends >> 4;
@@ -931,7 +931,7 @@ void insert_instrtxt(CSOUND *csound, INSTRTXT *instrtxt, int32 instrNum) {
csound->instrtxtp[instrNum] = instrtxt;
}
-OPCODINFO *find_opcode_info(CSOUND *csound, char *opname)
+OPCODINFO *find_opcode_info(CSOUND *csound, char *opname)
{
OPCODINFO *opinfo = csound->opcodeInfo;
if (UNLIKELY(opinfo == NULL)) {
@@ -953,7 +953,7 @@ OPCODINFO *find_opcode_info(CSOUND *csound, char *opname)
/**
* Compile the given TREE node into structs for Csound to use
*/
-void csound_orc_compile(CSOUND *csound, TREE *root)
+void csound_orc_compile(CSOUND *csound, TREE *root)
{
// csound->Message(csound, "Begin Compiling AST (Currently Implementing)\n");
@@ -1218,7 +1218,7 @@ void csound_orc_compile(CSOUND *csound, TREE *root)
csound->DebugMsg(csound, "Instr 0 check on opcode=%s\n", bp->t.opcod);
if (UNLIKELY((thread = csound->opcodlst[opnum].thread) & 06 ||
(!thread && bp->t.pftype != 'b'))) {
- csound->DebugMsg(csound, "***opcode=%s thread=%d pftype=%c\n",
+ csound->DebugMsg(csound, "***opcode=%s thread=%d pftype=%c\n",
bp->t.opcod, thread, bp->t.pftype);
synterr(csound, Str("perf-pass statements illegal in header blk\n"));
}
@@ -1826,7 +1826,7 @@ char argtyp2(CSOUND *csound, char *s)
{ /* find arg type: d, w, a, k, i, c, p, r, S, B, b, t */
char c = *s; /* also set lgprevdef if !c && !p && !S */
- /* VL: added this to make sure the object exists before we try to read
+ /* VL: added this to make sure the object exists before we try to read
from it */
if (UNLIKELY(csound->otranGlobals == NULL)) {
csound->otranGlobals = csound->Calloc(csound, sizeof(OTRAN_GLOBALS));
@@ -1882,4 +1882,3 @@ int file_to_int(CSOUND *csound, const char *name)
}
return n;
}
-
diff --git a/Engine/csound_orc_semantics.c b/Engine/csound_orc_semantics.c
index 400e854..413c94a 100644
--- a/Engine/csound_orc_semantics.c
+++ b/Engine/csound_orc_semantics.c
@@ -90,7 +90,7 @@ static TREE * optimize_ifun(CSOUND *csound, TREE *root)
}
/** Verifies and optimise; constant fold and opcodes and args are correct*/
-static TREE * verify_tree1(CSOUND *csound, TREE *root)
+static TREE * verify_tree1(CSOUND *csound, TREE *root)
{
TREE *ans, *last;
double lval, rval;
@@ -110,7 +110,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
last = last->next;
}
}
- if (root->right->type == T_FUNCTION &&
+ if (root->right->type == T_FUNCTION &&
(strcmp(root->right->value->lexeme, "i") == 0)) { /* i() function */
root->right = optimize_ifun(csound, root->right);
}
@@ -121,7 +121,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
}
root->right = verify_tree1(csound, root->right);
if (root->left) {
- if (root->left->type == T_FUNCTION &&
+ if (root->left->type == T_FUNCTION &&
(strcmp(root->left->value->lexeme, "i") == 0)) { /* i() function */
root->left = optimize_ifun(csound, root->left);
}
@@ -145,7 +145,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
(char*)mrealloc(csound, ans->value->lexeme, 24);
sprintf(ans->value->lexeme, "%f", ans->value->fvalue);
ans->next = root->next;
- //Memory leak!!
+ //Memory leak!!
//mfree(csound, root); mfree(csound root->right);
return ans;
case '-':
@@ -154,7 +154,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
(char*)mrealloc(csound, ans->value->lexeme, 24);
sprintf(ans->value->lexeme, "%f", ans->value->fvalue);
ans->next = root->next;
- //Memory leak!!
+ //Memory leak!!
//mfree(csound, root); mfree(csound, root->right);
return ans;
case '*':
@@ -163,7 +163,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
(char*)mrealloc(csound, ans->value->lexeme, 24);
sprintf(ans->value->lexeme, "%f", ans->value->fvalue);
ans->next = root->next;
- //Memory leak!!
+ //Memory leak!!
//mfree(csound, root); mfree(csound, root->right);
return ans;
case '/':
@@ -172,7 +172,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
(char*)mrealloc(csound, ans->value->lexeme, 24);
sprintf(ans->value->lexeme, "%f", ans->value->fvalue);
ans->next = root->next;
- //Memory leak!!
+ //Memory leak!!
//mfree(csound, root); mfree(csound, root->right);
return ans;
/* case S_NEQ: */
@@ -218,7 +218,7 @@ static TREE * verify_tree1(CSOUND *csound, TREE *root)
return root;
}
-TREE * verify_tree(CSOUND *csound, TREE *root)
+TREE * verify_tree(CSOUND *csound, TREE *root)
{
TREE *original=root, *last = NULL;
while (root) {
@@ -260,7 +260,7 @@ void csound_orcerror(PARSE_PARM *pp, void *yyscanner,
/* csound->Message(csound, Str("error: %s (\"\\n\")"), */
/* str); */
/* csound->Message(csound, Str(" line %d:\n>>> "), */
- /* csound_orcget_lineno(yyscanner)); */
+ /* csound_orcget_lineno(yyscanner)); */
/* } */
/* else { */
/* csound->Message(csound, Str("\nerror: %s (token \"%s\")"), */
diff --git a/Engine/csound_pre.lex b/Engine/csound_pre.lex
index f006634..22d0c3e 100644
--- a/Engine/csound_pre.lex
+++ b/Engine/csound_pre.lex
@@ -75,8 +75,8 @@ DEFINE #[ \t]*define
UNDEF "#undef"
IFDEF #ifn?def
ELSE #else[ \t]*(;.*)?$
-END #end(if)?[ \t]*(;.*)?\n
-CONT \\[ \t]*(;.*)?\n
+END #end(if)?[ \t]*(;.*)?(\n|\r\n?)
+CONT \\[ \t]*(;.*)?(\n|\r\n?)
%x incl
%x macro
@@ -219,6 +219,7 @@ CONT \\[ \t]*(;.*)?\n
}
{MACRONAMEA} {
MACRO *mm = PARM->macros;
+ char *mname;
int c, i, j;
/* csound->DebugMsg(csound,"Macro with arguments call %s\n", yytext); */
yytext[yyleng-1] = '\0';
@@ -232,6 +233,7 @@ CONT \\[ \t]*(;.*)?\n
csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
csound->LongJmp(csound, 1);
}
+ mname = yytext;
/* Need to read from macro definition */
csound->DebugMsg(csound,"Looking for %d args\n", mm->acnt);
for (j = 0; j < mm->acnt; j++) {
@@ -280,11 +282,12 @@ CONT \\[ \t]*(;.*)?\n
yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
csound_preset_lineno(1, yyscanner);
PARM->lstack[++PARM->depth] =
- (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
+ (strchr(mm->body,'\n') ?file_to_int(csound, mname) : 63);
yy_scan_string(mm->body, yyscanner);
}
{MACRONAMEDA} {
MACRO *mm = PARM->macros;
+ char *mname;
int c, i, j;
/* csound->DebugMsg(csound,"Macro with arguments call %s\n", yytext); */
yytext[yyleng-2] = '\0';
@@ -298,6 +301,7 @@ CONT \\[ \t]*(;.*)?\n
csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
csound->LongJmp(csound, 1);
}
+ mname = yytext;
/* Need to read from macro definition */
csound->DebugMsg(csound,"Looking for %d args\n", mm->acnt);
for (j = 0; j < mm->acnt; j++) {
@@ -342,7 +346,7 @@ CONT \\[ \t]*(;.*)?\n
}
csound_preset_lineno(1, yyscanner);
PARM->lstack[PARM->depth] =
- (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
+ (strchr(mm->body,'\n') ?file_to_int(csound, mname) : 63);
yy_scan_string(mm->body, yyscanner);
}
{INCLUDE} {
@@ -508,24 +512,58 @@ void comment(yyscan_t yyscanner) /* Skip until nextline */
{
char c;
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
- while ((c = input(yyscanner)) != '\n' && c != '\r'); /* skip */
- if (c == '\r' && (c = input(yyscanner)) != '\n')
- unput(c);
+ while ((c = input(yyscanner)) != '\n' && c != '\r') { /* skip */
+ if (c == EOF) {
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ return;
+ }
+ }
+ if (c == '\r' && (c = input(yyscanner)) != '\n') {
+ if (c != EOF)
+ unput(c);
+ else
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
}
void do_comment(yyscan_t yyscanner) /* Skip until * and / chars */
{
char c;
+ struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
for (;;) {
c = input(yyscanner);
- if (UNLIKELY(c=='\n')) /* skip */
- csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
+ if (UNLIKELY(c == '\r')) { /* skip */
+ if ((c = input(yyscanner)) != '\n')
+ unput(c);
+ csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
+ }
+ else if (UNLIKELY(c=='\n')) { /* skip */
+ csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
+ }
+ if (c == EOF) {
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ return;
+ }
if (c != '*') continue;
while ((c=input(yyscanner))=='*');
if (c=='/') return;
- if (UNLIKELY(c=='\n'))
+ if (UNLIKELY(c == '\r')) {
+ if ((c = input(yyscanner)) != '\n')
+ unput(c);
csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
+ }
+ else if (UNLIKELY(c=='\n')) {
+ csound_preset_lineno(1+csound_preget_lineno(yyscanner),yyscanner);
+ }
+ if (c == EOF) {
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ return;
+ }
}
}
@@ -814,7 +852,7 @@ void cs_init_math_constants_macros(CSOUND *csound, PRE_PARM* qq)
add_math_const_macro(csound, qq,"2_SQRTPI", "1.12837916709551257390");
add_math_const_macro(csound, qq, "SQRT2", "1.41421356237309504880");
add_math_const_macro(csound, qq,"SQRT1_2","0.70710678118654752440");
- add_math_const_macro(csound, qq, "INF", "2147483647.0"); /* ~7 years */
+ add_math_const_macro(csound, qq, "INF", "800000000000.0"); /* ~25367 years */
}
void cs_init_omacros(CSOUND *csound, PRE_PARM *qq, NAMES *nn)
diff --git a/Engine/entry1.c b/Engine/entry1.c
index b705816..fa20861 100644
--- a/Engine/entry1.c
+++ b/Engine/entry1.c
@@ -413,8 +413,8 @@ OENTRY opcodlst_1[] = {
{ "pan", S(PAN), 5, "aaaa", "akkioo",(SUBR)panset,NULL, (SUBR)pan },
{ "soundin",S(SOUNDIN_),5,"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm","Toooo",
sndinset, NULL, soundin },
-{ "soundout",S(SNDOUT), DP|5, "", "aTo", sndo1set, NULL, soundout },
-{ "soundouts",S(SNDOUTS),DP|5, "", "aaTo", sndo1set, NULL, soundouts },
+{ "soundout",S(SNDOUT), _QQ|5, "", "aTo", sndo1set, NULL, soundout },
+{ "soundouts",S(SNDOUTS),_QQ|5, "", "aaTo", sndo1set, NULL, soundouts },
{ "in", S(INM), 4, "a", "", NULL, NULL, in },
{ "ins", S(INS), 4, "aa", "", NULL, NULL, ins },
{ "inq", S(INQ), 4, "aaaa", "", NULL, NULL, inq },
@@ -505,10 +505,11 @@ OENTRY opcodlst_1[] = {
{ "unirand.i",S(PRAND), 1, "i", "k", ikuniform, NULL, NULL },
{ "unirand.k",S(PRAND), 2, "k", "k", NULL, ikuniform, NULL},
{ "unirand.a",S(PRAND), 4, "a", "k", NULL, NULL, auniform },
-{ "diskin",S(SOUNDINEW),DP|5, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+
+{ "diskin",S(SOUNDINEW),_QQ|5, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
"Tkooooo",
(SUBR) newsndinset, NULL, (SUBR) soundinew },
-{ "diskin2",S(DISKIN2), 5, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+{ "diskin2",S(DISKIN2), 5, "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
"Tkoooooo",
(SUBR) diskin2_init, (SUBR) NULL,
(SUBR) diskin2_perf },
@@ -573,7 +574,7 @@ OENTRY opcodlst_1[] = {
{ "tableicopy",S(TABLECOPY),TB|1, "", "ii", (SUBR)itablecopy, NULL, NULL},
{ "tablecopy", S(TABLECOPY),TB|2, "", "kk",
(SUBR)tablecopyset, (SUBR)tablecopy, NULL},
-{ "tablera", S(TABLERA),TR|5, "a", "kkk",
+{ "tablera", S(TABLERA),TR|5, "a", "kkk",
(SUBR)tableraset, NULL, (SUBR)tablera},
{ "tablewa", S(TABLEWA),TW|5, "k", "kak",
(SUBR)tablewaset, NULL, (SUBR)tablewa},
@@ -657,7 +658,7 @@ OENTRY opcodlst_1[] = {
{ "event", S(LINEVENT), 2, "", "SUz", NULL, eventOpcode, NULL },
{ "event_i", S(LINEVENT),1, "", "STm", eventOpcodeI, NULL, NULL },
{ "lfo", S(LFO), 7, "s", "kko", lfoset, lfok, lfoa },
-{ "oscils", S(OSCILS), 5, "a", "iiio",
+{ "oscils", S(OSCILS), 5, "a", "iiio",
(SUBR)oscils_set, NULL, (SUBR)oscils },
{ "lphasor", S(LPHASOR),5, "a", "xooooooo" ,
(SUBR)lphasor_set, NULL, (SUBR)lphasor },
@@ -665,7 +666,7 @@ OENTRY opcodlst_1[] = {
(SUBR)tablexkt_set, NULL, (SUBR)tablexkt },
{ "reverb2", S(NREV2), 5, "a", "akkoojoj",
(SUBR)reverbx_set,NULL,(SUBR)reverbx },
-{ "nreverb", S(NREV2), 5, "a", "akkoojoj",
+{ "nreverb", S(NREV2), 5, "a", "akkoojoj",
(SUBR)reverbx_set,NULL,(SUBR) reverbx },
{ "=.f", S(FASSIGN), 2, "f", "f", NULL, fassign, NULL },
{ "init.f", S(FASSIGN), 2, "f", "f", fassign, NULL, NULL },
@@ -760,7 +761,7 @@ OENTRY opcodlst_1[] = {
{ "a.k", S(INTERP), 5, "a", "k", (SUBR)a_k_set,NULL, (SUBR)interp },
{ "integ", S(INDIFF), 7, "s", "xo", (SUBR)indfset,(SUBR)kntegrate,(SUBR)integrate},
{ "diff", S(INDIFF), 7, "s", "xo", (SUBR)indfset,(SUBR)kdiff, (SUBR)diff },
-{ "samphold",S(SAMPHOLD),7, "s", "xxoo",
+{ "samphold",S(SAMPHOLD),7, "s", "xxoo",
(SUBR)samphset,(SUBR)ksmphold,(SUBR)samphold},
{ "delay", S(DELAY), 5, "a", "aio", (SUBR)delset, NULL, (SUBR)delay },
{ "delayr", S(DELAYR), 5, "aX","io", (SUBR)delrset,NULL, (SUBR)delayr },
@@ -773,7 +774,7 @@ OENTRY opcodlst_1[] = {
{ "reverb", S(REVERB), 5, "a", "ako", (SUBR)rvbset, NULL, (SUBR)reverb },
{ "vdelay", S(VDEL), 5, "a", "axio", (SUBR)vdelset, NULL, (SUBR)vdelay },
{ "vdelay3", S(VDEL), 5, "a", "axio", (SUBR)vdelset, NULL, (SUBR)vdelay3 },
-{ "vdelayxwq",S(VDELXQ),5, "aaaa", "aaaaaiio",
+{ "vdelayxwq",S(VDELXQ),5, "aaaa", "aaaaaiio",
(SUBR)vdelxqset, NULL, (SUBR)vdelayxwq},
{ "vdelayxws",S(VDELXS),5, "aa", "aaaiio", (SUBR)vdelxsset, NULL, (SUBR)vdelayxws},
{ "vdelayxw", S(VDELX), 5, "a", "aaiio", (SUBR)vdelxset, NULL, (SUBR)vdelayxw},
@@ -934,9 +935,9 @@ OENTRY opcodlst_1[] = {
{ "remove", S(DELETEIN), 1, "", "T",
(SUBR) delete_instr, (SUBR) NULL, (SUBR) NULL },
#ifdef PARCS
-{ "##globallock", S(GLOBAL_LOCK_UNLOCK), 3, "", "k",
+{ "##globallock", S(GLOBAL_LOCK_UNLOCK), 3, "", "k",
globallock, globallock, NULL},
-{ "##globalunlock", S(GLOBAL_LOCK_UNLOCK), 3, "", "k",
+{ "##globalunlock", S(GLOBAL_LOCK_UNLOCK), 3, "", "k",
globalunlock, globalunlock, NULL},
#endif
{ "##error",S(ERRFN), 1, "i", "i", error_fn, NULL, NULL },
@@ -954,4 +955,3 @@ OENTRY opcodlst_1[] = {
/* terminate list */
{ NULL, 0, 0, NULL, NULL, (SUBR) NULL, (SUBR) NULL, (SUBR) NULL }
};
-
diff --git a/Engine/envvar.c b/Engine/envvar.c
index 8e70fba..64d2065 100644
--- a/Engine/envvar.c
+++ b/Engine/envvar.c
@@ -789,7 +789,9 @@ char *csoundGetDirectoryForPath(CSOUND* csound, const char * path) {
/* do we need to worry about ~/ on *nix systems ? */
/* we have a relative path or just a filename */
cwd = mmalloc(csound, 512);
- getcwd(cwd, 512);
+ if (UNLIKELY(getcwd(cwd, 512)==NULL)) {
+ csoundDie(csound, "Current directory path name too long\n");
+ }
if (lastIndex == NULL) {
return cwd;
diff --git a/Engine/express.c b/Engine/express.c
index 18eefa0..d8fbaa4 100644
--- a/Engine/express.c
+++ b/Engine/express.c
@@ -138,7 +138,7 @@ int express(CSOUND *csound, char *s)
else if (nontermin(c)) { /* if not just a termin char */
if (c == '.' || (c >= '0' && c <= '9')) {
char *tmp = --s;
- (void) strtod(s, &tmp); /* copy constant */
+ double tt = strtod(s, &tmp); /* copy constant */
while (++s < tmp)
*t++ = *s;
/* also copy any trailing characters after a constant, */
diff --git a/Engine/fgens.c b/Engine/fgens.c
index 047f659..b76bc39 100644
--- a/Engine/fgens.c
+++ b/Engine/fgens.c
@@ -2137,7 +2137,7 @@ static int gen42(FGDATA *ff, FUNC *ftp) /*gab d5*/
p3 = *valp++;
if (UNLIKELY(nsw && valp>=&ff->e.p[PMAX-1]))
nsw =0, valp = &(ff->e.c.extra[1]);
- width = (int) ((p3/tot_prob) * ff->flen +FL(0.5));
+ width = (int) ((p3/tot_prob) * ff->flen +FL(0.5));
inc = (p2-p1) / (MYFLT) (width-1);
for ( k=0; k < width; k++) {
*fp++ = p1+(inc*k);
@@ -2567,11 +2567,11 @@ static int gen01raw(FGDATA *ff, FUNC *ftp)
ftp->end1 = ftp->flenfrms; /* Greg Sullivan */
#endif /* HAVE_LIBSNDFILE >= 1013 */
/* read sound with opt gain */
-
+
if (UNLIKELY((inlocs=getsndin(csound, fd, ftp->ftable, table_length, p)) < 0)) {
return fterror(ff, Str("GEN1 read error"));
}
-
+
if (p->audrem > 0 && !truncmsg && p->framesrem > ff->flen) {
/* Reduce msg */
csound->Warning(csound, Str("GEN1: aiff file truncated by ftable size"));
@@ -2584,7 +2584,7 @@ static int gen01raw(FGDATA *ff, FUNC *ftp)
if (def) {
MYFLT *tab = (MYFLT *) ftp->ftable;
ftresdisp(ff, ftp); /* VL: 11.01.05 for deferred alloc tables */
- tab[ff->flen] = tab[0]; /* guard point */
+ tab[ff->flen] = tab[0]; /* guard point */
ftp->flen -= 1; /* exclude guard point */
}
return OK;
@@ -3190,7 +3190,7 @@ int resize_table(CSOUND *csound, RESIZE *p)
}
if ((ftp = csound->FTFind(csound, p->fn)) == NULL)
return NOTOK;
- if (ftp->flen<fsize)
+ if (ftp->flen<fsize)
ftp = (FUNC*) csound->ReAlloc(csound, ftp, sizeof(FUNC)+sizeof(MYFLT)*fsize);
ftp->flen = fsize;
csound->flist[fno] = ftp;
diff --git a/Engine/insert.c b/Engine/insert.c
index f0b9ea7..a66c79b 100644
--- a/Engine/insert.c
+++ b/Engine/insert.c
@@ -371,7 +371,7 @@ int MIDIinsert(CSOUND *csound, int insno, MCHNBLK *chn, MEVENT *mep)
MYFLT value = (MYFLT) ip->m_pitch;
pfields[index] = value;
if (O->msglevel & WARNMSG) {
- csound->Message(csound, " midiKey: pfield: %3d value: %.3f\n",
+ csound->Message(csound, " midiKey: pfield: %3d value: %3d\n",
pfield, (int) pfields[index]);
}
}
@@ -431,7 +431,7 @@ int MIDIinsert(CSOUND *csound, int insno, MCHNBLK *chn, MEVENT *mep)
}
else if (O->midiVelocityAmp) {
int pfield = O->midiVelocityAmp;
- int index = pfield - 1;
+ int index = pfield - 1;
MYFLT *pfields = &ip->p1;
MYFLT value = (MYFLT) ip->m_veloc;
value = value * value / FL(16239.0);
@@ -442,17 +442,17 @@ int MIDIinsert(CSOUND *csound, int insno, MCHNBLK *chn, MEVENT *mep)
pfield, pfields[index]);
}
}
- /*
- the code above assumes &p1 is a pointer to an array of N pfields, but
+ /*
+ the code above assumes &p1 is a pointer to an array of N pfields, but
this is wrong. It overwrites memory and uses it for passing p-field
values. When the overwritten memory is taken to be a pointer in the
loop below, the loop does not stop at the end of the opcode list
- and causes iopadr to be garbage, leading to a segfault.
- This happens where there is exactly one opcode in an instrument.
- It is a nasty bug that needs to be fixed.
-
+ and causes iopadr to be garbage, leading to a segfault.
+ This happens where there is exactly one opcode in an instrument.
+ It is a nasty bug that needs to be fixed.
+
A possible solution is to allocate always a minimum of 5 p-fields (see line
- approx 1809 below). The extra p-fields appear to be hanging at the end of
+ approx 1809 below). The extra p-fields appear to be hanging at the end of
an INSDS structure, and &p1 appears to be a legal array start address.
This allows p4 and p5 to be mapped, but no further p-fields (possibly).
@@ -1103,7 +1103,7 @@ int xinset(CSOUND *csound, XIN *p)
*(tmp++) = NULL; /* put delimiter */
/* ... same for k-rate */
while (*++ndx_list >= 0) {
- *(tmp++) = *(bufs + *ndx_list); /* "from" address */
+ *(tmp++) = *(bufs + *ndx_list); /* "from" address */
*(tmp++) = *(p->args + *ndx_list);/* "to" address */
}
*(tmp++) = NULL; /* put delimiter */
@@ -1111,23 +1111,23 @@ int xinset(CSOUND *csound, XIN *p)
while (*++ndx_list >= 0) {
void *in, *out;
in = (void *)*(bufs + *ndx_list);
- *(tmp++) = (MYFLT *) in;
+ *(tmp++) = (MYFLT *) in;
out = (void *) *(p->args + *ndx_list);
*(tmp++) = (MYFLT *) out;
- memcpy(out, in, sizeof(PVSDAT));
+ memcpy(out, in, sizeof(PVSDAT));
}
*(tmp++) = NULL;
/* tsigs: similar to avove */
while (*++ndx_list >= 0) {
void *in, *out;
in = (void *)*(bufs + *ndx_list);
- *(tmp++) = (MYFLT *) in;
+ *(tmp++) = (MYFLT *) in;
out = (void *) *(p->args + *ndx_list);
*(tmp++) = (MYFLT *) out;
- memcpy(out, in, sizeof(TABDAT));
+ memcpy(out, in, sizeof(TABDAT));
}
*(tmp++) = NULL;
-
+
/* fix for case when xout is omitted */
*(tmp++) = NULL; *(tmp++) = NULL; *(tmp++) = NULL; *tmp = NULL;
return OK;
@@ -1139,7 +1139,7 @@ int xoutset(CSOUND *csound, XOUT *p)
OPCODINFO *inm;
int16 *ndx_list;
MYFLT **tmp, **bufs;
-
+
(void) csound;
buf = (OPCOD_IOBUFS*) p->h.insdshead->opcod_iobufs;
inm = buf->opcode_info;
@@ -1167,7 +1167,7 @@ int xoutset(CSOUND *csound, XOUT *p)
tmp += 4; /* VL: this was 2, now 4 with fsigs and tsigs added */
if (*tmp || *(tmp + 1))
return OK;
-
+
/* find a-rate variables and add to list of perf-time buf ptrs ... */
while (*++ndx_list >= 0) {
*(tmp++) = *(p->args + *ndx_list);/* "from" address */
@@ -1180,23 +1180,23 @@ int xoutset(CSOUND *csound, XOUT *p)
*(tmp++) = *(bufs + *ndx_list); /* "to" address */
}
*(tmp++) = NULL; /* put delimiter */
-
+
/* fsigs: we'll need to do extra work */
while (*++ndx_list >= 0) {
void *in, *out;
in = (void *) *(p->args + *ndx_list);
*(tmp++) = (MYFLT *) in;
- out = (void *) *(bufs + *ndx_list);
+ out = (void *) *(bufs + *ndx_list);
*(tmp++) = (MYFLT *) out;
memcpy(out, in, sizeof(PVSDAT));
}
- *(tmp++) = NULL;
+ *(tmp++) = NULL;
/* tsigs: as above */
while (*++ndx_list >= 0) {
void *in, *out;
in = (void *) *(p->args + *ndx_list);
*(tmp++) = (MYFLT *) in;
- out = (void *) *(bufs + *ndx_list);
+ out = (void *) *(bufs + *ndx_list);
*(tmp++) = (MYFLT *) out;
memcpy(out, in, sizeof(TABDAT));
}
@@ -1593,16 +1593,16 @@ int useropcd1(CSOUND *csound, UOPCODE *p)
ptr1 = *tmp; *(*(++tmp)) = *ptr1;
}
/* VL: fsigs in need to be dealt with here */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
}
/* and tsigs */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
}
-
+
/* run each opcode */
csound->pds = (OPDS *) (p->ip);
while ((csound->pds = csound->pds->nxtp)) {
@@ -1630,15 +1630,15 @@ int useropcd1(CSOUND *csound, UOPCODE *p)
ptr1 = *tmp; *(*(++tmp)) = *ptr1;
}
/* VL: fsigs in need to be dealt with here */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
}
/* and tsigs */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
- }
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
+ }
/* run each opcode */
csound->pds = (OPDS *) (p->ip);
while ((csound->pds = csound->pds->nxtp)) {
@@ -1658,20 +1658,20 @@ int useropcd1(CSOUND *csound, UOPCODE *p)
/* k-rate outputs are copied only in the last sub-kperiod, */
/* so we do it now */
while (*(++tmp)) { /* k-rate */
- ptr1 = *tmp;
+ ptr1 = *tmp;
*(*(++tmp)) = *ptr1;
}
/* VL: fsigs out need to be dealt with here */
- while (*(++tmp)) {
+ while (*(++tmp)) {
ptr1 = *tmp;
memcpy((void *)(*(++tmp)), (void *)ptr1, sizeof(PVSDAT));
}
/* tsigs */
- while (*(++tmp)) {
+ while (*(++tmp)) {
ptr1 = *tmp;
memcpy((void *)(*(++tmp)), (void *)ptr1, sizeof(TABDAT));
}
-
+
/* restore globals */
csound->ksmps = g_ksmps;
csound->pool[csound->poolcount + 2] = (MYFLT) g_ksmps;
@@ -1694,13 +1694,13 @@ int useropcd2(CSOUND *csound, UOPCODE *p)
OPDS *saved_pds = csound->pds;
int n;
MYFLT **tmp, *ptr1, *ptr2;
-
+
if (!(csound->pds = (OPDS*) (p->ip->nxtp))) goto endop; /* no perf code */
- //csound->Message(csound, "end input\n"); /* FOR SOME REASON the opcode has no perf code */
+ //csound->Message(csound, "end input\n"); /* FOR SOME REASON the opcode has no perf code */
/* IV - Nov 16 2002: update release flag */
p->ip->relesing = p->parent_ip->relesing;
-
+
tmp = p->buf->iobufp_ptrs;
if (csound->ksmps != 1) { /* generic case for kr != sr */
@@ -1712,23 +1712,23 @@ int useropcd2(CSOUND *csound, UOPCODE *p)
*(ptr2++) = *(ptr1++);
} while (--n);
}
-
+
while (*(++tmp)) { /* k-rate */
ptr1 = *tmp; *(*(++tmp)) = *ptr1;
}
-
+
/* VL: fsigs in need to be dealt with here */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
- }
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
+ }
/* VL: tsigs */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
- }
-
-
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
+ }
+
+
/* run each opcode */
do {
(*csound->pds->opadr)(csound, csound->pds);
@@ -1745,22 +1745,22 @@ int useropcd2(CSOUND *csound, UOPCODE *p)
else { /* special case for kr == sr */
/* copy inputs */
while (*tmp) { /* a-rate */
- ptr1 = *(tmp++);
+ ptr1 = *(tmp++);
*(*(tmp++)) = *ptr1;
}
while (*(++tmp)) { /* k-rate */
ptr1 = *tmp; *(*(++tmp)) = *ptr1;
}
/* VL: fsigs in need to be dealt with here */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(PVSDAT));
}
/* VL: tsigs */
- while (*(++tmp)) {
- ptr1 = *tmp;
- memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
- }
+ while (*(++tmp)) {
+ ptr1 = *tmp;
+ memcpy((void *)(*(++tmp)), (void *) ptr1, sizeof(TABDAT));
+ }
/* run each opcode */
do {
(*csound->pds->opadr)(csound, csound->pds);
@@ -1774,15 +1774,15 @@ int useropcd2(CSOUND *csound, UOPCODE *p)
ptr1 = *tmp; *(*(++tmp)) = *ptr1;
}
/* VL: fsigs out need to be dealt with here */
- while (*(++tmp)) {
+ while (*(++tmp)) {
ptr1 = *tmp;
memcpy((void *)(*(++tmp)), (void *)ptr1, sizeof(PVSDAT));
}
/* tsigs */
- while (*(++tmp)) {
+ while (*(++tmp)) {
ptr1 = *tmp;
memcpy((void *)(*(++tmp)), (void *)ptr1, sizeof(TABDAT));
- }
+ }
endop:
/* restore globals */
csound->pds = saved_pds;
@@ -1804,7 +1804,7 @@ static void instance(CSOUND *csound, int insno)
const OENTRY *ep;
LBLBLK **lopdsp;
LARGNO *largp;
- int n, cnt, pextent, opnum;
+ int n, cnt, pextent, opnum, pextra;
char *nxtopds, *opdslim;
MYFLT **argpp, *lclbas, *gbloffbas, *lcloffbas;
int *ndxp;
@@ -1823,7 +1823,8 @@ static void instance(CSOUND *csound, int insno)
if (O->midiKeyPch>n) n = O->midiKeyPch;
if (O->midiVelocity>n) n = O->midiVelocity;
if (O->midiVelocityAmp>n) n = O->midiVelocityAmp;
- pextent = sizeof(INSDS) + tp->pextrab + (n-3)*sizeof(MYFLT *); /* alloc new space, */
+ pextra = n-3;
+ pextent = sizeof(INSDS) + tp->pextrab + pextra*sizeof(MYFLT *); /* alloc new space, */
ip = (INSDS*) mcalloc(csound, (size_t) pextent + tp->localen + tp->opdstot);
ip->csound = csound;
ip->m_chnbp = (MCHNBLK*) NULL;
@@ -2040,5 +2041,3 @@ int delete_instr(CSOUND *csound, DELETEIN *p)
}
return NOTOK;
}
-
-
diff --git a/Engine/memfiles.c b/Engine/memfiles.c
index 61fc234..b3d04cd 100644
--- a/Engine/memfiles.c
+++ b/Engine/memfiles.c
@@ -349,7 +349,7 @@ SNDMEMFILE *csoundLoadSoundFile(CSOUND *csound, const char *fileName, void *sfi)
SNDMEMFILE *p = NULL;
SF_INFO tmp;
unsigned char h;
-
+
if (UNLIKELY(fileName == NULL || fileName[0] == '\0'))
return NULL;
@@ -458,4 +458,3 @@ SNDMEMFILE *csoundLoadSoundFile(CSOUND *csound, const char *fileName, void *sfi)
/* return with pointer to file structure */
return p;
}
-
diff --git a/Engine/musmon.c b/Engine/musmon.c
index c6f7ff0..71961bf 100644
--- a/Engine/musmon.c
+++ b/Engine/musmon.c
@@ -85,7 +85,7 @@ static void settempo(CSOUND *csound, MYFLT tempo)
{
if (tempo <= FL(0.0)) return;
if (csound->oparms->Beatmode==1)
- csound->ibeatTime = (int)(csound->esr*60.0 / (double) tempo);
+ csound->ibeatTime = (int64_t)(csound->esr*60.0 / (double) tempo);
csound->curBeat_inc = (double) tempo / (60.0 * (double) csound->global_ekr);
}
@@ -395,7 +395,7 @@ PUBLIC int csoundCleanup(CSOUND *csound)
}
orcompact(csound);
corfile_rm(&csound->scstr);
-
+
/* print stats only if musmon was actually run */
if (UNLIKELY(csound->musmonGlobals != NULL)) {
csound->Message(csound, Str("end of score.\t\t overall amps:"));
@@ -417,12 +417,12 @@ PUBLIC int csoundCleanup(CSOUND *csound)
csound->perferrcnt);
print_benchmark_info(csound, Str("end of performance"));
}
-
+
/* close line input (-L) */
RTclose(csound);
/* close MIDI input */
MidiClose(csound);
-
+
/* IV - Feb 03 2005: do not need to call rtclose from here, */
/* as sfclosein/sfcloseout will do that. */
if (!csound->enableHostImplementedAudioIO) {
@@ -435,7 +435,7 @@ PUBLIC int csoundCleanup(CSOUND *csound)
if (csound->remoteGlobals) remote_Cleanup(csound);
if (csound->oparms->ringbell)
cs_beep(csound);
-
+
return dispexit(csound); /* hold or terminate the display output */
}
@@ -704,8 +704,8 @@ static int process_score_event(CSOUND *csound, EVTBLK *evt, int rtEvt)
break;
case 'a':
{
- int kCnt;
- kCnt = (int) ((double) csound->global_ekr * (double) evt->p[3] + 0.5);
+ int64_t kCnt;
+ kCnt = (int64_t) ((double) csound->global_ekr * (double) evt->p[3] + 0.5);
if (kCnt > csound->advanceCnt) {
csound->advanceCnt = kCnt;
csound->Message(csound,
@@ -724,7 +724,7 @@ static void process_midi_event(CSOUND *csound, MEVENT *mep, MCHNBLK *chn)
{
int n, insno = chn->insno;
if (mep->type == NOTEON_TYPE && mep->dat2) { /* midi note ON: */
- if (UNLIKELY((n = MIDIinsert(csound, insno, chn, mep)))) {
+ if (UNLIKELY((n = MIDIinsert(csound, insno, chn, mep)))) {
/* alloc,init,activ */
csound->Message(csound,
Str("\t\t T%7.3f - note deleted. "), csound->curp2);
@@ -805,7 +805,7 @@ static int process_rt_event(CSOUND *csound, int sensType)
return retval;
}
-#define RNDINT(x) ((int) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
+#define RNDINT64(x) ((int64_t) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
extern int sensMidi(CSOUND *);
@@ -919,10 +919,10 @@ int sensevents(CSOUND *csound)
/* calculate the number of k-periods remaining until next event */
if (O->Beatmode)
csound->cyclesRemaining =
- RNDINT((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
+ RNDINT64((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
else {
csound->cyclesRemaining =
- RNDINT((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
+ RNDINT64((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
csound->nxtim = (csound->cyclesRemaining*csound->ksmps+csound->icurTime)/csound->esr;
}
}
@@ -1029,14 +1029,14 @@ int sensevents(CSOUND *csound)
return 2; /* done with entire score */
}
-static inline uint32 time2kcnt(CSOUND *csound, double tval)
+static inline uint64_t time2kcnt(CSOUND *csound, double tval)
{
if (tval > 0.0) {
tval *= (double) csound->global_ekr;
#ifdef HAVE_C99
- return (uint32) llrint(tval);
+ return (uint64_t) llrint(tval);
#else
- return (uint32) (tval + 0.5);
+ return (uint64_t) (tval + 0.5);
#endif
}
return 0UL;
@@ -1057,7 +1057,7 @@ static inline uint32 time2kcnt(CSOUND *csound, double tval)
/* made. */
/* Return value is zero on success. */
-int insert_score_event_at_sample(CSOUND *csound, EVTBLK *evt, long time_ofs)
+int insert_score_event_at_sample(CSOUND *csound, EVTBLK *evt, int64_t time_ofs)
{
double start_time;
EVTNODE *e, *prv;
@@ -1268,4 +1268,3 @@ PUBLIC int csoundRegisterSenseEventCallback(CSOUND *csound,
return 0;
}
-
diff --git a/Engine/namedins.c b/Engine/namedins.c
index e1c0ca5..4bbdb44 100644
--- a/Engine/namedins.c
+++ b/Engine/namedins.c
@@ -538,7 +538,7 @@ char *strsav_string(CSOUND *csound, char *s)
sp->sp =
(char*)mcalloc(csound, sp->size = n+STRSPACE);
csound->DebugMsg(csound,
- "internal message: strsav: buffer length now %d\n",
+ "internal message: strsav: buffer length now %d\n",
sp->size);
}
@@ -1119,4 +1119,3 @@ int csoundLoadAllPluginOpcodes(CSOUND *csound)
#ifdef __cplusplus
}
#endif
-
diff --git a/Engine/new_orc_parser.c b/Engine/new_orc_parser.c
index 9caed43..5bcb3ef 100644
--- a/Engine/new_orc_parser.c
+++ b/Engine/new_orc_parser.c
@@ -67,7 +67,7 @@ void csound_print_preextra(CSOUND *csound, PRE_PARM *x)
csound->DebugMsg(csound,"********* Extra Pre Data %p *********\n", x);
csound->DebugMsg(csound,"macros = %p, macro_stack_ptr = %u, ifdefStack=%p, isIfndef=%d\n"
"isInclude=%d, clearBufferAfterEOF=%d, line=%d\n",
- x->macros, x->macro_stack_ptr, x->ifdefStack, x->isIfndef,
+ x->macros, x->macro_stack_ptr, x->ifdefStack, x->isIfndef,
x->isInclude, x->clearBufferAfterEOF, x->line);
csound->DebugMsg(csound,"******************\n");
}
@@ -107,7 +107,7 @@ int new_orc_parser(CSOUND *csound)
sprintf(bb, "#line %d\n", csound->orcLineOffset);
corfile_puts(bb, csound->expanded_orc);
}
- csound->DebugMsg(csound, "Calling preprocess on >>%s<<\n",
+ csound->DebugMsg(csound, "Calling preprocess on >>%s<<\n",
corfile_body(csound->orchstr));
//csound->DebugMsg(csound,"FILE: %s \n", csound->orchstr->body);
// csound_print_preextra(&qq);
@@ -121,7 +121,7 @@ int new_orc_parser(CSOUND *csound)
}
csound_prelex_destroy(qq.yyscanner);
csound->DebugMsg(csound, "yielding >>%s<<\n", corfile_body(csound->expanded_orc));
- free(csound->orchstr); csound->orchstr=NULL;
+ corfile_rm(&csound->orchstr);
}
{
TREE* astTree = (TREE *)mcalloc(csound, sizeof(TREE));
@@ -136,9 +136,9 @@ int new_orc_parser(CSOUND *csound)
csound_orcset_extra(&pp, pp.yyscanner);
csound_orc_scan_buffer(corfile_body(csound->expanded_orc),
corfile_tell(csound->expanded_orc), pp.yyscanner);
- free(csound->expanded_orc);
//csound_orcset_lineno(csound->orcLineOffset, pp.yyscanner);
retVal = csound_orcparse(&pp, pp.yyscanner, csound, astTree);
+ corfile_rm(&csound->expanded_orc);
if (csound->synterrcnt) retVal = 3;
if (LIKELY(retVal == 0)) {
csound->Message(csound, "Parsing successful!\n");
@@ -174,14 +174,14 @@ int new_orc_parser(CSOUND *csound)
if (UNLIKELY(PARSER_DEBUG)) {
print_tree(csound, "AST - AFTER EXPANSION\n", astTree);
- }
+ }
#ifdef PARCS
if (LIKELY(O->numThreads > 1)) {
/* calculate the weights for the instruments */
csp_weights_calculate(csound, astTree);
}
#endif /* PARCS */
-
+
astTree = csound_orc_optimize(csound, astTree);
csound_orc_compile(csound, astTree);
@@ -190,4 +190,3 @@ int new_orc_parser(CSOUND *csound)
}
return retVal;
}
-
diff --git a/Engine/otran.c b/Engine/otran.c
index 0e8b359..ac0acb1 100644
--- a/Engine/otran.c
+++ b/Engine/otran.c
@@ -135,7 +135,7 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
break;
case 't':
t_incnt++; *otypes++ = *types;
- break;
+ break;
case 'i':
case 'o':
case 'p':
@@ -183,7 +183,7 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
break;
case 't':
t_outcnt++; *otypes++ = *types;
- break;
+ break;
case 'i':
i_outcnt++; *otypes++ = *types;
break;
@@ -211,14 +211,14 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
a_inlist = S_inlist + S_incnt + 1;
k_inlist = a_inlist + a_incnt + 1;
f_inlist = k_inlist + k_incnt + 1;
- t_inlist = f_inlist + f_incnt + 1;
+ t_inlist = f_inlist + f_incnt + 1;
i = 0; types = inm->intypes;
while (*types) {
switch (*types++) {
case 'a': *a_inlist++ = i; break;
case 'k': *k_inlist++ = i; break;
case 'f': *f_inlist++ = i; break;
- case 't': *t_inlist++ = i; break;
+ case 't': *t_inlist++ = i; break;
case 'K': *k_inlist++ = i; /* also updated at i-time */
case 'i':
case 'o':
@@ -234,14 +234,14 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
a_outlist = S_outlist + S_outcnt + 1;
k_outlist = a_outlist + a_outcnt + 1;
f_outlist = k_outlist + k_outcnt + 1;
- t_outlist = f_outlist + f_outcnt + 1;
+ t_outlist = f_outlist + f_outcnt + 1;
i = 0; types = inm->outtypes;
while (*types) {
switch (*types++) {
case 'a': *a_outlist++ = i; break;
case 'k': *k_outlist++ = i; break;
case 'f': *f_outlist++ = i; break;
- case 't': *t_outlist++ = i; break;
+ case 't': *t_outlist++ = i; break;
case 'K': *k_outlist++ = i; /* also updated at i-time */
case 'i': *i_outlist++ = i; break;
case 'S': *S_outlist++ = i; break;
@@ -303,7 +303,6 @@ void otran(CSOUND *csound)
ST(poolcount) = 0;
ST(nconsts) = NCONSTS;
ST(constTbl) = (int*) mcalloc(csound, (256 + NCONSTS) * sizeof(int));
- setlocale(LC_NUMERIC, "C"); /* Ensure C syntax */
constndx(csound, "0");
while ((tp = getoptxt(csound, &init)) != NULL) {
@@ -991,14 +990,14 @@ int lgexist(CSOUND *csound, const char *s)
{
unsigned char h = name_hash(csound, s);
NAME *p;
-
-
+
+
for (p = ST(gblNames)[h]; p != NULL && sCmp(p->namep, s); p = p->nxt);
if (p != NULL)
return 1;
for (p = ST(lclNames)[h]; p != NULL && sCmp(p->namep, s); p = p->nxt);
-
+
return (p == NULL ? 0 : 1);
}
@@ -1443,7 +1442,7 @@ void oload(CSOUND *p)
if (O->Beatmode && O->cmdTempo > 0) {
/* if performing from beats, set the initial tempo */
p->curBeat_inc = (double) O->cmdTempo / (60.0 * (double) p->ekr);
- p->ibeatTime = (int)(p->esr*60.0 / (double) O->cmdTempo);
+ p->ibeatTime = (int64_t)(p->esr*60.0 / (double) O->cmdTempo);
}
else {
p->curBeat_inc = 1.0 / (double) p->ekr;
@@ -1460,4 +1459,3 @@ void oload(CSOUND *p)
if (UNLIKELY(init0(p) != 0))
csoundDie(p, Str("header init errors"));
}
-
diff --git a/Engine/parse_param.h b/Engine/parse_param.h
index dd37005..6df0617 100644
--- a/Engine/parse_param.h
+++ b/Engine/parse_param.h
@@ -4,7 +4,7 @@ struct MACRO;
typedef struct MACRON {
int n;
- unsigned int line;
+ unsigned int line;
struct MACRO *s;
} MACRON;
@@ -27,7 +27,7 @@ typedef struct IFDEFSTACK_ {
} IFDEFSTACK;
-typedef struct pre_parm_s {
+typedef struct pre_parm_s {
void *yyscanner;
MACRO *macros;
MACRON alt_stack[MAX_INCLUDE_DEPTH];
@@ -41,7 +41,7 @@ typedef struct pre_parm_s {
uint32_t locn;
uint32_t llocn;
uint16_t depth;
- uint8_t lstack[1024];
+ uint8_t lstack[1024];
} PRE_PARM;
typedef struct parse_parm_s {
diff --git a/Engine/rdorch.c b/Engine/rdorch.c
index 0e6b837..084bccd 100644
--- a/Engine/rdorch.c
+++ b/Engine/rdorch.c
@@ -414,7 +414,7 @@ static void init_math_constants_macros(CSOUND *csound)
add_math_const_macro(csound, "2_SQRTPI", "1.12837916709551257390");
add_math_const_macro(csound, "SQRT2", "1.41421356237309504880");
add_math_const_macro(csound, "SQRT1_2", "0.70710678118654752440");
- add_math_const_macro(csound, "INF", "2147483647.0"); /* ~7 years */
+ add_math_const_macro(csound, "INF", "800000000000.0"); /* ~25367 years */
}
static void init_omacros(CSOUND *csound, NAMES *nn)
@@ -1933,7 +1933,7 @@ TEXT *getoptxt(CSOUND *csound, int *init)
}
tfound = argtyp(csound, s); /* else get arg type */
/* IV - Oct 31 2002 */
-
+
tfound_m = ST(typemask_tabl)[(unsigned char) tfound];
if (UNLIKELY(!(tfound_m & (ARGTYP_c|ARGTYP_p)) &&
!ST(lgprevdef) && *s != '"')) {
diff --git a/Engine/rdscor.c b/Engine/rdscor.c
index bde13b1..c22de11 100644
--- a/Engine/rdscor.c
+++ b/Engine/rdscor.c
@@ -29,7 +29,7 @@ static void dumpline(CSOUND *);
static void flushline(CSOUND *csound) /* flush scorefile to next newline */
{
int c;
- while ((c = corfile_getc(csound->scstr)) != '0' && c != '\n')
+ while ((c = corfile_getc(csound->scstr)) != '\0' && c != '\n')
;
}
diff --git a/Engine/scsort.c b/Engine/scsort.c
index d26222a..c44bcb0 100644
--- a/Engine/scsort.c
+++ b/Engine/scsort.c
@@ -68,7 +68,7 @@ void scsortstr(CSOUND *csound, CORFIL *scin)
swritestr(csound);
m++;
}
- if (m==0) corfile_puts("f0 2147483647.0\ne\n", csound->scstr);
+ if (m==0) corfile_puts("f0 800000000000.0\ne\n", csound->scstr); /* ~25367 years */
else corfile_puts("e\n", csound->scstr);
corfile_flush(csound->scstr);
sfree(csound); /* return all memory used */
diff --git a/Engine/sort.c b/Engine/sort.c
index c8a11f8..7aa2683 100644
--- a/Engine/sort.c
+++ b/Engine/sort.c
@@ -125,7 +125,7 @@ static void inline sift(SRTBLK *A[], int data[])
static void inline trinkle(SRTBLK *A[], int data[])
{
- int p1,r2,r3, r0, temp;
+ int p1, r2, r3, r0, temp;
SRTBLK * T;
p1 = p; b1 = b; c1 = c;
r0 = r1; T = A[r0];
@@ -140,13 +140,13 @@ static void inline trinkle(SRTBLK *A[], int data[])
p1--;
if (b1==1) {
A[r1] = A[r3];
- r1 = r3;
+ r1 = r3;
}
else
if (b1 >= 3) {
r2 = r1-b1+c1;
if (! ordering(A[r1-1],A[r2])) {
- r2 = r1-1;
+ r2 = r1-1;
DOWN(b1,c1)
p1 <<= 1;
}
@@ -179,7 +179,8 @@ static void inline semitrinkle(SRTBLK *A[], int data[])
static void smoothsort(SRTBLK *A[], const int N)
{
int temp;
- int data[] = {/*q*/ 1, /*r*/ 0, /*p*/ 1, /*b*/ 1, /*c*/ 1, 0,0,0};
+ int data[] = {/*q*/ 1, /*r*/ 0, /*p*/ 1, /*b*/ 1,
+ /*c*/ 1, /*r1*/ 0, /*b1*/ 0, /*c1*/ 0};
/* building tree */
while (q < N) {
@@ -198,7 +199,7 @@ static void smoothsort(SRTBLK *A[], const int N)
p <<= 1;
while (b > 1) {
DOWN(b,c)
- p <<= 1;
+ p <<= 1;
}
p++;
}
diff --git a/Engine/sread.c b/Engine/sread.c
index abb97ed..3386931 100644
--- a/Engine/sread.c
+++ b/Engine/sread.c
@@ -228,10 +228,10 @@ static void print_input_backtrace(CSOUND *csound, int needLFs,
(lastsource == 0 ? csound->scoLineOffset + curr->line - 1 :
csound->scoLineOffset + curr->line), csound->csdname, lf);
}
- else {
- msgfunc(csound, m, (lastsource == 0 ? curr->line - 1 : curr->line),
- corfile_tell(curr->cf), lf); /* #include is one line before */
- }
+ /* else { */
+ /* msgfunc(csound, m, (lastsource == 0 ? curr->line - 1 : curr->line), */
+ /* corfile_tell(curr->cf), lf); /\* #include is one line before *\/ */
+ /* } */
} while (!lastsource);
curr--;
return;
@@ -319,7 +319,7 @@ static int getscochar(CSOUND *csound, int expand)
c = corfile_getc(ST(str)->cf);
if (c == EOF) {
if (ST(str) == &ST(inputs)[0]) {
- corfile_ungetc(ST(str)->cf); /* to ensure repeated EOF */
+ corfile_putc('\n', ST(str)->cf); /* to ensure repeated EOF */
return EOF;
}
if (ST(str)->mac == 0) {
@@ -668,7 +668,7 @@ static int nested_repeat(CSOUND *csound) /* gab A9*/
#ifdef MACDEBUG
csound->DebugMsg(csound,"%s(%d) reset point to %d\n", __FILE__, __LINE__,
ST(repeat_point_n)[ST(repeat_index)], i);
- csound->DebugMsg(csound,"%s(%d) corefile: %s %d %d\n", __FILE__, __LINE__,
+ csound->DebugMsg(csound,"%s(%d) corefile: %s %d %d\n", __FILE__, __LINE__,
ST(repeat_mm_n)[ST(repeat_index)]->body->body,
ST(repeat_mm_n)[ST(repeat_index)]->body->p,
ST(repeat_mm_n)[ST(repeat_index)]->body->len);
@@ -684,7 +684,7 @@ static int nested_repeat(CSOUND *csound) /* gab A9*/
corfile_puts(buffer, ST(repeat_mm_n)[ST(repeat_index)]->body);
corfile_rewind(ST(repeat_mm_n)[ST(repeat_index)]->body);
#ifdef MACDEBUG
- csound->DebugMsg(csound,"%s(%d) corefile: %s %d %d\n", __FILE__, __LINE__,
+ csound->DebugMsg(csound,"%s(%d) corefile: %s %d %d\n", __FILE__, __LINE__,
ST(repeat_mm_n)[ST(repeat_index)]->body->body,
ST(repeat_mm_n)[ST(repeat_index)]->body->p,
ST(repeat_mm_n)[ST(repeat_index)]->body->len);
@@ -795,7 +795,7 @@ static void init_smacros(CSOUND *csound, NAMES *nn)
mm = (MACRO*) mcalloc(csound, sizeof(MACRO));
mm->name = (char*)mmalloc(csound,4);
strcpy(mm->name, "INF");
- mm->body = corfile_create_r("2147483647.0");
+ mm->body = corfile_create_r("800000000000.0");
#ifdef MACDEBUG
csound->DebugMsg(csound,"%s(%d): INF %p\n", __FILE__, __LINE__, mm->body);
#endif
@@ -998,7 +998,7 @@ int sread(CSOUND *csound) /* called from main, reads from SCOREIN */
flushlin(csound); /* Ignore rest of line */
ST(repeat_point_n)[ST(repeat_index)] =
corfile_tell(ST(str)->cf);
-
+
/* { does not start a new section - akozar */
/* ST(clock_base) = FL(0.0);
ST(warp_factor) = FL(1.0);
@@ -1110,7 +1110,7 @@ int sread(CSOUND *csound) /* called from main, reads from SCOREIN */
else mfree(csound, ST(names)[j].file);
ST(names)[ST(next_name)].posit = corfile_tell(ST(str)->cf);
ST(names)[ST(next_name)].line = ST(str)->line;
- ST(names)[ST(next_name)].file =
+ ST(names)[ST(next_name)].file =
mmalloc(csound, strlen(corfile_body(ST(str)->cf)) + 1);
strcpy(ST(names)[ST(next_name)].file, corfile_body(ST(str)->cf));
if (csound->oparms->msglevel & TIMEMSG)
@@ -1836,7 +1836,7 @@ MYFLT stof(CSOUND *csound, char s[]) /* convert string to MYFLT */
char *p;
MYFLT x = (MYFLT) strtod(s, &p);
- if (*p=='z') return FL(INF); /* Infinity or 7 years */
+ if (*p=='z') return FL(800000000000.0); /* 25367 years */
if (UNLIKELY(s == p || !(*p == '\0' || isspace(*p)))) {
csound->Message(csound, Str("sread: illegal number format: "));
p = s;
@@ -1850,4 +1850,3 @@ MYFLT stof(CSOUND *csound, char s[]) /* convert string to MYFLT */
}
return x;
}
-
diff --git a/Engine/swritestr.c b/Engine/swritestr.c
index 3c3d46c..a7e1821 100644
--- a/Engine/swritestr.c
+++ b/Engine/swritestr.c
@@ -37,11 +37,13 @@ static char *randramp(CSOUND *,SRTBLK *, char *, int, int);
static char *pfStr(CSOUND *,char *, int, int);
static char *fpnum(CSOUND *,char *, int, int);
-static void fltout(CSOUND *csound, MYFLT n)
+static void fltout(CSOUND *csound, MYFLT n)
{
- char buffer[1024];
+ char *c, buffer[1024];
sprintf(buffer, "%.6f", n);
- corfile_puts(buffer, csound->scstr);
+ /* corfile_puts(buffer, csound->scstr); */
+ for (c = buffer; *c != '\0'; c++)
+ corfile_putc(*c, csound->scstr);
}
void swritestr(CSOUND *csound)
@@ -539,4 +541,3 @@ static char *fpnum(CSOUND *csound,
}
return(p);
}
-
diff --git a/Engine/symbtab.c b/Engine/symbtab.c
index 398d29d..d35b530 100644
--- a/Engine/symbtab.c
+++ b/Engine/symbtab.c
@@ -139,6 +139,7 @@ void init_symbtab(CSOUND *csound)
add_token(csound, "ampdbfs", T_FUNCTION);
add_token(csound, "dbamp", T_FUNCTION);
add_token(csound, "dbfsamp", T_FUNCTION);
+ add_token_p(csound, "ftcps", T_FUNCTION, TR);
add_token_p(csound, "ftlen", T_FUNCTION, TR);
add_token_p(csound, "ftsr", T_FUNCTION, TR);
add_token_p(csound, "ftlptim", T_FUNCTION, TR);
@@ -205,7 +206,7 @@ ORCTOKEN *add_token(CSOUND *csound, char *s, int type)
while (a!=NULL) {
if (strcmp(a->lexeme, s)==0) {
if (type == a->type) return a;
- if (type!= T_FUNCTION || a->type!=T_OPCODE)
+ if (type!= T_FUNCTION || a->type!=T_OPCODE)
csound->Warning(csound,
Str("Type confusion for %s (%d,%d), replacing\n"),
s, type, a->type);
@@ -230,7 +231,7 @@ static ORCTOKEN *add_token_p(CSOUND *csound, char *s, int type, int val)
ans->value = val;
return ans;
}
-
+
int isUDOArgList(char *s)
{
int len = strlen(s) - 1;
@@ -297,7 +298,7 @@ ORCTOKEN *lookup_token(CSOUND *csound, char *s, void *yyscanner)
if (PARSER_DEBUG)
csound->Message(csound, "Looking up token for: %d: %d: %s : %s\n",
hash("reverb"), hash("a4"), s, a->lexeme);
- }
+ }
if (strcmp(a->lexeme, s)==0) {
ans = (ORCTOKEN*)mmalloc(csound, sizeof(ORCTOKEN));
memcpy(ans, a, sizeof(ORCTOKEN));
@@ -308,7 +309,7 @@ ORCTOKEN *lookup_token(CSOUND *csound, char *s, void *yyscanner)
}
a = a->next;
}
-
+
ans = new_token(csound, T_IDENT);
ans->lexeme = (char*)mmalloc(csound, 1+strlen(s));
@@ -378,7 +379,7 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
int S_incnt, S_outcnt, f_outcnt, f_incnt, t_incnt, t_outcnt;
int16 *a_inlist, *k_inlist, *i_inlist, *a_outlist, *k_outlist, *i_outlist;
int16 *S_inlist, *S_outlist, *f_inlist, *f_outlist, *t_inlist, *t_outlist;
-
+
/* count the number of arguments, and check types */
i = i_incnt = S_incnt = a_incnt = k_incnt = f_incnt = f_outcnt =
i_outcnt = S_outcnt = a_outcnt = k_outcnt = t_incnt = t_outcnt = err = 0;
@@ -494,9 +495,9 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
}
i++;
}
-
+
/* put delimiters */
- *i_inlist = *S_inlist = *a_inlist = *k_inlist = *f_inlist = *t_inlist = -1;
+ *i_inlist = *S_inlist = *a_inlist = *k_inlist = *f_inlist = *t_inlist = -1;
i_outlist = inm->out_ndx_list = t_inlist + 1;
S_outlist = i_outlist + i_outcnt + 1;
a_outlist = S_outlist + S_outcnt + 1;
@@ -516,7 +517,7 @@ static int parse_opcode_args(CSOUND *csound, OENTRY *opc)
}
i++;
}
-
+
*i_outlist = *S_outlist = *a_outlist = *k_outlist =
*f_outlist = *t_outlist = -1; /* put delimiters */
return err;
diff --git a/Engine/twarp.c b/Engine/twarp.c
index 871dfbf..03ea820 100644
--- a/Engine/twarp.c
+++ b/Engine/twarp.c
@@ -148,7 +148,7 @@ int realtset(CSOUND *csound, SRTBLK *bp)
tp->durslp = FL(0.0); /* clear last durslp */
if (UNLIKELY(++tp > (TSEG*) csound->tplim))
goto error3;
- tp->betbas = FL(999999.9); /* and cap with large betval */
+ tp->betbas = FL(9223372036854775807.0); /* and cap with large betval */
return(1);
error1:
diff --git a/H/csound.h b/H/csound.h
index b027cb4..4f08e2a 100644
--- a/H/csound.h
+++ b/H/csound.h
@@ -954,6 +954,9 @@ extern "C" {
PUBLIC int csoundScoreEvent(CSOUND *,
char type, const MYFLT *pFields, long numFields);
+ PUBLIC int csoundScoreEventAbsolute(CSOUND *,
+ char type, const MYFLT *pfields, long numFields, double time_ofs);
+
/*
* MIDI
*/
@@ -1415,7 +1418,7 @@ extern "C" {
# define CSOUND_SPIN_UNLOCK csoundSpinUnLock(&spinlock);
#elif defined(MACOSX)
-
+
#ifndef SWIG
#include <libkern/OSAtomic.h>
@@ -1968,4 +1971,3 @@ extern "C" {
#endif
#endif /* CSOUND_H */
-
diff --git a/H/csound.hpp b/H/csound.hpp
index b3dbbe4..89b8a1e 100644
--- a/H/csound.hpp
+++ b/H/csound.hpp
@@ -454,6 +454,11 @@ public:
{
return csoundScoreEvent(csound, type, pFields, numFields);
}
+ virtual int ScoreEventAbsolute(char type, const MYFLT *pFields,
+ long numFields, double time_ofs)
+ {
+ return csoundScoreEventAbsolute(csound, type, pFields, numFields, time_ofs);
+ }
// MIDI
virtual void SetExternalMidiInOpenCallback(
int (*func)(CSOUND *, void **, const char *))
diff --git a/H/csoundCore.h b/H/csoundCore.h
index 3231c07..d833264 100644
--- a/H/csoundCore.h
+++ b/H/csoundCore.h
@@ -35,7 +35,7 @@
#endif /* PARCS */
#include <stdarg.h>
#include <setjmp.h>
-
+
/*
#include <sndfile.h>
JPff: But this gives warnings in many files as rewriteheader expects
@@ -798,6 +798,8 @@ typedef struct {
MYFLT value));
int (*ScoreEvent)(CSOUND *,
char type, const MYFLT *pFields, long numFields);
+ int (*ScoreEventAbsolute)(CSOUND *,
+ char type, const MYFLT *pFields, long numFields, double time_ofs);
void (*SetExternalMidiInOpenCallback)(CSOUND *,
int (*func)(CSOUND *, void **, const char *));
void (*SetExternalMidiReadCallback)(CSOUND *,
@@ -1062,12 +1064,12 @@ typedef struct {
/** start time of current section */
double timeOffs, beatOffs;
/** current time in seconds, inc. per kprd */
- long icurTime; /* Current time in samples */
+ int64_t icurTime; /* Current time in samples */
double curTime_inc;
/** current time in beats, inc per kprd */
double curBeat, curBeat_inc;
/** beat time = 60 / tempo */
- long ibeatTime; /* Beat time in samples */
+ int64_t ibeatTime; /* Beat time in samples */
#if defined(HAVE_PTHREAD_SPIN_LOCK) && defined(PARCS)
pthread_spinlock_t spoutlock, spinlock;
#else
@@ -1186,7 +1188,7 @@ typedef struct {
EVTNODE *OrcTrigEvts; /* List of events to be started */
EVTNODE *freeEvtNodes;
int csoundIsScorePending_;
- int advanceCnt;
+ int64_t advanceCnt;
int initonly;
int evt_poll_cnt;
int evt_poll_maxcnt;
@@ -1209,7 +1211,7 @@ typedef struct {
void **cfgVariableDB;
double prvbt, curbt, nxtbt;
double curp2, nxtim;
- int cyclesRemaining;
+ int64_t cyclesRemaining;
EVTBLK evt;
void *memalloc_db;
MGLOBAL *midiGlobals;
@@ -1347,7 +1349,7 @@ typedef struct {
struct global_var_lock_t **global_var_lock_cache;
int global_var_lock_count;
int opcode_weight_cache_ctr;
- struct opcode_weight_cache_entry_t
+ struct opcode_weight_cache_entry_t
*opcode_weight_cache[OPCODE_WEIGHT_CACHE_SIZE];
int opcode_weight_have_cache;
struct dag_cache_entry_t *cache[DAG_2_CACHE_SIZE];
@@ -1381,11 +1383,11 @@ typedef struct {
#define LINKAGE1(name) \
long name##_init(CSOUND *csound, OENTRY **ep) \
-{ (void) csound; *ep = name; return (long) (sizeof(name)); }
+{ (void) csound; *ep = name; return (long) (sizeof(name)); }
#define FLINKAGE1(name) \
NGFENS* name##_init(CSOUND *csound) \
-{ (void) csound; return name; }
+{ (void) csound; return name; }
#ifdef __cplusplus
}
diff --git a/H/entry1.h b/H/entry1.h
index 7e84640..455d072 100644
--- a/H/entry1.h
+++ b/H/entry1.h
@@ -316,7 +316,7 @@ int lp2_set(CSOUND *, void *), lp2(CSOUND *, void *);
int phaser2set(CSOUND *, void *), phaser2(CSOUND *, void *);
int phaser1set(CSOUND *, void *), phaser1(CSOUND *, void *);
int balnset(CSOUND *, void *), balance(CSOUND *, void *);
-int prealloc(CSOUND *, void *);
+int prealloc(CSOUND *, void *), active_alloc(CSOUND*, void*);
int cpsxpch(CSOUND *, void *), cps2pch(CSOUND *, void *);
int cpstmid(CSOUND *, void *);
int cpstun(CSOUND *, void *), cpstun_i(CSOUND *, void *);
diff --git a/H/interlocks.h b/H/interlocks.h
index 8d0328d..b5b9a5c 100644
--- a/H/interlocks.h
+++ b/H/interlocks.h
@@ -34,6 +34,6 @@
#define CB (0x3000)
#define SB (0x4000)
+#define _QQ (0x8000)
-#define DP (0x8000)
diff --git a/H/prototyp.h b/H/prototyp.h
index bcfaa07..44d7ee0 100644
--- a/H/prototyp.h
+++ b/H/prototyp.h
@@ -103,7 +103,7 @@ int csoundCheckOpcodePluginFile(CSOUND *, const char *);
int csoundLoadAllPluginOpcodes(CSOUND *);
int csoundLoadAndInitModule(CSOUND *, const char *);
void csoundNotifyFileOpened(CSOUND *, const char *, int, int, int);
-int insert_score_event_at_sample(CSOUND *, EVTBLK *, long);
+int insert_score_event_at_sample(CSOUND *, EVTBLK *, int64_t);
/**
* Register a function to be called at note deactivation.
diff --git a/H/soundio.h b/H/soundio.h
index c64522b..fe0d288 100644
--- a/H/soundio.h
+++ b/H/soundio.h
@@ -32,6 +32,9 @@
#elif defined(NeXT) || defined(__MACH__)
#define IOBUFSAMPS 1024 /* default sampframes in audio iobuf, -b settable */
#define IODACSAMPS 4096 /* default samps in hardware buffer, -B settable */
+#elif defined(ANDROID)
+#define IOBUFSAMPS 2048 /* default sampframes in audio iobuf, -b settable */
+#define IODACSAMPS 4096 /* default samps in hardware buffer, -B settable */
#else
#define IOBUFSAMPS 256 /* default sampframes in audio iobuf, -b settable */
#define IODACSAMPS 1024 /* default samps in hardware buffer, -B settable */
diff --git a/H/version.h b/H/version.h
index 55a12d2..3a69332 100644
--- a/H/version.h
+++ b/H/version.h
@@ -24,7 +24,7 @@
#ifndef CSOUND_VERSION_H
#define CSOUND_VERSION_H
-#define VERSION "5.16"
+#define VERSION "5.17"
/* Define to the full name of this package. */
#ifndef PARCS
@@ -46,7 +46,7 @@
/* Define to the version of this package. */
#define CS_PACKAGE_VERSION VERSION
#define CS_VERSION (5)
-#define CS_SUBVER (16)
+#define CS_SUBVER (17)
#define CS_PATCHLEVEL (6)
#define CS_APIVERSION 2 /* should be increased anytime a new version
diff --git a/How_to_Build_Csound_on_Windows.doc b/How_to_Build_Csound_on_Windows.doc
index 9c0d095..3dcb646 100644
Binary files a/How_to_Build_Csound_on_Windows.doc and b/How_to_Build_Csound_on_Windows.doc differ
diff --git a/InOut/FL_graph.cpp b/InOut/FL_graph.cpp
index 1ec008d..a557fbe 100644
--- a/InOut/FL_graph.cpp
+++ b/InOut/FL_graph.cpp
@@ -72,7 +72,7 @@ typedef struct {
#define ST(x) (((FLGRAPH_GLOBALS*) csound->flgraphGlobals)->x)
-/*void printouts(CSOUND *csound){
+/*void printouts(CSOUND *csound){
csound->Message(csound, "menu object: %p\n", ST(menu));
csound->Message(csound, "form object: %p\n", ST(form));
csound->Message(csound, "graph object: %p\n", ST(graph));
@@ -82,8 +82,8 @@ typedef struct {
void flgraph_init(CSOUND *csound)
{
-
- if (csound->flgraphGlobals==NULL) {
+
+ if (csound->flgraphGlobals==NULL) {
csound->flgraphGlobals =
(FLGRAPH_GLOBALS*) csound->Malloc(csound,sizeof(FLGRAPH_GLOBALS));
}
@@ -93,12 +93,12 @@ void flgraph_init(CSOUND *csound)
ST(graph) = (graph_box *) 0;
ST(menu) = (Fl_Menu_Item *) 0;
ST(graph_created) = 0;
-
+
/*ST(menu) = (Fl_Menu_Item*) csound->Calloc(csound,
sizeof(Fl_Menu_Item)*(1+NUMOFWINDOWS));*/
/* VL: moved menu object to be built at each new compilation */
-
+
}
/* static graph_box *graph = (graph_box *) 0; */
@@ -203,12 +203,12 @@ void add_graph(CSOUND *csound, WINDAT *wdptr)
int m;
WINDAT *old;
int replacing = 0;
-
+
memcpy(n, wdptr, sizeof(WINDAT));
n->fdata = (MYFLT*) malloc(n->npts * sizeof(MYFLT));
memcpy(n->fdata, wdptr->fdata, n->npts * sizeof(MYFLT));
-
+
for (m = 0; m < NUMOFWINDOWS; m++) { // If text the same use slot
if(ST(menu) != NULL) {
if (ST(menu)[m].text != NULL && wdptr->caption != NULL){
@@ -225,7 +225,7 @@ void add_graph(CSOUND *csound, WINDAT *wdptr)
if (m >= NUMOFWINDOWS)
m = ST(graph)->last = 0;
replace:
-
+
old = (WINDAT*)ST(menu)[m].user_data_;
if (old) {
free((void*) old->fdata);
@@ -238,11 +238,11 @@ void add_graph(CSOUND *csound, WINDAT *wdptr)
ST(menu)[m].text = (const char*) malloc(strlen(n->caption) + 1);
strcpy((char*) ST(menu)[m].text, n->caption);
}
-
-
+
+
// ST(graph)->curr = m;
// ST(choice)->value(m);
-
+
ST(graph)->curr = ST(choice)->value(); /* VL: 29.04.09 fix */
ST(graph)->redraw();
}
@@ -258,10 +258,10 @@ void makeWindow(CSOUND *csound, char *name)
{
if (ST(form))
return;
-
+
ST(form) = new Fl_Window(WIDTH, HEIGHT, name);
ST(menu) = new Fl_Menu_Item[1+NUMOFWINDOWS];
- memset(ST(menu), 0, sizeof(Fl_Menu_Item)*(1+NUMOFWINDOWS));
+ memset(ST(menu), 0, sizeof(Fl_Menu_Item)*(1+NUMOFWINDOWS));
ST(choice) = new Fl_Choice(140, 0, 140, 20, "Choose Graph");
ST(choice)->menu(ST(menu));
ST(choice)->value(0);
@@ -274,7 +274,7 @@ void makeWindow(CSOUND *csound, char *name)
ST(form)->resizable(ST(graph));
ST(form)->end();
ST(graph_created) = 1;
-
+
}
void graphs_reset(CSOUND * csound){
@@ -285,19 +285,19 @@ extern "C" {
void DrawGraph_FLTK(CSOUND *csound, WINDAT *wdptr)
{
-
+
add_graph(csound, wdptr);
csound->CheckEvents(csound);
}
uintptr_t MakeWindow_FLTK(CSOUND *csound, char *name)
{
-
+
if (ST(form) == NULL) {
makeWindow(csound, name);
ST(form)->show();
}
-
+
return (uintptr_t) ST(form);
}
@@ -331,41 +331,41 @@ extern "C" {
int ExitGraph_FLTK(CSOUND *csound)
{
if (ST(form) && ST(graph_created) == 1) {
-
+
if (ST(form)->shown() && !(getFLTKFlags(csound) & 256)) {
const char *env = csound->GetEnv(csound, "CSNOSTOP");
if (env == NULL || strcmp(env, "yes") != 0) {
ST(end)->show();
- // print click-Exit message in most recently active window
+ // print click-Exit message in most recently active window
while (ST(end)->value() == 0 && ST(form)->shown()) {
Fl_wait_locked(csound, 0.03);
}
}
}
- delete ST(form);
+ delete ST(form);
ST(form) = (Fl_Window *) 0;
Fl_wait_locked(csound, 0.0);
-
+
ST(choice) = (Fl_Choice *) 0;
ST(graph) = (graph_box *) 0;
ST(end) = (Fl_Button *) 0;
ST(graph_created) = 0;
-
+
for (int i = 0; i < NUMOFWINDOWS; i++) {
WINDAT *n = (WINDAT*) ST(menu)[i].user_data_;
if (n)
kill_graph(csound, (uintptr_t) ((void*) n));
- }
+ }
if(ST(menu)){
delete ST(menu);
ST(menu) = (Fl_Menu_Item *) 0;
}
-
-
-
+
+
+
}
-
+
return 0;
}
@@ -456,9 +456,8 @@ extern "C" {
void KillXYin_FLTK(CSOUND *csound, XYINDAT *wdptr)
{
-
+
delete ((Fl_Window*) wdptr->windid);
wdptr->windid = (uintptr_t) 0;
}
}
-
diff --git a/InOut/cmidi.c b/InOut/cmidi.c
index 8917e15..b168b0d 100644
--- a/InOut/cmidi.c
+++ b/InOut/cmidi.c
@@ -24,7 +24,7 @@
/* Realtime MIDI using coremidi */
-#include <CoreMidi/CoreMidi.h>
+#include <CoreMIDI/CoreMIDI.h>
#include <CoreAudio/HostTime.h>
#include <CoreFoundation/CoreFoundation.h>
#include "csdl.h" /* CMIDI.C */
@@ -55,94 +55,97 @@ typedef struct _cdata {
/* coremidi callback, called when MIDI data is available */
-void ReadProc(const MIDIPacketList *pktlist, void *refcon, void *srcConnRefCon){
-
- cdata *data = (cdata *)refcon;
- MIDIdata *mdata = data->mdata;
- int *p = &data->p, i, j;
- MIDIPacket *packet = &((MIDIPacketList *)pktlist)->packet[0];
- Byte *curpack;
-
- for (i = 0; i < pktlist->numPackets; i++) {
- for(j=0; j < packet->length; j+=3){
- curpack = packet->data+j;
- memcpy(&mdata[*p], curpack, 3);
- mdata[*p].flag = 1;
- (*p)++;
- if(*p == DSIZE) *p = 0;
- }
- packet = MIDIPacketNext(packet);
- }
+void ReadProc(const MIDIPacketList *pktlist, void *refcon, void *srcConnRefCon)
+{
+ cdata *data = (cdata *)refcon;
+ MIDIdata *mdata = data->mdata;
+ int *p = &data->p, i, j;
+ MIDIPacket *packet = &((MIDIPacketList *)pktlist)->packet[0];
+ Byte *curpack;
+
+ for (i = 0; i < pktlist->numPackets; i++) {
+ for (j=0; j < packet->length; j+=3) {
+ curpack = packet->data+j;
+ memcpy(&mdata[*p], curpack, 3);
+ mdata[*p].flag = 1;
+ (*p)++;
+ if(*p == DSIZE) *p = 0;
+ }
+ packet = MIDIPacketNext(packet);
+ }
}
-/* csound MIDI input open callback, sets the device for input */
+/* csound MIDI input open callback, sets the device for input */
static int MidiInDeviceOpen(CSOUND *csound, void **userData, const char *dev)
{
- int k, endpoints, dest;
- CFStringRef name = NULL, cname = NULL, pname = NULL;
- CFStringEncoding defaultEncoding = CFStringGetSystemEncoding();
- MIDIClientRef mclient = (MIDIClientRef) 0;
- MIDIPortRef mport = (MIDIPortRef) 0;
- MIDIEndpointRef endpoint;
- MIDIdata *mdata = (MIDIdata *) malloc(DSIZE*sizeof(MIDIdata));
- OSStatus ret;
- cdata *refcon = (cdata *) malloc(sizeof(cdata));
- memset(mdata, 0, sizeof(MIDIdata)*DSIZE);
- refcon->mdata = mdata;
- refcon->p = 0;
- refcon->q = 0;
-
- /* MIDI client */
- cname = CFStringCreateWithCString(NULL, "my client", defaultEncoding);
- ret = MIDIClientCreate(cname, NULL, NULL, &mclient);
- if(!ret){
+ int k, endpoints, dest;
+ CFStringRef name = NULL, cname = NULL, pname = NULL;
+ CFStringEncoding defaultEncoding = CFStringGetSystemEncoding();
+ MIDIClientRef mclient = (MIDIClientRef) 0;
+ MIDIPortRef mport = (MIDIPortRef) 0;
+ MIDIEndpointRef endpoint;
+ MIDIdata *mdata = (MIDIdata *) malloc(DSIZE*sizeof(MIDIdata));
+ OSStatus ret;
+ cdata *refcon = (cdata *) malloc(sizeof(cdata));
+ memset(mdata, 0, sizeof(MIDIdata)*DSIZE);
+ refcon->mdata = mdata;
+ refcon->p = 0;
+ refcon->q = 0;
+
+ /* MIDI client */
+ cname = CFStringCreateWithCString(NULL, "my client", defaultEncoding);
+ ret = MIDIClientCreate(cname, NULL, NULL, &mclient);
+ if(!ret){
/* MIDI input port */
- pname = CFStringCreateWithCString(NULL, "inport", defaultEncoding);
- ret = MIDIInputPortCreate(mclient, pname, ReadProc, refcon, &mport);
- if(!ret){
- /* sources, we connect to all available input sources */
+ pname = CFStringCreateWithCString(NULL, "inport", defaultEncoding);
+ ret = MIDIInputPortCreate(mclient, pname, ReadProc, refcon, &mport);
+ if(!ret){
+ /* sources, we connect to all available input sources */
endpoints = MIDIGetNumberOfSources();
csound->Message(csound, "%d MIDI sources in system \n", endpoints);
- if(!strcmp(dev,"all")) {
- csound->Message(csound, "receiving from all sources \n");
- for(k=0; k < endpoints; k++){
- endpoint = MIDIGetSource(k);
- long srcRefCon = (long) endpoint;
- MIDIPortConnectSource(mport, endpoint, (void *) srcRefCon);
- MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name);
- csound->Message(csound, "connecting midi device %d: %s \n", k,
- CFStringGetCStringPtr(name, defaultEncoding));
- }
+ if(!strcmp(dev,"all")) {
+ csound->Message(csound, "receiving from all sources \n");
+ for(k=0; k < endpoints; k++){
+ endpoint = MIDIGetSource(k);
+ long srcRefCon = (long) endpoint;
+ MIDIPortConnectSource(mport, endpoint, (void *) srcRefCon);
+ MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name);
+ csound->Message(csound, "connecting midi device %d: %s \n", k,
+ CFStringGetCStringPtr(name, defaultEncoding));
+ }
}
else{
k = atoi(dev);
if(k < endpoints){
- endpoint = MIDIGetSource(k);
- long srcRefCon = (long) endpoint;
- MIDIPortConnectSource(mport, endpoint, (void *) srcRefCon);
- MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name);
- csound->Message(csound, "connecting midi device %d: %s \n", k,
- CFStringGetCStringPtr(name, defaultEncoding));
+ endpoint = MIDIGetSource(k);
+ long srcRefCon = (long) endpoint;
+ MIDIPortConnectSource(mport, endpoint, (void *) srcRefCon);
+ MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name);
+ csound->Message(csound, "connecting midi device %d: %s \n", k,
+ CFStringGetCStringPtr(name, defaultEncoding));
}
- else csound->Message(csound, "MIDI device number %d is out-of-range, not connected \n", k);
+ else
+ csound->Message(csound,
+ "MIDI device number %d is out-of-range, "
+ "not connected \n", k);
}
- }
- }
- refcon->mclient = mclient;
- *userData = (void*) refcon;
+ }
+ }
+ refcon->mclient = mclient;
+ *userData = (void*) refcon;
if(name) CFRelease(name);
if(pname) CFRelease(pname);
- if(cname) CFRelease(cname);
+ if(cname) CFRelease(cname);
/* report success */
return 0;
}
static int MidiOutDeviceOpen(CSOUND *csound, void **userData, const char *dev)
{
- /*stub for the moment */
- csound->Message(csound, "output not implemented yet in CoreMIDI \n");
+ /*stub for the moment */
+ csound->Message(csound, "output not implemented yet in CoreMIDI \n");
return 0;
}
@@ -159,43 +162,43 @@ static int MidiDataRead(CSOUND *csound, void *userData,
/* check if there is new data in circular queue */
while (mdata[*q].flag) {
- st = (int) mdata[*q].status;
- d1 = (int) mdata[*q].data1;
- d2 = (int) mdata[*q].data2;
-
- if (st < 0x80) goto next;
-
- if (st >= 0xF0 &&
- !(st == 0xF8 || st == 0xFA || st == 0xFB ||
- st == 0xFC || st == 0xFF)) goto next;
-
- nbytes -= (datbyts[(st - 0x80) >> 4] + 1);
- if (nbytes < 0) break;
-
- /* write to csound midi buffer */
- n += (datbyts[(st - 0x80) >> 4] + 1);
- switch (datbyts[(st - 0x80) >> 4]) {
- case 0:
- *mbuf++ = (unsigned char) st;
- break;
- case 1:
- *mbuf++ = (unsigned char) st;
- *mbuf++ = (unsigned char) d1;
- break;
- case 2:
- *mbuf++ = (unsigned char) st;
- *mbuf++ = (unsigned char) d1;
- *mbuf++ = (unsigned char) d2;
- break;
- }
- /* mark as read */
- next:
- mdata[*q].flag = 0;
- (*q)++;
- if(*q==DSIZE) *q = 0;
-
+ st = (int) mdata[*q].status;
+ d1 = (int) mdata[*q].data1;
+ d2 = (int) mdata[*q].data2;
+
+ if (st < 0x80) goto next;
+
+ if (st >= 0xF0 &&
+ !(st == 0xF8 || st == 0xFA || st == 0xFB ||
+ st == 0xFC || st == 0xFF)) goto next;
+
+ nbytes -= (datbyts[(st - 0x80) >> 4] + 1);
+ if (nbytes < 0) break;
+
+ /* write to csound midi buffer */
+ n += (datbyts[(st - 0x80) >> 4] + 1);
+ switch (datbyts[(st - 0x80) >> 4]) {
+ case 0:
+ *mbuf++ = (unsigned char) st;
+ break;
+ case 1:
+ *mbuf++ = (unsigned char) st;
+ *mbuf++ = (unsigned char) d1;
+ break;
+ case 2:
+ *mbuf++ = (unsigned char) st;
+ *mbuf++ = (unsigned char) d1;
+ *mbuf++ = (unsigned char) d2;
+ break;
}
-
+ /* mark as read */
+ next:
+ mdata[*q].flag = 0;
+ (*q)++;
+ if(*q==DSIZE) *q = 0;
+
+ }
+
/* return the number of bytes read */
return n;
}
@@ -213,7 +216,7 @@ static int MidiInDeviceClose(CSOUND *csound, void *userData)
static int MidiDataWrite(CSOUND *csound, void *userData,
const unsigned char *mbuf, int nbytes)
{
- /* stub at the moment */
+ /* stub at the moment */
return nbytes;
}
@@ -221,7 +224,7 @@ static int MidiDataWrite(CSOUND *csound, void *userData,
static int MidiOutDeviceClose(CSOUND *csound, void *userData)
{
- /* sutb at the mement */
+ /* stub at the mement */
return 0;
}
diff --git a/InOut/libsnd.c b/InOut/libsnd.c
index 4477421..0b35260 100644
--- a/InOut/libsnd.c
+++ b/InOut/libsnd.c
@@ -222,14 +222,14 @@ static void writesf_dither_16(CSOUND *csound, const MYFLT *outbuf, int nbytes)
return;
for (n=0; n<m; n++) {
- int tmp = ((ST(dither) * 15625) + 1) & 0xFFFF;
- int rnd = ((tmp * 15625) + 1) & 0xFFFF;
- MYFLT result;
- ST(dither) = rnd;
- rnd = (rnd+tmp)>>1; /* triangular distribution */
- result = (MYFLT) (rnd - 0x8000) / ((MYFLT) 0x10000);
- result /= ((MYFLT) 0x7fff);
- buf[n] += result;
+ int tmp = ((ST(dither) * 15625) + 1) & 0xFFFF;
+ int rnd = ((tmp * 15625) + 1) & 0xFFFF;
+ MYFLT result;
+ ST(dither) = rnd;
+ rnd = (rnd+tmp)>>1; /* triangular distribution */
+ result = (MYFLT) (rnd - 0x8000) / ((MYFLT) 0x10000);
+ result /= ((MYFLT) 0x7fff);
+ buf[n] += result;
}
n = (int) sf_write_MYFLT(ST(outfile), (MYFLT*) outbuf,
nbytes / sizeof(MYFLT)) * (int) sizeof(MYFLT);
diff --git a/InOut/midisend.c b/InOut/midisend.c
index 665ef97..6e631d4 100644
--- a/InOut/midisend.c
+++ b/InOut/midisend.c
@@ -191,7 +191,10 @@ void openMIDIout(CSOUND *csound)
}
p->midiOutFileData = (void *) fp;
/* write header */
- fwrite(&(midiOutFile_header[0]), (size_t)1, (size_t)22, fp->f);
+ if (UNLIKELY(fwrite(&(midiOutFile_header[0]),
+ (size_t)1, (size_t)22, fp->f) != 22)) {
+ csound->Die(csound, "SHort write in MIDI\n");
+ }
}
void csoundCloseMidiOutFile(CSOUND *csound)
diff --git a/InOut/rtauhal.c b/InOut/rtauhal.c
index a011627..27d8954 100644
--- a/InOut/rtauhal.c
+++ b/InOut/rtauhal.c
@@ -21,7 +21,6 @@
02111-1307 USA
*/
-#include <CoreMidi/CoreMidi.h>
#include <AudioUnit/AudioUnit.h>
#include <CoreAudio/AudioHardware.h>
#include <CoreFoundation/CoreFoundation.h>
@@ -114,7 +113,7 @@ int AuHAL_open(CSOUND *csound, const csRtAudioParams * parm,
psize = sizeof(AudioDeviceID);
AudioObjectGetPropertyData(kAudioObjectSystemObject,
&prop, 0, NULL, &psize, &dev);
-
+
if(isInput) cdata->defdevin = dev;
else cdata->defdevout = dev;
@@ -178,22 +177,22 @@ int AuHAL_open(CSOUND *csound, const csRtAudioParams * parm,
bufframes = csound->GetInputBufferSize(csound)/nchnls;
}
- /* although the SR is set in the stream properties,
+ /* although the SR is set in the stream properties,
we also need to set the device to match */
prop.mSelector = kAudioDevicePropertyNominalSampleRate;
psize = sizeof(double);
AudioObjectSetPropertyData(dev, &prop, 0, NULL, psize, &srate);
-
+
double sr;
AudioObjectGetPropertyData(dev, &prop, 0, NULL, &psize, &sr);
if(sr != srate) {
- csound->Die(csound,
+ csound->Die(csound,
"could not set SR, tried %.1f, got %.1f \n", srate, sr);
- }
+ }
HALOutput = AudioComponentFindNext(NULL, &cd);
if(isInput){
- AudioComponentInstanceNew(HALOutput, &(cdata->inunit));
+ AudioComponentInstanceNew(HALOutput, &(cdata->inunit));
enableIO = 1;
AudioUnitSetProperty(cdata->inunit, kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input, 1, &enableIO, sizeof(enableIO));
@@ -203,7 +202,7 @@ int AuHAL_open(CSOUND *csound, const csRtAudioParams * parm,
psize = sizeof(AudioDeviceID);
/* for input, select device AFTER enabling IO */
AudioUnitSetProperty(cdata->inunit,kAudioOutputUnitProperty_CurrentDevice,
- kAudioUnitScope_Global, isInput, &dev, psize);
+ kAudioUnitScope_Global, isInput, &dev, psize);
aunit = &(cdata->inunit);
} else {
AudioComponentInstanceNew(HALOutput, &(cdata->outunit));
@@ -508,14 +507,14 @@ static void rtclose_(CSOUND *csound)
};
UInt32 psize = sizeof(AudioDeviceID);
AudioObjectSetPropertyData(kAudioObjectSystemObject,
- &prop, 0, NULL, psize, &cdata->defdevin);
+ &prop, 0, NULL, psize, &cdata->defdevin);
}
- if(cdata->defdevout) {
+ if(cdata->defdevout) {
AudioObjectPropertyAddress prop = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
- };
+ };
UInt32 psize = sizeof(AudioDeviceID);
AudioObjectSetPropertyData(kAudioObjectSystemObject,
&prop, 0, NULL, psize, &cdata->defdevout);
diff --git a/InOut/rtpa.c b/InOut/rtpa.c
index e752907..20a0dcd 100644
--- a/InOut/rtpa.c
+++ b/InOut/rtpa.c
@@ -30,7 +30,7 @@
#endif
#include <portaudio.h>
-#define NO_FULLDUPLEX_PA_LOCK 0
+#define NO_FULLDUPLEX_PA_LOCK 0
typedef struct PaAlsaStreamInfo {
unsigned long size;
@@ -355,12 +355,12 @@ static int paBlockingReadWriteStreamCallback(const void *input,
float *paInput = (float*) input;
float *paOutput = (float*) output;
-
+
if (pabs->complete == 1) {
return paComplete;
}
-
-#ifdef WIN32
+
+#ifdef WIN32
if (pabs->paStream == NULL
|| pabs->paused
) {
@@ -378,13 +378,13 @@ return paContinue;
/*# ifdef WIN32 */
err = csound->WaitThreadLock(pabs->paLock, (size_t) pabs->paLockTimeout);
/*# else
- err = csound->WaitThreadLock(pabs->paLock, (size_t) 500);
+ err = csound->WaitThreadLock(pabs->paLock, (size_t) 500);
# endif
#else
csound->WaitThreadLock(pabs->paLock, (size_t) 500);
err = 0;
#endif*/
-
+
if (pabs->mode & 1) {
int n = pabs->inBufSamples;
int i = 0;
@@ -407,7 +407,7 @@ return paContinue;
paClearOutputBuffer(pabs, paOutput);
}
}
-
+
paClearOutputBuffer(pabs, pabs->outputBuffer);
csound->NotifyThreadLock(pabs->clientLock);
@@ -499,7 +499,7 @@ static int recopen_(CSOUND *csound, const csRtAudioParams *parm)
*(p->GetRtRecordUserData(p)) = (void*) pabs;
pabs->complete = 0;
-
+
return 0;
}
@@ -523,7 +523,7 @@ static int playopen_(CSOUND *csound, const csRtAudioParams *parm)
*(p->GetRtPlayUserData(p)) = (void*) pabs;
pabs->complete = 0;
-
+
return (paBlockingReadWriteOpen(p));
}
@@ -536,7 +536,7 @@ static void rtclose_(CSOUND *csound)
"_rtpaGlobals");
if (pabs == NULL)
return;
-
+
pabs->complete = 1;
if (pabs->paStream != NULL) {
@@ -551,7 +551,7 @@ static void rtclose_(CSOUND *csound)
csound->NotifyThreadLock(pabs->clientLock);
// Pa_Sleep(80);
}
-
+
Pa_StopStream(stream);
Pa_CloseStream(stream);
// Pa_Sleep(80);
@@ -833,4 +833,3 @@ PUBLIC int csoundModuleInfo(void)
{
return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT));
}
-
diff --git a/InOut/virtual_keyboard/FLTKKeyboardWidget.cpp b/InOut/virtual_keyboard/FLTKKeyboardWidget.cpp
index 08149de..c43f31c 100644
--- a/InOut/virtual_keyboard/FLTKKeyboardWidget.cpp
+++ b/InOut/virtual_keyboard/FLTKKeyboardWidget.cpp
@@ -135,12 +135,12 @@ FLTKKeyboardWidget::FLTKKeyboardWidget(CSOUND *csound,
setProgramNames();
octaveChoice->clear();
-
+
for(unsigned int i = 1; i < 8; i++) {
octave[0] = i + 48;
octaveChoice->add(octave);
}
-
+
octaveChoice->value(4);
this->bankChoice->callback((Fl_Callback*)bankChange, this);
diff --git a/InOut/virtual_keyboard/SliderBank.hpp b/InOut/virtual_keyboard/SliderBank.hpp
index cde4f6f..6dceb65 100644
--- a/InOut/virtual_keyboard/SliderBank.hpp
+++ b/InOut/virtual_keyboard/SliderBank.hpp
@@ -35,7 +35,7 @@ class WheelSlider: public Fl_Value_Slider
{
int handle(int);
public:
- WheelSlider(int x, int y, int w, int h, const char *l=0) :
+ WheelSlider(int x, int y, int w, int h, const char *l=0) :
Fl_Value_Slider (x,y,w,h,l) {}
};
diff --git a/InOut/widgets.cpp b/InOut/widgets.cpp
index 994f349..ba58272 100644
--- a/InOut/widgets.cpp
+++ b/InOut/widgets.cpp
@@ -1094,8 +1094,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_:
case EXP_:
val = *p->kout;
- if (val < min) val=min;
- else if(val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default: val = ((Fl_Valuator *)v.WidgAddress)->value();
}
@@ -1115,8 +1121,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_: case EXP_:
val = *fld->sldbnk[j].out;
min = fld->sldbnk[j].min; max = fld->sldbnk[j].max;
- if (val < min) val = min;
- if (val > max) val = max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default:
val = ((Fl_Valuator *) ((Fl_Group*)v.WidgAddress)->
@@ -1138,8 +1150,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_: case EXP_:
val = *fld->sldbnk[j].out;
min = fld->sldbnk[j].min; max = fld->sldbnk[j].max;
- if (val < min) val = min;
- if (val > max) val = max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default:
val = ((Fl_Valuator *) ((Fl_Group*) v.WidgAddress)->child(j))->value();
@@ -1156,8 +1174,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_:
case EXP_:
val = *p->kout;
- if (val < min) val=min;
- else if(val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default: val = ((Fl_Valuator *)v.WidgAddress)->value();
}
@@ -1172,8 +1196,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_:
case EXP_:
val = *p->kout;
- if (val < min) val=min;
- else if(val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default: val = ((Fl_Valuator *)v.WidgAddress)->value();
}
@@ -1183,8 +1213,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
FLTEXT *p = (FLTEXT *) (v.opcode);
fld->widg_name = GetString(csound, p->name, p->XSTRCODE);
val = *p->kout; min = fld->min = *p->imin; max = fld->max = *p->imax;
- if (val < min) val=min;
- else if (val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
fld->value = val;
fld->exp = LIN_;
}
@@ -1197,8 +1233,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_:
case EXP_:
val = *p->koutx;
- if (val < min) val=min;
- else if(val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default:
val = ((Fl_Positioner *)v.WidgAddress)->xvalue();
@@ -1209,8 +1251,14 @@ SNAPSHOT::SNAPSHOT (vector<ADDR_SET_VALUE>& valuators, int snapGroup)
switch (fld->exp2) {
case LIN_: case EXP_:
val = *p->kouty;
- if (val < min) val=min;
- else if(val>max) val=max;
+ if (min < max) {
+ if (val < min) val=min;
+ else if(val>max) val=max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
break;
default:
val = ((Fl_Positioner *)v.WidgAddress)->yvalue();
@@ -1278,8 +1326,14 @@ int SNAPSHOT::get(vector<ADDR_SET_VALUE>& valuators, int snapGroup)
MYFLT val = fld->value, valtab = fld->value, min=fld->min,
max=fld->max, range,base;
- if (val < min) val = min;
- else if (val >max) val = max;
+ if (min < max) {
+ if (val < min) val = min;
+ else if (val >max) val = max;
+ }
+ else {
+ if (val < max) val=max;
+ else if(val>min) val=min;
+ }
if (opcode_name == "FLjoy") {
switch(fld->exp) {
@@ -1418,7 +1472,10 @@ int SNAPSHOT::get(vector<ADDR_SET_VALUE>& valuators, int snapGroup)
case LIN_:
if (opcode_name == "FLbox" || opcode_name == "FLvalue" ) continue;
else if (opcode_name == "FLtext" &&
- *((FLTEXT *)opcode)->itype == 1) continue;
+ *((FLTEXT *)opcode)->itype == 1) {
+ ((Fl_Valuator*) o)->value(val);
+ continue;
+ }
((Fl_Valuator*) o)->value(val);
break;
case EXP_:
@@ -1519,7 +1576,7 @@ extern "C" {
Fl_lock(csound);
n = fl_choice("%s", Str("Saving could overwrite the old file.\n"
"Are you sure you want to save ?"),
- Str("No"), Str("Yes"), (char*)NULL); // should thing be "" ?
+ Str("No"), Str("Yes"), (const char*)""); // used to be NULL
Fl_unlock(csound);
if (!n)
return OK;
@@ -2682,11 +2739,12 @@ extern "C" {
{
Fl_Pack *o = new Fl_Pack ((int) *p->ix, (int) *p->iy,
(int) *p->iwidth, (int) *p->iheight);
- Fl_Boxtype borderType;
+ Fl_Boxtype borderType = FL_FLAT_BOX;
int iborder = (int)*p->iborder;
// fl_window->resizable(o);
- if (iborder<0 || iborder>7) borderType = FL_FLAT_BOX;
- else borderType = BOX_TABLE[iborder];
+ if (!((iborder<0 || iborder>7)))
+ borderType = BOX_TABLE[iborder];
+ o->box(borderType); // JPff added March 2012
o->type((int)*p->itype);
o->spacing((int)*p->ispace);
diff --git a/InOut/winEPS.c b/InOut/winEPS.c
index 6a1668c..ddcc6b1 100644
--- a/InOut/winEPS.c
+++ b/InOut/winEPS.c
@@ -193,7 +193,7 @@ static void setAxisNumbers(MYFLT *min, MYFLT *max, char *cmin, char *cmax)
bmax = 0.0000001;
if (fabs((double)*max) > bmax) {
- while ((i = (int)(fabs(*max) / bmax)))
+ while ((i = (int)(FABS(*max) / bmax)))
bmax = bmax * 10.0;
}
if (fabs(bmin) > fabs(bmax))
diff --git a/InOut/winFLTK.c b/InOut/winFLTK.c
index c6a4cec..3474bcd 100644
--- a/InOut/winFLTK.c
+++ b/InOut/winFLTK.c
@@ -103,7 +103,7 @@ PUBLIC int csoundModuleInit(CSOUND *csound)
/* seemed to crash, but not anymore... */
csound->RegisterResetCallback(csound, NULL, widget_reset);
csound->Message(csound, "graph init \n");
-
+
}
#ifdef LINUX
}
@@ -150,4 +150,3 @@ PUBLIC int csoundModuleInfo(void)
{
return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int)sizeof(MYFLT));
}
-
diff --git a/InOut/window.c b/InOut/window.c
index 5894fbd..eefd0c1 100644
--- a/InOut/window.c
+++ b/InOut/window.c
@@ -153,7 +153,7 @@ void display(CSOUND *csound, WINDAT *wdptr) /* prepare a MYFLT array, then */
MYFLT *fp, *fplim;
MYFLT max, min, absmax, fval;
int pol;
-
+
if (!csound->oparms->displays) return; /* displays disabled? return */
fp = wdptr->fdata;
fplim = fp + wdptr->npts;
@@ -177,7 +177,7 @@ void display(CSOUND *csound, WINDAT *wdptr) /* prepare a MYFLT array, then */
else if (pol == (int16)POSPOL && min < FL(0.0)) pol = (int16)BIPOL;
else if (pol == (int16)NEGPOL && max > FL(0.0)) pol = (int16)BIPOL;
wdptr->polarity = pol;
-
+
/* now graph the function */
csound->csoundDrawGraphCallback_(csound, wdptr);
@@ -186,4 +186,3 @@ void display(CSOUND *csound, WINDAT *wdptr) /* prepare a MYFLT array, then */
if (csound->oparms->postscript)
PS_DrawGraph(csound, wdptr);
}
-
diff --git a/OOps/aops.c b/OOps/aops.c
index d5896e7..b6195e9 100644
--- a/OOps/aops.c
+++ b/OOps/aops.c
@@ -76,7 +76,7 @@ MYFLT csoundPow2(CSOUND *csound, MYFLT a){
/*static inline MYFLT pow2(MYFLT a)
{
- int n = (int)MYFLT2LRND(a * FL(POW2TABSIZI)) + POW2MAX*POW2TABSIZI;
+ int n = (int)MYFLT2LRND(a * FL(POW2TABSIZI)) + POW2MAX*POW2TABSIZI;
return ((MYFLT) (1 << (n >> 12)) * powerof2[n & (POW2TABSIZI-1)]);
}*/
@@ -162,7 +162,7 @@ typedef struct {
OPDS h;
TABDAT *tab;
} TABDEL;
-
+
static int tabdel(CSOUND *csound, void *p)
{
TABDAT *t = ((TABDEL*)p)->tab;
@@ -177,7 +177,7 @@ int tinit(CSOUND *csound, INITT *p)
MYFLT val = *p->value;
TABDAT *t = p->a;
int i;
-
+
t->size = size;
mfree(csound, t->data);
t->data = mmalloc(csound, sizeof(MYFLT)*(size+1));
@@ -195,7 +195,7 @@ int tassign(CSOUND *csound, ASSIGNT *p)
{
TABDAT *t = p->tab;
int ind = MYFLT2LRND(*p->ind);
- if (ind<0 || ind>t->size)
+ if (ind<0 || ind>t->size)
return csound->PerfError(csound,
Str("Index %d out of range [0,%d] in t[]\n"),
ind, t->size);
@@ -214,7 +214,7 @@ int tabref(CSOUND *csound, TABREF *p)
{
int ind = MYFLT2LRND(*p->ind);
TABDAT *t = p->tab;
- if (ind<0 || ind>t->size)
+ if (ind<0 || ind>t->size)
return csound->PerfError(csound,
Str("Index %d out of range [0,%d] in t[]\n"),
ind, t->size);
@@ -1804,7 +1804,7 @@ int is_NaNa(CSOUND *csound, ASSIGN *p)
int k, nsmps = csound->ksmps;
MYFLT *a = p->a;
*p->r = FL(0.0);
- for (k=0; k<nsmps; k++)
+ for (k=0; k<nsmps; k++)
*p->r += isnan(a[k]);
return OK;
}
diff --git a/OOps/bus.c b/OOps/bus.c
index 93955b9..2bf729d 100644
--- a/OOps/bus.c
+++ b/OOps/bus.c
@@ -547,7 +547,7 @@ static CS_NOINLINE int create_new_channel(CSOUND *csound, MYFLT **p,
do {
h = strhash_tabl_8[(unsigned char) *(s++) ^ h];
} while (isalnum((unsigned char) *s) ||
- *s == (char) '_' || *s == (char) '.');
+ *s == (char) '_' || *s == (char) '-' || *s == (char) '.');
if (*s != (char) 0)
return CSOUND_ERROR;
/* create new empty database on first call */
@@ -1389,8 +1389,9 @@ int sensekey_perf(CSOUND *csound, KSENSE *p)
retval = select(1, &rfds, NULL, NULL, &tv);
if (retval) {
- char ch = (char) 0;
- read(0, &ch, 1);
+ char ch = '\0';
+ if (UNLIKELY(read(0, &ch, 1)!=1))
+ csound->Die(csound, "read failure in sensekey\n");
keyCode = (int)((unsigned char) ch);
/* FD_ISSET(0, &rfds) will be true. */
}
diff --git a/OOps/cmath.c b/OOps/cmath.c
index 796ee2e..ded4f75 100644
--- a/OOps/cmath.c
+++ b/OOps/cmath.c
@@ -34,7 +34,7 @@ int ipow(CSOUND *csound, POW *p) /* Power for i-rate */
MYFLT powerOf = *p->powerOf;
if (UNLIKELY(in == FL(0.0) && powerOf == FL(0.0)))
return csound->PerfError(csound, Str("NaN in pow\n"));
- else if (p->norm!=NULL)
+ else if (p->norm!=NULL && *p->norm != FL(0.0))
*p->sr = POWER(in, powerOf) / *p->norm;
else
*p->sr = POWER(in, powerOf);
@@ -270,7 +270,7 @@ int auniform(CSOUND *csound, PRAND *p) /* Uniform distribution */
int n, nsmps = csound->ksmps;
double scale = (double)*p->arg1 * (1.0 / 4294967295.03125);
- for (n=0; n>nsmps; n++) {
+ for (n=0; n<nsmps; n++) {
out[n] = (MYFLT)((double)csoundRandMT(&(csound->randState_)) * scale);
}
return OK;
@@ -335,7 +335,7 @@ int kexprndi(CSOUND *csound, PRANDI *p)
if (UNLIKELY(p->phs >= MAXLEN)) { /* when phs overflows, */
p->phs &= PHMASK; /* mod the phs */
p->num1 = p->num2; /* & new num vals */
- p->num2 = exprand(csound, *p->arg1);
+ p->num2 = exprand(csound, *p->arg1);
p->dfdmax = (p->num2 - p->num1) / FMAXLEN;
}
return OK;
@@ -457,7 +457,7 @@ int kgaussi(CSOUND *csound, PRANDI *p)
if (UNLIKELY(p->phs >= MAXLEN)) { /* when phs overflows, */
p->phs &= PHMASK; /* mod the phs */
p->num1 = p->num2; /* & new num vals */
- p->num2 = gaussrand(csound, *p->arg1);
+ p->num2 = gaussrand(csound, *p->arg1);
p->dfdmax = (p->num2 - p->num1) / FMAXLEN;
}
return OK;
@@ -540,7 +540,7 @@ int kcauchyi(CSOUND *csound, PRANDI *p)
if (UNLIKELY(p->phs >= MAXLEN)) { /* when phs overflows, */
p->phs &= PHMASK; /* mod the phs */
p->num1 = p->num2; /* & new num vals */
- p->num2 = cauchrand(csound, *p->arg1);
+ p->num2 = cauchrand(csound, *p->arg1);
p->dfdmax = (p->num2 - p->num1) / FMAXLEN;
}
return OK;
@@ -706,4 +706,3 @@ int gen21_rand(FGDATA *ff, FUNC *ftp)
}
return OK;
}
-
diff --git a/OOps/diskin2.c b/OOps/diskin2.c
index f4abff7..0066951 100644
--- a/OOps/diskin2.c
+++ b/OOps/diskin2.c
@@ -228,12 +228,14 @@ int diskin2_init(CSOUND *csound, DISKIN2 *p)
p->fdch.fd = fd;
fdrecord(csound, &(p->fdch));
/* print file information */
- csound->Message(csound, Str("diskin2: opened '%s':\n"
- " %d Hz, %d channel(s), "
- "%ld sample frames\n"),
- csound->GetFileName(fd),
- (int)sfinfo.samplerate, (int)sfinfo.channels,
- (int32) sfinfo.frames);
+ if (UNLIKELY((csound->oparms_.msglevel & 7) == 7)) {
+ csound->Message(csound, Str("diskin2: opened '%s':\n"
+ " %d Hz, %d channel(s), "
+ "%ld sample frames\n"),
+ csound->GetFileName(fd),
+ (int)sfinfo.samplerate, (int)sfinfo.channels,
+ (int32) sfinfo.frames);
+ }
/* check number of channels in file (must equal the number of outargs) */
if (UNLIKELY(sfinfo.channels != p->nChannels)) {
return csound->InitError(csound,
diff --git a/OOps/dumpf.c b/OOps/dumpf.c
index 0be1493..942d036 100644
--- a/OOps/dumpf.c
+++ b/OOps/dumpf.c
@@ -139,7 +139,7 @@ int kdmp4set(CSOUND *csound, KDUMP4 *p)
static void nkdump(CSOUND *csound, MYFLT *kp, FILE *ofd, int format, int nk)
{
- char buf1[128], outbuf[256];
+ char buf1[256], outbuf[256];
int len = 0;
switch(format) { /* place formatted kvals into outbuf */
@@ -192,7 +192,9 @@ static void nkdump(CSOUND *csound, MYFLT *kp, FILE *ofd, int format, int nk)
break;
default: csound->Die(csound, Str("unknown kdump format"));
}
- fwrite(outbuf, 1, len, ofd); /* now write the buffer */
+ if (UNLIKELY(fwrite(outbuf, len, 1, ofd)!=1)) { /* now write the buffer */
+ csound->PerfError(csound, Str("write failure in dumpk"));
+ }
}
int kdump(CSOUND *csound, KDUMP *p)
@@ -370,16 +372,15 @@ static void nkread(CSOUND *csound, MYFLT *kp, FILE *ifd, int format, int nk)
case 1: {
int8_t *bp = (int8_t*)inbuf;
len = nk;
- fread(inbuf, 1, len, ifd); /* now read the buffer */
- while (nk--) {
+ len = fread(inbuf, 1, len, ifd); /* now read the buffer */
+ while (nk--)
*kp++ = (MYFLT)*bp++;
- break;
- }
+ break;
}
case 4: {
int16_t *bp = (int16_t*)inbuf;
len = nk * 2;
- fread(inbuf, 1, len, ifd); /* now read the buffer */
+ len = fread(inbuf, 1, len, ifd); /* now read the buffer */
while (nk--)
*kp++ = (MYFLT)*bp++;
break;
@@ -387,7 +388,7 @@ static void nkread(CSOUND *csound, MYFLT *kp, FILE *ifd, int format, int nk)
case 5: {
int32_t *bp = (int32_t*)inbuf;
len = nk * 4;
- fread(inbuf, 1, len, ifd); /* now read the buffer */
+ len = fread(inbuf, 1, len, ifd); /* now read the buffer */
while (nk--)
*kp++ = (MYFLT)*bp++;
break;
@@ -395,7 +396,7 @@ static void nkread(CSOUND *csound, MYFLT *kp, FILE *ifd, int format, int nk)
case 6: {
float *bp = (float*)inbuf;
len = nk * sizeof(float);
- fread(inbuf, 1, len, ifd); /* now read the buffer */
+ len = fread(inbuf, 1, len, ifd); /* now read the buffer */
while (nk--)
*kp++ = (MYFLT)*bp++;
break;
@@ -538,7 +539,9 @@ int kreads(CSOUND *csound, KREADS *p)
{
if (--p->countdown <= 0) {
p->countdown = p->timcount;
- fgets(p->lasts, csound->strVarMaxLen, p->f);
+ if (UNLIKELY(fgets(p->lasts, csound->strVarMaxLen, p->f)==NULL)) {
+ csound->PerfError(csound, "Read failure in readks");
+ }
}
strncpy((char*) p->str, p->lasts, csound->strVarMaxLen);
return OK;
diff --git a/OOps/goto_ops.c b/OOps/goto_ops.c
index 7ff9b4c..e0b59f1 100644
--- a/OOps/goto_ops.c
+++ b/OOps/goto_ops.c
@@ -181,7 +181,7 @@ int turnoff2(CSOUND *csound, TURNOFF2 *p, int isStringArg)
if (p1 <= FL(0.0))
return OK; /* not triggered */
-
+
insno = (int) p1;
if (UNLIKELY(insno < 1 || insno > (int) csound->maxinsno ||
csound->instrtxtp[insno] == NULL)) {
@@ -318,4 +318,3 @@ int loop_ge_p(CSOUND *csound, LOOP_OPS *p)
csound->pds = p->l->prvp;
return OK;
}
-
diff --git a/OOps/midiout.c b/OOps/midiout.c
index 5bbd61f..241391d 100644
--- a/OOps/midiout.c
+++ b/OOps/midiout.c
@@ -308,13 +308,13 @@ int out_controller (CSOUND *csound, OUT_CONTR *p)
value = (int)((*p->value - min) * FL(127.0) / (*p->max - min));
value = (value < 128) ? value : 127;
value = (value > -1) ? value : 0;
- if (value != p->last_value || *p->chn != p->lastchn || *p->num != p->lastctrl) {
+ if (value != p->last_value || *p->chn != p->lastchn || *p->num != p->lastctrl) {
/* csound->Message(csound, "out contr value: %d\n", value); */
control_change(csound, (int)*p->chn-1,(int)*p->num ,value);
p->last_value = value;
p->lastchn = *p->chn;
p->lastctrl = *p->num;
- }
+ }
}
return OK;
}
@@ -363,11 +363,11 @@ int out_progchange (CSOUND *csound, OUT_PCHG *p)
prog_num = (int)((*p->prog_num - min) * FL(127.0) / (*p->max - min));
prog_num = prog_num < 128 ? prog_num : 127;
prog_num = prog_num > -1 ? prog_num : 0;
- if (prog_num != p->last_prog_num || *p->chn != p->lastchn) {
+ if (prog_num != p->last_prog_num || *p->chn != p->lastchn) {
program_change(csound, (int)*p->chn-1, prog_num);
p->last_prog_num = prog_num;
p->lastchn = *p->chn;
- }
+ }
}
return OK;
}
@@ -392,7 +392,7 @@ int out_controller14 (CSOUND *csound, OUT_CONTR14 *p)
p->last_value = value;
p->lastchn = *p->chn;
p->lastctrl = *p->msb_num;
- }
+ }
}
return OK;
}
@@ -550,4 +550,3 @@ int mdelay(CSOUND *csound, MDELAY *p) /*gab-A6 fixed*/
}
return OK;
}
-
diff --git a/OOps/pvsanal.c b/OOps/pvsanal.c
index 19d9577..1079e27 100644
--- a/OOps/pvsanal.c
+++ b/OOps/pvsanal.c
@@ -140,7 +140,7 @@ int pvssanalset(CSOUND *csound, PVSANAL *p)
double *s = c+NB;
p->cosine = c;
p->sine = s;
- c[0] = 1.0; s[0] = 0.0;
+ c[0] = 1.0; s[0] = 0.0; // assignment to s unnecessary as auxalloc zeros
/*
direct computation of c and s may be better for large n
c[i] = cos(2*M_PI*i/n);
@@ -228,13 +228,13 @@ int pvsanalset(CSOUND *csound, PVSANAL *p)
}
/* get net amp */
sum = FL(0.0);
-
+
for (i = -halfwinsize; i <= halfwinsize; i++)
sum += *(analwinhalf + i);
sum = FL(2.0) / sum; /* factor of 2 comes in later in trig identity */
for (i = -halfwinsize; i <= halfwinsize; i++)
*(analwinhalf + i) *= sum;
-
+
/* p->invR = (float)(FL(1.0) / csound->esr); */
p->RoverTwoPi = (float)(p->arate / TWOPI_F);
@@ -384,7 +384,7 @@ static void generate_frame(CSOUND *csound, PVSANAL *p)
/* add in filter center freq.*/
/* *i1 */ anal[ii+1] = angleDif * p->RoverTwoPi + ((MYFLT) i * p->Fexact);
-
+
}
/* } */
/* else must be PVOC_COMPLEX */
@@ -681,7 +681,7 @@ int pvsynthset(CSOUND *csound, PVSYNTH *p)
int32 halfwinsize,buflen;
int i,nBins,Mf,Lf;
double IO;
-
+
/* get params from input fsig */
/* we TRUST they are legal */
int32 N = p->fsig->N;
@@ -722,34 +722,34 @@ int pvsynthset(CSOUND *csound, PVSYNTH *p)
csound->AuxAlloc(csound, nBins * sizeof(MYFLT), &p->oldOutPhase);
csound->AuxAlloc(csound, buflen * sizeof(MYFLT), &p->output);
-
+
synwinhalf = (MYFLT *) (p->synwinbuf.auxp) + halfwinsize;
-
-
-
+
+
+
/* synthesis windows */
if (M <= N) {
if (UNLIKELY(PVS_CreateWindow(csound, synwinhalf, wintype, M) != OK))
return NOTOK;
-
+
for (i = 1; i <= halfwinsize; i++)
*(synwinhalf - i) = *(synwinhalf + i - Lf);
-
- sum = FL(0.0);
+
+ sum = FL(0.0);
for (i = -halfwinsize; i <= halfwinsize; i++)
sum += *(synwinhalf + i);
sum = FL(2.0) / sum;
for (i = -halfwinsize; i <= halfwinsize; i++)
*(synwinhalf + i) *= sum;
-
- sum = FL(0.0);
+
+ sum = FL(0.0);
/* no timescaling, so I(nterpolation) will always = D(ecimation) = overlap */
for (i = -halfwinsize; i <= halfwinsize; i+=overlap)
- sum += *(synwinhalf + i) * *(synwinhalf + i);
+ sum += *(synwinhalf + i) * *(synwinhalf + i);
}
else {
/* have to make analysis window to get amp scaling */
@@ -761,8 +761,8 @@ int pvsynthset(CSOUND *csound, PVSYNTH *p)
for (i = 1; i <= halfwinsize; i++)
analwinhalf[-i] = analwinhalf[i - Mf];
-
- // sinc function
+
+ // sinc function
if (Mf)
*analwinhalf *= (MYFLT)(dN * sin(PI*0.5/dN) / ( PI*0.5));
for (i = 1; i <= halfwinsize; i++)
@@ -770,9 +770,9 @@ int pvsynthset(CSOUND *csound, PVSYNTH *p)
(dN * sin((double)(PI*(i+0.5*Mf)/dN)) / (PI*(i+0.5*Mf)));
for (i = 1; i <= halfwinsize; i++)
*(analwinhalf - i) = *(analwinhalf + i - Mf);
-
+
/* get net amp */
- sum = FL(0.0);
+ sum = FL(0.0);
for (i = -halfwinsize; i <= halfwinsize; i++)
sum += *(analwinhalf + i);
sum = FL(2.0) / sum; /* factor of 2 comes in later in trig identity */
@@ -792,16 +792,16 @@ int pvsynthset(CSOUND *csound, PVSYNTH *p)
for (i = 1; i <= halfwinsize; i++)
*(synwinhalf - i) = *(synwinhalf + i - Lf);
}
-
-
+
+
if (!(N & (N - 1L)))
sum = csound->GetInverseRealFFTScale(csound, (int) N) / sum;
else
sum = FL(1.0) / sum;
-
+
for (i = -halfwinsize; i <= halfwinsize; i++)
*(synwinhalf + i) *= sum;
-
+
/* p->invR = FL(1.0) / csound->esr; */
p->RoverTwoPi = p->arate / TWOPI_F;
p->TwoPioverR = TWOPI_F / p->arate;
@@ -1101,4 +1101,3 @@ static void vonhann(MYFLT *win, int winLen, int even)
win[i] = (MYFLT)(0.5 + 0.5 * cos(ftmp*(double)i));
}
}
-
diff --git a/OOps/ugens1.c b/OOps/ugens1.c
index 1b82a3d..3795436 100644
--- a/OOps/ugens1.c
+++ b/OOps/ugens1.c
@@ -116,7 +116,7 @@ int lsgset(CSOUND *csound, LINSEG *p)
MYFLT **argp;
double val;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (SEG *) p->auxch.auxp) == NULL ||
nsegs*sizeof(SEG) < (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(SEG), &p->auxch);
@@ -341,8 +341,8 @@ int lsgrset(CSOUND *csound, LINSEG *p)
int32 relestim;
lsgset(csound,p);
relestim = (p->cursegp + p->segsrem - 1)->cnt;
- p->xtra = relestim; /* VL 4-1-2011 was -1, making all linsegr
- releases in an instr => xtratim
+ p->xtra = relestim; /* VL 4-1-2011 was -1, making all linsegr
+ releases in an instr => xtratim
set to relestim seems to fix this */
if (relestim > p->h.insdshead->xtratim)
p->h.insdshead->xtratim = (int)relestim;
@@ -430,7 +430,7 @@ int xsgset(CSOUND *csound, EXXPSEG *p)
MYFLT d, **argp, val, dur, nxtval;
int n=0;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (XSEG *) p->auxch.auxp) == NULL ||
nsegs*sizeof(XSEG) < (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(XSEG), &p->auxch);
@@ -474,7 +474,7 @@ int xsgset_bkpt(CSOUND *csound, EXXPSEG *p)
MYFLT d, **argp, val, dur, dursum = FL(0.0), bkpt, nxtval;
int n=0;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (XSEG *) p->auxch.auxp) == NULL ||
nsegs*sizeof(XSEG) < (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(XSEG), &p->auxch);
@@ -524,7 +524,7 @@ int xsgset2b(CSOUND *csound, EXPSEG2 *p)
MYFLT d, **argp, val, dur, dursum = FL(0.0), bkpt, nxtval;
int n;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (XSEG*) p->auxch.auxp) == NULL ||
(unsigned int)nsegs*sizeof(XSEG) > (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(XSEG), &p->auxch);
@@ -575,7 +575,7 @@ int xsgset2(CSOUND *csound, EXPSEG2 *p) /*gab-A1 (G.Maldonado) */
MYFLT d, **argp, val, dur, nxtval;
int n;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (XSEG*) p->auxch.auxp) == NULL ||
(unsigned int)nsegs*sizeof(XSEG) > (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(XSEG), &p->auxch);
@@ -741,7 +741,7 @@ int xsgrset(CSOUND *csound, EXPSEG *p)
MYFLT **argp, prvpt;
p->xtra = -1;
- nsegs = p->INOCOUNT >> 1; /* count segs & alloc if nec */
+ nsegs = (p->INOCOUNT - (!(p->INOCOUNT & 1))) >> 1; /* count segs & alloc if nec */
if ((segp = (SEG *) p->auxch.auxp) == NULL ||
(unsigned int)nsegs*sizeof(SEG) > (unsigned int)p->auxch.size) {
csound->AuxAlloc(csound, (int32)nsegs*sizeof(SEG), &p->auxch);
@@ -1420,4 +1420,3 @@ int envlpxr(CSOUND *csound, ENVLPR *p)
}
return OK;
}
-
diff --git a/OOps/ugens2.c b/OOps/ugens2.c
index 234d54b..d0c8462 100644
--- a/OOps/ugens2.c
+++ b/OOps/ugens2.c
@@ -87,11 +87,11 @@ int ephsor(CSOUND *csound, EPHSOR *p)
b *= R;
if (UNLIKELY(phase >= 1.0)) {
phase -= 1.0;
- b = pow(R, 1+phase);
+ b = pow(R, 1+phase);
}
else if (UNLIKELY(phase < 0.0)) {
phase += 1.0;
- b = pow(R, 1+phase);
+ b = pow(R, 1+phase);
}
}
}
@@ -104,11 +104,11 @@ int ephsor(CSOUND *csound, EPHSOR *p)
b *= R;
if (UNLIKELY(phase >= 1.0)) {
phase -= 1.0;
- b = pow(R, 1+phase);
+ b = pow(R, 1+phase);
}
else if (UNLIKELY(phase < 0.0)) {
phase += 1.0;
- b = pow(R, 1+phase);
+ b = pow(R, 1+phase);
}
}
}
@@ -144,8 +144,8 @@ int phsor(CSOUND *csound, PHSOR *p)
incr = (double)(cps[n] * onedsr);
rs[n] = (MYFLT)phase;
phase += incr;
- if (UNLIKELY((MYFLT)phase >= 1.0)) /* VL convert to MYFLT
- to avoid rounded output
+ if (UNLIKELY((MYFLT)phase >= 1.0)) /* VL convert to MYFLT
+ to avoid rounded output
exceeding 1.0 on float version */
phase -= 1.0;
else if (UNLIKELY((MYFLT)phase < 0.0))
@@ -1589,4 +1589,3 @@ int oscaa3(CSOUND *csound, OSC *p)
err1:
return csound->PerfError(csound, Str("oscil3: not initialised"));
}
-
diff --git a/OOps/vdelay.c b/OOps/vdelay.c
index e361413..6bd5568 100644
--- a/OOps/vdelay.c
+++ b/OOps/vdelay.c
@@ -732,7 +732,9 @@ int multitap_set(CSOUND *csound, MDEL *p)
int32 n;
MYFLT max = FL(0.0);
- if (UNLIKELY(p->INOCOUNT/2 == (MYFLT)p->INOCOUNT*FL(0.5)))
+ //if (UNLIKELY(p->INOCOUNT/2 == (MYFLT)p->INOCOUNT*FL(0.5)))
+ /* Should this test just be p->INOCOUNT&1 == */
+ if (UNLIKELY((p->INOCOUNT&1)==0))
csound->Die(csound, Str("Wrong input count in multitap\n"));
for (n = 0; n < p->INOCOUNT - 1; n += 2) {
@@ -992,9 +994,10 @@ int reverbx_set(CSOUND *csound, NREV2 *p)
p->z[i] = FL(0.0);
}
csound->AuxAlloc(csound, n * sizeof(MYFLT), &p->caux);
- for (i = 0; i < n; i++) {
- ((MYFLT*) p->caux.auxp)[i] = FL(0.0);
- }
+ /* unnecessary as Auxlloc clears to 0 */
+ /* for (i = 0; i < n; i++) { */
+ /* ((MYFLT*) p->caux.auxp)[i] = FL(0.0); */
+ /* } */
p->pcbuf_cur[0] = p->cbuf_cur[0] = (MYFLT*)p->caux.auxp;
for (i = 0; i < p->numCombs; i++) {
p->pcbuf_cur[i + 1] = p->cbuf_cur[i + 1] =
@@ -1021,9 +1024,10 @@ int reverbx_set(CSOUND *csound, NREV2 *p)
n += a_time;
}
csound->AuxAlloc(csound, n * sizeof(MYFLT), &p->aaux);
- for (i = 0; i < n; i++) {
- ((MYFLT*) p->aaux.auxp)[i] = FL(0.0);
- }
+ /* unnecessary as AuxAlloc clears */
+ /* for (i = 0; i < n; i++) { */
+ /* ((MYFLT*) p->aaux.auxp)[i] = FL(0.0); */
+ /* } */
p->pabuf_cur[0] = p->abuf_cur[0] = (MYFLT*) p->aaux.auxp;
for (i = 0; i < p->numAlpas; i++) {
p->pabuf_cur[i + 1] = p->abuf_cur[i + 1] =
diff --git a/Opcodes/CMakeLists.txt b/Opcodes/CMakeLists.txt
index 133fa88..e8ca737 100644
--- a/Opcodes/CMakeLists.txt
+++ b/Opcodes/CMakeLists.txt
@@ -1,151 +1,161 @@
-option(BUILD_CHUA_OPCODES "Build the chua opcodes (requires boost)" ON)
-option(BUILD_DSSI_OPCODES "Build the DSSI opcodes" ON)
-option(BUILD_FLUID_OPCODES "Build the fluidsynth opcodes" ON)
-option(BUILD_JACK_OPCODES "Build the JACK related opcodes" ON)
-option(BUILD_LINEAR_ALGEBRA_OPCODES "Build the Linear Algebra Opcodes" ON)
-option(BUILD_OSC_OPCODES "Build the OSC Opcodes" ON)
-option(BUILD_IMAGE_OPCODES "Build the image opcodes" ON)
-option(BUILD_PYTHON_OPCODES "Build the Python opcodes" ON)
-option(BUILD_LUA_OPCODES "Build the Lua opcodes" ON)
-
-find_package(Boost)
-check_include_file(ladspa.h LADSPA_H)
-check_include_file(fluidsynth.h FLUIDSYNTH_H)
-find_library(JACK_LIBRARY jack)
-find_library(JACKDMP_LIBRARY jackdmp)
-check_include_file(jack/jack.h JACK_HEADER)
-check_include_file_cxx(gmm/gmm.h GMM_HEADER)
-check_include_file(lo/lo.h OSC_HEADER)
-find_package(PNG)
-find_package(PythonLibs)
-find_package(Lua51)
-
-
-## OPCODE LIBS WITH NO EXTERNAL DEPENDENCIES ##
-
-make_plugin(mixer mixer.cpp)
-make_plugin(signalflowgraph signalflowgraph.cpp)
-
-make_plugin(ampmidid ampmidid.cpp)
-make_plugin(cs_date date.c)
-make_plugin(system_call system_call.c)
-make_plugin(doppler doppler.cpp)
-make_plugin(fractalnoise tl/fractalnoise.cpp)
-
-make_plugin(fareygen fareygen.c)
-
-# temporarily do not build on Windows until these opcodes are fixed
-# to compile
-if(NOT WIN32)
- make_plugin(udprecv sockrecv.c)
- make_plugin(udpsend socksend.c)
-
-endif()
-
-set(scansyn_SRCS
- scansyn.c scansynx.c)
-make_plugin(scansyn "${scansyn_SRCS}" m)
-
-if(UNIX)
- make_plugin(control control.c)
-endif()
-
-if(LINUX)
- make_plugin(urandom urandom.c)
-endif()
-
-## OPCODES WITH EXTERNAL DEPENDENCIES ##
-
-check_deps(BUILD_CHUA_OPCODES Boost_FOUND)
-if(BUILD_CHUA_OPCODES)
- include_directories(${Boost_INCLUDE_DIRS})
- make_plugin(chua chua/ChuaOscillator.cpp)
-endif()
-
-check_deps(BUILD_DSSI_OPCODES LADSPA_H)
-if(BUILD_DSSI_OPCODES)
- set(dssi_SRC dssi4cs/src/load.c dssi4cs/src/dssi4cs.c)
- make_plugin(dssi4cs "${dssi_SRC}" )
-endif()
-
-check_deps(BUILD_FLUID_OPCODES FLUIDSYNTH_H)
-if(BUILD_FLUID_OPCODES)
- make_plugin(fluidOpcodes fluidOpcodes/fluidOpcodes.cpp fluidsynth)
-endif()
-
-set(JACK_LIB (JACK_LIBRARY OR JACKDMP_LIBRARY))
-check_deps(BUILD_JACK_OPCODES JACK_HEADER JACK_LIB)
-if(BUILD_JACK_OPCODES)
- set(jack_LIBS ${PTHREAD_LIBRARY})
- if(JACKDMP_LIBRARY)
- list(APPEND jack_LIBS ${JACKDMP_LIBRARY})
- else()
- list(APPEND jack_LIBS ${JACK_LIBRARY})
- endif()
- make_plugin(jacko jacko.cpp "${jack_LIBS}")
- make_plugin(jackTransport jackTransport.c "${jack_LIBS}")
-endif()
-
-check_deps(BUILD_LINEAR_ALGEBRA_OPCODES GMM_HEADER)
-if(BUILD_LINEAR_ALGEBRA_OPCODES)
- make_plugin(linear_algebra linear_algebra.cpp)
-endif()
-
-check_deps(BUILD_OSC_OPCODES OSC_HEADER)
-if(BUILD_OSC_OPCODES)
- make_plugin(osc OSC.c)
- target_link_libraries(osc lo pthread)
-endif()
-
-check_deps(BUILD_IMAGE_OPCODES PNG_FOUND)
-if(BUILD_IMAGE_OPCODES)
- include_directories(${PNG_INCLUDE_DIR})
- make_plugin(image imageOpcodes.c "${PNG_LIBRARIES}")
- set_target_properties(image
- PROPERTIES COMPILER_FLAGS "${PNG_DEFINITIONS}")
-endif()
-
-check_deps(BUILD_PYTHON_OPCODES PYTHONLIBS_FOUND)
-if(BUILD_PYTHON_OPCODES)
- include_directories(${PYTHON_INCLUDE_DIRS})
- make_plugin(py py/pythonopcodes.c ${PYTHON_LIBRARIES})
-endif()
-
-check_deps(BUILD_LUA_OPCODES LUA51_FOUND)
-if(BUILD_LUA_OPCODES)
- include_directories(${LUA_INCLUDE_DIR})
- make_plugin(LuaCsound LuaCsound.cpp ${LUA_LIBRARIES})
-endif()
-
-# OGG Opcode previously was built only for OLPC
-#if(VORBISFILE_LIBRARY)
-# set(vorbis_LIBS ${libcsound_LIBS} ${VORBISFILE_LIBRARY})
-# make_plugin(ogg ogg.c "${vorbis_LIBS}")
-#endif()
-
-
-
-#set(sfont_FLAGS "")
-
-#if(CMAKE_C_COMPILER MATCHES "gcc")
-# set(sfont_FLAGS ${sfont_FLAGS} -fno-strict-aliasing)
-#endif()
-#if(BIG_ENDIAN)
-# set(sfont_FLAGS ${sfont_FLAGS} -DWORDS_BIGENDIAN)
-#endif()
-#message(STATUS "Compiler flags used for sfont lib: ${sfont_FLAGS}")
-#make_plugin(sfont sfont.c m)
-#set_target_properties(sfont
-# PROPERTIES COMPILER_FLAGS "${sfont_FLAGS}")
-
-
-
-
-#if wiifound==1:
-# WiiEnvironment = pluginEnvironment.Clone()
-# makePlugin(WiiEnvironment, 'wiimote', ['wiimote.c'])
-#if p5gfound==1:
-# P5GEnvironment = pluginEnvironment.Clone()
-# makePlugin(P5GEnvironment, 'p5g', ['p5glove.c'])
-
-add_subdirectory(stk)
+option(BUILD_CHUA_OPCODES "Build the chua opcodes (requires boost)" ON)
+option(BUILD_DSSI_OPCODES "Build the DSSI opcodes" ON)
+option(BUILD_FLUID_OPCODES "Build the fluidsynth opcodes" ON)
+option(BUILD_JACK_OPCODES "Build the JACK related opcodes" ON)
+option(BUILD_LINEAR_ALGEBRA_OPCODES "Build the Linear Algebra Opcodes" ON)
+option(BUILD_OSC_OPCODES "Build the OSC Opcodes" ON)
+option(BUILD_IMAGE_OPCODES "Build the image opcodes" ON)
+option(BUILD_PYTHON_OPCODES "Build the Python opcodes" ON)
+option(BUILD_LUA_OPCODES "Build the Lua opcodes" ON)
+option(BUILD_WIIMOTE_OPCODES "Build the Lua opcodes" ON)
+
+find_package(Boost)
+check_include_file(ladspa.h LADSPA_H)
+check_include_file(fluidsynth.h FLUIDSYNTH_H)
+find_library(JACK_LIBRARY jack)
+find_library(JACKDMP_LIBRARY jackdmp)
+check_include_file(jack/jack.h JACK_HEADER)
+check_include_file_cxx(gmm/gmm.h GMM_HEADER)
+check_include_file(lo/lo.h OSC_HEADER)
+find_package(PNG)
+find_package(PythonLibs)
+find_package(Lua51)
+check_include_file(wiiuse.h WIIUSE_H)
+find_library(WIIUSE_LIB wiiuse)
+
+## OPCODE LIBS WITH NO EXTERNAL DEPENDENCIES ##
+
+make_plugin(mixer mixer.cpp)
+make_plugin(signalflowgraph signalflowgraph.cpp)
+
+make_plugin(ampmidid ampmidid.cpp)
+make_plugin(cs_date date.c)
+make_plugin(system_call system_call.c)
+make_plugin(doppler doppler.cpp)
+make_plugin(fractalnoise tl/fractalnoise.cpp)
+
+make_plugin(fareygen fareygen.c)
+
+make_plugin(cellular cellular.c)
+
+# temporarily do not build on Windows until these opcodes are fixed
+# to compile
+if(NOT WIN32)
+ make_plugin(udprecv sockrecv.c)
+ make_plugin(udpsend socksend.c)
+
+endif()
+
+set(scansyn_SRCS
+ scansyn.c scansynx.c)
+make_plugin(scansyn "${scansyn_SRCS}" m)
+
+if(UNIX)
+ make_plugin(control control.c)
+endif()
+
+if(LINUX)
+ make_plugin(urandom urandom.c)
+endif()
+
+## OPCODES WITH EXTERNAL DEPENDENCIES ##
+
+check_deps(BUILD_CHUA_OPCODES Boost_FOUND)
+if(BUILD_CHUA_OPCODES)
+ include_directories(${Boost_INCLUDE_DIRS})
+ make_plugin(chua chua/ChuaOscillator.cpp)
+endif()
+
+check_deps(BUILD_DSSI_OPCODES LADSPA_H)
+if(BUILD_DSSI_OPCODES)
+ set(dssi_SRC dssi4cs/src/load.c dssi4cs/src/dssi4cs.c)
+ make_plugin(dssi4cs "${dssi_SRC}" )
+endif()
+
+check_deps(BUILD_FLUID_OPCODES FLUIDSYNTH_H)
+if(BUILD_FLUID_OPCODES)
+ make_plugin(fluidOpcodes fluidOpcodes/fluidOpcodes.cpp fluidsynth)
+endif()
+
+set(JACK_LIB (JACK_LIBRARY OR JACKDMP_LIBRARY))
+check_deps(BUILD_JACK_OPCODES JACK_HEADER JACK_LIB)
+if(BUILD_JACK_OPCODES)
+ set(jack_LIBS ${PTHREAD_LIBRARY})
+ if(JACKDMP_LIBRARY)
+ list(APPEND jack_LIBS ${JACKDMP_LIBRARY})
+ else()
+ list(APPEND jack_LIBS ${JACK_LIBRARY})
+ endif()
+ make_plugin(jacko jacko.cpp "${jack_LIBS}")
+ make_plugin(jackTransport jackTransport.c "${jack_LIBS}")
+endif()
+
+check_deps(BUILD_LINEAR_ALGEBRA_OPCODES GMM_HEADER)
+if(BUILD_LINEAR_ALGEBRA_OPCODES)
+ make_plugin(linear_algebra linear_algebra.cpp)
+endif()
+
+check_deps(BUILD_OSC_OPCODES OSC_HEADER)
+if(BUILD_OSC_OPCODES)
+ make_plugin(osc OSC.c)
+ target_link_libraries(osc lo pthread)
+endif()
+
+check_deps(BUILD_IMAGE_OPCODES PNG_FOUND)
+if(BUILD_IMAGE_OPCODES)
+ include_directories(${PNG_INCLUDE_DIR})
+ make_plugin(image imageOpcodes.c "${PNG_LIBRARIES}")
+ set_target_properties(image
+ PROPERTIES COMPILER_FLAGS "${PNG_DEFINITIONS}")
+endif()
+
+check_deps(BUILD_PYTHON_OPCODES PYTHONLIBS_FOUND)
+if(BUILD_PYTHON_OPCODES)
+ include_directories(${PYTHON_INCLUDE_DIRS})
+ make_plugin(py py/pythonopcodes.c ${PYTHON_LIBRARIES})
+endif()
+
+check_deps(BUILD_LUA_OPCODES LUA51_FOUND)
+if(BUILD_LUA_OPCODES)
+ include_directories(${LUA_INCLUDE_DIR})
+ make_plugin(LuaCsound LuaCsound.cpp ${LUA_LIBRARIES})
+endif()
+
+check_deps(BUILD_WIIMOTE_OPCODES WIIUSE_H)
+if(BUILD_WIIMOTE_OPCODES)
+ make_plugin(wiimote wiimote.c ${WIIUSE_LIB})
+endif()
+
+
+# OGG Opcode previously was built only for OLPC
+#if(VORBISFILE_LIBRARY)
+# set(vorbis_LIBS ${libcsound_LIBS} ${VORBISFILE_LIBRARY})
+# make_plugin(ogg ogg.c "${vorbis_LIBS}")
+#endif()
+
+
+
+#set(sfont_FLAGS "")
+
+#if(CMAKE_C_COMPILER MATCHES "gcc")
+# set(sfont_FLAGS ${sfont_FLAGS} -fno-strict-aliasing)
+#endif()
+#if(BIG_ENDIAN)
+# set(sfont_FLAGS ${sfont_FLAGS} -DWORDS_BIGENDIAN)
+#endif()
+#message(STATUS "Compiler flags used for sfont lib: ${sfont_FLAGS}")
+#make_plugin(sfont sfont.c m)
+#set_target_properties(sfont
+# PROPERTIES COMPILER_FLAGS "${sfont_FLAGS}")
+
+
+
+
+#if wiifound==1:
+# WiiEnvironment = pluginEnvironment.Clone()
+# makePlugin(WiiEnvironment, 'wiimote', ['wiimote.c'])
+#if p5gfound==1:
+# P5GEnvironment = pluginEnvironment.Clone()
+# makePlugin(P5GEnvironment, 'p5g', ['p5glove.c'])
+
+add_subdirectory(stk)
diff --git a/Opcodes/Loris/lorisgens5.C b/Opcodes/Loris/lorisgens5.C
index ee25247..2dcbff0 100644
--- a/Opcodes/Loris/lorisgens5.C
+++ b/Opcodes/Loris/lorisgens5.C
@@ -949,7 +949,7 @@ LorisMorpher::LorisMorpher( LORISMORPH * params ) :
#ifdef DEBUG_LORISGENS
std::cerr << "** Morph will use " << labelMap.size() << " labeled Partials, ";
std::cerr << src_unlabeled.size() << " unlabeled source Partials, and ";
- std::cerr << tgt_unlabeled.size() << " unlabeled target Partials."
+ std::cerr << tgt_unlabeled.size() << " unlabeled target Partials."
<< std::endl;
#endif
@@ -1011,7 +1011,7 @@ LorisMorpher::updateEnvelopes( void )
if ( itgt < 0 && isrc < 0 )
{
#ifdef DEBUG_LORISGENS
- std::cerr <<
+ std::cerr <<
"HEY!!!! The labelMap had a pair of bogus indices in it at pos "
<< envidx << std::endl;
#endif
@@ -1155,4 +1155,3 @@ extern "C"
csound --opcode-lib=.libs/lorisgens.so tryit.csd
*/
-
diff --git a/Opcodes/LuaCsound.cpp b/Opcodes/LuaCsound.cpp
index 7210211..95b85be 100644
--- a/Opcodes/LuaCsound.cpp
+++ b/Opcodes/LuaCsound.cpp
@@ -39,7 +39,7 @@ extern "C"
* Author: Michael Gogins
* 1 September 2011
*
- * These opcodes require LuaJIT 2.0 or later with FFI to be installed with
+ * These opcodes require LuaJIT 2.0 or later with FFI to be installed with
* Csound. They allow users to define new opcodes in Lua, a modern language
* with simple sytax, full lexical scoping, support for classes, and support
* for functional programming. These opcodes are designed to be thread-safe.
@@ -47,7 +47,7 @@ extern "C"
*/
/**
- * Stores Lua references to opcode subroutines for greater efficiency of
+ * Stores Lua references to opcode subroutines for greater efficiency of
* calling.
*/
struct keys_t
@@ -59,7 +59,7 @@ struct keys_t
int noteoff_key;
};
-/**
+/**
* Thread-safe storage for Lua references to opcode subroutines.
*/
keys_t &manageLuaReferenceKeys(const lua_State *L, const std::string &opcode, char operation = 'O')
@@ -88,7 +88,7 @@ keys_t &manageLuaReferenceKeys(const lua_State *L, const std::string &opcode, ch
/**
* Thread-safe storage for Lua states (virtual machines). There is one Lua state
- * per thread, rather than per instance of Csound, in case one instance of Csound
+ * per thread, rather than per instance of Csound, in case one instance of Csound
* is running multiple threads with multiple instances of a Lua opcode.
*/
lua_State *manageLuaState(char operation = 'O')
@@ -169,21 +169,21 @@ public:
};
/**
- * lua_iopcall Sname, ... Calls a Lua opcode at i-rate only. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_iopcall Sname, ... Calls a Lua opcode at i-rate only. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init to be defined in Lua.
*
- * lua_ikopcall Sname, ... Calls a Lua opcode at i-rate and k-rate. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_ikopcall Sname, ... Calls a Lua opcode at i-rate and k-rate. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init and opname_kontrol to be defined in Lua.
*
- * lua_iaopcall Sname, ... Calls a Lua opcode at i-rate and a-rate. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_iaopcall Sname, ... Calls a Lua opcode at i-rate and a-rate. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init and opname_audio to be defined in Lua.
*
@@ -283,21 +283,21 @@ public:
};
/**
- * lua_iopcall_off Sname, ... Calls a Lua opcode at i-rate only. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_iopcall_off Sname, ... Calls a Lua opcode at i-rate only. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init to be defined in Lua.
*
- * lua_ikopcall_off Sname, ... Calls a Lua opcode at i-rate and k-rate. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_ikopcall_off Sname, ... Calls a Lua opcode at i-rate and k-rate. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init and opname_kontrol to be defined in Lua.
*
- * lua_iaopcall_off Sname, ... Calls a Lua opcode at i-rate and a-rate. Any number of
- * output and/or input arguments may be passed.
- * All arguments must be passed on the right-hand
+ * lua_iaopcall_off Sname, ... Calls a Lua opcode at i-rate and a-rate. Any number of
+ * output and/or input arguments may be passed.
+ * All arguments must be passed on the right-hand
* side and outputs are returned in the argument.
* Requires opname_init and opname_audio to be defined in Lua.
*
@@ -423,9 +423,9 @@ public:
};
/**
- * lua_opdef Sname, Scode -- Define an opcode in Lua at i-rate. The opcode can
- * take any number of output and/or input arguments
- * of any type.
+ * lua_opdef Sname, Scode -- Define an opcode in Lua at i-rate. The opcode can
+ * take any number of output and/or input arguments
+ * of any type.
*
* Opcode that effectively defines new opcodes in Lua. The Lua code must
* define all functions that will be called from Csound,
diff --git a/Opcodes/ambicode.c b/Opcodes/ambicode.c
index 709a8d3..ca5595e 100644
--- a/Opcodes/ambicode.c
+++ b/Opcodes/ambicode.c
@@ -29,7 +29,7 @@ typedef struct {
OPDS h; /* required header */
MYFLT *mw, *mx, *my, *mz, *mr, *ms, *mt, *mu, *mv, *mk,
*ml, *mm, *mn, *mo, *mp, *mq; /* addr outarg */
- MYFLT *asig, *kalpha, *kbeta, *kin[4]; /* addr inargs */
+ MYFLT *asig, *kalpha, *kbeta, *kin[4]; /* addr inargs */
/* private dataspace */
double w, x, y, z, r, s, t, u, v, k, l, m, n, o, p, q;
} AMBIC;
@@ -714,9 +714,9 @@ static int aambideco(CSOUND *csound, AMBID *p)
#define S(x) sizeof(x)
static OENTRY localops[] = {
- { "bformenc", S(AMBIC), DP|5, "mmmmmmmmmmmmmmmm", "akkPPPP",
+ { "bformenc", S(AMBIC), _QQ|5, "mmmmmmmmmmmmmmmm", "akkPPPP",
(SUBR)iambicode, NULL, (SUBR)aambicode },
- { "bformdec", S(AMBID), DP|5, "mmmmmmmm", "iaaay",
+ { "bformdec", S(AMBID), _QQ|5, "mmmmmmmm", "iaaay",
(SUBR)iambideco, NULL, (SUBR)aambideco }
};
diff --git a/Opcodes/ambicode1.c b/Opcodes/ambicode1.c
index 6efed2a..798bd6a 100644
--- a/Opcodes/ambicode1.c
+++ b/Opcodes/ambicode1.c
@@ -29,7 +29,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <assert.h>
#include <math.h>
@@ -38,14 +38,14 @@
typedef struct {
- /* Required header: */
- OPDS h;
+ /* Required header: */
+ OPDS h;
- /* Output channels (4, 9 or 16 in use): */
- MYFLT *aouts[16];
+ /* Output channels (4, 9 or 16 in use): */
+ MYFLT *aouts[16];
- /* Input arguments: */
- MYFLT *ain, *kangle, *kelevation;
+ /* Input arguments: */
+ MYFLT *ain, *kangle, *kelevation;
} AMBIC;
@@ -53,15 +53,15 @@ typedef struct {
typedef struct {
- /* Required header: */
- OPDS h;
+ /* Required header: */
+ OPDS h;
- /* Output channels (up to eight supported here, depending on the
+ /* Output channels (up to eight supported here, depending on the
isetup parameter). */
- MYFLT *aouts[8];
+ MYFLT *aouts[8];
- /* Input arguments: */
- MYFLT *isetup, *ains[VARGMAX];
+ /* Input arguments: */
+ MYFLT *isetup, *ains[VARGMAX];
} AMBID;
@@ -69,89 +69,89 @@ typedef struct {
#define ROOT27 (5.1961524227066318806)
#define ROOT135d16 (0.72618437741389066597) /* sqrt(135.0/256.0) */
-static int
-ibformenc(CSOUND * csound, AMBIC * p) {
- /* All we do in here is police our parameters. */
- switch (p->OUTOCOUNT) {
- case 4:
- case 9:
- case 16:
- return OK;
- default:
- return csound->InitError
- (csound, Str("The numbers of input and output arguments are not valid."));
+static int ibformenc(CSOUND * csound, AMBIC * p)
+{
+ /* All we do in here is police our parameters. */
+ switch (p->OUTOCOUNT) {
+ case 4:
+ case 9:
+ case 16:
+ return OK;
+ default:
+ return csound->InitError
+ (csound, Str("The numbers of input and output arguments are not valid."));
}
}
static int
abformenc(CSOUND * csound, AMBIC * p) {
- int sampleCount, sampleIndex, channelCount, channelIndex;
- double angle, elevation, x, y, z;
- MYFLT coefficients[16], coefficient, * output, * input;
- MYFLT x2, y2, z2;
-
- /* Find basic mode & angles: */
- sampleCount = csound->ksmps;
- channelCount = p->OUTOCOUNT;
- angle = (double)(*(p->kangle)) * (PI / 180.0);
- elevation = (double)(*(p->kelevation)) * (PI / 180.0);
-
- /* Find direction cosines: */
- x = cos(elevation);
- y = x;
- z = sin(elevation);
- x *= cos(angle);
- y *= sin(angle);
- x2 = x * x;
- y2 = y * y;
- z2 = z * z;
-
- /* Find directional coefficients: */
- switch (channelCount) {
- case 16:
- /* Third order. */
- coefficients[ 9] = (MYFLT)((2.5 * z2 - 1.5) * z);
- coefficients[10] = (MYFLT)(ROOT135d16 * x * (5.0 * z2 - 1));
- coefficients[11] = (MYFLT)(ROOT135d16 * y * (5.0 * z2 - 1));
- coefficients[12] = (MYFLT)(0.5*ROOT27 * z * (x2 - y2));
- coefficients[13] = (MYFLT)(ROOT27 * x * y * z);
- coefficients[14] = (MYFLT)(x * (x2 - 3.0 * y2));
- coefficients[15] = (MYFLT)(y * (3.0 * x2 - y2));
- /* Deliberately no break;. */
- case 9:
- /* Second order. */
- coefficients[ 4] = (MYFLT)(1.5 * z2 - 0.5);
- coefficients[ 5] = (MYFLT)(2.0 * z * x);
- coefficients[ 6] = (MYFLT)(2.0 * y * z);
- coefficients[ 7] = (MYFLT)(x2 - y2);
- coefficients[ 8] = (MYFLT)(2.0 * x * y);
- /* Deliberately no break;. */
- case 4:
- /* Zero and first order. */
- coefficients[ 0] = SQRT(FL(0.5));
- coefficients[ 1] = (MYFLT)x;
- coefficients[ 2] = (MYFLT)y;
- coefficients[ 3] = (MYFLT)z;
- break;
- default:
- /* Should never be reached as this is policed at init time. */
- assert(0);
- }
- /* (There are some repeated multiplies in the code above, but I
- suggest these aren't removed until everyone is sure the
- unoptimised code is doing the right thing!) */
-
- /* Process channels: */
- for (channelIndex = 0; channelIndex < channelCount; channelIndex++) {
- coefficient = coefficients[channelIndex];
- input = p->ain;
- output = p->aouts[channelIndex];
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
- output[sampleIndex] = coefficient * input[sampleIndex];
- }
+ int sampleCount, sampleIndex, channelCount, channelIndex;
+ double angle, elevation, x, y, z;
+ MYFLT coefficients[16], coefficient, * output, * input;
+ MYFLT x2, y2, z2;
+
+ /* Find basic mode & angles: */
+ sampleCount = csound->ksmps;
+ channelCount = p->OUTOCOUNT;
+ angle = (double)(*(p->kangle)) * (PI / 180.0);
+ elevation = (double)(*(p->kelevation)) * (PI / 180.0);
+
+ /* Find direction cosines: */
+ x = cos(elevation);
+ y = x;
+ z = sin(elevation);
+ x *= cos(angle);
+ y *= sin(angle);
+ x2 = x * x;
+ y2 = y * y;
+ z2 = z * z;
+
+ /* Find directional coefficients: */
+ switch (channelCount) {
+ case 16:
+ /* Third order. */
+ coefficients[ 9] = (MYFLT)((2.5 * z2 - 1.5) * z);
+ coefficients[10] = (MYFLT)(ROOT135d16 * x * (5.0 * z2 - 1));
+ coefficients[11] = (MYFLT)(ROOT135d16 * y * (5.0 * z2 - 1));
+ coefficients[12] = (MYFLT)(0.5*ROOT27 * z * (x2 - y2));
+ coefficients[13] = (MYFLT)(ROOT27 * x * y * z);
+ coefficients[14] = (MYFLT)(x * (x2 - 3.0 * y2));
+ coefficients[15] = (MYFLT)(y * (3.0 * x2 - y2));
+ /* Deliberately no break;. */
+ case 9:
+ /* Second order. */
+ coefficients[ 4] = (MYFLT)(1.5 * z2 - 0.5);
+ coefficients[ 5] = (MYFLT)(2.0 * z * x);
+ coefficients[ 6] = (MYFLT)(2.0 * y * z);
+ coefficients[ 7] = (MYFLT)(x2 - y2);
+ coefficients[ 8] = (MYFLT)(2.0 * x * y);
+ /* Deliberately no break;. */
+ case 4:
+ /* Zero and first order. */
+ coefficients[ 0] = SQRT(FL(0.5));
+ coefficients[ 1] = (MYFLT)x;
+ coefficients[ 2] = (MYFLT)y;
+ coefficients[ 3] = (MYFLT)z;
+ break;
+ default:
+ /* Should never be reached as this is policed at init time. */
+ assert(0);
+ }
+ /* (There are some repeated multiplies in the code above, but I
+ suggest these aren't removed until everyone is sure the
+ unoptimised code is doing the right thing!) */
+
+ /* Process channels: */
+ for (channelIndex = 0; channelIndex < channelCount; channelIndex++) {
+ coefficient = coefficients[channelIndex];
+ input = p->ain;
+ output = p->aouts[channelIndex];
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
+ output[sampleIndex] = coefficient * input[sampleIndex];
+ }
- return OK;
+ return OK;
}
@@ -159,309 +159,311 @@ abformenc(CSOUND * csound, AMBIC * p) {
static int
ibformdec(CSOUND * csound, AMBID * p) {
- /* All we do in here is police our parameters. */
- if (UNLIKELY(p->INOCOUNT != 1 + 4 && p->INOCOUNT != 1 + 9 && p->INOCOUNT != 1 + 16)) {
- return csound->InitError(csound,
- Str("The number of input arguments is not valid."));
- }
- else if (UNLIKELY(*(p->isetup) < 1 || *(p->isetup) > 5)) {
- return csound->InitError(csound,
- Str("The isetup value should be between 1 and 5."));
- }
- else {
- /* Then we check the output arguments. */
- if (*(p->isetup) == 1 && p->OUTOCOUNT == 2) {
- /* Stereo. */
- return OK;
- }
- else if (*(p->isetup) == 2 && p->OUTOCOUNT == 4) {
- /* Quad. */
- return OK;
- }
- else if (*(p->isetup) == 3 && p->OUTOCOUNT == 5) {
- /* Surround 5.0. */
- return OK;
- }
- else if (*(p->isetup) == 4 && p->OUTOCOUNT == 8) {
- /* Octagon. */
- return OK;
+ /* All we do in here is police our parameters. */
+ if (UNLIKELY(p->INOCOUNT != 1 + 4 &&
+ p->INOCOUNT != 1 + 9 &&
+ p->INOCOUNT != 1 + 16)) {
+ return csound->InitError(csound,
+ Str("The number of input arguments is not valid."));
}
- else if (*(p->isetup) == 5 && p->OUTOCOUNT == 8) {
- /* Cube. */
- return OK;
+ else if (UNLIKELY(*(p->isetup) < 1 || *(p->isetup) > 5)) {
+ return csound->InitError(csound,
+ Str("The isetup value should be between 1 and 5."));
}
else {
- return csound->InitError(csound,
- Str("The output channel count does not"
- " match the isetup value."));
+ /* Then we check the output arguments. */
+ if (*(p->isetup) == 1 && p->OUTOCOUNT == 2) {
+ /* Stereo. */
+ return OK;
+ }
+ else if (*(p->isetup) == 2 && p->OUTOCOUNT == 4) {
+ /* Quad. */
+ return OK;
+ }
+ else if (*(p->isetup) == 3 && p->OUTOCOUNT == 5) {
+ /* Surround 5.0. */
+ return OK;
+ }
+ else if (*(p->isetup) == 4 && p->OUTOCOUNT == 8) {
+ /* Octagon. */
+ return OK;
+ }
+ else if (*(p->isetup) == 5 && p->OUTOCOUNT == 8) {
+ /* Cube. */
+ return OK;
+ }
+ else {
+ return csound->InitError(csound,
+ Str("The output channel count does not"
+ " match the isetup value."));
+ }
}
- }
- return OK; /* Never used */
+ return OK; /* Never used */
}
static int
abformdec(CSOUND * csound, AMBID * p) {
- /* All assert() calls in here should already have been validated in
- ibformdec(). I've also abused the notation a fair bit, often
- holding scaled values in w, x, y etc. */
-
- /* (There are some repeated multiplies in the code below, but I
- suggest these aren't removed until everyone is sure the
- unoptimised code is doing the right thing!) */
-
- int sampleCount, sampleIndex;
- MYFLT p0, q, u, v, w, x, y, z;
-
- sampleCount = csound->ksmps;
- assert(p->INOCOUNT >= 5);
-
- switch ((int)*(p->isetup)) {
- case 1: /* Stereo */
- assert(p->OUTOCOUNT == 2);
- /* Use a 90degree stereo decode, equivalent to a M+S microphone
- array at the origin. Works better than front-facing
- arrangements for most purposes, as a composer using this opcode
- probably wants to hear the back stage. */
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex] * SQRT(FL(0.5));
- y = p->ains[2][sampleIndex] * FL(0.5);
- /* Left: */
- p->aouts[0][sampleIndex] = w + y;
- /* Right: */
- p->aouts[1][sampleIndex] = w - y;
- }
- break;
- case 2: /* Quad */
- assert(p->OUTOCOUNT == 4);
- /* Use a first-order 'in-phase' decode. */
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex] * FL(0.35355);
- x = p->ains[1][sampleIndex] * FL(0.17677);
- y = p->ains[2][sampleIndex] * FL(0.17677);
- /* Front left: */
- p->aouts[0][sampleIndex] = w + x + y;
- /* Back left: */
- p->aouts[1][sampleIndex] = w - x + y;
- /* Back right: */
- p->aouts[2][sampleIndex] = w - x - y;
- /* Front right: */
- p->aouts[3][sampleIndex] = w + x - y;
- }
- break;
- case 3: /* 5.0 */
- assert(p->OUTOCOUNT == 5);
- /* This is a second order decoder provided by Bruce Wiggins. It is
- optimised for high frequency use within a dual-band decoder,
- however it has good a low-frequency response. It isn't quite
- 'in-phase' but it is not far off. */
- if (p->INOCOUNT == 1 + 4) {
- /* Matrix truncated to first order (not ideal). */
+ /* All assert() calls in here should already have been validated in
+ ibformdec(). I've also abused the notation a fair bit, often
+ holding scaled values in w, x, y etc. */
+
+ /* (There are some repeated multiplies in the code below, but I
+ suggest these aren't removed until everyone is sure the
+ unoptimised code is doing the right thing!) */
+
+ int sampleCount, sampleIndex;
+ MYFLT p0, q, u, v, w, x, y, z;
+
+ sampleCount = csound->ksmps;
+ assert(p->INOCOUNT >= 5);
+
+ switch ((int)*(p->isetup)) {
+ case 1: /* Stereo */
+ assert(p->OUTOCOUNT == 2);
+ /* Use a 90degree stereo decode, equivalent to a M+S microphone
+ array at the origin. Works better than front-facing
+ arrangements for most purposes, as a composer using this opcode
+ probably wants to hear the back stage. */
for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex];
- x = p->ains[1][sampleIndex];
- y = p->ains[2][sampleIndex];
+ w = p->ains[0][sampleIndex] * SQRT(FL(0.5));
+ y = p->ains[2][sampleIndex] * FL(0.5);
/* Left: */
- p->aouts[0][sampleIndex]
- = w * FL(0.405) + x * FL(0.32) + y * FL(0.31);
+ p->aouts[0][sampleIndex] = w + y;
/* Right: */
- p->aouts[1][sampleIndex]
- = w * FL(0.405) + x * FL(0.32) - y * FL(0.31);
- /* Centre: */
- p->aouts[2][sampleIndex]
- = w * FL(0.085) + x * FL(0.04);
- /* Surround Left: */
- p->aouts[3][sampleIndex]
- = w * FL(0.635) - x * FL(0.335) + y * FL(0.28);
- /* Surround Right: */
- p->aouts[4][sampleIndex]
- = w * FL(0.635) - x * FL(0.335) - y * FL(0.28);
+ p->aouts[1][sampleIndex] = w - y;
}
- }
- else {
- /* This is the full matrix. */
+ break;
+ case 2: /* Quad */
+ assert(p->OUTOCOUNT == 4);
+ /* Use a first-order 'in-phase' decode. */
for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex];
- x = p->ains[1][sampleIndex];
- y = p->ains[2][sampleIndex];
- u = p->ains[7][sampleIndex];
- v = p->ains[8][sampleIndex];
- /* Left: */
- p->aouts[0][sampleIndex]
- = (w * FL(0.405) + x * FL(0.32) + y * FL(0.31)
- + u * FL(0.085) + v * FL(0.125));
- /* Right: */
- p->aouts[1][sampleIndex]
- = (w * FL(0.405) + x * FL(0.32) - y * FL(0.31)
- + u * FL(0.085) - v * FL(0.125));
- /* Centre: */
- p->aouts[2][sampleIndex]
- = (w * FL(0.085) + x * FL(0.04)
- + u * FL(0.045));
- /* Surround Left: */
- p->aouts[3][sampleIndex]
- = (w * FL(0.635) - x * FL(0.335) + y * FL(0.28)
- - u * FL(0.08) + v * FL(0.08));
- /* Surround Right: */
- p->aouts[4][sampleIndex]
- = (w * FL(0.635) - x * FL(0.335) - y * FL(0.28)
- - u * FL(0.08) - v * FL(0.08));
+ w = p->ains[0][sampleIndex] * FL(0.35355);
+ x = p->ains[1][sampleIndex] * FL(0.17677);
+ y = p->ains[2][sampleIndex] * FL(0.17677);
+ /* Front left: */
+ p->aouts[0][sampleIndex] = w + x + y;
+ /* Back left: */
+ p->aouts[1][sampleIndex] = w - x + y;
+ /* Back right: */
+ p->aouts[2][sampleIndex] = w - x - y;
+ /* Front right: */
+ p->aouts[3][sampleIndex] = w + x - y;
}
- }
- break;
- case 4: /* Octagon: */
- assert(p->OUTOCOUNT == 8);
- if (p->INOCOUNT == 1 + 4) {
- /* First order 'in-phase' decode: */
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex] * FL(0.17677);
- x = p->ains[1][sampleIndex];
- y = p->ains[2][sampleIndex];
- /* About 11 o'clock: */
- p->aouts[0][sampleIndex] = w + x * FL(0.11548) + y * FL(0.04783);
- /* About 10 o'clock: */
- p->aouts[1][sampleIndex] = w + x * FL(0.04783) + y * FL(0.11546);
- /* About 8 o'clock: */
- p->aouts[2][sampleIndex] = w - x * FL(0.04783) + y * FL(0.11546);
- /* About 7 o'clock: */
- p->aouts[3][sampleIndex] = w - x * FL(0.11548) + y * FL(0.04783);
- /* About 5 o'clock: */
- p->aouts[4][sampleIndex] = w - x * FL(0.11548) - y * FL(0.04783);
- /* About 4 o'clock: */
- p->aouts[5][sampleIndex] = w - x * FL(0.04783) - y * FL(0.11546);
- /* About 2 o'clock: */
- p->aouts[6][sampleIndex] = w + x * FL(0.04783) - y * FL(0.11546);
- /* About 1 o'clock: */
- p->aouts[7][sampleIndex] = w + x * FL(0.11548) - y * FL(0.04783);
+ break;
+ case 3: /* 5.0 */
+ assert(p->OUTOCOUNT == 5);
+ /* This is a second order decoder provided by Bruce Wiggins. It is
+ optimised for high frequency use within a dual-band decoder,
+ however it has good a low-frequency response. It isn't quite
+ 'in-phase' but it is not far off. */
+ if (p->INOCOUNT == 1 + 4) {
+ /* Matrix truncated to first order (not ideal). */
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
+ w = p->ains[0][sampleIndex];
+ x = p->ains[1][sampleIndex];
+ y = p->ains[2][sampleIndex];
+ /* Left: */
+ p->aouts[0][sampleIndex]
+ = w * FL(0.405) + x * FL(0.32) + y * FL(0.31);
+ /* Right: */
+ p->aouts[1][sampleIndex]
+ = w * FL(0.405) + x * FL(0.32) - y * FL(0.31);
+ /* Centre: */
+ p->aouts[2][sampleIndex]
+ = w * FL(0.085) + x * FL(0.04);
+ /* Surround Left: */
+ p->aouts[3][sampleIndex]
+ = w * FL(0.635) - x * FL(0.335) + y * FL(0.28);
+ /* Surround Right: */
+ p->aouts[4][sampleIndex]
+ = w * FL(0.635) - x * FL(0.335) - y * FL(0.28);
+ }
}
- }
- else if (p->INOCOUNT == 1 + 9) {
- /* Second order 'in-phase' / 'controlled opposites' decode: */
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex] * FL(0.17677);
- x = p->ains[1][sampleIndex];
- y = p->ains[2][sampleIndex];
- u = p->ains[7][sampleIndex] * FL(0.03417);
- v = p->ains[8][sampleIndex] * FL(0.03417);
- /* About 11 o'clock: */
- p->aouts[0][sampleIndex]
- = w + x * FL(0.15906) + y * FL(0.06588) + u + v;
- /* About 10 o'clock: */
- p->aouts[1][sampleIndex]
- = w + x * FL(0.06588) + y * FL(0.15906) - u + v;
- /* About 8 o'clock: */
- p->aouts[2][sampleIndex]
- = w - x * FL(0.06588) + y * FL(0.15906) - u - v;
- /* About 7 o'clock: */
- p->aouts[3][sampleIndex]
- = w - x * FL(0.15906) + y * FL(0.06588) + u - v;
- /* About 5 o'clock: */
- p->aouts[4][sampleIndex]
- = w - x * FL(0.15906) - y * FL(0.06588) + u + v;
- /* About 4 o'clock: */
- p->aouts[5][sampleIndex]
- = w - x * FL(0.06588) - y * FL(0.15906) - u + v;
- /* About 2 o'clock: */
- p->aouts[6][sampleIndex]
- = w + x * FL(0.06588) - y * FL(0.15906) - u - v;
- /* About 1 o'clock: */
- p->aouts[7][sampleIndex]
- = w + x * FL(0.15906) - y * FL(0.06588) + u - v;
+ else {
+ /* This is the full matrix. */
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
+ w = p->ains[0][sampleIndex];
+ x = p->ains[1][sampleIndex];
+ y = p->ains[2][sampleIndex];
+ u = p->ains[7][sampleIndex];
+ v = p->ains[8][sampleIndex];
+ /* Left: */
+ p->aouts[0][sampleIndex]
+ = (w * FL(0.405) + x * FL(0.32) + y * FL(0.31)
+ + u * FL(0.085) + v * FL(0.125));
+ /* Right: */
+ p->aouts[1][sampleIndex]
+ = (w * FL(0.405) + x * FL(0.32) - y * FL(0.31)
+ + u * FL(0.085) - v * FL(0.125));
+ /* Centre: */
+ p->aouts[2][sampleIndex]
+ = (w * FL(0.085) + x * FL(0.04)
+ + u * FL(0.045));
+ /* Surround Left: */
+ p->aouts[3][sampleIndex]
+ = (w * FL(0.635) - x * FL(0.335) + y * FL(0.28)
+ - u * FL(0.08) + v * FL(0.08));
+ /* Surround Right: */
+ p->aouts[4][sampleIndex]
+ = (w * FL(0.635) - x * FL(0.335) - y * FL(0.28)
+ - u * FL(0.08) - v * FL(0.08));
+ }
}
- }
- else {
- assert(p->INOCOUNT == 1 + 16);
- /* Third order 'in-phase' / 'controlled opposites' decode: */
+ break;
+ case 4: /* Octagon: */
+ assert(p->OUTOCOUNT == 8);
+ if (p->INOCOUNT == 1 + 4) {
+ /* First order 'in-phase' decode: */
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
+ w = p->ains[0][sampleIndex] * FL(0.17677);
+ x = p->ains[1][sampleIndex];
+ y = p->ains[2][sampleIndex];
+ /* About 11 o'clock: */
+ p->aouts[0][sampleIndex] = w + x * FL(0.11548) + y * FL(0.04783);
+ /* About 10 o'clock: */
+ p->aouts[1][sampleIndex] = w + x * FL(0.04783) + y * FL(0.11546);
+ /* About 8 o'clock: */
+ p->aouts[2][sampleIndex] = w - x * FL(0.04783) + y * FL(0.11546);
+ /* About 7 o'clock: */
+ p->aouts[3][sampleIndex] = w - x * FL(0.11548) + y * FL(0.04783);
+ /* About 5 o'clock: */
+ p->aouts[4][sampleIndex] = w - x * FL(0.11548) - y * FL(0.04783);
+ /* About 4 o'clock: */
+ p->aouts[5][sampleIndex] = w - x * FL(0.04783) - y * FL(0.11546);
+ /* About 2 o'clock: */
+ p->aouts[6][sampleIndex] = w + x * FL(0.04783) - y * FL(0.11546);
+ /* About 1 o'clock: */
+ p->aouts[7][sampleIndex] = w + x * FL(0.11548) - y * FL(0.04783);
+ }
+ }
+ else if (p->INOCOUNT == 1 + 9) {
+ /* Second order 'in-phase' / 'controlled opposites' decode: */
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
+ w = p->ains[0][sampleIndex] * FL(0.17677);
+ x = p->ains[1][sampleIndex];
+ y = p->ains[2][sampleIndex];
+ u = p->ains[7][sampleIndex] * FL(0.03417);
+ v = p->ains[8][sampleIndex] * FL(0.03417);
+ /* About 11 o'clock: */
+ p->aouts[0][sampleIndex]
+ = w + x * FL(0.15906) + y * FL(0.06588) + u + v;
+ /* About 10 o'clock: */
+ p->aouts[1][sampleIndex]
+ = w + x * FL(0.06588) + y * FL(0.15906) - u + v;
+ /* About 8 o'clock: */
+ p->aouts[2][sampleIndex]
+ = w - x * FL(0.06588) + y * FL(0.15906) - u - v;
+ /* About 7 o'clock: */
+ p->aouts[3][sampleIndex]
+ = w - x * FL(0.15906) + y * FL(0.06588) + u - v;
+ /* About 5 o'clock: */
+ p->aouts[4][sampleIndex]
+ = w - x * FL(0.15906) - y * FL(0.06588) + u + v;
+ /* About 4 o'clock: */
+ p->aouts[5][sampleIndex]
+ = w - x * FL(0.06588) - y * FL(0.15906) - u + v;
+ /* About 2 o'clock: */
+ p->aouts[6][sampleIndex]
+ = w + x * FL(0.06588) - y * FL(0.15906) - u - v;
+ /* About 1 o'clock: */
+ p->aouts[7][sampleIndex]
+ = w + x * FL(0.15906) - y * FL(0.06588) + u - v;
+ }
+ }
+ else {
+ assert(p->INOCOUNT == 1 + 16);
+ /* Third order 'in-phase' / 'controlled opposites' decode: */
+ for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
+ w = p->ains[ 0][sampleIndex] * FL(0.176777);
+ x = p->ains[ 1][sampleIndex];
+ y = p->ains[ 2][sampleIndex];
+ u = p->ains[ 7][sampleIndex] * FL(0.053033);
+ v = p->ains[ 8][sampleIndex] * FL(0.053033);
+ p0 = p->ains[14][sampleIndex];
+ q = p->ains[15][sampleIndex];
+ /* About 11 o'clock: */
+ p->aouts[0][sampleIndex]
+ = (w
+ + x * FL(0.173227) + y * FL(0.071753)
+ + u + v
+ + p0 * FL(0.004784) + q * FL(0.011548));
+ /* About 10 o'clock: */
+ p->aouts[1][sampleIndex]
+ = (w
+ + x * FL(0.071753) + y * FL(0.173227)
+ - u + v
+ - p0 * FL(0.011548) - q * FL(0.004784));
+ /* About 8 o'clock: */
+ p->aouts[2][sampleIndex]
+ = (w
+ - x * FL(0.071753) + y * FL(0.173227)
+ - u - v
+ + p0 * FL(0.004784) - q * FL(0.011548));
+ /* About 7 o'clock: */
+ p->aouts[3][sampleIndex]
+ = (w
+ - x * FL(0.173227) + y * FL(0.071753)
+ + u - v
+ - p0 * FL(0.011548) + q * FL(0.004784));
+ /* About 5 o'clock: */
+ p->aouts[4][sampleIndex]
+ = (w
+ - x * FL(0.173227) - y * FL(0.071753)
+ + u + v
+ - p0 * FL(0.004784) - q * FL(0.011548));
+ /* About 4 o'clock: */
+ p->aouts[5][sampleIndex]
+ = (w
+ - x * FL(0.071753) - y * FL(0.173227)
+ - u + v
+ + p0 * FL(0.011548) + q * FL(0.004784));
+ /* About 2 o'clock: */
+ p->aouts[6][sampleIndex]
+ = (w
+ + x * FL(0.071753) - y * FL(0.173227)
+ - u - v
+ - p0 * FL(0.004784) + q * FL(0.011548));
+ /* About 1 o'clock: */
+ p->aouts[7][sampleIndex]
+ = (w
+ + x * FL(0.173227) - y * FL(0.071753)
+ + u - v
+ + p0 * FL(0.011548) - q * FL(0.004784));
+ }
+ }
+ break;
+ case 5: /* Cube: */
+ assert(p->OUTOCOUNT == 8);
+ /* First order 'in-phase' decode: */
for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[ 0][sampleIndex] * FL(0.176777);
- x = p->ains[ 1][sampleIndex];
- y = p->ains[ 2][sampleIndex];
- u = p->ains[ 7][sampleIndex] * FL(0.053033);
- v = p->ains[ 8][sampleIndex] * FL(0.053033);
- p0 = p->ains[14][sampleIndex];
- q = p->ains[15][sampleIndex];
- /* About 11 o'clock: */
- p->aouts[0][sampleIndex]
- = (w
- + x * FL(0.173227) + y * FL(0.071753)
- + u + v
- + p0 * FL(0.004784) + q * FL(0.011548));
- /* About 10 o'clock: */
- p->aouts[1][sampleIndex]
- = (w
- + x * FL(0.071753) + y * FL(0.173227)
- - u + v
- - p0 * FL(0.011548) - q * FL(0.004784));
- /* About 8 o'clock: */
- p->aouts[2][sampleIndex]
- = (w
- - x * FL(0.071753) + y * FL(0.173227)
- - u - v
- + p0 * FL(0.004784) - q * FL(0.011548));
- /* About 7 o'clock: */
- p->aouts[3][sampleIndex]
- = (w
- - x * FL(0.173227) + y * FL(0.071753)
- + u - v
- - p0 * FL(0.011548) + q * FL(0.004784));
- /* About 5 o'clock: */
- p->aouts[4][sampleIndex]
- = (w
- - x * FL(0.173227) - y * FL(0.071753)
- + u + v
- - p0 * FL(0.004784) - q * FL(0.011548));
- /* About 4 o'clock: */
- p->aouts[5][sampleIndex]
- = (w
- - x * FL(0.071753) - y * FL(0.173227)
- - u + v
- + p0 * FL(0.011548) + q * FL(0.004784));
- /* About 2 o'clock: */
- p->aouts[6][sampleIndex]
- = (w
- + x * FL(0.071753) - y * FL(0.173227)
- - u - v
- - p0 * FL(0.004784) + q * FL(0.011548));
- /* About 1 o'clock: */
- p->aouts[7][sampleIndex]
- = (w
- + x * FL(0.173227) - y * FL(0.071753)
- + u - v
- + p0 * FL(0.011548) - q * FL(0.004784));
+ w = p->ains[0][sampleIndex] * FL(0.17677);
+ x = p->ains[1][sampleIndex] * FL(0.07216);
+ y = p->ains[2][sampleIndex] * FL(0.07216);
+ z = p->ains[3][sampleIndex] * FL(0.07216);
+ /* Front left bottom: */
+ p->aouts[0][sampleIndex] = w + x + y - z;
+ /* Front left top: */
+ p->aouts[1][sampleIndex] = w + x + y + z;
+ /* Back left bottom: */
+ p->aouts[2][sampleIndex] = w - x + y - z;
+ /* Back left top: */
+ p->aouts[3][sampleIndex] = w - x + y + z;
+ /* Back right bottom: */
+ p->aouts[4][sampleIndex] = w - x - y - z;
+ /* Back right top: */
+ p->aouts[5][sampleIndex] = w - x - y + z;
+ /* Front right bottom: */
+ p->aouts[6][sampleIndex] = w + x - y - z;
+ /* Front right top: */
+ p->aouts[7][sampleIndex] = w + x - y + z;
}
+ break;
+ default:
+ assert(0);
}
- break;
- case 5: /* Cube: */
- assert(p->OUTOCOUNT == 8);
- /* First order 'in-phase' decode: */
- for (sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) {
- w = p->ains[0][sampleIndex] * FL(0.17677);
- x = p->ains[1][sampleIndex] * FL(0.07216);
- y = p->ains[2][sampleIndex] * FL(0.07216);
- z = p->ains[3][sampleIndex] * FL(0.07216);
- /* Front left bottom: */
- p->aouts[0][sampleIndex] = w + x + y - z;
- /* Front left top: */
- p->aouts[1][sampleIndex] = w + x + y + z;
- /* Back left bottom: */
- p->aouts[2][sampleIndex] = w - x + y - z;
- /* Back left top: */
- p->aouts[3][sampleIndex] = w - x + y + z;
- /* Back right bottom: */
- p->aouts[4][sampleIndex] = w - x - y - z;
- /* Back right top: */
- p->aouts[5][sampleIndex] = w - x - y + z;
- /* Front right bottom: */
- p->aouts[6][sampleIndex] = w + x - y - z;
- /* Front right top: */
- p->aouts[7][sampleIndex] = w + x - y + z;
- }
- break;
- default:
- assert(0);
- }
- return OK;
+ return OK;
}
@@ -477,4 +479,3 @@ static OENTRY ambicode1_localops[] = {
};
LINKAGE1(ambicode1_localops)
-
diff --git a/Opcodes/babo.c b/Opcodes/babo.c
index b6e3c54..0d09bfb 100644
--- a/Opcodes/babo.c
+++ b/Opcodes/babo.c
@@ -155,7 +155,7 @@ BaboMemory_create(CSOUND *csound, BaboMemory *this, size_t size_in_floats)
csound->AuxAlloc(csound, size_in_bytes, &this->memptr);
- memset(this->memptr.auxp, 0, size_in_bytes);
+ //memset(this->memptr.auxp, 0, size_in_bytes);
this->samples = size_in_floats;
diff --git a/Opcodes/cellular.c b/Opcodes/cellular.c
index 430aa0e..f416261 100644
--- a/Opcodes/cellular.c
+++ b/Opcodes/cellular.c
@@ -41,7 +41,7 @@ static int cell_set(CSOUND *csound,CELL *p)
FUNC *ftp;
int elements;
MYFLT *currLine, *initVec = NULL;
-
+
if (LIKELY((ftp = csound->FTnp2Find(csound,p->ioutFunc)) != NULL)) {
p->outVec = ftp->ftable;
elements = (p->elements = (int) *p->ielements);
@@ -61,7 +61,7 @@ static int cell_set(CSOUND *csound,CELL *p)
}
else
return csound->InitError(csound, Str("cell: invalid rule table"));
-
+
if (p->auxch.auxp == NULL)
csound->AuxAlloc(csound, elements * sizeof(MYFLT) * 2, &p->auxch);
currLine = (p->currLine = (MYFLT *) p->auxch.auxp);
@@ -89,14 +89,14 @@ static int cell(CSOUND *csound,CELL *p)
p->NewOld += 1;
p->NewOld %= 2;
actual = &(p->currLine[elements * p->NewOld]);
-// Cellular Engine
+// Cellular Engine
for (j=0; j < elements; j++) {
jm1 = (j < 1) ? elements-1 : j-1;
outVec[j] = previous[j];
actual[j] = ruleVec[(int)(previous[jm1]*4 + previous[j]*2 +
- previous[(j+1) % elements])];
+ previous[(j+1) % elements])];
}
-
+
} else {
int elements = p->elements;
MYFLT *actual = &(p->currLine[elements * !(p->NewOld)]);
@@ -112,9 +112,9 @@ static int cell(CSOUND *csound,CELL *p)
#define S sizeof
static OENTRY localops[] = {
- {"cell", S(CELL), 3, "", "kkiiii",(SUBR)cell_set, (SUBR)cell }
- };
+ {"cell", S(CELL), 3|TB, "", "kkiiii",(SUBR)cell_set, (SUBR)cell }
+};
-LINKAGE
+LINKAGE
// Author: Gleb Rogozinsky, October 2011
diff --git a/Opcodes/chua/ChuaOscillator.cpp b/Opcodes/chua/ChuaOscillator.cpp
index e8a681c..6be129a 100644
--- a/Opcodes/chua/ChuaOscillator.cpp
+++ b/Opcodes/chua/ChuaOscillator.cpp
@@ -97,12 +97,12 @@
// k3(2) = (G*(M(1) + h2*k2(1) - (M(2) + h2*k2(2))) + M(3) + h2*k2(3))/C2;
// k3(3) = (-(M(2) + h2*k2(2) + R0*(M(3) + h2*k2(3))))/L;
// % Round Four
-// k4(1) = (G*(M(2) + h*k3(2) - (M(1) + h*k3(1))) - gnor(M(1) +
+// k4(1) = (G*(M(2) + h*k3(2) - (M(1) + h*k3(1))) - gnor(M(1) +
// h*k3(1),sys_variables))/C1;
// k4(2) = (G*(M(1) + h*k3(1) - (M(2) + h*k3(2))) + M(3) + h*k3(3))/C2;
// k4(3) = (-(M(2) + h*k3(2) + R0*(M(3) + h*k3(3))))/L;
// %Finishes integration and assigns values to M(1),
-// M = M + (k1 + 2*k2 + 2*k3 + k4)*(h6);
+// M = M + (k1 + 2*k2 + 2*k3 + k4)*(h6);
// %M(2) and M(3)
// TimeSeries(3,i+1) = M(1); %TimeSeries 3 is V1
// TimeSeries(2,i+1) = M(2); %TimeSeries 2 is V2
@@ -131,7 +131,7 @@ public:
MYFLT *V1;
// INPUTS
// % L,R0,C2,G,Ga,Gb,E,C1,a,b,c,d
- // sys_variables = [system_vars(5:12),system_vars(23:26)];
+ // sys_variables = [system_vars(5:12),system_vars(23:26)];
// % x0,y0,z0,dataset_size,step_size
// integ_variables = [system_vars(14:16),system_vars(1:2)];
// function TimeSeries = chuacc(L,R0,C2,G,Ga,Gb,C1,E,x0,y0,z0,
@@ -208,9 +208,9 @@ public:
d = 0.0;
ksmps = csound->GetKsmps(csound);
warn(csound, "ChuasOscillatorCubic::init: L: %f R0: %f C2: %f G: %f"
- " C1: %f V1: %f V2: %f I3: %f step: %f\n",
+ " C1: %f V1: %f V2: %f I3: %f step: %f\n",
*L_, *R0_, *C2_, *G_, *C1_, M(1), M(2), M(3), h);
- warn(csound, "ChuasOscillatorCubic::init: a: %f b: %f c: %f d: %f\n",
+ warn(csound, "ChuasOscillatorCubic::init: a: %f b: %f c: %f d: %f\n",
a, b, c, d);
return OK;
}
@@ -343,7 +343,7 @@ public:
// k1(3) = -beta*M(2) - gammaloc*M(3);
// % Round Two
// temp = M(1) + h2*k1(1);
-// k2(1) = alpha*(M(2) + h2*k1(2) - bnorplus1*temp -
+// k2(1) = alpha*(M(2) + h2*k1(2) - bnorplus1*temp -
// (.5)*(anor - bnor)*(abs(temp + 1) - abs(temp - 1)));
// k2(2) = k1(2) + h2*(k1(1) - k1(2) + k1(3));
// k2(3) = omch2*k1(3) - bh2*k1(2);
@@ -355,7 +355,7 @@ public:
// k3(3) = k1(3) - bh2*k2(2) - ch2*k2(3);
// % Round Four
// temp = M(1) + h*k3(1);
-// k4(1) = alpha*(M(2) + h*k3(2) - bnorplus1*temp -
+// k4(1) = alpha*(M(2) + h*k3(2) - bnorplus1*temp -
// (.5)*(anor - bnor)*(abs(temp + 1) - abs(temp - 1)));
// k4(2) = k1(2) + h*(k3(1) - k3(2) + k3(3));
// k4(3) = k1(3) - bh*k3(2) - ch*k3(3);
@@ -616,4 +616,3 @@ extern "C"
return 0;
}
}
-
diff --git a/Opcodes/control.c b/Opcodes/control.c
index 9713387..c2cedf4 100644
--- a/Opcodes/control.c
+++ b/Opcodes/control.c
@@ -70,7 +70,10 @@ static void start_tcl_tk(CONTROL_GLOBALS *p)
int i;
p->csound->Message(p->csound, "TCL/Tk\n");
- pipe(p->pip1); pipe(p->pip2);
+ if (UNLIKELY(pipe(p->pip1) || pipe(p->pip2))) {
+ printf("Failed to create pipes");
+ return;
+ }
if ((p->wish_pid = fork()) < 0)
return;
if (p->wish_pid == 0) { /* Child process */
@@ -99,7 +102,10 @@ static void start_tcl_tk(CONTROL_GLOBALS *p)
p->csound->RegisterResetCallback(p->csound, (void*) p,
(int (*)(CSOUND *, void *)) kill_wish);
fprintf(p->wish_cmd, "source nsliders.tk\n");
- fgets(p->cmd, 100, p->wish_res);
+ if (UNLIKELY(NULL==fgets(p->cmd, 100, p->wish_res))) {
+ printf("Failed to read from child");
+ return;
+ };
p->csound->Message(p->csound, "Wish %s\n", p->cmd);
p->values = (int*) calloc(8, sizeof(int));
p->minvals = (int*) calloc(8, sizeof(int));
@@ -147,7 +153,10 @@ static void readvalues(CONTROL_GLOBALS *p)
/* Read all changes */
while (select(p->pip1[0] + 1, &rfds, NULL, NULL, &tv)) {
int n, val;
- fscanf(p->wish_res, "%d %d", &n, &val);
+ if (UNLIKELY(2!=fscanf(p->wish_res, "%d %d", &n, &val))) {
+ printf("Failed to read from child");
+ return;
+ }
if (n > 0) p->values[n] = val;
else if (n == 0) p->buttons[val] = 1;
else p->checks[-n] = val;
diff --git a/Opcodes/cpumeter.c b/Opcodes/cpumeter.c
index 38e8911..e6b5875 100644
--- a/Opcodes/cpumeter.c
+++ b/Opcodes/cpumeter.c
@@ -13,11 +13,11 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
*/
#if defined(__MACH__) || defined(LINUX)
-
+
#include "csoundCore.h"
#include <sys/resource.h>
#include <sys/time.h>
@@ -43,7 +43,7 @@ typedef long long SIC_t;
typedef struct CPU_t {
TIC_t u, n, s, i, w, x, y, z; // as represented in /proc/stat
- TIC_t u_sav, n_sav, s_sav, i_sav,
+ TIC_t u_sav, n_sav, s_sav, i_sav,
w_sav, x_sav, y_sav, z_sav;
unsigned id; // the CPU ID number
} CPU_t;
@@ -107,7 +107,7 @@ static int cpupercent_renew(CSOUND *csound, CPUMETER* p)
rewind(p->fp);
fflush(p->fp);
k = p->cpu_max;
- if (!fgets(buf, SMLBUFSIZ, p->fp))
+ if (!fgets(buf, SMLBUFSIZ, p->fp))
return csound->PerfError(csound,Str("failed /proc/stat read"));
num = sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
&cpu[k].u, &cpu[k].n, &cpu[k].s, &cpu[k].i,
@@ -198,7 +198,7 @@ static int cpupercent(CSOUND *csound, CPUMETER* p)
p->cnt = p->trig;
return n;
}
- return OK;
+ return OK;
}
#define S(x) sizeof(x)
diff --git a/Opcodes/crossfm.h b/Opcodes/crossfm.h
index 129d167..67b9f1d 100644
--- a/Opcodes/crossfm.h
+++ b/Opcodes/crossfm.h
@@ -49,12 +49,12 @@
typedef struct {
OPDS h; /* common to all opcodes */
-
+
MYFLT *aout1, *aout2; /* output args */
MYFLT *xfrq1, *xfrq2, *xndx1, *xndx2; /* input args */
MYFLT *kcps, *ifn1, *ifn2; /* input args */
MYFLT *iphs1, *iphs2; /* input args */
-
+
MYFLT phase1, phase2; /* phase of oscillators */
MYFLT sig1, sig2; /* a-rate oscillators outputs */
MYFLT siz1, siz2; /* size of funtion tables */
@@ -63,4 +63,3 @@ typedef struct {
/* pointers (0 for i-rate and */
/* k-rate, 1 for a-rate args */
} CROSSFM;
-
diff --git a/Opcodes/dcblockr.c b/Opcodes/dcblockr.c
index f8b5eed..260e03a 100644
--- a/Opcodes/dcblockr.c
+++ b/Opcodes/dcblockr.c
@@ -92,6 +92,7 @@ static int dcblock2set(CSOUND *csound, DCBlock2* p)
p->delay1.size < (order-1)*2*sizeof(double))
csound->AuxAlloc(csound, (order-1)*2*sizeof(double),
&p->delay1);
+
if (p->iirdelay1.auxp == NULL ||
p->iirdelay1.size < (order)*sizeof(double))
csound->AuxAlloc(csound,
diff --git a/Opcodes/dssi4cs/src/dssi4cs.c b/Opcodes/dssi4cs/src/dssi4cs.c
index 68c7b7f..c890df3 100644
--- a/Opcodes/dssi4cs/src/dssi4cs.c
+++ b/Opcodes/dssi4cs/src/dssi4cs.c
@@ -587,6 +587,16 @@ int dssiaudio_init(CSOUND * csound, DSSIAUDIO * p)
{
/* TODO not realtime safe, try to make it so. */
int Number = *p->iDSSIhandle;
+ int icnt = csound->GetInputArgCnt(p) - 1;
+ int ocnt = csound->GetOutputArgCnt(p);
+
+ if (UNLIKELY(icnt > DSSI4CS_MAX_IN_CHANNELS))
+ csound->Die(csound, Str("DSSI4CS: number of audio input channels is greater than %d"),
+ DSSI4CS_MAX_IN_CHANNELS);
+
+ if (UNLIKELY(ocnt > DSSI4CS_MAX_OUT_CHANNELS))
+ csound->Die(csound, Str("DSSI4CS: number of audio output channels is greater than %d"),
+ DSSI4CS_MAX_OUT_CHANNELS);
#ifdef DEBUG
csound->Message(csound,
@@ -669,7 +679,7 @@ int dssiaudio_init(CSOUND * csound, DSSIAUDIO * p)
p->NumInputPorts = ConnectedInputPorts;
p->NumOutputPorts = ConnectedOutputPorts;
- if ((p->NumInputPorts) < (csound->GetInputArgCnt(p) - 1)) {
+ if ((p->NumInputPorts) < icnt) {
if (p->NumInputPorts == 0)
csound->Message(csound, "DSSI4CS: Plugin '%s' has %i audio input ports "
"audio input discarded.\n",
@@ -679,7 +689,7 @@ int dssiaudio_init(CSOUND * csound, DSSIAUDIO * p)
"has %i audio input ports.",
Descriptor->Name, p->NumOutputPorts);
}
- if (p->NumOutputPorts < csound->GetOutputArgCnt(p))
+ if (p->NumOutputPorts < ocnt)
return csound->InitError(csound, "DSSI4CS: Plugin '%s' "
"has %i audio output ports.",
Descriptor->Name, p->NumOutputPorts);
@@ -1048,7 +1058,7 @@ static OENTRY dssi_localops[] = {
{"dssiactivate", sizeof(DSSIACTIVATE), 3, "", "ik",
(SUBR) dssiactivate_init, (SUBR) dssiactivate, NULL }
,
- {"dssiaudio", sizeof(DSSIAUDIO), 5, "mmmm", "iy", (SUBR) dssiaudio_init,
+ {"dssiaudio", sizeof(DSSIAUDIO), 5, "mmmmmmmmm", "iMMMMMMMMM", (SUBR) dssiaudio_init,
NULL, (SUBR) dssiaudio }
,
{"dssictls", sizeof(DSSICTLS), 3, "", "iikk", (SUBR) dssictls_init,
diff --git a/Opcodes/dssi4cs/src/dssi4cs.h b/Opcodes/dssi4cs/src/dssi4cs.h
index 31e369a..7621e63 100644
--- a/Opcodes/dssi4cs/src/dssi4cs.h
+++ b/Opcodes/dssi4cs/src/dssi4cs.h
@@ -23,8 +23,8 @@
#include "dssi.h"
/* When changing these remember to change dssiaudio function */
-#define DSSI4CS_MAX_IN_CHANNELS 4
-#define DSSI4CS_MAX_OUT_CHANNELS 4
+#define DSSI4CS_MAX_IN_CHANNELS 9
+#define DSSI4CS_MAX_OUT_CHANNELS 9
enum PluginType {LADSPA, DSSI};
diff --git a/Opcodes/fout.c b/Opcodes/fout.c
index e65d2a8..fa0decd 100644
--- a/Opcodes/fout.c
+++ b/Opcodes/fout.c
@@ -516,7 +516,7 @@ static int ioutfile_set(CSOUND *csound, IOUTFILE *p)
}
else { /* binary format */
for (j = 0; j < p->INOCOUNT - 3; j++) {
- fwrite(args[j], sizeof(MYFLT), 1, rfil);
+ if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK;
}
}
return OK;
@@ -583,7 +583,7 @@ static int ioutfile_r(CSOUND *csound, IOUTFILE_R *p)
}
else { /* binary format */
for (j = 0; j < p->INOCOUNT - 3; j++) {
- fwrite(args[j], sizeof(MYFLT), 1, rfil);
+ if (UNLIKELY(1!=fwrite(args[j], sizeof(MYFLT), 1, rfil))) return NOTOK;
}
}
p->done = 0;
diff --git a/Opcodes/ftgen.c b/Opcodes/ftgen.c
index 21fa8cb..1062238 100644
--- a/Opcodes/ftgen.c
+++ b/Opcodes/ftgen.c
@@ -252,77 +252,78 @@ static int ftload(CSOUND *csound, FTLOAD *p)
memset(&header, 0, sizeof(FUNC));
/* IMPORTANT!! If FUNC structure and/or GEN01ARGS structure
will be modified, the following code has to be modified too */
- fgets(s, 64, file);
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4;
+ s1 = strchr(s, ' ')+1;
header.flen = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.lenmask = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.lobits = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.lomask = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.lodiv = (MYFLT)strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.cvtbas = (MYFLT)strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.cpscvt = (MYFLT)strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.loopmode1 = (int16) strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.loopmode2 = (int16) strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.begin1 = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.end1 = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.begin2 = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.end2 = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.soundend = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.flenfrms = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.nchanls = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.fno = strtol(s1, &endptr, 10);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.gen01 = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.ifilno = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.iskptim = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.iformat = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.channel = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file); s1 = strchr(s, ' ')+1;
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
header.gen01args.sample_rate = (MYFLT)strtod(s1, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
- fgets(s, 64, file);
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4; s1 = strchr(s, ' ')+1;
/* WARNING! skips header.gen01args.strarg from saving/loading
in text format */
header.fno = (int32) fno;
@@ -332,11 +333,11 @@ static int ftload(CSOUND *csound, FTLOAD *p)
memcpy(ftp, &header, sizeof(FUNC) - sizeof(MYFLT));
memset(&(ftp->ftable[0]), 0, sizeof(MYFLT) * (ftp->flen + 1));
for (j = 0; j <= ftp->flen; j++) {
- fgets(s, 64, file);
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4;
ftp->ftable[j] = (MYFLT) strtod(s, &endptr);
if (UNLIKELY(endptr==NULL)) goto err4;
}
- fgets(s, 64, file);
+ if (UNLIKELY(NULL==fgets(s, 64, file))) goto err4;
argp++;
}
}
diff --git a/Opcodes/grain4.c b/Opcodes/grain4.c
index 17cfd3c..fdea5ff 100644
--- a/Opcodes/grain4.c
+++ b/Opcodes/grain4.c
@@ -34,7 +34,7 @@
/* Minor changes by John Fitch Dec 1995 */
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include "grain4.h"
#include <math.h>
@@ -436,4 +436,3 @@ static OENTRY grain4_localops[] = {
};
LINKAGE1(grain4_localops)
-
diff --git a/Opcodes/hrtfearly.c b/Opcodes/hrtfearly.c
index 4e95070..3e71ae8 100644
--- a/Opcodes/hrtfearly.c
+++ b/Opcodes/hrtfearly.c
@@ -153,7 +153,7 @@ typedef struct
coeffs, gain for 3 band pass, same for floor and ceiling] */
MYFLT *in, *srcx, *srcy, *srcz, *lstnrx, *lstnry, *lstnrz, *ifilel, *ifiler,
*idefroom, *ofade, *osr, *porder, *othreed, *Oheadrot,
- *ormx, *ormy, *ormz, *owlh, *owll, *owlg1, *owlg2, *owlg3, *oflh,
+ *ormx, *ormy, *ormz, *owlh, *owll, *owlg1, *owlg2, *owlg3, *oflh,
*ofll, *oflg1, *oflg2, *oflg3,*oclh, *ocll, *oclg1, *oclg2, *oclg3;
/* check if relative source has changed, to avoid recalculations */
@@ -325,7 +325,7 @@ static int early_init(CSOUND *csound, early *p)
return
csound->InitError(csound,
Str("\n\n\nCannot load left data file, exiting\n\n"));
-
+
fpr = csound->ldmemfile2withCB(csound, filer, CSFTYPE_FLOATS_BINARY,
swap4bytes);
if (UNLIKELY(fpr == NULL))
@@ -355,7 +355,7 @@ static int early_init(CSOUND *csound, early *p)
/* 3 default rooms allowed*/
if(defroom > 3)
defroom = 1;
-
+
/* setup wall coeffs: walls: plasterboard, ceiling: painted plaster,
floor: carpet
if any default room is chosen, default parameters for walls/ceiling/floor */
@@ -433,7 +433,7 @@ static int early_init(CSOUND *csound, early *p)
rmy = 25;
rmz = 7;
}
-
+
/* read values if they exist, use medium if not valid (must be at
least a 2*2*2 room! */
else
@@ -474,35 +474,53 @@ static int early_init(CSOUND *csound, early *p)
/* allocate memory, reuse if possible: interpolation buffers */
if (!p->lowl1.auxp || p->lowl1.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->lowl1);
+ else
+ memset(p->lowl1.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->lowr1.auxp || p->lowr1.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->lowr1);
+ else
+ memset(p->lowr1.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->lowl2.auxp || p->lowl2.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->lowl2);
+ else
+ memset(p->lowl2.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->lowr2.auxp || p->lowr2.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->lowr2);
+ else
+ memset(p->lowr2.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->highl1.auxp || p->highl1.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highl1);
+ else
+ memset(p->highl1.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->highr1.auxp || p->highr1.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highr1);
+ else
+ memset(p->highr1.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->highl2.auxp || p->highl2.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highl2);
+ else
+ memset(p->highl2.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->highr2.auxp || p->highr2.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highr2);
+ else
+ memset(p->highr2.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->hrtflinterp.auxp || p->hrtflinterp.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->hrtflinterp);
+ else
+ memset(p->hrtflinterp.auxp, 0, irlength * sizeof(MYFLT));
+
if (!p->hrtfrinterp.auxp || p->hrtfrinterp.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->hrtfrinterp);
-
- memset(p->lowl1.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->lowr1.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->lowl2.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->lowr2.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->highl1.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->highl2.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->highr1.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->highr2.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->hrtflinterp.auxp, 0, irlength * sizeof(MYFLT));
- memset(p->hrtfrinterp.auxp, 0, irlength * sizeof(MYFLT));
+ else
+ memset(p->hrtfrinterp.auxp, 0, irlength * sizeof(MYFLT));
/* hrtf processing buffers */
if (!p->hrtflpad.auxp || p->hrtflpad.size < irlengthpad * sizeof(MYFLT))
@@ -1605,23 +1623,23 @@ static int early_process(CSOUND *csound, early *p)
band(hrtfrinterp, FL(4000.0), FL(4000.0) / p->q, p->ceilingg3, deldoubler, irlength, sr);
}
}
-
+
for(i = 0; i < irlength; i++)
{
hrtflpad[i] = hrtflinterp[i];
hrtfrpad[i] = hrtfrinterp[i];
}
-
+
for(i = irlength; i < irlengthpad; i++)
{
hrtflpad[i] = FL(0.0);
hrtfrpad[i] = FL(0.0);
}
-
+
/* back to freq domain */
csound->RealFFT(csound, hrtflpad, irlengthpad);
csound->RealFFT(csound, hrtfrpad, irlengthpad);
-
+
/* store */
for(i = 0; i < irlengthpad; i++)
{
@@ -1631,7 +1649,7 @@ static int early_process(CSOUND *csound, early *p)
}
} /* end of source / listener relative
change process */
-
+
/* look after overlap add */
for(i = 0; i < overlapsize ; i++)
{
diff --git a/Opcodes/hrtferX.c b/Opcodes/hrtferX.c
index 565f3e4..34c2ad3 100644
--- a/Opcodes/hrtferX.c
+++ b/Opcodes/hrtferX.c
@@ -51,7 +51,7 @@
***************************************************************/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <stdio.h>
#include <math.h>
@@ -499,4 +499,3 @@ static OENTRY hrtferX_localops[] = {
};
LINKAGE1(hrtferX_localops)
-
diff --git a/Opcodes/hrtfopcodes.c b/Opcodes/hrtfopcodes.c
index 3587c62..7282255 100644
--- a/Opcodes/hrtfopcodes.c
+++ b/Opcodes/hrtfopcodes.c
@@ -769,7 +769,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
lowr1[i] = fpindexr[skip+i];
}
}
-
+
skip = 0;
if(angleindex2 > elevationarray[elevindexlow] / 2)
{
@@ -797,7 +797,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
lowr2[i] = fpindexr[skip+i];
}
}
-
+
skip = 0;
if(angleindex3 > elevationarray[elevindexhigh] / 2)
{
@@ -825,7 +825,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
highr1[i] = fpindexr[skip+i];
}
}
-
+
skip = 0;
if(angleindex4 > elevationarray[elevindexhigh] / 2)
{
@@ -888,7 +888,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
logmagl[1] = LOG(magl == FL(0.0) ? FL(0.00000001) : magl);
}
else
-
+
{
if(currentphasel[1] < FL(0.0))
hrtflfloat[1] = -magl;
@@ -1037,7 +1037,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
hrtflpad[i] = FL(0.0);
hrtfrpad[i] = FL(0.0);
}
-
+
/* back to freq domain */
csound->RealFFT(csound, hrtflpad, irlengthpad);
csound->RealFFT(csound, hrtfrpad, irlengthpad);
@@ -1065,7 +1065,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
skip++;
delaylow1 = minphasedels[skip];
}
-
+
/* point 2 */
skip = 0;
if(angleindex2 > elevationarray[elevindexlow] / 2)
@@ -1086,7 +1086,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
skip++;
delaylow2 = minphasedels[skip];
}
-
+
/* point 3 */
skip = 0;
if(angleindex3 > elevationarray[elevindexhigh] / 2)
@@ -1107,7 +1107,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
skip++;
delayhigh1 = minphasedels[skip];
}
-
+
/* point 4 */
skip = 0;
if(angleindex4 > elevationarray[elevindexhigh] / 2)
@@ -1136,7 +1136,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
angleindex4per);
delayfloat = delaylow + ((delayhigh - delaylow) *
elevindexhighper);
-
+
p->delayfloat = delayfloat;
}
/* end of angle/elev change process */
@@ -1180,7 +1180,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
irlengthpad, FL(1.0));
csound->RealFFTMult(csound, outspecr, hrtfrpad, complexinsig,
irlengthpad, FL(1.0));
-
+
/* convolution is the inverse FFT of above result */
csound->InverseRealFFT(csound, outspecl, irlengthpad);
csound->InverseRealFFT(csound, outspecr, irlengthpad);
@@ -1214,7 +1214,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
outlold[i] = outspecoldl[i] / (sr / FL(38000.0));
outrold[i] = outspecoldr[i] / (sr / FL(38000.0));
}
-
+
cross++;
/* number of processing buffers in a fade */
cross = cross % fade;
@@ -1296,7 +1296,7 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
outl[i] = outvdl;
ptl = (ptl != mdtl - 1 ? ptl + 1 : 0);
}
-
+
p->ptl = ptl;
p->ptr = ptr;
}
@@ -1309,11 +1309,11 @@ static int hrtfmove_process(CSOUND *csound, hrtfmove *p)
p->cross = cross;
p->l = l;
}
-
+
} /* end of irlength == counter */
-
+
} /* end of ksmps audio loop */
-
+
/* update */
p->counter = counter;
if(phasetrunc)
@@ -1447,7 +1447,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
irlengthpad = 512;
overlapsize = (irlength - 1);
}
-
+
/* copy in string name... */
strncpy(filel, (char*) p->ifilel, MAXNAME);
strncpy(filer, (char*) p->ifiler, MAXNAME);
@@ -1459,7 +1459,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
return
csound->InitError(csound,
Str("\n\n\nCannot load left data file, exiting\n\n"));
-
+
fpr = csound->ldmemfile2withCB(csound, filer, CSFTYPE_FLOATS_BINARY,
swap4bytes);
if (UNLIKELY(fpr == NULL))
@@ -1503,7 +1503,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
csound->AuxAlloc(csound, overlapsize*sizeof(MYFLT), &p->overlapl);
if (!p->overlapr.auxp || p->overlapr.size < overlapsize * sizeof(MYFLT))
csound->AuxAlloc(csound, overlapsize*sizeof(MYFLT), &p->overlapr);
-
+
memset(p->insig.auxp, 0, irlength * sizeof(MYFLT));
memset(p->outl.auxp, 0, irlengthpad * sizeof(MYFLT));
memset(p->outr.auxp, 0, irlengthpad * sizeof(MYFLT));
@@ -1534,7 +1534,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highl2);
if (!p->highr2.auxp || p->highr2.size < irlength * sizeof(MYFLT))
csound->AuxAlloc(csound, irlength * sizeof(MYFLT), &p->highr2);
-
+
/* best to zero, for future changes (filled in init) */
memset(p->lowl1.auxp, 0, irlength * sizeof(MYFLT));
memset(p->lowr1.auxp, 0, irlength * sizeof(MYFLT));
@@ -1590,16 +1590,16 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
/* two nearest elev indices to avoid recalculating */
elevindexstore = (elev - minelev) / elevincrement;
elevindexlow = (int)elevindexstore;
-
+
if(elevindexlow < 13)
elevindexhigh = elevindexlow + 1;
/* highest index reached */
else
elevindexhigh = elevindexlow;
-
+
/* get percentage value for interpolation */
elevindexhighper = elevindexstore - elevindexlow;
-
+
/* avoid recalculation */
angleindexlowstore = angle / (FL(360.0) / elevationarray[elevindexlow]);
angleindexhighstore = angle / (FL(360.0) / elevationarray[elevindexhigh]);
@@ -1646,7 +1646,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
lowr1[i] = fpindexr[skip + i];
}
}
-
+
skip = 0;
if(angleindex2 > elevationarray[elevindexlow] / 2)
{
@@ -1672,7 +1672,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
lowr2[i] = fpindexr[skip + i];
}
}
-
+
skip = 0;
if(angleindex3 > elevationarray[elevindexhigh] / 2)
{
@@ -1796,7 +1796,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
if((i / 2) < 6)
itd = itdww * nonlinitd[(i / 2) - 1];
}
-
+
if(angle > FL(180.))
{
phasel = TWOPI_F * freq * (itd / 2);
@@ -1807,7 +1807,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
phasel = TWOPI_F * freq * -(itd / 2);
phaser = TWOPI_F * freq * (itd / 2);
}
-
+
/* polar to rectangular */
hrtflfloat[i] = magl * COS(phasel);
hrtflfloat[i+1] = magl * SIN(phasel);
@@ -1848,7 +1848,7 @@ static int hrtfstat_init(CSOUND *csound, hrtfstat *p)
hrtflpad[i] = FL(0.0);
hrtfrpad[i] = FL(0.0);
}
-
+
/* back to freq domain */
csound->RealFFT(csound, hrtflpad, irlengthpad);
csound->RealFFT(csound, hrtfrpad, irlengthpad);
@@ -1919,9 +1919,9 @@ static int hrtfstat_process(CSOUND *csound, hrtfstat *p)
for (i = irlength; i < irlengthpad; i++)
complexinsig[i] = FL(0.0);
-
+
csound->RealFFT(csound, complexinsig, irlengthpad);
-
+
/* complex multiplication */
csound->RealFFTMult(csound, outspecl, hrtflpad, complexinsig,
irlengthpad, FL(1.0));
@@ -2062,21 +2062,21 @@ static int hrtfmove2_init(CSOUND *csound, hrtfmove2 *p)
strncpy(filel, (char*) p->ifilel, MAXNAME);
strncpy(filer, (char*) p->ifiler, MAXNAME);
- /* reading files, with byte swap */
+ /* reading files, with byte swap */
fpl = csound->ldmemfile2withCB(csound, filel, CSFTYPE_FLOATS_BINARY,
swap4bytes);
if (UNLIKELY(fpl == NULL))
return
csound->InitError(csound,
Str("\n\n\nCannot load left data file, exiting\n\n"));
-
+
fpr = csound->ldmemfile2withCB(csound, filer, CSFTYPE_FLOATS_BINARY,
swap4bytes);
if (UNLIKELY(fpr == NULL))
return
csound->InitError(csound,
Str("\n\n\nCannot load right data file, exiting\n\n"));
-
+
p->irlength = irlength;
p->sroverN = sr / irlength;
@@ -2091,7 +2091,7 @@ static int hrtfmove2_init(CSOUND *csound, hrtfmove2 *p)
if(r <= 0 || r > 15)
r = FL(8.8);
p->radius = r;
-
+
p->hopsize = (int)(irlength / overlap);
/* buffers */
@@ -2277,7 +2277,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
win[overlapskipin[i]];
overlapskipin[i]++;
}
-
+
counter++;
if(counter == hopsize)
@@ -2287,12 +2287,12 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
elev = FL(90.0);
if(elev < FL(-40.0))
elev = FL(-40.0);
-
+
while(angle < FL(0.0))
angle += FL(360.0);
while(angle >= FL(360.0))
angle -= FL(360.0);
-
+
if(angle != p->anglev || elev != p->elevv)
{
/* two nearest elev indices to avoid recalculating */
@@ -2304,16 +2304,16 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
/* highest index reached */
else
elevindexhigh = elevindexlow;
-
+
/* get percentage value for interpolation */
elevindexhighper = elevindexstore - elevindexlow;
-
+
/* avoid recalculation */
angleindexlowstore = angle / (FL(360.0) /
elevationarray[elevindexlow]);
angleindexhighstore = angle / (FL(360.0) /
elevationarray[elevindexhigh]);
-
+
/* 4 closest indices, 2 low and 2 high */
angleindex1 = (int)angleindexlowstore;
@@ -2414,7 +2414,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
highr1[i] = fpindexr[skip + i];
}
}
-
+
skip = 0;
if(angleindex4 > elevationarray[elevindexhigh] / 2)
{
@@ -2450,7 +2450,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
else
radianangle = angle * PI_F / FL(180.0); /* degrees to radians */
radianelev = elev * PI_F / FL(180.0);
-
+
/* get in correct range for formula */
if(radianangle > (PI_F / FL(2.0)))
radianangle = FL(PI) - radianangle;
@@ -2467,13 +2467,13 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
maglhigh = FABS(highl1[0]) + (FABS(highl2[0]) - FABS(highl1[0])) *
angleindex4per;
hrtflfloat[0] = magllow + (maglhigh - magllow) * elevindexhighper;
-
+
magllow = FABS(lowl1[1]) + (FABS(lowl2[1]) - FABS(lowl1[1])) *
angleindex2per;
maglhigh = FABS(highl1[1]) + (FABS(highl2[1]) - FABS(highl1[1])) *
angleindex4per;
hrtflfloat[1] = magllow + (maglhigh - magllow) * elevindexhighper;
-
+
magrlow = FABS(lowr1[0]) + (FABS(lowr2[0]) - FABS(lowr1[0])) *
angleindex2per;
magrhigh = FABS(highr1[0]) + (FABS(highr2[0]) - FABS(highr1[0])) *
@@ -2492,16 +2492,16 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
/* interpolate high and low mags */
magllow = lowl1[i] + (lowl2[i] - lowl1[i]) * angleindex2per;
maglhigh = highl1[i] + (highl2[i] - highl1[i]) * angleindex4per;
-
+
magrlow = lowr1[i] + (lowr2[i] - lowr1[i]) * angleindex2per;
magrhigh = highr1[i] + (highr2[i] - highr1[i]) * angleindex4per;
-
+
/* interpolate high and low results */
magl = magllow + (maglhigh - magllow) * elevindexhighper;
magr = magrlow + (magrhigh - magrlow) * elevindexhighper;
-
+
freq = (i / 2) * sroverN;
-
+
/* non linear itd...last value in array = 1.0, so back to itdww */
if(p->sr == 96000)
{
@@ -2518,7 +2518,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
if((i / 2) < 6)
itd = itdww * nonlinitd[(i / 2) - 1];
}
-
+
if(angle > FL(180.))
{
phasel = TWOPI_F * freq * (itd / 2);
@@ -2528,38 +2528,38 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
phasel = TWOPI_F * freq * -(itd / 2);
phaser = TWOPI_F * freq * (itd / 2);
}
-
+
/* polar to rectangular */
hrtflfloat[i] = magl * COS(phasel);
hrtflfloat[i+1] = magl * SIN(phasel);
-
+
hrtfrfloat[i] = magr * COS(phaser);
hrtfrfloat[i+1] = magr * SIN(phaser);
}
-
+
p->elevv = elev;
p->anglev = angle;
}
-
+
/* t used to read inbuf...*/
t--;
if(t < 0)
t = overlap - 1;
-
+
/* insert insig for complex real, im fft */
for(i = 0; i < irlength; i++)
complexinsig[i] = inbuf[(t * irlength) + i];
-
+
/* zero the current input sigframe time pointer */
overlapskipin[t] = 0;
-
+
csound->RealFFT(csound, complexinsig, irlength);
-
+
csound->RealFFTMult(csound, outspecl, hrtflfloat,
complexinsig, irlength, FL(1.0));
csound->RealFFTMult(csound, outspecr, hrtfrfloat,
complexinsig, irlength, FL(1.0));
-
+
/* convolution is the inverse FFT of above result */
csound->InverseRealFFT(csound, outspecl, irlength);
csound->InverseRealFFT(csound, outspecr, irlength);
@@ -2572,7 +2572,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
outbufr[(t * irlength) + i] = outspecr[i] /
(overlap * FL(0.5) * (sr / FL(44100.0)));
}
-
+
} /* end of !counter % hopsize */
/* output = sum of all relevant outputs: eg if overlap = 4 and
@@ -2607,7 +2607,7 @@ static int hrtfmove2_process(CSOUND *csound, hrtfmove2 *p)
outsigl[j] = outsuml;
outsigr[j] = outsumr;
-
+
} /* end of ksmps audio loop */
/* update */
diff --git a/Opcodes/hrtfreverb.c b/Opcodes/hrtfreverb.c
index ff57680..92722ab 100644
--- a/Opcodes/hrtfreverb.c
+++ b/Opcodes/hrtfreverb.c
@@ -411,7 +411,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
Mtwelve = abs((int)(delaytime / 12) - meanfpsamps);
Mtwentyfour = abs((int)(delaytime / 24) - meanfpsamps);
M = Mtwelve < Mtwentyfour ? (Msix < Mtwelve ? 6 : 12) : 24;
-
+
csound->Message(csound, "%d \n", M);
delaytime /= M;
@@ -442,7 +442,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
if(delaytimeint < 410)
delaytimeint = 410;
}
-
+
/* allocate memory based on M: number of delays */
if (!p->delays.auxp || p->delays.size < M * sizeof(int))
csound->AuxAlloc(csound, M * sizeof(int), &p->delays);
@@ -476,7 +476,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
test = (i > 15 ? i : 15) - 15;
else
test = (i > 16 ? i : 16) - 16;
-
+
if(primes[i] > delaytimeint || primes[test] > meanfpordersamps)
{
basedelay = i - 1;
@@ -592,7 +592,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
csound->AuxAlloc(csound, delaysp[22] * sizeof(MYFLT), &p->del11tf);
if (!p->del12tf.auxp || p->del12tf.size < delaysp[23] * sizeof(MYFLT))
csound->AuxAlloc(csound, delaysp[23] * sizeof(MYFLT), &p->del12tf);
-
+
memset(p->del1tf.auxp, 0, delaysp[12] * sizeof(MYFLT));
memset(p->del2tf.auxp, 0, delaysp[13] * sizeof(MYFLT));
memset(p->del3tf.auxp, 0, delaysp[14] * sizeof(MYFLT));
@@ -649,7 +649,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
powerp[0] = powerp[0] + SQUARE(bufflp[0]) + SQUARE(buffrp[0]);
powerp[1] = powerp[1] + SQUARE(bufflp[1]) + SQUARE(buffrp[1]);
}
-
+
for(j = 2; j < irlength; j += 2)
{
if(skipdouble)
@@ -664,7 +664,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
for(i = 0; i < irlength; i++)
HRTFavep[i] = SQRT(powerp[i] / FL(710.0));
-
+
fpindexl = (float *)fpl->beginp;
fpindexr = (float *)fpr->beginp;
skip = 0;
@@ -687,7 +687,7 @@ int hrtfreverb_init(CSOUND *csound, hrtfreverb *p)
bufflp[j] = fpindexl[skip + j];
buffrp[j] = fpindexr[skip + j];
}
-
+
/* back to rectangular to find numerator: need complex nos */
/* 0Hz and Nyq ok as real */
if(skipdouble)
@@ -955,7 +955,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
inmatlpp = (MYFLT *)p->inmatlp.auxp;
dellpp = (MYFLT *)p->dellp.auxp;
outmatp = (MYFLT *)p->outmat.auxp;
-
+
gip = (MYFLT *)p->gi.auxp;
aip = (MYFLT *)p->ai.auxp;
@@ -1067,7 +1067,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
gi ( 1 - ai / 1 - ai pow(z,-1)
op = gi - gi ai x(n) + ai del
del = op */
-
+
for(j = 0; j < M; j++)
{
inmatlpp[j] = (gip[j] * (1 - aip[j]) * inmatp[j]) +
@@ -1124,14 +1124,14 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
del11tfp[ytf2] = outmatp[22] + sigin;
del12tfp[ztf2] = outmatp[23] + sigin;
}
-
+
u = (u != delaysp[0] - 1 ? u + 1 : 0);
v = (v != delaysp[1] - 1 ? v + 1 : 0);
w = (w != delaysp[2] - 1 ? w + 1 : 0);
x = (x != delaysp[3] - 1 ? x + 1 : 0);
y = (y != delaysp[4] - 1 ? y + 1 : 0);
z = (z != delaysp[5] - 1 ? z + 1 : 0);
-
+
if(M == 12 || M == 24)
{
ut = (ut != delaysp[6] - 1 ? ut + 1 : 0);
@@ -1160,7 +1160,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
/* output, increment counter */
// outl[i] = hrtflp[counter];
// outr[i] = hrtfrp[counter];
-
+
outl[i] = hrtflp[counter] * (csound->e0dbfs / FL(32767.0));
outr[i] = hrtfrp[counter] * (csound->e0dbfs / FL(32767.0));
@@ -1236,7 +1236,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
hrtflp[j] = hrtflp[j]/(sr / FL(38000.0));
hrtfrp[j] = hrtfrp[j]/(sr / FL(38000.0));
}
-
+
for(j = 0; j < irlength; j++)
{
hrtflp[j] = hrtflp[j] + (j < overlapsize ?
@@ -1255,7 +1255,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
counter = 0;
} /* end of irlength loop */
} /* end of ksmps loop */
-
+
/* keep for next time */
p->counter = counter;
@@ -1289,7 +1289,7 @@ int hrtfreverb_process(CSOUND *csound, hrtfreverb *p)
p->ytf2 = ytf2;
p->ztf2 = ztf2;
}
-
+
p->inoldl = inoldl;
p->inoldr = inoldr;
diff --git a/Opcodes/imageOpcodes.c b/Opcodes/imageOpcodes.c
index 6e62156..7883215 100644
--- a/Opcodes/imageOpcodes.c
+++ b/Opcodes/imageOpcodes.c
@@ -103,7 +103,10 @@ static Image * __doOpenImage(char * filename, CSOUND *csound)
return NULL;
}
- fread(header, 1, hs, fp);
+ if (UNLIKELY(hs!=fread(header, 1, hs, fp)))
+ csound->InitError(csound,
+ Str("imageload: file %s is not in PNG format.\n"),
+ filename);
is_png = !png_sig_cmp(header, 0, hs);
if (UNLIKELY(!is_png)) {
diff --git a/Opcodes/jacko.cpp b/Opcodes/jacko.cpp
index 486663b..e9ae692 100644
--- a/Opcodes/jacko.cpp
+++ b/Opcodes/jacko.cpp
@@ -521,7 +521,7 @@ struct JackoState
result = pthread_mutex_init(&conditionMutex, 0);
result = pthread_cond_init(&csoundCondition, 0);
result = pthread_cond_init(&closeCondition, 0);
- // Create a thread to run the close routine. It will immediately
+ // Create a thread to run the close routine. It will immediately
// block until it is signaled.
result = pthread_create(&closeThread, 0, &JackoState::closeRoutine_, this);
std::memset(&jack_position, 0, sizeof(jack_position_t));
@@ -703,8 +703,8 @@ struct JackoState
// thread. Doing this inside the Jack process callback
// takes too long and may cause other problems.
result = pthread_mutex_lock(&conditionMutex);
- result = pthread_cond_signal(&closeCondition);
- result = pthread_mutex_unlock(&conditionMutex);
+ result |= pthread_cond_signal(&closeCondition);
+ result |= pthread_mutex_unlock(&conditionMutex);
return result;
}
}
@@ -713,15 +713,17 @@ struct JackoState
int result = 0;
// Wait until signaled to actually shut down the Jack client.
result = pthread_mutex_lock(&conditionMutex);
- result = pthread_cond_wait(&closeCondition, &conditionMutex);
- result = pthread_mutex_unlock(&conditionMutex);
+ result |= pthread_cond_wait(&closeCondition, &conditionMutex);
+ result |= pthread_mutex_unlock(&conditionMutex);
close();
- return (void *) result;
+ void *result_ = 0;
+ memcpy(&result_, &result, std::min(sizeof(result), sizeof(result_)));
+ return result_;
}
static void *closeRoutine_(void *userdata)
{
return ((JackoState *)userdata)->closeRoutine();
- }
+ }\
void startTransport()
{
midiInputQueue.clear();
diff --git a/Opcodes/loscilx.c b/Opcodes/loscilx.c
index 187aca1..5f464ce 100644
--- a/Opcodes/loscilx.c
+++ b/Opcodes/loscilx.c
@@ -22,7 +22,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include "soundio.h"
@@ -677,4 +677,3 @@ static OENTRY loscilx_localops[] = {
};
LINKAGE1(loscilx_localops)
-
diff --git a/Opcodes/minmax.c b/Opcodes/minmax.c
index b7e5b18..f96c76a 100644
--- a/Opcodes/minmax.c
+++ b/Opcodes/minmax.c
@@ -31,7 +31,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <math.h>
@@ -313,4 +313,3 @@ static OENTRY minmax_localops[] = {
};
LINKAGE1(minmax_localops)
-
diff --git a/Opcodes/nlfilt.c b/Opcodes/nlfilt.c
index 2129605..15daef1 100644
--- a/Opcodes/nlfilt.c
+++ b/Opcodes/nlfilt.c
@@ -54,7 +54,7 @@ static int nlfiltset(CSOUND *csound, NLFILT *p)
p->delay.size<MAX_DELAY * sizeof(MYFLT)) { /* get newspace */
csound->AuxAlloc(csound, MAX_DELAY * sizeof(MYFLT), &p->delay);
}
- else{
+ else {
memset(p->delay.auxp, 0, MAX_DELAY * sizeof(MYFLT));
}
p->point = 0;
diff --git a/Opcodes/pan2.c b/Opcodes/pan2.c
index e8d37f3..7664626 100644
--- a/Opcodes/pan2.c
+++ b/Opcodes/pan2.c
@@ -22,7 +22,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <math.h>
@@ -102,6 +102,3 @@ static OENTRY pan2_localops[] =
};
LINKAGE1(pan2_localops)
-
-
-
diff --git a/Opcodes/partikkel.c b/Opcodes/partikkel.c
index bf487a4..e7449bd 100644
--- a/Opcodes/partikkel.c
+++ b/Opcodes/partikkel.c
@@ -301,7 +301,8 @@ static int partikkel_init(CSOUND *csound, PARTIKKEL *p)
size = csound->ksmps*sizeof(MYFLT);
if (p->aux.auxp == NULL || p->aux.size < size)
csound->AuxAlloc(csound, size, &p->aux);
- memset(p->aux.auxp, 0, sizeof(MYFLT)*csound->ksmps);
+ else
+ memset(p->aux.auxp, 0, size);
/* allocate memory for the grain pool and initialize it*/
if (UNLIKELY(*p->max_grains < FL(1.0)))
diff --git a/Opcodes/phisem.c b/Opcodes/phisem.c
index 3073658..2d7573e 100644
--- a/Opcodes/phisem.c
+++ b/Opcodes/phisem.c
@@ -46,7 +46,7 @@
/**********************************************************/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include "phisem.h"
#include <math.h>
@@ -1249,4 +1249,3 @@ static OENTRY phisem_localops[] = {
};
LINKAGE1(phisem_localops)
-
diff --git a/Opcodes/pitch.c b/Opcodes/pitch.c
index 2778754..e1d296d 100644
--- a/Opcodes/pitch.c
+++ b/Opcodes/pitch.c
@@ -1806,7 +1806,7 @@ int trnsetr(CSOUND *csound, TRANSEG *p)
double dur = (double)**argp++;
MYFLT alpha = **argp++;
MYFLT nxtval = **argp++;
- MYFLT d = dur * csound->ekr;
+ MYFLT d = dur * csound->esr;
if ((segp->cnt = (int32)(d + FL(0.5))) < 0)
segp->cnt = 0;
else
@@ -1892,7 +1892,7 @@ int trnsegr(CSOUND *csound, TRANSEG *p)
return csound->PerfError(csound, Str("transeg: not initialised (arate)\n"));
}
val = p->curval; /* sav the cur value */
- if (LIKELY(p->segsrem)) { /* if no more segs putk */
+ if (LIKELY(p->segsrem)) { /* if no more segs putk */
NSEG *segp;
if (p->h.insdshead->relesing && p->segsrem > 1) {
while (p->segsrem > 1) { /* if release flag new */
diff --git a/Opcodes/pitch0.c b/Opcodes/pitch0.c
index 817f9e3..d196110 100644
--- a/Opcodes/pitch0.c
+++ b/Opcodes/pitch0.c
@@ -46,16 +46,27 @@ int mute_inst(CSOUND *csound, MUTE *p)
int instcount(CSOUND *csound, INSTCNT *p)
{
- int n = (int) csound->strarg2insno(csound, p->ins, p->XSTRCODE);
+ int n;
+ if (p->XSTRCODE)
+ n = (int) csound->strarg2insno(csound, p->ins, p->XSTRCODE);
+ else
+ n = *p->ins;
if (n<0 || n > csound->maxinsno || csound->instrtxtp[n] == NULL)
*p->cnt = FL(0.0);
+ else if (n==0) { /* Count all instruments */
+ int tot = 1;
+ for (n=1; n<csound->maxinsno; n++)
+ if (csound->instrtxtp[n]) /* If it exists */
+ tot += ((*p->opt) ? csound->instrtxtp[n]->instcnt :
+ csound->instrtxtp[n]->active);
+ *p->cnt = (MYFLT)tot;
+ }
else {
*p->cnt = ((*p->opt) ?
(MYFLT) csound->instrtxtp[n]->instcnt :
(MYFLT) csound->instrtxtp[n]->active);
}
-
return OK;
}
diff --git a/Opcodes/pitchtrack.c b/Opcodes/pitchtrack.c
index 8a072ae..e8452dc 100644
--- a/Opcodes/pitchtrack.c
+++ b/Opcodes/pitchtrack.c
@@ -471,14 +471,16 @@ int pitchafset(CSOUND *csound, PITCHAF *p){
int siz = (int)(csound->GetSr(csound)/ (*p->iflow));
if (p->buff1.auxp == NULL || p->buff1.size < siz*sizeof(MYFLT))
csound->AuxAlloc(csound, siz*sizeof(MYFLT), &p->buff1);
+ else
+ memset(p->buff1.auxp, 0, p->buff1.size);
if (p->buff2.auxp == NULL ||p-> buff2.size < siz*sizeof(MYFLT))
csound->AuxAlloc(csound, siz*sizeof(MYFLT), &p->buff2);
+ else
+ memset(p->buff2.auxp, 0, p->buff2.size);
if (p->cor.auxp == NULL || p->cor.size < siz*sizeof(MYFLT))
csound->AuxAlloc(csound, siz*sizeof(MYFLT), &p->cor);
-
- memset(p->buff1.auxp, 0, p->buff1.size);
- memset(p->buff2.auxp, 0, p->buff2.size);
- memset(p->cor.auxp, 0, p->cor.size);
+ else
+ memset(p->cor.auxp, 0, p->cor.size);
p->lag = 0;
p->pitch = FL(0.0);
p->len = siz;
diff --git a/Opcodes/psynth.c b/Opcodes/psynth.c
index b586fac..ece3738 100644
--- a/Opcodes/psynth.c
+++ b/Opcodes/psynth.c
@@ -222,7 +222,7 @@ static int psynth_process(CSOUND *csound, _PSYN *p)
}
/* keep amp, freq, and phase values for next time */
if (contin) {
-
+
amps[k] = ampnext;
freqs[k] = freqnext;
phases[k] = phase;
@@ -395,7 +395,7 @@ static int psynth2_process(CSOUND *csound, _PSYN2 *p)
}
/* keep amp, freq, and phase values for next time */
if (contin) {
-
+
amps[k] = ampnext;
freqs[k] = freqnext;
phases[k] = phasenext;
@@ -1239,4 +1239,3 @@ int psynth_init_(CSOUND *csound)
return csound->AppendOpcodes(csound, &(localops[0]),
(int) (sizeof(localops) / sizeof(OENTRY)));
}
-
diff --git a/Opcodes/pvlock.c b/Opcodes/pvlock.c
index 7c3fe82..7b190d9 100644
--- a/Opcodes/pvlock.c
+++ b/Opcodes/pvlock.c
@@ -70,13 +70,15 @@ static int sinit(CSOUND *csound, DATASPACE *p)
size = decim*sizeof(int);
if (p->framecount[i].auxp == NULL || p->framecount[i].size < size)
csound->AuxAlloc(csound, size, &p->framecount[i]);
- memset(p->framecount[i].auxp,0,size);
+ else
+ memset(p->framecount[i].auxp,0,size);
size = decim*sizeof(MYFLT)*N;
if (p->outframe[i].auxp == NULL || p->outframe[i].size < size)
csound->AuxAlloc(csound, size, &p->outframe[i]);
- memset(p->outframe[i].auxp,0,size);
+ else
+ memset(p->outframe[i].auxp,0,size);
}
- size = N*sizeof(MYFLT);
+ size = N*sizeof(MYFLT);
if (p->win.auxp == NULL || p->win.size < size)
csound->AuxAlloc(csound, size, &p->win);
@@ -113,13 +115,13 @@ static int sprocess(CSOUND *csound, DATASPACE *p)
ft = csound->FTnp2Find(csound,p->knum);
tab = ft->ftable;
size = ft->flen;
-
+
if (UNLIKELY((int) ft->nchanls != nchans))
return csound->PerfError(csound, Str("number of output arguments "
"inconsistent with number of "
"sound file channels"));
-
+
/* spos is the reading position in samples, hsize is hopsize,
time[n] is current read position in secs
@@ -235,14 +237,14 @@ static int sprocess(CSOUND *csound, DATASPACE *p)
framecnt[curframe] = curframe*N;
/* write to overlapped output frames */
for (i=0;i<N;i++) outframe[framecnt[curframe]+i] = win[i]*fwin[i];
-
+
}
cnt=0;
curframe++;
if (curframe == decim) curframe = 0;
}
-
+
for (j=0; j < nchans; j++) {
framecnt = (int *) p->framecount[j].auxp;
outframe = (MYFLT *) p->outframe[j].auxp;
@@ -258,7 +260,7 @@ static int sprocess(CSOUND *csound, DATASPACE *p)
}
cnt++;
}
-
+
p->cnt = cnt;
p->curframe = curframe;
return OK;
@@ -298,7 +300,7 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
int decim = p->decim;
for (n=0; n < ksmps; n++) {
-
+
if (cnt == hsize){
ft = csound->FTnp2Find(csound,p->knum);
tab = ft->ftable;
@@ -334,7 +336,7 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
prev = (MYFLT *)p->prev[j].auxp;
framecnt = (int *)p->framecount[j].auxp;
outframe= (MYFLT *) p->outframe[j].auxp;
-
+
for (i=0; i < N; i++) {
post = (int) pos;
frac = pos - post;
@@ -343,15 +345,15 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
if (post >= 0 && post < size)
in = tab[post] + frac*(tab[post+nchans] - tab[post]);
else in = (MYFLT) 0;
- fwin[i] = in * win[i];
-
+ fwin[i] = in * win[i];
+
post = (int) (pos - hsize*pitch);
post *= nchans;
post += j;
if (post >= 0 && post < size)
in = tab[post] + frac*(tab[post+nchans] - tab[post]);
else in = (MYFLT) 0;
- bwin[i] = in * win[i];
+ bwin[i] = in * win[i];
post = (int) pos + hsize;
post *= nchans;
post += j;
@@ -360,7 +362,7 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
nwin[i] = in * win[i];
pos += pitch;
}
-
+
csound->RealFFT(csound, bwin, N);
bwin[N] = bwin[1];
bwin[N+1] = FL(0.0);
@@ -421,7 +423,7 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
tmp_real = fwin[i] * ph_real - fwin[i+1] * ph_im;
tmp_im = fwin[i] * ph_im + fwin[i+1] * ph_real;
-
+
prev[i] = fwin[i] = tmp_real;
prev[i+1] = fwin[i+1] = tmp_im;
}
@@ -432,27 +434,27 @@ static int sprocess2(CSOUND *csound, DATASPACE *p)
framecnt[curframe] = curframe*N;
for (i=0;i<N;i++) outframe[framecnt[curframe]+i] = win[i]*fwin[i];
-
+
}
cnt=0;
curframe++;
if (curframe == decim) curframe = 0;
}
-
+
for (j=0; j < nchans; j++) {
out = p->out[j];
framecnt = (int *) p->framecount[j].auxp;
outframe = (MYFLT *) p->outframe[j].auxp;
-
+
out[n] = (MYFLT) 0;
-
+
for (i = 0; i < decim; i++) {
out[n] += outframe[framecnt[i]];
- framecnt[i]++;
+ framecnt[i]++;
}
out[n] *= amp*(2./3.);
}
- cnt++;
+ cnt++;
}
p->cnt = cnt;
p->curframe = curframe;
@@ -497,13 +499,13 @@ static int pvslockset(CSOUND *csound, PVSLOCK *p)
static int pvslockproc(CSOUND *csound, PVSLOCK *p)
{
int i;
- float *fout = (float *) p->fout->frame.auxp,
+ float *fout = (float *) p->fout->frame.auxp,
*fin = (float *) p->fin->frame.auxp;
int N = p->fin->N;
-
+
if (p->lastframe < p->fin->framecount) {
memcpy(fout,fin, sizeof(float)*(N+2));
-
+
if (*p->klock) {
for (i=2; i < N-4; i+=2){
float p2 = fin[i];
@@ -511,7 +513,7 @@ static int pvslockproc(CSOUND *csound, PVSLOCK *p)
float p1 = fin[i-2];
float p4 = fin[i+4];
float p5 = fin[i+6];
- if (p3 > p1 && p3 > p2 && p3 > p4 && p3 > p5) {
+ if (p3 > p1 && p3 > p2 && p3 > p4 && p3 > p5) {
float freq = fin[i+3], d;
d = 0.01*freq;
if (FABS(fout[i-1] - freq) < d)fout[i-1] = freq;
diff --git a/Opcodes/pvoc.c b/Opcodes/pvoc.c
index 2635ecb..f5e6147 100644
--- a/Opcodes/pvoc.c
+++ b/Opcodes/pvoc.c
@@ -36,7 +36,7 @@ int pvinterpset(CSOUND *, void *), pvinterp(CSOUND *, void *);
static OENTRY pvoc_localops[] = {
{ "pvoc", S(PVOC), 5, "a", "kkToooo", pvset, NULL, pvoc },
{ "tableseg", S(TABLESEG), TR|3, "", "iin", tblesegset, ktableseg, NULL },
-{ "ktableseg", S(TABLESEG), DP|TR|3, "", "iin", tblesegset, ktableseg, NULL },
+{ "ktableseg", S(TABLESEG), _QQ|TR|3, "", "iin", tblesegset, ktableseg, NULL },
{ "tablexseg", S(TABLESEG), TW|3, "", "iin", tblesegset, ktablexseg, NULL },
{ "vpvoc", S(VPVOC), TR|5, "a", "kkToo", vpvset, NULL, vpvoc },
{ "pvread", S(PVREAD), 3, "kk", "kTi", pvreadset, pvread, NULL },
diff --git a/Opcodes/pvoc.h b/Opcodes/pvoc.h
index c3deebe..ba3f21b 100644
--- a/Opcodes/pvoc.h
+++ b/Opcodes/pvoc.h
@@ -23,8 +23,8 @@
#define CSOUND_PVOC_H
// #include "csdl.h"
-#include "csoundCore.h"
-#include "interlocks.h"
+#include "csoundCore.h"
+#include "interlocks.h"
typedef struct PVOC_GLOBALS_ PVOC_GLOBALS;
@@ -56,4 +56,3 @@ static inline PVOC_GLOBALS *PVOC_GetGlobals(CSOUND *csound)
}
#endif /* CSOUND_PVOC_H */
-
diff --git a/Opcodes/pvsbasic.c b/Opcodes/pvsbasic.c
index 247da60..91d4527 100644
--- a/Opcodes/pvsbasic.c
+++ b/Opcodes/pvsbasic.c
@@ -105,7 +105,7 @@ static int pvsgain(CSOUND *csound, PVSGAIN *p)
p->fout->framecount = p->fa->framecount;
p->lastframe = p->fout->framecount;
}
- return OK;
+ return OK;
}
@@ -148,7 +148,7 @@ static int pvsinit(CSOUND *csound, PVSINI *p)
}
bframe = (float *) p->fout->frame.auxp;
for (i = 0; i < N + 2; i += 2) {
- bframe[i] = 0.0f;
+ //bframe[i] = 0.0f;
bframe[i + 1] = (i >>1) * N * csound->onedsr;
}
}
@@ -388,26 +388,29 @@ int pvstanalset(CSOUND *csound, PVST *p)
if (p->fout[i]->frame.auxp == NULL ||
p->fout[i]->frame.size < sizeof(float) * (N + 2))
csound->AuxAlloc(csound, (N + 2) * sizeof(float), &p->fout[i]->frame);
+ else
+ memset(p->fout[i]->frame.auxp, 0, sizeof(float)*(N+2));
if (p->bwin[i].auxp == NULL ||
p->bwin[i].size < sizeof(MYFLT) * (N + 2))
csound->AuxAlloc(csound, (N + 2) * sizeof(MYFLT), &p->bwin[i]);
+ else
+ memset(p->bwin[i].auxp, 0, p->bwin[i].size);
if (p->fwin[i].auxp == NULL ||
p->fwin[i].size < sizeof(MYFLT) * (N + 2))
csound->AuxAlloc(csound, (N + 2) * sizeof(MYFLT), &p->fwin[i]);
+ else
+ memset(p->fwin[i].auxp, 0, sizeof(MYFLT)*(N+2));
if (p->nwin[i].auxp == NULL ||
p->nwin[i].size < sizeof(MYFLT) * (N + 2))
csound->AuxAlloc(csound, (N + 2) * sizeof(MYFLT), &p->nwin[i]);
- memset(p->fwin[i].auxp, 0, sizeof(MYFLT)*(N+2));
- memset(p->bwin[i].auxp, 0, sizeof(MYFLT)*(N+2));
- memset(p->nwin[i].auxp, 0, sizeof(MYFLT)*(N+2));
- memset(p->fout[i]->frame.auxp, 0, sizeof(float)*(N+2));
-
+ else
+ memset(p->nwin[i].auxp, 0, sizeof(MYFLT)*(N+2));
}
if (p->win.auxp == NULL ||
p->win.size < sizeof(MYFLT) * (N))
csound->AuxAlloc(csound, (N) * sizeof(MYFLT), &p->win);
- p->scale = 0.f;
+ p->scale = 0.0f;
for (i=0; i < N; i++)
p->scale += (((MYFLT *)p->win.auxp)[i] = 0.5 - 0.5*cos(i*2*PI/N));
for (i=0; i < N; i++)
@@ -701,7 +704,7 @@ static int pvsoscset(CSOUND *csound, PVSOSC *p)
csound->AuxAlloc(csound, (N + 2) * sizeof(float), &p->fout->frame);
bframe = (float *) p->fout->frame.auxp;
for (i = 0; i < N + 2; i += 2) {
- bframe[i] = 0.0f;
+ //bframe[i] = 0.0f;
bframe[i + 1] = (i / 2) * N * csound->onedsr;
}
p->lastframe = 1;
@@ -1419,11 +1422,13 @@ static int pvsshiftset(CSOUND *csound, PVSSHIFT *p)
if (p->ceps.auxp == NULL ||
p->ceps.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->ceps);
- memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
if (p->fenv.auxp == NULL ||
p->fenv.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fenv);
- memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
return OK;
}
@@ -1607,11 +1612,13 @@ static int pvswarpset(CSOUND *csound, PVSWARP *p)
if (p->ceps.auxp == NULL ||
p->ceps.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->ceps);
- memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
if (p->fenv.auxp == NULL ||
p->fenv.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fenv);
- memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
return OK;
}
@@ -2037,11 +2044,13 @@ static int pvsenvwset(CSOUND *csound, PVSENVW *p)
if (p->ceps.auxp == NULL ||
p->ceps.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->ceps);
- memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
if (p->fenv.auxp == NULL ||
p->fenv.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fenv);
- memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
+ else
+ memset(p->fenv.auxp, 0, sizeof(MYFLT)*(N+2));
return OK;
}
@@ -2135,7 +2144,7 @@ static int pvsenvw(CSOUND *csound, PVSENVW *p)
}
-typedef struct pvs2tab_t {
+typedef struct pvs2tab_t {
OPDS h;
MYFLT *framecount;
TABDAT *ans;
@@ -2153,16 +2162,16 @@ int pvs2tab_init(CSOUND *csound, PVS2TAB_T *p)
}
int pvs2tab(CSOUND *csound, PVS2TAB_T *p){
-
+
int size = p->ans->size, N = p->fsig->N, i;
float *fsig = (float *) p->fsig->frame.auxp;
for(i = 0; i < size && i < N+2; i++)
- p->ans->data[i] = (MYFLT) fsig[i];
+ p->ans->data[i] = (MYFLT) fsig[i];
*p->framecount = (MYFLT) p->fsig->framecount;
- return OK;
+ return OK;
}
-typedef struct tab2pvs_t {
+typedef struct tab2pvs_t {
OPDS h;
PVSDAT *fout;
TABDAT *in;
@@ -2185,8 +2194,8 @@ int tab2pvs_init(CSOUND *csound, TAB2PVS_T *p)
p->fout->frame.size < sizeof(float) * (N + 2)) {
csound->AuxAlloc(csound, (N + 2) * sizeof(float), &p->fout->frame);
}
-
- memset(p->fout->frame.auxp, 0, sizeof(float)*(N+2));
+ else
+ memset(p->fout->frame.auxp, 0, sizeof(float)*(N+2));
return OK;
}
else return csound->InitError(csound, Str("t-variable not initialised"));
@@ -2196,11 +2205,11 @@ int tab2pvs(CSOUND *csound, TAB2PVS_T *p)
{
int size = p->in->size, i;
float *fout = (float *) p->fout->frame.auxp;
-
+
if (p->lastframe < p->fout->framecount){
for (i = 0; i < size; i++){
- fout[i] = (float) p->in->data[i];
- }
+ fout[i] = (float) p->in->data[i];
+ }
p->lastframe = p->fout->framecount;
}
return OK;
@@ -2220,7 +2229,7 @@ static OENTRY localops[] = {
(SUBR) pvsshift},
{"pvsfilter", sizeof(PVSFILTER), 3, "f", "fffp", (SUBR) pvsfilterset,
(SUBR) pvsfilter},
- {"pvscale", sizeof(PVSSCALE), 3, "f", "fkOPO",
+ {"pvscale", sizeof(PVSSCALE), 3, "f", "fkOPO",
(SUBR) pvsscaleset, (SUBR) pvsscale},
{"pvshift", sizeof(PVSSHIFT), 3, "f", "fkkOPO", (SUBR) pvsshiftset,
(SUBR) pvsshift},
@@ -2256,4 +2265,3 @@ int pvsbasic_init_(CSOUND *csound)
return csound->AppendOpcodes(csound, &(localops[0]),
(int) (sizeof(localops) / sizeof(OENTRY)));
}
-
diff --git a/Opcodes/pvsbuffer.c b/Opcodes/pvsbuffer.c
index 7e1448c..c874f32 100644
--- a/Opcodes/pvsbuffer.c
+++ b/Opcodes/pvsbuffer.c
@@ -67,7 +67,7 @@ static int pvsbufferset(CSOUND *csound, PVSBUFFER *p)
if (p->buffer.auxp == NULL ||
p->buffer.size < sizeof(float) * (N + 2) * p->nframes)
csound->AuxAlloc(csound, (N + 2) * sizeof(float) * p->nframes, &p->buffer);
- /*else*/
+ else
memset(p->buffer.auxp, 0, (N + 2) * sizeof(float) * p->nframes);
p->handle->header.frame.auxp = p->buffer.auxp;
@@ -206,7 +206,7 @@ static int pvsbufreadset(CSOUND *csound, PVSBUFFERREAD *p)
buffer = handle->data;
N = p->fout->N;
overlap = p->fout->overlap;
-
+
if (p->scnt >= overlap){
float *frame1, *frame2;
strt /= (sr/N);
@@ -215,7 +215,7 @@ static int pvsbufreadset(CSOUND *csound, PVSBUFFERREAD *p)
end = (int)(end <= strt ? N/2 + 2 : end > N/2 + 2 ? N/2 + 2 : end);
frames = handle->frames-1;
pos = *p->ktime*(sr/overlap);
-
+
if (p->iclear) memset(fout, 0, sizeof(float)*(N+2));
while (pos >= frames) pos -= frames;
while (pos < 0) pos += frames;
@@ -274,19 +274,19 @@ static int pvsbufreadproc2(CSOUND *csound, PVSBUFFERREAD *p)
buffer = handle->data;
N = p->fout->N;
overlap = p->fout->overlap;
-
-
+
+
if (p->scnt >= overlap) {
float *frame1, *frame2;
frames = handle->frames-1;
ftab = csound->FTFind(csound, p->strt);
- if (ftab->flen < N/2+1)
+ if (ftab->flen < N/2+1)
csound->PerfError(csound,
Str("table length too small: needed %d, got %d\n"),
N/2+1, ftab->flen);
tab = tab1 = ftab->ftable;
ftab = csound->FTFind(csound, p->end);
- if (ftab->flen < N/2+1)
+ if (ftab->flen < N/2+1)
csound->PerfError(csound,
Str("table length too small: needed %d, got %d\n"),
N/2+1, ftab->flen);
@@ -321,7 +321,7 @@ static int pvsbufreadproc2(CSOUND *csound, PVSBUFFERREAD *p)
#define S(x) sizeof(x)
-/* static */
+/* static */
static OENTRY pvsbuffer_localops[] = {
{"pvsbuffer", S(PVSBUFFER), 3, "ik", "fi",
(SUBR)pvsbufferset, (SUBR)pvsbufferproc, NULL},
diff --git a/Opcodes/serial.c b/Opcodes/serial.c
index 2883889..37806bb 100644
--- a/Opcodes/serial.c
+++ b/Opcodes/serial.c
@@ -354,7 +354,8 @@ int serialWrite(CSOUND *csound, SERIALWRITE *p)
#endif
if (p->XSTRCODE & 2) {
#ifndef WIN32
- write((int)*p->port, p->toWrite, strlen((char *)p->toWrite));
+ if (UNLIKELY(write((int)*p->port, p->toWrite, strlen((char *)p->toWrite))<0))
+ return NOTOK;
#else
int nbytes;
WriteFile(port,p->toWrite, strlen((char *)p->toWrite),
@@ -364,7 +365,8 @@ int serialWrite(CSOUND *csound, SERIALWRITE *p)
else {
unsigned char b = *p->toWrite;
#ifndef WIN32
- write((int)*p->port, &b, 1);
+ if (UNLIKELY(write((int)*p->port, &b, 1)<0))
+ return NOTOK;
#else
int nbytes;
WriteFile(port, &b, 1, (PDWORD)&nbytes, NULL);
diff --git a/Opcodes/sfont.c b/Opcodes/sfont.c
index c679e32..3d4f15a 100644
--- a/Opcodes/sfont.c
+++ b/Opcodes/sfont.c
@@ -30,7 +30,7 @@
directive switch. */
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <stdio.h>
#include <stdlib.h>
@@ -1952,8 +1952,10 @@ static void splitDefaults(splitType *split)
static int chunk_read(FILE *fil, CHUNK *chunk)
{
- fread(chunk->ckID,1,4, fil);
- fread(&chunk->ckSize,4,1,fil);
+ if (UNLIKELY(4 != fread(chunk->ckID,1,4, fil)))
+ return 0;
+ if (UNLIKELY(1 != fread(&chunk->ckSize,4,1,fil)))
+ return 0;
ChangeByteOrder("d", (char *)&chunk->ckSize, 4);
chunk->ckDATA = (BYTE *) malloc( chunk->ckSize);
return fread(chunk->ckDATA,1,chunk->ckSize,fil);
@@ -2562,4 +2564,3 @@ int sfont_ModuleInit(CSOUND *csound)
}
return err;
}
-
diff --git a/Opcodes/signalflowgraph.cpp b/Opcodes/signalflowgraph.cpp
index 91d7032..2da195c 100644
--- a/Opcodes/signalflowgraph.cpp
+++ b/Opcodes/signalflowgraph.cpp
@@ -912,7 +912,7 @@ struct FtGenOnce : public OpcodeBase<FtGenOnce> {
// otherwise, look up and return the already created function table's number.
if(functionTablesForCsoundsForEvtblks[csound].find(eventBlock) != functionTablesForCsoundsForEvtblks[csound].end()) {
*ifno = functionTablesForCsoundsForEvtblks[csound][eventBlock];
- warn(csound, "ftgenonce: re-using existing func: %f\n", *ifno);
+ // warn(csound, "ftgenonce: re-using existing func: %f\n", *ifno);
// std::cerr << "ftgenonce: re-using existing func:" << evtblk << std::endl;
} else {
FUNC *func = 0;
@@ -1090,21 +1090,21 @@ extern "C"
{
aoutletsForCsoundsForSourceOutletIds[csound].clear();
ainletsForCsoundsForSinkInletIds[csound].clear();
- for (size_t i = 0, n = aoutletVectorsForCsounds[csound].size(); i < n; i++) {
- delete aoutletVectorsForCsounds[csound][i];
- }
+ //for (size_t i = 0, n = aoutletVectorsForCsounds[csound].size(); i < n; i++) {
+ // delete aoutletVectorsForCsounds[csound][i];
+ //}
aoutletVectorsForCsounds[csound].clear();
koutletsForCsoundsForSourceOutletIds[csound].clear();
kinletsForCsoundsForSinkInletIds[csound].clear();
- for (size_t i = 0, n = koutletVectorsForCsounds[csound].size(); i < n; i++) {
- delete koutletVectorsForCsounds[csound][i];
- }
+ //for (size_t i = 0, n = koutletVectorsForCsounds[csound].size(); i < n; i++) {
+ // delete koutletVectorsForCsounds[csound][i];
+ //}
koutletVectorsForCsounds[csound].clear();
foutletsForCsoundsForSourceOutletIds[csound].clear();
finletsForCsoundsForSinkInletIds[csound].clear();
- for (size_t i = 0, n = foutletVectorsForCsounds[csound].size(); i < n; i++) {
- delete foutletVectorsForCsounds[csound][i];
- }
+ //for (size_t i = 0, n = foutletVectorsForCsounds[csound].size(); i < n; i++) {
+ // delete foutletVectorsForCsounds[csound][i];
+ //}
foutletVectorsForCsounds[csound].clear();
connectionsForCsounds[csound].clear();
}
diff --git a/Opcodes/sndloop.c b/Opcodes/sndloop.c
index 74b3f6c..827a5e1 100644
--- a/Opcodes/sndloop.c
+++ b/Opcodes/sndloop.c
@@ -656,7 +656,7 @@ static int flooper2_process(CSOUND *csound, flooper2 *p)
static int flooper3_init(CSOUND *csound, flooper3 *p)
{
int len,i,p2s,lomod;
- p->sfunc = csound->FTnp2Find(csound, p->ifn);
+ p->sfunc = csound->FTnp2Find(csound, p->ifn);
if (UNLIKELY(p->sfunc==NULL)) {
return csound->InitError(csound,Str("function table not found\n"));
}
@@ -832,7 +832,7 @@ static int flooper3_process(CSOUND *csound, flooper3 *p)
}
else if (mode == 2){
out[i] = 0;
-
+
tndx0 = ndx[0]>>lobits;
frac0 = (ndx[0] & lomask)*lodiv;
if (init && tndx0 < loop_start + crossfade) {
@@ -870,7 +870,7 @@ static int flooper3_process(CSOUND *csound, flooper3 *p)
count += ei;
}
-
+
tndx1 = ndx[1]>>lobits;
frac1 = (ndx[1] & lomask)*lodiv;
if (tndx1 > loop_end - crossfade) {
@@ -998,15 +998,16 @@ static int pvsvoc_init(CSOUND *csound, pvsvoc *p)
if (p->ceps.auxp == NULL ||
p->ceps.size < sizeof(MYFLT) * (N+2))
csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->ceps);
- memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
- if (p->fenv.auxp == NULL ||
- p->fenv.size < sizeof(MYFLT) * (N+2))
- csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fenv);
- if (p->fexc.auxp == NULL ||
- p->fexc.size < sizeof(MYFLT) * (N+2))
- csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fexc);
-
- return OK;
+ else
+ memset(p->ceps.auxp, 0, sizeof(MYFLT)*(N+2));
+ if (p->fenv.auxp == NULL ||
+ p->fenv.size < sizeof(MYFLT) * (N+2))
+ csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fenv);
+ if (p->fexc.auxp == NULL ||
+ p->fexc.size < sizeof(MYFLT) * (N+2))
+ csound->AuxAlloc(csound, sizeof(MYFLT) * (N + 2), &p->fexc);
+
+ return OK;
}
static int pvsvoc_process(CSOUND *csound, pvsvoc *p)
diff --git a/Opcodes/sockrecv.c b/Opcodes/sockrecv.c
index e498f9c..550e697 100644
--- a/Opcodes/sockrecv.c
+++ b/Opcodes/sockrecv.c
@@ -50,7 +50,7 @@ typedef struct {
OPDS h;
MYFLT *asig, *ipaddress, *port;
AUXCH aux, tmp;
- int sock;
+ int sock, conn;
struct sockaddr_in server_addr;
} SOCKRECVT;
@@ -307,6 +307,7 @@ static int send_recvS(CSOUND *csound, SOCKRECV *p)
/* TCP version */
static int init_srecv(CSOUND *csound, SOCKRECVT *p)
{
+ socklen_t clilen;
#ifdef WIN32
WSADATA wsaData = {0};
int err;
@@ -337,16 +338,23 @@ static int init_srecv(CSOUND *csound, SOCKRECVT *p)
/* the port we are going to listen on, in network byte order */
p->server_addr.sin_port = htons((int) *p->port);
-again:
- if (connect(p->sock, (struct sockaddr *) &p->server_addr,
- sizeof(p->server_addr)) < 0) {
-#ifdef ECONNREFUSED
- if (errno == ECONNREFUSED)
- goto again;
-#endif
- return csound->InitError(csound, Str("connect failed (%d)"), errno);
+ /* associate the socket with the address and port */
+ if (UNLIKELY(bind
+ (p->sock, (struct sockaddr *) &p->server_addr, sizeof(p->server_addr))
+ < 0)) {
+ return csound->InitError(csound, Str("bind failed"));
}
+ /* start the socket listening for new connections -- may wait */
+ if (UNLIKELY(listen(p->sock, 5) < 0)) {
+ return csound->InitError(csound, Str("listen failed"));
+ }
+ clilen = sizeof(p->server_addr);
+ p->conn = accept(p->sock, (struct sockaddr *) &p->server_addr, &clilen);
+
+ if (UNLIKELY(p->conn < 0)) {
+ return csound->InitError(csound, Str("accept failed"));
+ }
return OK;
}
@@ -354,12 +362,9 @@ static int send_srecv(CSOUND *csound, SOCKRECVT *p)
{
int n = sizeof(MYFLT) * csound->ksmps;
- if (n != read(p->sock, p->asig, n)) {
- csound->Message(csound, "Expected %d got %d\n",
- (int) (sizeof(MYFLT) * csound->ksmps), n);
+ if (UNLIKELY(n != read(p->conn, p->asig, sizeof(MYFLT) * csound->ksmps))) {
return csound->PerfError(csound, Str("read from socket failed"));
}
-
return OK;
}
diff --git a/Opcodes/socksend.c b/Opcodes/socksend.c
index 6bf318a..566ad81 100644
--- a/Opcodes/socksend.c
+++ b/Opcodes/socksend.c
@@ -34,6 +34,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
extern int inet_aton(const char *cp, struct in_addr *inp);
@@ -42,7 +43,7 @@ typedef struct {
MYFLT *asig, *ipaddress, *port, *buffersize;
MYFLT *format;
AUXCH aux;
- int sock, conn;
+ int sock;
int bsize, wp;
int ff, bwidth;
struct sockaddr_in server_addr;
@@ -53,7 +54,7 @@ typedef struct {
MYFLT *asigl, *asigr, *ipaddress, *port, *buffersize;
MYFLT *format;
AUXCH aux;
- int sock, conn;
+ int sock;
int bsize, wp;
int ff, bwidth;
struct sockaddr_in server_addr;
@@ -81,7 +82,7 @@ static int init_send(CSOUND *csound, SOCKSEND *p)
/* } */
p->wp = 0;
- p->sock = socket(AF_INET, SOCK_DGRAM, 0);
+ p->sock = socket(AF_INET, SOCK_DGRAM, 0);
if (UNLIKELY(p->sock < 0)) {
return csound->InitError(csound, Str("creating socket"));
}
@@ -137,7 +138,7 @@ static int send_send(CSOUND *csound, SOCKSEND *p)
ch.benchar[1] = 0xFF & (val >> 8);
outs[wp] = ch.bensht;
}
- else
+ else
out[wp] = asig[i];
}
p->wp = wp;
@@ -244,7 +245,6 @@ static int send_sendS(CSOUND *csound, SOCKSENDS *p)
/* TCP version */
static int init_ssend(CSOUND *csound, SOCKSEND *p)
{
- socklen_t clilen;
#ifdef WIN32
WSADATA wsaData = {0};
int err;
@@ -277,23 +277,16 @@ static int init_ssend(CSOUND *csound, SOCKSEND *p)
/* the port we are going to listen on, in network byte order */
p->server_addr.sin_port = htons((int) *p->port);
- /* associate the socket with the address and port */
- if (UNLIKELY(bind
- (p->sock, (struct sockaddr *) &p->server_addr, sizeof(p->server_addr))
- < 0)) {
- return csound->InitError(csound, Str("bind failed"));
- }
-
- /* start the socket listening for new connections -- may wait */
- if (UNLIKELY(listen(p->sock, 5) < 0)) {
- return csound->InitError(csound, Str("listen failed"));
+again:
+ if (connect(p->sock, (struct sockaddr *) &p->server_addr,
+ sizeof(p->server_addr)) < 0) {
+#ifdef ECONNREFUSED
+ if (errno == ECONNREFUSED)
+ goto again;
+#endif
+ return csound->InitError(csound, Str("connect failed (%d)"), errno);
}
- clilen = sizeof(p->server_addr);
- p->conn = accept(p->sock, (struct sockaddr *) &p->server_addr, &clilen);
- if (UNLIKELY(p->conn < 0)) {
- return csound->InitError(csound, Str("accept failed"));
- }
return OK;
}
@@ -301,9 +294,12 @@ static int send_ssend(CSOUND *csound, SOCKSEND *p)
{
int n = sizeof(MYFLT) * csound->ksmps;
- if (UNLIKELY(n != write(p->conn, p->asig, sizeof(MYFLT) * csound->ksmps))) {
+ if (n != write(p->sock, p->asig, n)) {
+ csound->Message(csound, "Expected %d got %d\n",
+ (int) (sizeof(MYFLT) * csound->ksmps), n);
return csound->PerfError(csound, Str("write to socket failed"));
}
+
return OK;
}
@@ -319,4 +315,3 @@ static OENTRY socksend_localops[] = {
};
LINKAGE1(socksend_localops)
-
diff --git a/Opcodes/spectra.c b/Opcodes/spectra.c
index 0f8d945..a036e44 100644
--- a/Opcodes/spectra.c
+++ b/Opcodes/spectra.c
@@ -22,7 +22,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
#include <math.h>
#include "cwindow.h"
@@ -1247,11 +1247,10 @@ static OENTRY spectra_localops[] = {
{ "active.i", S(INSTCNT),1, "i", "To", (SUBR)instcount, NULL, NULL },
{ "active.k", S(INSTCNT),2, "k", "Uo", NULL, (SUBR)instcount, NULL },
{ "p.i", S(PFUN), 1, "i", "i", (SUBR)pfun, NULL, NULL },
-{ "p.k", S(PFUNK), 3, "k", "k", (SUBR)pfunk_init, (SUBR)pfunk, NULL },
+{ "p.k", S(PFUNK), 3, "k", "k", (SUBR)pfunk_init, (SUBR)pfunk, NULL },
{ "mute", S(MUTE), 1, "", "To", (SUBR)mute_inst },
{ "median", S(MEDFILT), 5, "a", "akio", (SUBR)medfiltset, NULL, (SUBR)medfilt},
{ "mediank", S(MEDFILT), 5, "k", "kkio", (SUBR)medfiltset, (SUBR)kmedfilt},
};
LINKAGE1(spectra_localops)
-
diff --git a/Opcodes/stk/CMakeLists.txt b/Opcodes/stk/CMakeLists.txt
index 9aaf761..15152f0 100644
--- a/Opcodes/stk/CMakeLists.txt
+++ b/Opcodes/stk/CMakeLists.txt
@@ -3,29 +3,50 @@ option(BUILD_STK_OPCODES "Build the stk opcodes" ON)
if(BUILD_STK_OPCODES)
find_library(STK_LIBRARY stk)
if(STK_LIBRARY)
- make_plugin(stk-ops stkOpcodes.cpp "stk")
- set_target_properties(stk-ops PROPERTIES
- OUTPUT_NAME stk)
+ find_path(STK_INCLUDE_DIR Stk.h
+ /usr/include/stk
+ /usr/local/include/stk)
+
+ check_deps(BUILD_STK_OPCODES STK_INCLUDE_DIR)
+ if(STK_INCLUDE_DIR)
+ include_directories(${STK_INCLUDE_DIR})
+
+ make_plugin(stk-ops stkOpcodes.cpp "stk")
+
+ set_target_properties(stk-ops PROPERTIES
+ OUTPUT_NAME stk)
+ endif()
else()
- set(stk_srcs
+
+ set(stk_remove_srcs
src/InetWvIn.cpp src/InetWvOut.cpp
src/Mutex.cpp src/RtAudio.cpp
src/RtMidi.cpp
src/RtWvIn.cpp src/RtWvOut.cpp
src/Socket.cpp src/TcpClient.cpp
src/TcpServer.cpp src/Thread.cpp
- src/UdpSocket.cpp
- stkOpcodes.cpp)
+ src/UdpSocket.cpp)
+
+ file(GLOB stk_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*)
+
+ list(REMOVE_ITEM stk_srcs ${stk_remove_srcs})
+ list(APPEND stk_srcs stkOpcodes.cpp)
+
# Assume that if this file exists, then we have the sources
find_file(STK_FOUND
NAMES src/InetWvIn.cpp
HINTS ${CMAKE_CURRENT_SOURCE_DIR})
- check_deps(BUILD_STK_OPCODES STK_FOUND)
+
+ find_path(STK_INCLUDE_DIR Stk.h ./include)
+
+ check_deps(BUILD_STK_OPCODES STK_FOUND STK_INCLUDE_DIR)
if(BUILD_STK_OPCODES)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/stk)
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
make_plugin(stk "${stk_srcs}")
diff --git a/Opcodes/system_call.c b/Opcodes/system_call.c
index d5b197e..edcb37a 100644
--- a/Opcodes/system_call.c
+++ b/Opcodes/system_call.c
@@ -64,8 +64,8 @@ static int call_system(CSOUND *csound, SYSTEM *p)
if ((*p->res = fork()))
return OK;
else {
- system((char*)p->commandLine);
- exit(1);
+ if (UNLIKELY(system((char*)p->commandLine)<0)) exit(1);
+ exit(0);
}
}
else {
diff --git a/Opcodes/tabvars.c b/Opcodes/tabvars.c
index 6d1e9ce..ccf7025 100644
--- a/Opcodes/tabvars.c
+++ b/Opcodes/tabvars.c
@@ -22,7 +22,7 @@
*/
// #include "csdl.h"
-#include "csoundCore.h"
+#include "csoundCore.h"
#include "interlocks.h"
@@ -85,7 +85,7 @@ static int tabmult(CSOUND *csound, TABARITH *p)
ans->data[i] = l->data[i] * r->data[i];
return OK;
}
-
+
static int tabqset(CSOUND *csound, TABQUERY *p)
{
if (LIKELY(p->tab->data)) return OK;
@@ -103,7 +103,7 @@ static int tabmax(CSOUND *csound, TABQUERY *p)
*p->ans = ans;
return OK;
}
-
+
static int tabmin(CSOUND *csound, TABQUERY *p)
{
TABDAT *t = p->tab;
@@ -115,7 +115,7 @@ static int tabmin(CSOUND *csound, TABQUERY *p)
*p->ans = ans;
return OK;
}
-
+
static int tabsum(CSOUND *csound, TABQUERY *p)
{
TABDAT *t = p->tab;
@@ -127,7 +127,7 @@ static int tabsum(CSOUND *csound, TABQUERY *p)
*p->ans = ans;
return OK;
}
-
+
static int tabscaleset(CSOUND *csound, TABSCALE *p)
{
if (LIKELY(p->tab->data)) return OK;
@@ -177,7 +177,7 @@ static int tabcopy_set(CSOUND *csound, TABCPY *p)
int sizes,sized;
if (UNLIKELY(p->src->data==NULL))
return csound->InitError(csound, Str("t-variable not initialised"));
- if (UNLIKELY(p->dst->data==NULL))
+ if (UNLIKELY(p->dst->data==NULL))
return csound->InitError(csound, Str("t-variable not initialised"));
sizes = p->src->size;
sized = p->dst->size;
@@ -216,7 +216,7 @@ static int ftab2tab(CSOUND *csound, TABCOPY *p)
int tlen = p->tab->size;
if (UNLIKELY(p->tab->data==NULL))
return csound->PerfError(csound, Str("t-var not initialised"));
- if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL))
+ if (UNLIKELY((ftp = csound->FTFindP(csound, p->kfn)) == NULL))
return csound->PerfError(csound, Str("No table for copy2ftab"));
fsize = ftp->flen;
fdata = ftp->ftable;
@@ -241,10 +241,7 @@ static OENTRY tabvars_localops[] =
};
// reverse, scramble, mirror, stutter, rotate, ...
// jpff: stutter is an interesting one (very musical). It basically
-// randomly repeats (holds) values based on a probability parameter
+// randomly repeats (holds) values based on a probability parameter
LINKAGE1(tabvars_localops)
-
-
-
diff --git a/Opcodes/tl/fractalnoise.cpp b/Opcodes/tl/fractalnoise.cpp
index a7bb797..5531c67 100644
--- a/Opcodes/tl/fractalnoise.cpp
+++ b/Opcodes/tl/fractalnoise.cpp
@@ -44,25 +44,25 @@ inline void *aligned_calloc(size_t nmemb, size_t size)
/* ABSTRACT USER INTERFACE */
-struct Meta
+struct Meta
{
void declare (const char* key, const char* value) { }
};
class UserInterface
{
- bool fStopped;
+ bool fStopped;
public:
UserInterface() : fStopped(false) {}
virtual ~UserInterface() {}
virtual void addButton(char* label, MYFLT* zone) = 0;
virtual void addToggleButton(char* label, MYFLT* zone) = 0;
virtual void addCheckButton(char* label, MYFLT* zone) = 0;
- virtual void addVerticalSlider(char* label, MYFLT* zone, MYFLT init,
- MYFLT min, MYFLT max, MYFLT step) = 0;
- virtual void addHorizontalSlider(char* label, MYFLT* zone, MYFLT init,
- MYFLT min, MYFLT max, MYFLT step) = 0;
- virtual void addNumEntry(char* label, MYFLT* zone, MYFLT init, MYFLT min,
+ virtual void addVerticalSlider(char* label, MYFLT* zone, MYFLT init,
+ MYFLT min, MYFLT max, MYFLT step) = 0;
+ virtual void addHorizontalSlider(char* label, MYFLT* zone, MYFLT init,
+ MYFLT min, MYFLT max, MYFLT step) = 0;
+ virtual void addNumEntry(char* label, MYFLT* zone, MYFLT init, MYFLT min,
MYFLT max, MYFLT step) = 0;
virtual void openFrameBox(char* label) = 0;
virtual void openTabBox(char* label) = 0;
@@ -78,7 +78,7 @@ class csUI : public UserInterface {
private:
MYFLT* args[2];
int ctrlCount;
-
+
void addZone(MYFLT* zone) {
args[ctrlCount++] = zone;
}
@@ -149,65 +149,65 @@ public:
class mydsp : public dsp {
private:
- int iConst0;
- MYFLT fConst1;
- MYFLT fConst2;
- int iRec8[2];
- MYFLT fConst3;
- MYFLT fConst4;
- MYFLT fConst5;
- MYFLT fConst6;
- MYFLT fConst7;
- MYFLT fConst8;
- MYFLT fRec7[3];
- MYFLT fslider0;
- MYFLT fConst9;
- MYFLT fConst10;
- MYFLT fConst11;
- MYFLT fConst12;
- MYFLT fConst13;
- MYFLT fConst14;
- MYFLT fRec6[3];
- MYFLT fConst15;
- MYFLT fConst16;
- MYFLT fConst17;
- MYFLT fConst18;
- MYFLT fConst19;
- MYFLT fConst20;
- MYFLT fRec5[3];
- MYFLT fConst21;
- MYFLT fConst22;
- MYFLT fConst23;
- MYFLT fConst24;
- MYFLT fConst25;
- MYFLT fConst26;
- MYFLT fRec4[3];
- MYFLT fConst27;
- MYFLT fConst28;
- MYFLT fConst29;
- MYFLT fConst30;
- MYFLT fConst31;
- MYFLT fConst32;
- MYFLT fRec3[3];
- MYFLT fConst33;
- MYFLT fConst34;
- MYFLT fConst35;
- MYFLT fConst36;
- MYFLT fConst37;
- MYFLT fConst38;
- MYFLT fRec2[3];
- MYFLT fConst39;
- MYFLT fConst40;
- MYFLT fConst41;
- MYFLT fConst42;
- MYFLT fConst43;
- MYFLT fConst44;
- MYFLT fRec1[3];
- MYFLT fRec0[2];
- MYFLT fslider1;
+ int iConst0;
+ MYFLT fConst1;
+ MYFLT fConst2;
+ int iRec8[2];
+ MYFLT fConst3;
+ MYFLT fConst4;
+ MYFLT fConst5;
+ MYFLT fConst6;
+ MYFLT fConst7;
+ MYFLT fConst8;
+ MYFLT fRec7[3];
+ MYFLT fslider0;
+ MYFLT fConst9;
+ MYFLT fConst10;
+ MYFLT fConst11;
+ MYFLT fConst12;
+ MYFLT fConst13;
+ MYFLT fConst14;
+ MYFLT fRec6[3];
+ MYFLT fConst15;
+ MYFLT fConst16;
+ MYFLT fConst17;
+ MYFLT fConst18;
+ MYFLT fConst19;
+ MYFLT fConst20;
+ MYFLT fRec5[3];
+ MYFLT fConst21;
+ MYFLT fConst22;
+ MYFLT fConst23;
+ MYFLT fConst24;
+ MYFLT fConst25;
+ MYFLT fConst26;
+ MYFLT fRec4[3];
+ MYFLT fConst27;
+ MYFLT fConst28;
+ MYFLT fConst29;
+ MYFLT fConst30;
+ MYFLT fConst31;
+ MYFLT fConst32;
+ MYFLT fRec3[3];
+ MYFLT fConst33;
+ MYFLT fConst34;
+ MYFLT fConst35;
+ MYFLT fConst36;
+ MYFLT fConst37;
+ MYFLT fConst38;
+ MYFLT fRec2[3];
+ MYFLT fConst39;
+ MYFLT fConst40;
+ MYFLT fConst41;
+ MYFLT fConst42;
+ MYFLT fConst43;
+ MYFLT fConst44;
+ MYFLT fRec1[3];
+ MYFLT fRec0[2];
+ MYFLT fslider1;
public:
- static void metadata(Meta* m)
- {
+ static void metadata(Meta* m)
+ {
m->declare("name", "Fractal Noise");
m->declare("author", "Tito Latini");
m->declare("license", "GNU LGPL");
@@ -223,12 +223,12 @@ class mydsp : public dsp {
m->declare("math.lib/copyright", "GRAME");
m->declare("math.lib/version", "1.0");
m->declare("math.lib/license", "LGPL");
- }
+ }
- virtual int getNumInputs() { return 0; }
- virtual int getNumOutputs() { return 1; }
- static void classInit(int samplingFreq) { }
- virtual void instanceInit(int samplingFreq)
+ virtual int getNumInputs() { return 0; }
+ virtual int getNumOutputs() { return 1; }
+ static void classInit(int samplingFreq) { }
+ virtual void instanceInit(int samplingFreq)
{
fSamplingFreq = samplingFreq;
iConst0 = min(192000, max(1, fSamplingFreq));
@@ -287,13 +287,13 @@ class mydsp : public dsp {
for (int i=0; i<3; i++) fRec1[i] = 0;
for (int i=0; i<2; i++) fRec0[i] = 0;
fslider1 = FL(1.0);
- }
- virtual void init(int samplingFreq)
+ }
+ virtual void init(int samplingFreq)
{
classInit(samplingFreq);
instanceInit(samplingFreq);
- }
- virtual void buildUserInterface(UserInterface* userInterface)
+ }
+ virtual void buildUserInterface(UserInterface* userInterface)
{
userInterface->openVerticalBox((char*)"fractalnoise");
userInterface->addVerticalSlider((char*)"amp", &fslider1, FL(1.0),
@@ -301,7 +301,7 @@ class mydsp : public dsp {
userInterface->addVerticalSlider((char*)"beta", &fslider0, FL(1.75),
FL(0.0), FL(10.0), FL(0.01));
userInterface->closeBox();
- }
+ }
virtual void compute (CSOUND* csound, MYFLT* output)
{
int nn = csound->ksmps;
@@ -366,7 +366,7 @@ class mydsp : public dsp {
fRec7[2] = fRec7[1]; fRec7[1] = fRec7[0];
iRec8[1] = iRec8[0];
}
- }
+ }
};
//typedef struct mydsp FaustCode;
@@ -408,7 +408,7 @@ extern "C"
}
static OENTRY localops[] = {
- { (char*)"fractalnoise", sizeof(FRACTALNOISE), 5, (char*)"a", (char*)"kk",
+ { (char*)"fractalnoise", sizeof(FRACTALNOISE), 5, (char*)"a", (char*)"kk",
(SUBR)fractalnoise_init, NULL, (SUBR)fractalnoise_process },
{ 0, 0, 0, 0, 0, 0, 0, 0, }
};
diff --git a/Opcodes/uggab.c b/Opcodes/uggab.c
index 329dc9d..8757af1 100644
--- a/Opcodes/uggab.c
+++ b/Opcodes/uggab.c
@@ -211,7 +211,7 @@ static int posc_set(CSOUND *csound, POSC *p)
{
FUNC *ftp;
- if (UNLIKELY((ftp = csound->FTnp2Find(csound, p->ift)) == NULL))
+ if (UNLIKELY((ftp = csound->FTnp2Find(csound, p->ift)) == NULL))
return csound->InitError(csound, Str("table not found in poscil"));
p->ftp = ftp;
p->tablen = ftp->flen;
@@ -1889,4 +1889,3 @@ int uggab_init_(CSOUND *csound)
return csound->AppendOpcodes(csound, &(localops[0]),
(int) (sizeof(localops) / sizeof(OENTRY)));
}
-
diff --git a/Opcodes/uggab.h b/Opcodes/uggab.h
index 6e26558..96d1593 100644
--- a/Opcodes/uggab.h
+++ b/Opcodes/uggab.h
@@ -206,7 +206,7 @@ typedef struct {
/* by Francois Pinot, jan. 2011 */
typedef struct {
OPDS h;
- MYFLT *ar, *min, *max, *xcps, *mode, *fstval;
+ MYFLT *ar, *min, *max, *xcps, *mode, *fstval;
int16 cpscod;
int32 phs;
MYFLT num1, num2, dfdmax;
@@ -232,4 +232,3 @@ typedef struct {
} RANDOM3;
#endif /* UGGAB_H */
-
diff --git a/Opcodes/ugnorman.c b/Opcodes/ugnorman.c
index 1ed5460..93c0d0a 100644
--- a/Opcodes/ugnorman.c
+++ b/Opcodes/ugnorman.c
@@ -785,7 +785,7 @@ static void FetchADDNZbands(int ptls, int firstband, double *datastart,
#endif
frame = (int) position;
frm_0 = datastart + frame * frmInc;
-
+
/* if we are using the data from the last frame */
/* we should not try to interpolate */
if (frame == maxFr) {
@@ -798,7 +798,7 @@ static void FetchADDNZbands(int ptls, int firstband, double *datastart,
frm_1 = frm_0 + frmInc;
frac = (double) (position - frame);
-
+
for (i = 0; i < ptls; i++) {
if (swapped == 1) {
frm0val = bswap(&(frm_0[firstband + i]));
@@ -808,11 +808,11 @@ static void FetchADDNZbands(int ptls, int firstband, double *datastart,
frm0val = frm_0[firstband + i];
frm1val = frm_1[firstband + i];
}
-
+
buf[i] = frm0val + frac * (frm1val - frm0val); /* calc energy */
-
+
}
-
+
}
static double freqs[25]= {
@@ -921,7 +921,7 @@ static int atsaddnzset(CSOUND *csound, ATSADDNZ *p)
{
double tmp = TWOPI * csound->onedsr;
-
+
/* initialise frequencies to modulate noise by */
p->phaseinc[0] = 50.0 * tmp;
p->phaseinc[1] = 150.0 * tmp;
@@ -1129,7 +1129,7 @@ static int atssinnoiset(CSOUND *csound, ATSSINNOI *p)
+ sizeof(RANDIATS));
/* allocate space if we need it */
/* need room for a buffer and an array of oscillator phase increments */
- if(p->auxch.auxp != NULL || memsize > p->auxch.size)
+ if(p->auxch.auxp != NULL || memsize > p->auxch.size)
csound->AuxAlloc(csound, (size_t) memsize, &p->auxch);
/* set up the buffer, phase, etc. */
@@ -1160,7 +1160,7 @@ static int atssinnoiset(CSOUND *csound, ATSSINNOI *p)
p->nzdata = (double *) csound->Malloc(csound, sizeof(double) * nzmemsize);
}
-
+
/* make sure partials are in range */
if (UNLIKELY((int) (*p->iptloffset + *p->iptls * *p->iptlincr) > p->npartials ||
(int) (*p->iptloffset) < 0)) {
@@ -1221,8 +1221,8 @@ static int atssinnoiset(CSOUND *csound, ATSSINNOI *p)
}
/* save the memory size of the noise */
p->nzmemsize = nzmemsize;
-
-
+
+
/* flag set to reduce the amount of warnings sent out */
/* for time pointer out of range */
p->prFlg = 1; /* true */
@@ -1288,7 +1288,7 @@ static int atssinnoiset(CSOUND *csound, ATSSINNOI *p)
for (i = 0; i < (int) *p->iptls; i++) {
randiats_setup(csound, freqs[i], &(p->randinoise[i]));
}
-
+
return OK;
}
@@ -1328,14 +1328,14 @@ static int atssinnoi(CSOUND *csound, ATSSINNOI *p)
}
else
p->prFlg = 1;
-
-
+
+
fetchSINNOIpartials(p, frIndx);
-
+
FetchADDNZbands(*p->iptls, p->firstband, p->datastart, p->frmInc, p->maxFr,
p->swapped, p->nzbuf, frIndx);
-
-
+
+
/* set local pointer to output and initialise output to zero */
ar = p->aoutput;
@@ -1344,7 +1344,7 @@ static int atssinnoi(CSOUND *csound, ATSSINNOI *p)
/* *ar++ = FL(0.0); */
oscbuf = p->oscbuf;
-
+
/* do synthesis */
if (p->firstband != -1) {
@@ -1371,11 +1371,11 @@ static int atssinnoi(CSOUND *csound, ATSSINNOI *p)
/* calc output */
ar[n] += csound->e0dbfs *
(MYFLT)(amp * sinewave * *p->ksinamp + noise **p->knzamp);
-
+
}
p->oscphase[i] = phase;
}
-
+
}
else {
for (i = 0; i < (int) *p->iptls; i++) {
@@ -1393,9 +1393,9 @@ static int atssinnoi(CSOUND *csound, ATSSINNOI *p)
}
p->oscphase[i] = phase;
}
-
+
}
-
+
return OK;
}
@@ -2167,4 +2167,3 @@ int ugnorman_init_(CSOUND *csound)
return csound->AppendOpcodes(csound, &(localops[0]),
(int) (sizeof(localops) / sizeof(OENTRY)));
}
-
diff --git a/Opcodes/ugsc.c b/Opcodes/ugsc.c
index bc17330..1bf2176 100644
--- a/Opcodes/ugsc.c
+++ b/Opcodes/ugsc.c
@@ -381,7 +381,7 @@ static int phaser1(CSOUND *csound, PHASER1 *p)
static int phaser2set(CSOUND *csound, PHASER2 *p)
{
- int modetype, j;
+ int modetype;
int loop;
p->modetype = modetype = (int)*p->mode;
diff --git a/Opcodes/urandom.c b/Opcodes/urandom.c
index f60c292..b7ce86f 100644
--- a/Opcodes/urandom.c
+++ b/Opcodes/urandom.c
@@ -57,11 +57,11 @@ static int urand_run(CSOUND *csound, URANDOM *p)
int ur = p->ur;
/* union ieee754_double x; */
int64_t x;
- read(ur, &x, sizeof(int64_t));
+ if (UNLIKELY(read(ur, &x, sizeof(int64_t))!=sizeof(int64_t))) return NOTOK;
- /* x.ieee.exponent = x.ieee.exponent& 0x377; */
- /* printf("Debug: %s(%d): %g %d %03x %05x %08x\n", __FILE__, __LINE__, x.d, */
- /* x.ieee.negative, x.ieee.exponent, x.ieee.mantissa0, x.ieee.mantissa1); */
+/* x.ieee.exponent = x.ieee.exponent& 0x377; */
+/* printf("Debug: %s(%d): %g %d %03x %05x %08x\n", __FILE__, __LINE__, x.d, */
+/* x.ieee.negative, x.ieee.exponent, x.ieee.mantissa0, x.ieee.mantissa1); */
*p->ar = p->mul *((MYFLT)x/(MYFLT)0x7fffffffffffffff) + p->add;
return OK;
}
@@ -80,7 +80,7 @@ static int urand_arun(CSOUND *csound, URANDOM *p)
MYFLT *ar = p->ar;
int n, nsmps = csound->ksmps;
for (n=0; n<nsmps; n++) {
- read(ur, &x, sizeof(int64_t));
+ if (UNLIKELY(read(ur, &x, sizeof(int64_t))!= sizeof(int64_t))) return NOTOK;
ar[n] = p->mul *((MYFLT)x/(MYFLT)0x7fffffffffffffff) + p->add;
}
return OK;
diff --git a/Opcodes/vbap.c b/Opcodes/vbap.c
index 1f3d181..e122e98 100644
--- a/Opcodes/vbap.c
+++ b/Opcodes/vbap.c
@@ -899,7 +899,7 @@ void new_spread_base(CART_VEC spreaddir, CART_VEC vscartdir,
#define S(x) sizeof(x)
-/* static */
+/* static */
static OENTRY vbap_localops[] = {
{ "vbap4", S(VBAP_FOUR), TR|5, "aaaa", "akOO",
(SUBR) vbap_FOUR_init, (SUBR) NULL, (SUBR) vbap_FOUR },
diff --git a/Opcodes/vbap_zak.c b/Opcodes/vbap_zak.c
index 18baf42..e0cc0ae 100644
--- a/Opcodes/vbap_zak.c
+++ b/Opcodes/vbap_zak.c
@@ -75,7 +75,7 @@ int vbap_zak(CSOUND *csound, VBAP_ZAK *p) /* during note performance: */
for (i=0; i<nsmps; ++i)
outptr[i] = inptr[i] * ogain;
}
- else
+ else
memset(outptr, 0, nsmps*sizeof(MYFLT));
outptr += nsmps;
}
diff --git a/Opcodes/vst4cs/src/vsthost.cpp b/Opcodes/vst4cs/src/vsthost.cpp
index 764669d..b066768 100644
--- a/Opcodes/vst4cs/src/vsthost.cpp
+++ b/Opcodes/vst4cs/src/vsthost.cpp
@@ -857,11 +857,11 @@ bool VSTPlugin::OnOutputConnected(AEffect *effect, long output)
return true;
}
-long VSTPlugin::Master(AEffect *effect,
- long opcode,
+long VSTPlugin::Master(AEffect *effect,
+ long opcode,
long index,
- long value,
- void *ptr,
+ long value,
+ void *ptr,
float opt)
{
VSTPlugin *plugin = 0;
@@ -965,4 +965,3 @@ long VSTPlugin::Master(AEffect *effect,
}
return 0;
}
-
diff --git a/Opcodes/vst4cs/src/vsthost.h b/Opcodes/vst4cs/src/vsthost.h
index 9e9e66f..da5900b 100644
--- a/Opcodes/vst4cs/src/vsthost.h
+++ b/Opcodes/vst4cs/src/vsthost.h
@@ -114,16 +114,16 @@ class VSTPlugin {
virtual bool IsSynth();
virtual bool AddMIDI(int data, int deltaFrames, int detune);
virtual void SendMidi();
- virtual void processReplacing(float **inputs,
+ virtual void processReplacing(float **inputs,
float **outputs,
long sampleframes);
- virtual void process(float **inputs,
- float **outputs,
+ virtual void process(float **inputs,
+ float **outputs,
long sampleframes);
- virtual long Dispatch(long opCode,
- long index=0,
- long value=0,
- void *ptr=0,
+ virtual long Dispatch(long opCode,
+ long index=0,
+ long value=0,
+ void *ptr=0,
float opt=0);
virtual void Log(const char *format, ...);
virtual void Debug(const char *format, ...);
@@ -142,17 +142,17 @@ class VSTPlugin {
{
return Dispatch(effGetChunk, isPreset, 0, ptr);
}
- long EffGetProgram()
- {
- return Dispatch(effGetProgram);
+ long EffGetProgram()
+ {
+ return Dispatch(effGetProgram);
}
- void EffSetProgram(long lValue)
- {
- Dispatch(effSetProgram, 0, lValue);
+ void EffSetProgram(long lValue)
+ {
+ Dispatch(effSetProgram, 0, lValue);
}
- void EffGetProgramName(char *ptr)
- {
- Dispatch(effGetProgramName, 0, 0, ptr);
+ void EffGetProgramName(char *ptr)
+ {
+ Dispatch(effGetProgramName, 0, 0, ptr);
}
static std::map<long, std::string> &masterOpcodes()
{
@@ -197,4 +197,3 @@ inline void VSTPlugin::process(float **ins, float **outs, long frames)
}
#endif
-
diff --git a/Opcodes/wiimote.c b/Opcodes/wiimote.c
index 2408894..3c0decc 100644
--- a/Opcodes/wiimote.c
+++ b/Opcodes/wiimote.c
@@ -80,7 +80,11 @@ typedef struct {
MYFLT *num;
} WIIRANGE;
-#define WIIMOTE_STATE_CONNECTED (0x0008)
+#ifdef WIIUSE_0_12
+# define WIIMOTE_STATE_CONNECTED (0x0008)
+#else
+# define WIIMOTE_STATE_CONNECTED (0x0010)
+#endif
int wiimote_find(CSOUND *csound, WIIMOTE *p)
{
@@ -116,7 +120,7 @@ int wiimote_find(CSOUND *csound, WIIMOTE *p)
return csound->InitError(csound, Str("unable to open wiimote\n"));
}
/* Initialise ranges */
- for (i=0; i<max_wiimotes; i++) {
+ for (i=0; i<n; i++) {
wiiuse_set_leds(wiimotes[i], WIIMOTE_LED_1<<i);
wiirange[i].axis_x_min = FL(0.0);
wiirange[i].axis_x_scale = FL(1.0);
@@ -136,7 +140,7 @@ int wiimote_find(CSOUND *csound, WIIMOTE *p)
wiiuse_motion_sensing(wiimotes[i], 1);
}
p->wii = wiimotes;
- p->max_wiimotes = max_wiimotes;
+ p->max_wiimotes = n;
*p->res = FL(1.0);
return OK;
}
@@ -207,8 +211,10 @@ int wii_data(CSOUND *csound, WIIMOTE *p)
wiirange_t *wiir = p->wiir;
int n = (int)*p->num;
int kontrol = (int)(*p->kControl+FL(0.5));
- if (UNLIKELY(n>=MAX_WIIMOTES || !(wii[n]->state & WIIMOTE_STATE_CONNECTED)))
+ if (UNLIKELY(n>=MAX_WIIMOTES || !(wii[n]->state & WIIMOTE_STATE_CONNECTED))) {
+ printf("state of wii %d is %x\n", n, wii[n]->state);
return csound->PerfError(csound, Str("wiimote %d does not exist"), n);
+ }
if (kontrol<0) {
printf("%f -- %.4x: "
"tilt=[%f %f];\nforce=(%f %f %f)\n",
diff --git a/SConstruct b/SConstruct
index 987f033..233a6f3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -267,14 +267,14 @@ commandOptions.Add('tclversion',
'Set to 8.4 or 8.5',
'8.5')
commandOptions.Add('includeWii',
- 'Set to 1 if using libwiimote',
+ 'Set to 12 or 13 if using libwiiuse v0.12 or v0.13',
'0')
commandOptions.Add('includeP5Glove',
'Set to 1 if using P5 Glove',
'0')
commandOptions.Add('buildBeats',
'Set to 1 if building beats score language',
- '0')
+ '1')
commandOptions.Add('buildcatalog',
'Set to 1 if building opcode/library catalogue',
'0')
@@ -529,8 +529,8 @@ elif getPlatform() == 'win32':
commonEnvironment.Prepend(CCFLAGS = ["-Wall"])
commonEnvironment.Append(CPPPATH = '/usr/local/include')
commonEnvironment.Append(CPPPATH = '/usr/include')
- commonEnvironment.Append(SHLINKFLAGS = Split(' -mno-cygwin -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc'))
- commonEnvironment.Append(LINKFLAGS = Split(' -mno-cygwin -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc'))
+ commonEnvironment.Append(SHLINKFLAGS = Split('-Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc'))
+ commonEnvironment.Append(LINKFLAGS = Split('-Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc'))
else:
commonEnvironment.Append(CCFLAGS = '/DMSVC')
commonEnvironment.Append(CXXFLAGS = '/EHsc')
@@ -701,8 +701,9 @@ if not configure.CheckLibWithHeader("pthread", "pthread.h", language = "C"):
# Support for GEN49 (load MP3 file)
-if commonEnvironment['includeWii'] == '1' and configure.CheckLibWithHeader('wiiuse', "wiiuse.h", language = "C") :
+if commonEnvironment['includeWii'] != '0' and configure.CheckLibWithHeader('wiiuse', "wiiuse.h", language = "C") :
wiifound = 1
+ wiiversion = commonEnvironment['includeWii']
print 'CONFIGURATION DECISION: Building with Wiimote support'
else:
wiifound = 0
@@ -885,6 +886,9 @@ if getPlatform() == 'darwin':
tmp = OSXFrameworkBaseDir + '/Versions/%s'
OSXFrameworkCurrentVersion = tmp % csoundLibraryVersion
+if getPlatform() == "win32":
+ Tool('lex')(commonEnvironment)
+ Tool('yacc')(commonEnvironment)
csoundLibraryEnvironment = commonEnvironment.Clone()
if commonEnvironment['buildMultiCore'] != '0':
@@ -894,9 +898,6 @@ if commonEnvironment['buildMultiCore'] != '0':
if commonEnvironment['buildNewParser'] != '0':
if commonEnvironment['buildMultiCore'] != '0':
csoundLibraryEnvironment.Append(CPPFLAGS = ['-DPARCS'])
- if getPlatform() == "win32":
- Tool('lex')(csoundLibraryEnvironment)
- Tool('yacc')(csoundLibraryEnvironment)
print 'CONFIGURATION DECISION: Building with new parser enabled'
reportflag='--report=itemset'
csoundLibraryEnvironment.Append(YACCFLAGS = ['-d', reportflag, '-p','csound_orc'])
@@ -1297,7 +1298,7 @@ pluginEnvironment.Append(LIBS = Split('sndfile'))
if getPlatform() == 'darwin':
pluginEnvironment.Append(LINKFLAGS = Split('''
- -framework CoreMidi -framework CoreFoundation -framework CoreServices -framework CoreAudio
+ -framework CoreMIDI -framework CoreFoundation -framework CoreServices -framework CoreAudio
'''))
# pluginEnvironment.Append(LINKFLAGS = ['-dynamiclib'])
pluginEnvironment['SHLIBSUFFIX'] = '.dylib'
@@ -1462,8 +1463,8 @@ else:
if getPlatform() == 'win32':
csoundLuaInterface = luaWrapperEnvironment.SharedObject(
'interfaces/lua_interface.i',
- SWIGFLAGS = [swigflags, '-lua', '-module', 'luaCsnd', '-lua51', '-outdir', '.'])
- luaWrapperEnvironment.Prepend(LIBS = ['csnd','luaj51'])
+ SWIGFLAGS = [swigflags, '-lua', '-module', 'luaCsnd', '-outdir', '.'])
+ luaWrapperEnvironment.Prepend(LIBS = ['csnd','lua51'])
else:
csoundLuaInterface = luaWrapperEnvironment.SharedObject(
'interfaces/lua_interface.i',
@@ -1517,7 +1518,7 @@ else:
libs.append(javaWrapper)
jcsnd = javaWrapperEnvironment.Java(
target = './interfaces', source = './interfaces',
- JAVACFLAGS = ['-source', '1.4', '-target', '1.4'])
+ JAVACFLAGS = ['-source', '5', '-target', '5'])
try:
os.mkdir('interfaces/csnd', 0755)
except:
@@ -1737,6 +1738,8 @@ else:
if wiifound==1:
WiiEnvironment = pluginEnvironment.Clone()
makePlugin(WiiEnvironment, 'wiimote', ['Opcodes/wiimote.c'])
+ if wiiversion=='12':
+ WiiEnvironment.Append(CCFLAGS = ['-DWIIUSE_0_12'])
if p5gfound==1:
P5GEnvironment = pluginEnvironment.Clone()
makePlugin(P5GEnvironment, 'p5g', ['Opcodes/p5glove.c'])
@@ -1820,13 +1823,16 @@ else:
guiProgramEnvironment.Append(LIBS = ['dl'])
csoundProgramEnvironment.Append(LIBS = ['pthread', 'm'])
if wiifound :
+ if getPlatform() == 'darwin':
+ WiiEnvironment.Append(LIBS = ['wiiuse'])
+ else:
WiiEnvironment.Append(LIBS = ['wiiuse', 'bluetooth'])
if p5gfound :
P5GEnvironment.Append(LIBS = ['p5glove'])
vstEnvironment.Append(LIBS = ['stdc++', 'pthread', 'm'])
guiProgramEnvironment.Append(LIBS = ['stdc++', 'pthread', 'm'])
if getPlatform() == 'darwin':
- csoundProgramEnvironment.Append(LINKFLAGS = Split('''-framework Carbon -framework CoreAudio -framework CoreMidi'''))
+ csoundProgramEnvironment.Append(LINKFLAGS = Split('''-framework Carbon -framework CoreAudio -framework CoreMIDI'''))
if (not (commonEnvironment['useFLTK'] == '1' and fltkFound)):
print 'CONFIGURATION DECISION: Not building with FLTK graphs and widgets.'
@@ -2009,7 +2015,7 @@ else:
vst4Environment = vstEnvironment.Clone()
vst4Environment.Append(LIBS = ['fltk'])
vst4Environment.Append(LIBS = ['stdc++'])
- vst4Environment.Append(LINKFLAGS=['-framework', 'carbon', '-framework',
+ vst4Environment.Append(LINKFLAGS=['-framework', 'Carbon', '-framework',
'ApplicationServices'])
vst4Environment.Append(CPPPATH = ['frontends/CsoundVST'])
vst4Environment.Append(CPPFLAGS = ['-DCS_VSTHOST'])
@@ -2272,7 +2278,7 @@ def addOSXResourceFork(env, baseName, dirName):
else:
fileName = baseName
env.Command(('%s/resources' % fileName).replace('/', '_'), fileName,
- "/Developer/Tools/Rez -i APPL -o $SOURCE cs5.r")
+ "Rez -i APPL -o $SOURCE cs5.r")
csoundProgramSources = ['frontends/csound/csound_main.c']
if getPlatform() == 'linux':
@@ -2453,7 +2459,7 @@ else:
elif getPlatform() == 'darwin':
acEnvironment.Append(LIBS = ['fltk'])
acEnvironment.Append(LIBS = ['dl', 'm', 'fltk_images', 'png', 'jpeg'])
- acEnvironment.Append(SHLINKFLAGS = '--no-export-all-symbols')
+ #acEnvironment.Append(SHLINKFLAGS = '--no-export-all-symbols')
acEnvironment.Append(SHLINKFLAGS = '--add-stdcall-alias')
acEnvironment['SHLIBSUFFIX'] = '.dylib'
elif getPlatform() == 'win32':
@@ -2473,6 +2479,15 @@ else:
acEnvironment.Append(SWIGFLAGS = [option])
print 'PATH =', commonEnvironment['ENV']['PATH']
csoundAcSources = Split('''
+ frontends/CsoundAC/allegro.cpp
+ frontends/CsoundAC/allegrord.cpp
+ frontends/CsoundAC/allegroserial.cpp
+ frontends/CsoundAC/allegrosmfrd.cpp
+ frontends/CsoundAC/allegrosmfwr.cpp
+ frontends/CsoundAC/allegrowr.cpp
+ frontends/CsoundAC/mfmidi.cpp
+ frontends/CsoundAC/strparse.cpp
+ frontends/CsoundAC/trace.cpp
frontends/CsoundAC/Cell.cpp
frontends/CsoundAC/ChordLindenmayer.cpp
frontends/CsoundAC/Composition.cpp
@@ -2694,7 +2709,7 @@ if commonEnvironment['buildTclcsound'] == '1' and tclhfound:
SHLIBPREFIX = '')
if getPlatform() == 'darwin':
csTclEnvironment.Command('cswish_resources', 'cswish',
- "/Developer/Tools/Rez -i APPL -o cswish frontends/tclcsound/cswish.r")
+ "Rez -i APPL -o cswish frontends/tclcsound/cswish.r")
#if commonEnvironment['dynamicCsoundLibrary'] == '1':
# if commonEnvironment['useDouble'] == '0':
# tcloc = 'CsoundLib.framework/Resources/TclTk/'
@@ -2753,7 +2768,7 @@ if commonEnvironment['buildWinsound'] == '1' and fltkFound:
csWinEnvironment.Append(CXXFLAGS = ['-fno-rtti'])
csWinEnvironment.Append(LIBS = ['fltk', 'stdc++', 'pthread', 'm'])
csWinEnvironment.Append(LINKFLAGS = Split('''
- -framework Carbon -framework CoreAudio -framework CoreMidi
+ -framework Carbon -framework CoreAudio -framework CoreMIDI
-framework ApplicationServices
'''))
appDir = 'frontends/winsound/Winsound.app/Contents/MacOS'
@@ -2810,7 +2825,7 @@ if not (commonEnvironment['buildBeats'] != '0'):
print 'CONFIGURATION DECISION: Not building beats score frontend.'
else:
print "CONFIGURATION DECISION: Building beats score frontend"
- csBeatsEnvironment = Environment(ENV = os.environ)
+ csBeatsEnvironment = commonEnvironment.Clone()
csBeatsEnvironment.Append(LINKFLAGS = ['-lm'])
csBeatsEnvironment.Append(YACCFLAGS = ['-d'])
#csBeatsEnvironment.Append(LEXFLAGS = ['-Pbeats'])
@@ -2820,8 +2835,8 @@ else:
source = 'frontends/beats/beats.l')
bb = csBeatsEnvironment.Program('csbeats',
['frontends/beats/main.c',
- 'frontends/beats/lex.yy.c',
- 'frontends/beats/beats.tab.c'])
+ byb,
+ blb])
executables.append(bb)
if not (commonEnvironment['buildcatalog'] != '0'):
diff --git a/SuSE/csound.spec b/SuSE/csound.spec
index 69da068..03a98f0 100644
--- a/SuSE/csound.spec
+++ b/SuSE/csound.spec
@@ -2,6 +2,7 @@
# spec file for package csound
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# (c) 2012 Csound Developers
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,8 +25,8 @@ BuildRequires: alsa-devel fdupes fluidsynth-devel gcc-c++ jack-devel liblo-deve
BuildRequires: fltk-devel libjpeg-devel libpng-devel xorg-x11-devel
%endif
Summary: Computer Sound Synthesis and Composition Program
-Version: 5.16.1
-Release: 130
+Version: 5.17.2
+Release: 135
License: GFDL-1.2 ; LGPL-2.1+ ; MIT
Group: Productivity/Multimedia/Sound/Utilities
Source: Csound%{version}.tar.bz2
diff --git a/Top/argdecode.c b/Top/argdecode.c
index f7559fb..abf7002 100644
--- a/Top/argdecode.c
+++ b/Top/argdecode.c
@@ -424,8 +424,6 @@ static int decode_long(CSOUND *csound, char *s, int argc, char **argv)
}
else if (!(strcmp (s, "nodisplays"))) {
O->displays = 0; /* no func displays */
- O->graphsoff = 1;
- O->postscript = 0;
return 1;
}
else if (!(strcmp (s, "displays"))) {
@@ -1028,8 +1026,6 @@ int argdecode(CSOUND *csound, int argc, char **argv_)
break;
case 'd':
O->displays = 0; /* no func displays */
- O->graphsoff = 1;
- O->postscript = 0;
break;
case 'g':
O->graphsoff = 1; /* don't use graphics */
diff --git a/Top/cscorfns.c b/Top/cscorfns.c
index a7a46c7..e7cf957 100644
--- a/Top/cscorfns.c
+++ b/Top/cscorfns.c
@@ -172,6 +172,10 @@ PUBLIC EVLIST * cscoreListCreate(CSOUND *csound, int nslots)
int needsiz = sizeof(EVLIST) + nslots * sizeof(EVENT *);
int minfreesiz = needsiz + sizeof(CSHDR);
+ if (minfreesiz > MAXALLOC) {
+ csound->Message(csound, Str("Not enough memory\n"));
+ exit(1);
+ }
if (nxtfree != NULL && nxtfree->size >= minfreesiz)
newblk = nxtfree;
else newblk = getfree(csound, minfreesiz);
@@ -199,6 +203,10 @@ PUBLIC EVENT * cscoreCreateEvent(CSOUND *csound, int pcnt)
int needsiz = sizeof(EVENT) + pcnt * sizeof(MYFLT);
int minfreesiz = needsiz + sizeof(CSHDR);
+ if (minfreesiz > MAXALLOC) {
+ csound->Message(csound, Str("Not enough memory\n"));
+ exit(1);
+ }
if (nxtfree != NULL && nxtfree->size >= minfreesiz)
newblk = nxtfree;
else newblk = getfree(csound, minfreesiz);
@@ -941,7 +949,7 @@ PUBLIC void cscoreFileSetCurrent(CSOUND *csound, FILE *fp)
corfile_rewind(inf);
corfile_rm(&csound->scstr);
csound->scstr = inf;
- nxtevt->op = NULL;
+ nxtevt->op = '\0';
atEOF = 0;
}
if (csound->scfp != NULL)
diff --git a/Top/csmodule.c b/Top/csmodule.c
index f3c1f75..eafccbb 100644
--- a/Top/csmodule.c
+++ b/Top/csmodule.c
@@ -1344,7 +1344,7 @@ const INITFN staticmodules[] = { hrtfopcodes_localops_init, babo_localops_init,
crossfm_localops_init, pvlock_localops_init,
fareyseq_localops_init, hrtfearly_localops_init,
hrtfreverb_localops_init, minmax_localops_init,
- vaops_localops_init,
+ vaops_localops_init,
#ifndef WIN32
cpumeter_localops_init,
#endif
diff --git a/Top/csound.c b/Top/csound.c
index 67b1e45..1a4f8d2 100644
--- a/Top/csound.c
+++ b/Top/csound.c
@@ -148,6 +148,7 @@ extern "C" {
csoundSetInputValueCallback,
csoundSetOutputValueCallback,
csoundScoreEvent,
+ csoundScoreEventAbsolute,
csoundSetExternalMidiInOpenCallback,
csoundSetExternalMidiReadCallback,
csoundSetExternalMidiInCloseCallback,
@@ -961,8 +962,8 @@ extern "C" {
if (!(flags & CSOUNDINIT_NO_SIGNAL_HANDLER)) {
install_signal_handler();
}
- if (!(flags & CSOUNDINIT_NO_ATEXIT))
#if !defined(WIN32)
+ if (!(flags & CSOUNDINIT_NO_ATEXIT))
atexit(destroy_all_instances);
#endif
/*aops_init_tables();*/
@@ -1326,7 +1327,9 @@ extern "C" {
#ifdef PARCS
static int inline nodePerf(CSOUND *csound, int index)
{
- struct instr_semantics_t *instr = NULL;
+#if (TRACE&4) == 4
+ struct instr_semantics_t *instr;
+#endif
INSDS *insds = NULL;
OPDS *opstart = NULL;
int update_hdl = -1;
@@ -1342,7 +1345,9 @@ extern "C" {
}
if (node->hdr.type == DAG_NODE_INDV) {
+#if (TRACE&4) == 4
instr = node->instr;
+#endif
insds = node->insds;
played_count++;
@@ -1361,9 +1366,12 @@ extern "C" {
int node_ctr = 0;
while (node_ctr < node->count) {
DAG_NODE *play_node = node->nodes[node_ctr];
+#if (TRACE&4) == 4
instr = play_node->instr;
+#endif
insds = play_node->insds;
- TRACE_1("DAG_NODE_LIST: node->nodes=%p: play_node = %p, instr=%p, insds=%p\n",
+ TRACE_1("DAG_NODE_LIST: node->nodes=%p: play_node = %p, "
+ "instr=%p, insds=%p\n",
node->nodes, play_node, instr, insds);
TRACE_2("[%i] Playing: %s [%p]\n", index, instr->name, insds);
@@ -1478,7 +1486,7 @@ extern "C" {
int kperf(CSOUND *csound)
{
#ifdef PARCS
- void *barrier1, *barrier2;
+ /* void *barrier1, *barrier2; */
INSDS *ip;
#endif /* PARCS */
/* update orchestra time */
@@ -1549,8 +1557,8 @@ extern "C" {
#endif
}
#else /* PARCS */
- barrier1 = csound->multiThreadedBarrier1;
- barrier2 = csound->multiThreadedBarrier2;
+ /* barrier1 = csound->multiThreadedBarrier1; */
+ /* barrier2 = csound->multiThreadedBarrier2; */
ip = csound->actanchor.nxtact;
if (ip != NULL) {
@@ -2096,8 +2104,22 @@ extern "C" {
evt.p[i + 1] = pfields[i];
//memcpy(&evt.p[1],pfields, numFields*sizeof(MYFLT));
return insert_score_event_at_sample(csound, &evt, csound->icurTime);
- }
+ }
+ PUBLIC int csoundScoreEventAbsolute(CSOUND *csound, char type,
+ const MYFLT *pfields, long numFields,
+ double time_ofs)
+ {
+ EVTBLK evt;
+ int i;
+
+ evt.strarg = NULL;
+ evt.opcod = type;
+ evt.pcnt = (int16) numFields;
+ for (i = 0; i < (int) numFields; i++)
+ evt.p[i + 1] = pfields[i];
+ return insert_score_event(csound, &evt, time_ofs);
+ }
/*
* REAL-TIME AUDIO
@@ -2626,9 +2648,9 @@ extern "C" {
void *p1, *p2;
uintptr_t length;
int n = 0;
-
+
csoundCleanup(csound);
-
+
/* call registered reset callbacks */
while (csound->reset_list != NULL) {
resetCallback_t *p = (resetCallback_t*) csound->reset_list;
@@ -2639,12 +2661,12 @@ extern "C" {
/* call local destructor routines of external modules */
/* should check return value... */
csoundDestroyModules(csound);
-
+
/* IV - Feb 01 2005: clean up configuration variables and */
/* named dynamic "global" variables of Csound instance */
csoundDeleteAllConfigurationVariables(csound);
csoundDeleteAllGlobalVariables(csound);
-
+
#ifdef CSCORE
cscoreRESET(csound);
#endif
@@ -2658,6 +2680,8 @@ extern "C" {
remove_tmpfiles(csound);
rlsmemfiles(csound);
memRESET(csound);
+ while (csound->filedir[n]) /* Clear source directory */
+ free(csound->filedir[n++]);
/**
* Copy everything EXCEPT the function pointers.
* We do it by saving them and copying them back again...
@@ -2678,9 +2702,6 @@ extern "C" {
memcpy(&(csound->exitjmp), &(saved_env->exitjmp), sizeof(jmp_buf));
csound->memalloc_db = saved_env->memalloc_db;
free(saved_env);
- while (csound->filedir[n]) /* Clear source directoiry */
- free(csound->filedir[n++]);
-
}
PUBLIC int csoundGetDebug(CSOUND *csound)
@@ -3715,4 +3736,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
diff --git a/Top/getstring.c b/Top/getstring.c
index aebba22..4f01821 100644
--- a/Top/getstring.c
+++ b/Top/getstring.c
@@ -43,6 +43,7 @@ int closedir(DIR*);
#ifndef GNU_GETTEXT
void init_getstring(void)
{
+ setlocale(LC_NUMERIC, "C"); /* Ensure C syntax */
}
PUBLIC char *csoundLocalizeString(const char *s)
{
@@ -67,6 +68,7 @@ void init_getstring(void)
/* This is experimental; where should these be?? */
bindtextdomain("csound5", "/home/jpff/Sourceforge/csound/csound5/po");
#endif
+ setlocale(LC_NUMERIC, "C"); /* Ensure C syntax */
}
PUBLIC char *csoundLocalizeString(const char *s)
diff --git a/Top/one_file.c b/Top/one_file.c
index 1a427cc..b61ced1 100644
--- a/Top/one_file.c
+++ b/Top/one_file.c
@@ -110,10 +110,16 @@ CS_NOINLINE char *csoundTmpFileName(CSOUND *csound, char *buf, const char *ext)
// if (UNLIKELY(mytmpnam(buf) == NULL))
// csound->Die(csound, Str(" *** cannot create temporary file"));
int fd;
- strcpy(buf, "/tmp/csoundXXXXXX");
+ char *tmpdir = getenv("TMPDIR");
+ if (tmpdir != NULL && tmpdir[0] != '\0')
+ snprintf(buf, nBytes, "%s/csound-XXXXXX", tmpdir);
+ else
+ strcpy(buf, "/tmp/csound-XXXXXX");
+ umask(0077); /* ensure exclusive access on buggy implementations of mkstemp */
if (UNLIKELY((fd = mkstemp(buf)) < 0))
csound->Die(csound, Str(" *** cannot create temporary file"));
close(fd);
+ unlink(buf);
#else
{
char *s = (char*) csoundGetEnv(csound, "SFDIR");
@@ -359,7 +365,7 @@ static int createOrchestra(CSOUND *csound, FILE *unf)
csound->orchstr = incore;
return TRUE;
}
- else
+ else
corfile_puts(buffer, incore);
}
csoundErrorMsg(csound, Str("Missing end tag </CsInstruments>"));
@@ -381,7 +387,7 @@ static int createScore(CSOUND *csound, FILE *unf)
csound->scorestr = incore;
return TRUE;
}
- else
+ else
corfile_puts(buffer, incore);
}
csoundErrorMsg(csound, Str("Missing end tag </CsScore>"));
@@ -430,6 +436,8 @@ static int createExScore(CSOUND *csound, char *p, FILE *unf)
sprintf(sys, "%s %s %s", prog, extname, ST(sconame));
if (UNLIKELY(system(sys) != 0)) {
csoundErrorMsg(csound, Str("External generation failed"));
+ remove(extname);
+ remove(ST(sconame));
return FALSE;
}
remove(extname);
@@ -800,7 +808,7 @@ int read_unified_file(CSOUND *csound, char **pname, char **score)
result = r && result;
}
else if (blank_buffer(csound, buffer)) continue;
- else if (started && strchr(p, '<') == buffer){
+ else if (started && strchr(p, '<') == buffer){
csoundMessage(csound, Str("unknown CSD tag: %s\n"), buffer);
}
}
@@ -818,4 +826,3 @@ int read_unified_file(CSOUND *csound, char **pname, char **score)
csoundFileClose(csound, fd);
return result;
}
-
diff --git a/Top/threads.c b/Top/threads.c
index 32d7b19..66e08e5 100644
--- a/Top/threads.c
+++ b/Top/threads.c
@@ -33,10 +33,6 @@
#include "csoundCore.h"
#include "csGblMtx.h"
-static CS_NOINLINE void notImplementedWarning_(const char *name)
-{
- fprintf(stderr, Str("%s() is not implemented on this platform.\n"), name);
-}
#if defined(WIN32)
#include <windows.h>
@@ -91,6 +87,11 @@ PUBLIC void csoundSleep(size_t milliseconds)
#elif defined(mac_classic)
+static CS_NOINLINE void notImplementedWarning_(const char *name)
+{
+ fprintf(stderr, Str("%s() is not implemented on this platform.\n"), name);
+}
+
PUBLIC long csoundRunCommand(const char * const *argv, int noWait)
{
notImplementedWarning_("csoundRunCommand");
@@ -181,7 +182,7 @@ PUBLIC void csoundSleep(size_t milliseconds)
#define BARRIER_SERIAL_THREAD (-1)
-#if !defined(HAVE_PTHREAD_BARRIER_INIT)
+#if !defined(HAVE_PTHREAD_BARRIER_INIT)
#ifndef __MACH__
typedef struct barrier {
@@ -550,6 +551,11 @@ PUBLIC void csoundDestroyMutex(void *mutex_)
#else
+static CS_NOINLINE void notImplementedWarning_(const char *name)
+{
+ fprintf(stderr, Str("%s() is not implemented on this platform.\n"), name);
+}
+
PUBLIC void *csoundCreateThread(uintptr_t (*threadRoutine)(void *),
void *userdata)
{
diff --git a/all_string_files b/all_string_files
index aae4bcd..09122b3 100644
--- a/all_string_files
+++ b/all_string_files
@@ -328,6 +328,7 @@
./Opcodes/bowed.h
./Opcodes/brass.h
./Opcodes/butter.c
+./Opcodes/cellular.c
./Opcodes/chua/ChuaOscillator.cpp
./Opcodes/clarinet.h
./Opcodes/clfilt.c
@@ -336,55 +337,10 @@
./Opcodes/control.c
./Opcodes/control.h
./Opcodes/cpumeter.c
-./Opcodes/cpupercent.c
./Opcodes/cross2.c
./Opcodes/crossfm.c
./Opcodes/crossfm.h
-./Opcodes/dam.c
-./Opcodes/dam.h
-./Opcodes/date.c
-./Opcodes/dcblockr.c
-./Opcodes/dcblockr.h
-./Opcodes/doppler.cpp
-./Opcodes/dsputil.c
-./Opcodes/dsputil.h
-./Opcodes/dssi4cs/src/dssi4cs.c
-./Opcodes/dssi4cs/src/dssi4cs.h
-./Opcodes/dssi4cs/src/dssi.h
-./Opcodes/dssi4cs/src/ladspa.h
-./Opcodes/dssi4cs/src/load.c
-./Opcodes/dssi4cs/src/seq_event.h
-./Opcodes/dssi4cs/src/utils.h
-./Opcodes/eqfil.c
-./Opcodes/fareygen.c
-./Opcodes/fareyseq.c
-./Opcodes/fhtfun.h
-./Opcodes/filter.c
-./Opcodes/filter.h
-./Opcodes/flanger.c
-./Opcodes/flanger.h
-./Opcodes/fluidOpcodes/fluidOpcodes.c
-./Opcodes/fluidOpcodes/fluidOpcodes.cpp
-./Opcodes/fluidOpcodes/fluidOpcodes.h
-./Opcodes/flute.h
-./Opcodes/fm4op.c
-./Opcodes/fm4op.h
-./Opcodes/follow.c
-./Opcodes/follow.h
-./Opcodes/fout.c
-./Opcodes/fout.h
-./Opcodes/freeverb.c
-./Opcodes/ftconv.c
-./Opcodes/ftest.c
-./Opcodes/ftgen.c
-./Opcodes/gab/gab.c
-./Opcodes/gab/gab.h
-./Opcodes/gab/hvs.c
-./Opcodes/gab/newgabopc.c
-./Opcodes/gab/radiobaton.c
-./Opcodes/gab/sliderTable.c
-./Opcodes/gab/tabmorph.c
-./Opcodes/gab/vectorial.c
+./Opcodes/gendy.c
./Opcodes/gab/vectorial.h
./Opcodes/grain4.c
./Opcodes/grain4.h
@@ -426,7 +382,6 @@
./Opcodes/moog1.c
./Opcodes/moog1.h
./Opcodes/mp3in.c
-./Opcodes/mutexops.cpp
./Opcodes/newfils.c
./Opcodes/newfils.h
./Opcodes/nlfilt.c
@@ -452,7 +407,6 @@
./Opcodes/pitchtrack.c
./Opcodes/pluck.c
./Opcodes/pluck.h
-./Opcodes/ppp.c
./Opcodes/psynth.c
./Opcodes/ptrigtbl.h
./Opcodes/pvadd.c
@@ -524,6 +478,8 @@
./Opcodes/system_call.c
./Opcodes/tabsum.c
./Opcodes/tabvars.c
+./Opcodes/tl/fractalnoise.cpp
+./Opcodes/tl/sc_noise.c
./Opcodes/ugakbari.c
./Opcodes/ugens7.c
./Opcodes/ugens8.c
diff --git a/COPYING b/android/COPYING
similarity index 100%
copy from COPYING
copy to android/COPYING
diff --git a/android/CSDPlayer/.classpath b/android/CSDPlayer/.classpath
new file mode 100644
index 0000000..a4763d1
--- /dev/null
+++ b/android/CSDPlayer/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/android/CSDPlayer/.gitignore b/android/CSDPlayer/.gitignore
new file mode 100644
index 0000000..91e378c
--- /dev/null
+++ b/android/CSDPlayer/.gitignore
@@ -0,0 +1,10 @@
+*DS_Store
+obj
+libs
+bin
+gen
+src/csnd*
+*swp
+jni/csound_orc*
+jni/csound_prelex.c
+jni/java_interface*
diff --git a/android/CSDPlayer/.project b/android/CSDPlayer/.project
new file mode 100644
index 0000000..d0336f8
--- /dev/null
+++ b/android/CSDPlayer/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CsoundApp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/android/CSDPlayer/AndroidManifest.xml b/android/CSDPlayer/AndroidManifest.xml
new file mode 100644
index 0000000..cc4a49b
--- /dev/null
+++ b/android/CSDPlayer/AndroidManifest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.csounds.CsoundApp"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk android:minSdkVersion="9" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:label="@string/app_name"
+ android:name=".CsoundAppActivity" >
+ <intent-filter >
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
\ No newline at end of file
diff --git a/COPYING b/android/CSDPlayer/COPYING
similarity index 100%
copy from COPYING
copy to android/CSDPlayer/COPYING
diff --git a/android/CSDPlayer/proguard.cfg b/android/CSDPlayer/proguard.cfg
new file mode 100644
index 0000000..b1cdf17
--- /dev/null
+++ b/android/CSDPlayer/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/android/CSDPlayer/project.properties b/android/CSDPlayer/project.properties
new file mode 100644
index 0000000..72d5245
--- /dev/null
+++ b/android/CSDPlayer/project.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-9
+android.library.reference.1=../CsoundAndroid
diff --git a/android/CSDPlayer/res/drawable-hdpi/directory_icon.png b/android/CSDPlayer/res/drawable-hdpi/directory_icon.png
new file mode 100755
index 0000000..b32dc34
Binary files /dev/null and b/android/CSDPlayer/res/drawable-hdpi/directory_icon.png differ
diff --git a/android/CSDPlayer/res/drawable-hdpi/directory_up.png b/android/CSDPlayer/res/drawable-hdpi/directory_up.png
new file mode 100755
index 0000000..29f2710
Binary files /dev/null and b/android/CSDPlayer/res/drawable-hdpi/directory_up.png differ
diff --git a/android/CSDPlayer/res/drawable-hdpi/file_icon.png b/android/CSDPlayer/res/drawable-hdpi/file_icon.png
new file mode 100755
index 0000000..912399b
Binary files /dev/null and b/android/CSDPlayer/res/drawable-hdpi/file_icon.png differ
diff --git a/android/CSDPlayer/res/drawable-hdpi/ic_launcher.png b/android/CSDPlayer/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..8074c4c
Binary files /dev/null and b/android/CSDPlayer/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/CSDPlayer/res/drawable-hdpi/icon.png b/android/CSDPlayer/res/drawable-hdpi/icon.png
new file mode 100755
index 0000000..8074c4c
Binary files /dev/null and b/android/CSDPlayer/res/drawable-hdpi/icon.png differ
diff --git a/android/CSDPlayer/res/drawable-ldpi/ic_launcher.png b/android/CSDPlayer/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..1095584
Binary files /dev/null and b/android/CSDPlayer/res/drawable-ldpi/ic_launcher.png differ
diff --git a/android/CSDPlayer/res/drawable-ldpi/icon.png b/android/CSDPlayer/res/drawable-ldpi/icon.png
new file mode 100755
index 0000000..1095584
Binary files /dev/null and b/android/CSDPlayer/res/drawable-ldpi/icon.png differ
diff --git a/android/CSDPlayer/res/drawable-mdpi/ic_launcher.png b/android/CSDPlayer/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..a07c69f
Binary files /dev/null and b/android/CSDPlayer/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/CSDPlayer/res/drawable-mdpi/icon.png b/android/CSDPlayer/res/drawable-mdpi/icon.png
new file mode 100755
index 0000000..a07c69f
Binary files /dev/null and b/android/CSDPlayer/res/drawable-mdpi/icon.png differ
diff --git a/android/CSDPlayer/res/layout/main.xml b/android/CSDPlayer/res/layout/main.xml
new file mode 100644
index 0000000..0ca5f2c
--- /dev/null
+++ b/android/CSDPlayer/res/layout/main.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/linearLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/browseButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Browse" />
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="ToggleButton" />
+
+ <SeekBar
+ android:id="@+id/seekBar1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="slider1"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <SeekBar
+ android:id="@+id/seekBar2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="slider2"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <SeekBar
+ android:id="@+id/seekBar3"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="slider3"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <SeekBar
+ android:id="@+id/seekBar4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="slider4"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <SeekBar
+ android:id="@+id/seekBar5"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="slider5"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <TextView
+ android:id="@+id/textView6"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="---------------------------------------"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+<LinearLayout
+ android:id="@+id/LinearLayout02"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true" >
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.52"
+ android:text="butt1" />
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.60"
+ android:text="butt2" />
+
+ <Button
+ android:id="@+id/button3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.79"
+ android:text="butt3" />
+
+ <Button
+ android:id="@+id/button4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.70"
+ android:text="butt4" />
+
+ <Button
+ android:id="@+id/button5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.34"
+ android:text="butt5" />
+</LinearLayout>
+
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/pad"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="trackpad" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/CSDPlayer/res/values/strings.xml b/android/CSDPlayer/res/values/strings.xml
new file mode 100644
index 0000000..e15c162
--- /dev/null
+++ b/android/CSDPlayer/res/values/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, CsoundAppActivity!</string>
+ <string name="app_name">CSD Player</string>
+
+</resources>
\ No newline at end of file
diff --git a/android/CSDPlayer/src/com/csounds/CsoundApp/CsoundAppActivity.java b/android/CSDPlayer/src/com/csounds/CsoundApp/CsoundAppActivity.java
new file mode 100644
index 0000000..3ba29d2
--- /dev/null
+++ b/android/CSDPlayer/src/com/csounds/CsoundApp/CsoundAppActivity.java
@@ -0,0 +1,260 @@
+package com.csounds.CsoundApp;
+
+import java.io.File;
+import java.util.ArrayList;
+import com.csounds.CsoundApp.R;
+
+import java.io.FilenameFilter;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CompoundButton;
+import android.widget.ListAdapter;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+
+public class CsoundAppActivity extends Activity implements CsoundObjCompletionListener {
+ Button browseButton;
+ ToggleButton startStopButton = null;
+ CsoundObj csound = null;
+ File csd = null;
+ Button pad;
+ ArrayList<SeekBar> sliders = new ArrayList<SeekBar>();
+ ArrayList<Button> buttons = new ArrayList<Button>();
+ ArrayList<String> str = new ArrayList<String>();
+ private Boolean firstLvl = true;
+ private Item[] fileList;
+ private File path = new File(Environment.getExternalStorageDirectory() + "");
+ private String chosenFile;
+ private static final int BROWSE_DIALOG = 0xFFFFFFFF;
+ private static final int ERROR_DIALOG = 0xFFFFFFF0;
+ ListAdapter adapter;
+ protected Handler handler = new Handler();
+ boolean running = false;
+ String errorMessage;
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ if(csound.getError() != 0) displayError(csound.getError());
+ running = false;
+ }
+ });
+ }
+
+ private void displayError(int error){
+ errorMessage = "Csound Compilation Error " + error;
+ showDialog(ERROR_DIALOG);
+ }
+
+ private void OnFileChosen(File file){
+ Log.d("FILE CHOSEN", file.getAbsolutePath());
+ csd = file;
+ }
+
+ @Override
+ protected void onDestroy() {
+ // TODO Auto-generated method stub
+ super.onDestroy();
+ try {
+ csound.stopCsound();
+ } catch (Exception e){
+ Log.e("error", "could not stop csound");
+ }
+
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ browseButton = (Button) findViewById(R.id.browseButton);
+ browseButton.setOnClickListener(new OnClickListener(){
+ @Override
+ public void onClick(View v){
+ if(!running) {
+ loadFileList();
+ showDialog(BROWSE_DIALOG);
+ }
+ }
+ });
+
+ sliders.add((SeekBar)findViewById(R.id.seekBar1));
+ sliders.add((SeekBar)findViewById(R.id.seekBar2));
+ sliders.add((SeekBar)findViewById(R.id.seekBar3));
+ sliders.add((SeekBar)findViewById(R.id.seekBar4));
+ sliders.add((SeekBar)findViewById(R.id.seekBar5));
+
+ buttons.add((Button)findViewById(R.id.button1));
+ buttons.add((Button)findViewById(R.id.button2));
+ buttons.add((Button)findViewById(R.id.button3));
+ buttons.add((Button)findViewById(R.id.button4));
+ buttons.add((Button)findViewById(R.id.button5));
+
+ pad = (Button)findViewById(R.id.pad);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+ startStopButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (csd == null) {
+ buttonView.toggle();
+ return;
+ }
+ Log.d("CSD", csd.getAbsolutePath());
+ if(isChecked) {
+ csound = new CsoundObj();
+ String channelName;
+ for(int i = 0; i < 5; i++){
+ channelName = "slider" + (i+1);
+ csound.addSlider(sliders.get(i),channelName, 0., 1.);
+ channelName = "butt" + (i+1);
+ csound.addButton(buttons.get(i),channelName, 1);
+ }
+ csound.addButton(pad,"trackpad", 1);
+ csound.enableAccelerometer(CsoundAppActivity.this);
+ csound.addCompletionListener(CsoundAppActivity.this);
+ csound.startCsound(csd);
+
+ } else {
+ csound.stopCsound();
+ running = false;
+ }
+ }
+ });
+ }
+ private void loadFileList() {
+ try {
+ path.mkdirs();
+ } catch (SecurityException e) {
+ Log.e("error", "unable to write on the sd card ");
+ }
+
+ if (path.exists()) {
+ FilenameFilter filter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String filename) {
+ File sel = new File(dir, filename);
+ return (sel.isFile() || sel.isDirectory())
+ && !sel.isHidden();
+ }
+ };
+
+ String[] fList = path.list(filter);
+ fileList = new Item[fList.length];
+ for (int i = 0; i < fList.length; i++) {
+ fileList[i] = new Item(fList[i], R.drawable.file_icon);
+ File sel = new File(path, fList[i]);
+ if (sel.isDirectory()) {
+ fileList[i].icon = R.drawable.directory_icon;
+ }
+ }
+ if (!firstLvl) {
+ Item temp[] = new Item[fileList.length + 1];
+ for (int i = 0; i < fileList.length; i++) {
+ temp[i + 1] = fileList[i];
+ }
+ temp[0] = new Item("Up", R.drawable.directory_up);
+ fileList = temp;
+ }
+ }
+ adapter = new ArrayAdapter<Item>(this,
+ android.R.layout.select_dialog_item, android.R.id.text1,
+ fileList) {
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = super.getView(position, convertView, parent);
+ TextView textView = (TextView) view
+ .findViewById(android.R.id.text1);
+ textView.setCompoundDrawablesWithIntrinsicBounds(
+ fileList[position].icon, 0, 0, 0);
+ int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
+ textView.setCompoundDrawablePadding(dp5);
+ return view;
+ }
+ };
+ }
+
+ private class Item {
+ public String file;
+ public int icon;
+ public Item(String file, Integer icon) {
+ this.file = file;
+ this.icon = icon;
+ }
+
+ @Override
+ public String toString() {
+ return file;
+ }
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ Dialog dialog = null;
+ AlertDialog.Builder builder = new Builder(this);
+ if (fileList == null) {
+ dialog = builder.create();
+ return dialog;
+ }
+
+ switch (id) {
+ case BROWSE_DIALOG:
+ builder.setTitle("Choose your file");
+ builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ chosenFile = fileList[which].file;
+ File sel = new File(path + "/" + chosenFile);
+ if (sel.isDirectory()) {
+ firstLvl = false;
+ str.add(chosenFile);
+ fileList = null;
+ path = new File(sel + "");
+ loadFileList();
+ removeDialog(BROWSE_DIALOG);
+ showDialog(BROWSE_DIALOG);
+ }
+ else if (chosenFile.equalsIgnoreCase("up") && !sel.exists()) {
+ String s = str.remove(str.size() - 1);
+ path = new File(path.toString().substring(0,
+ path.toString().lastIndexOf(s)));
+ fileList = null;
+ if (str.isEmpty()) {
+ firstLvl = true;
+ }
+ loadFileList();
+ removeDialog(BROWSE_DIALOG);
+ showDialog(BROWSE_DIALOG);
+ }
+ else OnFileChosen(sel);
+ }
+ });
+ break;
+ case ERROR_DIALOG:
+ builder.setTitle(errorMessage);
+ break;
+ }
+ dialog = builder.show();
+ return dialog;
+ }
+}
\ No newline at end of file
diff --git a/android/CsoundAndroid/.classpath b/android/CsoundAndroid/.classpath
new file mode 100644
index 0000000..a4763d1
--- /dev/null
+++ b/android/CsoundAndroid/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/android/CsoundAndroid/.gitignore b/android/CsoundAndroid/.gitignore
new file mode 100644
index 0000000..91e378c
--- /dev/null
+++ b/android/CsoundAndroid/.gitignore
@@ -0,0 +1,10 @@
+*DS_Store
+obj
+libs
+bin
+gen
+src/csnd*
+*swp
+jni/csound_orc*
+jni/csound_prelex.c
+jni/java_interface*
diff --git a/android/CsoundAndroid/.project b/android/CsoundAndroid/.project
new file mode 100644
index 0000000..369db1e
--- /dev/null
+++ b/android/CsoundAndroid/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CsoundAndroid</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/android/CsoundAndroid/AndroidManifest.xml b/android/CsoundAndroid/AndroidManifest.xml
new file mode 100644
index 0000000..9f0d80f
--- /dev/null
+++ b/android/CsoundAndroid/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.csounds"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:installLocation="auto">
+
+ <uses-sdk android:minSdkVersion="9" />
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <!-- MODIFY_AUDIO_SETTINGS is needed to use audio effects such as environmental reverb -->
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+</manifest>
\ No newline at end of file
diff --git a/COPYING b/android/CsoundAndroid/COPYING
similarity index 100%
copy from COPYING
copy to android/CsoundAndroid/COPYING
diff --git a/android/CsoundAndroid/android_interface.i b/android/CsoundAndroid/android_interface.i
new file mode 100644
index 0000000..fc7d2ed
--- /dev/null
+++ b/android/CsoundAndroid/android_interface.i
@@ -0,0 +1,73 @@
+/*
+* C S O U N D
+*
+* External language interfaces for the "C" Csound API.
+*
+* L I C E N S E
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+%module(directors="1") csnd
+
+%feature("director") CsoundCallbackWrapper;
+%feature("nodirector") Csound;
+%include "typemaps.i"
+%include "std_string.i"
+%include "std_vector.i"
+%feature("autodoc", "1");
+%{
+ #include "csound.h"
+ #include "cfgvar.h"
+ #include "csound.hpp"
+ #include "AndroidCsound.hpp"
+ #include "cs_glue.hpp"
+ #include "csPerfThread.hpp"
+ #include "CsoundFile.hpp"
+ #include "CppSound.hpp"
+ #include "Soundfile.hpp"
+%}
+
+%apply int { size_t };
+typedef unsigned int uint32_t;
+
+/* %typemap(freearg) char ** {
+ free((char *) $1);
+} */
+
+// Enable the JNI class to load the required native library.
+%pragma(java) jniclasscode=%{
+ static {
+ try {
+ java.lang.System.loadLibrary("csoundandroid");
+ } catch (UnsatisfiedLinkError e) {
+ java.lang.System.err.println("csoundandroid native code library failed to load.\n" + e);
+ java.lang.System.exit(1);
+ }
+ }
+%}
+
+%include "exclusions.i"
+
+%include "csound.h"
+%include "cfgvar.h"
+%include "csound.hpp"
+%include "AndroidCsound.hpp"
+%include "cs_glue.hpp"
+%include "csPerfThread.hpp"
+%include "CsoundFile.hpp"
+%include "CppSound.hpp"
+%include "Soundfile.hpp"
+
diff --git a/android/CsoundAndroid/build.sh b/android/CsoundAndroid/build.sh
new file mode 100755
index 0000000..49b7bd9
--- /dev/null
+++ b/android/CsoundAndroid/build.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export ANDROID_NDK_ROOT=$HOME/work/android-ndk-r7
+export NDK_MODULE_PATH=../../../android
+flex -B -t ../../Engine/csound_orc.l > jni/csound_orclex.c
+flex -B ../../Engine/csound_pre.lex > jni/csound_prelex.c
+bison -d -pcsound_orc --report=itemset -o jni/csound_orcparse.c ../../Engine/csound_orc.y
+
+rm -rf src/csnd
+mkdir -p src/csnd
+
+swig -java -package csnd -D__BUILDING_LIBCSOUND -DENABLE_NEW_PARSER -DPARCS -DHAVE_DIRENT_H -DHAVE_FCNTL_H -DHAVE_UNISTD_H -DHAVE_STDINT_H -DHAVE_SYS_TIME_H -DHAVE_SYS_TYPES_H -DHAVE_TERMIOS_H -includeall -verbose -outdir src/csnd -c++ -I/usr/local/include -I../../H -I../../Engine -I../.. -I../../interfaces -I/System/Library/Frameworks/Python.framework/Headers -I/System/Library/Frameworks/JavaVM.framework/Headers -I./jni -o jni/java_interfaceJAVA_wrap.cpp android_interface.i
+
+# ADJUST SWIG CODE FOR ANDROID and DIRECTORS
+sed -i "" 's/AttachCurrentThread((void \*\*)/AttachCurrentThread(/' jni/java_interfaceJAVA_wrap.cpp
+
+$ANDROID_NDK_ROOT/ndk-build TARGET_PLATFORM=android-9
+
+
+
diff --git a/android/CsoundAndroid/jni/Android.mk b/android/CsoundAndroid/jni/Android.mk
new file mode 100644
index 0000000..0fd820a
--- /dev/null
+++ b/android/CsoundAndroid/jni/Android.mk
@@ -0,0 +1,242 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+CSOUND_SRC_ROOT := ../../..
+LIBSNDFILE_SRC_DIR := $(LOCAL_PATH)/../../../../android/libsndfile-android/jni/
+
+LOCAL_MODULE := csoundandroid
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../H $(LOCAL_PATH)/../../../ $(LIBSNDFILE_SRC_DIR) $(LOCAL_PATH)/../../../Engine $(LOCAL_PATH)/../../../interfaces
+LOCAL_CFLAGS := -O3 -D__BUILDING_LIBCSOUND -DENABLE_NEW_PARSER -DLINUX -DHAVE_DIRENT_H -DHAVE_FCNTL_H -DHAVE_UNISTD_H -DHAVE_STDINT_H -DHAVE_SYS_TIME_H -DHAVE_SYS_TYPES_H -DHAVE_TERMIOS_H
+LOCAL_CPPFLAGS :=$(LOCAL_CFLAGS)
+###
+
+LOCAL_SRC_FILES := $(CSOUND_SRC_ROOT)/Engine/auxfd.c \
+$(CSOUND_SRC_ROOT)/Engine/cfgvar.c \
+$(CSOUND_SRC_ROOT)/Engine/corfiles.c \
+$(CSOUND_SRC_ROOT)/Engine/entry1.c \
+$(CSOUND_SRC_ROOT)/Engine/envvar.c \
+$(CSOUND_SRC_ROOT)/Engine/express.c \
+$(CSOUND_SRC_ROOT)/Engine/extract.c \
+$(CSOUND_SRC_ROOT)/Engine/fgens.c \
+$(CSOUND_SRC_ROOT)/Engine/insert.c \
+$(CSOUND_SRC_ROOT)/Engine/linevent.c \
+$(CSOUND_SRC_ROOT)/Engine/memalloc.c \
+$(CSOUND_SRC_ROOT)/Engine/memfiles.c \
+$(CSOUND_SRC_ROOT)/Engine/musmon.c \
+$(CSOUND_SRC_ROOT)/Engine/namedins.c \
+$(CSOUND_SRC_ROOT)/Engine/otran.c \
+$(CSOUND_SRC_ROOT)/Engine/rdorch.c \
+$(CSOUND_SRC_ROOT)/Engine/rdscor.c \
+$(CSOUND_SRC_ROOT)/Engine/scsort.c \
+$(CSOUND_SRC_ROOT)/Engine/scxtract.c \
+$(CSOUND_SRC_ROOT)/Engine/sort.c \
+$(CSOUND_SRC_ROOT)/Engine/sread.c \
+$(CSOUND_SRC_ROOT)/Engine/swrite.c \
+$(CSOUND_SRC_ROOT)/Engine/swritestr.c \
+$(CSOUND_SRC_ROOT)/Engine/twarp.c \
+$(CSOUND_SRC_ROOT)/InOut/libsnd.c \
+$(CSOUND_SRC_ROOT)/InOut/libsnd_u.c \
+$(CSOUND_SRC_ROOT)/InOut/midifile.c \
+$(CSOUND_SRC_ROOT)/InOut/midirecv.c \
+$(CSOUND_SRC_ROOT)/InOut/midisend.c \
+$(CSOUND_SRC_ROOT)/InOut/winascii.c \
+$(CSOUND_SRC_ROOT)/InOut/windin.c \
+$(CSOUND_SRC_ROOT)/InOut/window.c \
+$(CSOUND_SRC_ROOT)/InOut/winEPS.c \
+$(CSOUND_SRC_ROOT)/OOps/aops.c \
+$(CSOUND_SRC_ROOT)/OOps/bus.c \
+$(CSOUND_SRC_ROOT)/OOps/cmath.c \
+$(CSOUND_SRC_ROOT)/OOps/diskin.c \
+$(CSOUND_SRC_ROOT)/OOps/diskin2.c \
+$(CSOUND_SRC_ROOT)/OOps/disprep.c \
+$(CSOUND_SRC_ROOT)/OOps/dumpf.c \
+$(CSOUND_SRC_ROOT)/OOps/fftlib.c \
+$(CSOUND_SRC_ROOT)/OOps/goto_ops.c \
+$(CSOUND_SRC_ROOT)/OOps/midiinterop.c \
+$(CSOUND_SRC_ROOT)/OOps/midiops.c \
+$(CSOUND_SRC_ROOT)/OOps/midiout.c \
+$(CSOUND_SRC_ROOT)/OOps/mxfft.c \
+$(CSOUND_SRC_ROOT)/OOps/oscils.c \
+$(CSOUND_SRC_ROOT)/OOps/pstream.c \
+$(CSOUND_SRC_ROOT)/OOps/pvfileio.c \
+$(CSOUND_SRC_ROOT)/OOps/pvsanal.c \
+$(CSOUND_SRC_ROOT)/OOps/random.c \
+$(CSOUND_SRC_ROOT)/OOps/remote.c \
+$(CSOUND_SRC_ROOT)/OOps/schedule.c \
+$(CSOUND_SRC_ROOT)/OOps/sndinfUG.c \
+$(CSOUND_SRC_ROOT)/OOps/str_ops.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens1.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens2.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens2a.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens3.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens4.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens5.c \
+$(CSOUND_SRC_ROOT)/OOps/ugens6.c \
+$(CSOUND_SRC_ROOT)/OOps/ugrw1.c \
+$(CSOUND_SRC_ROOT)/OOps/ugrw2.c \
+$(CSOUND_SRC_ROOT)/OOps/vdelay.c \
+$(CSOUND_SRC_ROOT)/Opcodes/babo.c \
+$(CSOUND_SRC_ROOT)/Opcodes/bilbar.c \
+$(CSOUND_SRC_ROOT)/Opcodes/compress.c \
+$(CSOUND_SRC_ROOT)/Opcodes/eqfil.c \
+$(CSOUND_SRC_ROOT)/Opcodes/Vosim.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pitch.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pitch0.c \
+$(CSOUND_SRC_ROOT)/Opcodes/spectra.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ambicode1.c \
+$(CSOUND_SRC_ROOT)/Opcodes/sfont.c \
+$(CSOUND_SRC_ROOT)/Opcodes/grain4.c \
+$(CSOUND_SRC_ROOT)/Opcodes/hrtferX.c \
+$(CSOUND_SRC_ROOT)/Opcodes/loscilx.c \
+$(CSOUND_SRC_ROOT)/Opcodes/minmax.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pan2.c \
+$(CSOUND_SRC_ROOT)/Opcodes/tabvars.c \
+$(CSOUND_SRC_ROOT)/Opcodes/phisem.c \
+$(CSOUND_SRC_ROOT)/Opcodes/hrtfopcodes.c \
+$(CSOUND_SRC_ROOT)/Opcodes/stackops.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vbap.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vbap_eight.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vbap_four.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vbap_sixteen.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vbap_zak.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vaops.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugakbari.c \
+$(CSOUND_SRC_ROOT)/Opcodes/harmon.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pitchtrack.c \
+$(CSOUND_SRC_ROOT)/Opcodes/partikkel.c \
+$(CSOUND_SRC_ROOT)/Opcodes/shape.c \
+$(CSOUND_SRC_ROOT)/Opcodes/tabsum.c \
+$(CSOUND_SRC_ROOT)/Opcodes/crossfm.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvlock.c \
+$(CSOUND_SRC_ROOT)/Opcodes/fareyseq.c \
+$(CSOUND_SRC_ROOT)/Opcodes/modmatrix.c \
+$(CSOUND_SRC_ROOT)/Opcodes/scoreline.c \
+$(CSOUND_SRC_ROOT)/Opcodes/modal4.c \
+$(CSOUND_SRC_ROOT)/Opcodes/physutil.c \
+$(CSOUND_SRC_ROOT)/Opcodes/physmod.c \
+$(CSOUND_SRC_ROOT)/Opcodes/mandolin.c \
+$(CSOUND_SRC_ROOT)/Opcodes/singwave.c \
+$(CSOUND_SRC_ROOT)/Opcodes/fm4op.c \
+$(CSOUND_SRC_ROOT)/Opcodes/moog1.c \
+$(CSOUND_SRC_ROOT)/Opcodes/shaker.c \
+$(CSOUND_SRC_ROOT)/Opcodes/bowedbar.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/tabmorph.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/hvs.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/sliderTable.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/newgabopc.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ftest.c \
+$(CSOUND_SRC_ROOT)/Top/argdecode.c \
+$(CSOUND_SRC_ROOT)/Opcodes/hrtfearly.c \
+$(CSOUND_SRC_ROOT)/Opcodes/hrtfreverb.c \
+$(CSOUND_SRC_ROOT)/Opcodes/cpumeter.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gendy.c \
+$(CSOUND_SRC_ROOT)/Opcodes/tl/sc_noise.c \
+$(CSOUND_SRC_ROOT)/Top/cscore_internal.c \
+$(CSOUND_SRC_ROOT)/Top/cscorfns.c \
+$(CSOUND_SRC_ROOT)/Top/csmodule.c \
+$(CSOUND_SRC_ROOT)/Top/csound.c \
+$(CSOUND_SRC_ROOT)/Top/getstring.c \
+$(CSOUND_SRC_ROOT)/Top/main.c \
+$(CSOUND_SRC_ROOT)/Top/new_opts.c \
+$(CSOUND_SRC_ROOT)/Top/one_file.c \
+$(CSOUND_SRC_ROOT)/Top/opcode.c \
+$(CSOUND_SRC_ROOT)/Top/threads.c \
+$(CSOUND_SRC_ROOT)/Top/utility.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ambicode.c \
+$(CSOUND_SRC_ROOT)/Opcodes/bbcut.c \
+$(CSOUND_SRC_ROOT)/Opcodes/biquad.c \
+$(CSOUND_SRC_ROOT)/Opcodes/butter.c \
+$(CSOUND_SRC_ROOT)/Opcodes/clfilt.c \
+$(CSOUND_SRC_ROOT)/Opcodes/cross2.c \
+$(CSOUND_SRC_ROOT)/Opcodes/dam.c \
+$(CSOUND_SRC_ROOT)/Opcodes/dcblockr.c \
+$(CSOUND_SRC_ROOT)/Opcodes/filter.c \
+$(CSOUND_SRC_ROOT)/Opcodes/flanger.c \
+$(CSOUND_SRC_ROOT)/Opcodes/follow.c \
+$(CSOUND_SRC_ROOT)/Opcodes/fout.c \
+$(CSOUND_SRC_ROOT)/Opcodes/freeverb.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ftconv.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ftgen.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/gab.c \
+$(CSOUND_SRC_ROOT)/Opcodes/gab/vectorial.c \
+$(CSOUND_SRC_ROOT)/Opcodes/grain.c \
+$(CSOUND_SRC_ROOT)/Opcodes/locsig.c \
+$(CSOUND_SRC_ROOT)/Opcodes/lowpassr.c \
+$(CSOUND_SRC_ROOT)/Opcodes/metro.c \
+$(CSOUND_SRC_ROOT)/Opcodes/midiops2.c \
+$(CSOUND_SRC_ROOT)/Opcodes/midiops3.c \
+$(CSOUND_SRC_ROOT)/Opcodes/newfils.c \
+$(CSOUND_SRC_ROOT)/Opcodes/nlfilt.c \
+$(CSOUND_SRC_ROOT)/Opcodes/oscbnk.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pluck.c \
+$(CSOUND_SRC_ROOT)/Opcodes/repluck.c \
+$(CSOUND_SRC_ROOT)/Opcodes/reverbsc.c \
+$(CSOUND_SRC_ROOT)/Opcodes/seqtime.c \
+$(CSOUND_SRC_ROOT)/Opcodes/sndloop.c \
+$(CSOUND_SRC_ROOT)/Opcodes/sndwarp.c \
+$(CSOUND_SRC_ROOT)/Opcodes/space.c \
+$(CSOUND_SRC_ROOT)/Opcodes/spat3d.c \
+$(CSOUND_SRC_ROOT)/Opcodes/syncgrain.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugens7.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugens9.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugensa.c \
+$(CSOUND_SRC_ROOT)/Opcodes/uggab.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugmoss.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugnorman.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugsc.c \
+$(CSOUND_SRC_ROOT)/Opcodes/wave-terrain.c \
+$(CSOUND_SRC_ROOT)/Opcodes/stdopcod.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ifd.c \
+$(CSOUND_SRC_ROOT)/Opcodes/partials.c \
+$(CSOUND_SRC_ROOT)/Opcodes/psynth.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvsbasic.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvscent.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvsdemix.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvs_ops.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvsband.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvsbuffer.c \
+$(CSOUND_SRC_ROOT)/Opcodes/dsputil.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvadd.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvinterp.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvocext.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvread.c \
+$(CSOUND_SRC_ROOT)/Opcodes/ugens8.c \
+$(CSOUND_SRC_ROOT)/Opcodes/vpvoc.c \
+$(CSOUND_SRC_ROOT)/Opcodes/pvoc.c \
+$(CSOUND_SRC_ROOT)/Engine/csound_orc_semantics.c \
+$(CSOUND_SRC_ROOT)/Engine/csound_orc_expressions.c \
+$(CSOUND_SRC_ROOT)/Engine/csound_orc_optimize.c \
+$(CSOUND_SRC_ROOT)/Engine/csound_orc_compile.c \
+$(CSOUND_SRC_ROOT)/Engine/new_orc_parser.c \
+$(CSOUND_SRC_ROOT)/Engine/symbtab.c \
+$(CSOUND_SRC_ROOT)/Opcodes/mp3in.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/layer1.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/layer2.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/layer3.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/synth.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/tables.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/mpadec.c \
+$(CSOUND_SRC_ROOT)/InOut/libmpadec/mp3dec.c \
+csound_orclex.c \
+csound_prelex.c \
+csound_orcparse.c \
+rtopensl.c \
+AndroidCsound.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/CppSound.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/CsoundFile.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/Soundfile.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/csPerfThread.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/cs_glue.cpp \
+$(CSOUND_SRC_ROOT)/interfaces/filebuilding.cpp \
+java_interfaceJAVA_wrap.cpp
+#CsoundObj.cpp
+
+LOCAL_LDLIBS := -llog -lOpenSLES
+
+LOCAL_STATIC_LIBRARIES := sndfile
+
+
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,libsndfile-android/jni)
diff --git a/android/CsoundAndroid/jni/AndroidCsound.cpp b/android/CsoundAndroid/jni/AndroidCsound.cpp
new file mode 100644
index 0000000..ecd3004
--- /dev/null
+++ b/android/CsoundAndroid/jni/AndroidCsound.cpp
@@ -0,0 +1,42 @@
+#include "AndroidCsound.hpp"
+#include <android/log.h>
+extern "C" {
+extern void androidrtclose_(CSOUND *csound);
+extern void androidrtplay_(CSOUND *csound, const MYFLT *buffer, int nbytes);
+extern int androidrtrecord_(CSOUND *csound, MYFLT *buffer, int nbytes);
+extern int androidrecopen_(CSOUND *csound, const csRtAudioParams *parm);
+extern int androidplayopen_(CSOUND *csound, const csRtAudioParams *parm);
+
+static void androidMessageCallbac(CSOUND*, int attr, const char *format, va_list valist) {
+
+char message[1024];
+
+vsnprintf(message, 1024, format, valist);
+__android_log_print(ANDROID_LOG_INFO,"AndroidCsound",message);
+
+}
+
+
+}
+
+int AndroidCsound::PreCompile()
+{
+
+__android_log_print(ANDROID_LOG_INFO,"AndroidCsound","PreCompile()");
+
+ int retVal = Csound::PreCompile();
+__android_log_print(ANDROID_LOG_INFO,"AndroidCsound","set callbacks");
+ csoundSetPlayopenCallback(csound, androidplayopen_);
+ csoundSetRecopenCallback(csound, androidrecopen_);
+ csoundSetRtplayCallback(csound, androidrtplay_);
+ csoundSetRtrecordCallback(csound, androidrtrecord_);
+ csoundSetRtcloseCallback(csound, androidrtclose_);
+ csoundSetMessageCallback(csound, androidMessageCallbac);
+__android_log_print(ANDROID_LOG_INFO,"AndroidCsound","callbacks set");
+
+ return retVal;
+};
+
+void AndroidCsound::SetGlobalEnv(const char* name, const char* variable) {
+ csoundSetGlobalEnv(name, variable);
+}
diff --git a/android/CsoundAndroid/jni/AndroidCsound.hpp b/android/CsoundAndroid/jni/AndroidCsound.hpp
new file mode 100644
index 0000000..9d092d9
--- /dev/null
+++ b/android/CsoundAndroid/jni/AndroidCsound.hpp
@@ -0,0 +1,11 @@
+#ifdef SWIG
+%module csnd
+#endif
+
+#include "csound.hpp"
+
+class PUBLIC AndroidCsound : public Csound {
+public:
+virtual int PreCompile();
+void SetGlobalEnv(const char* name, const char* variable);
+};
diff --git a/android/CsoundAndroid/jni/Application.mk b/android/CsoundAndroid/jni/Application.mk
new file mode 100644
index 0000000..679fb59
--- /dev/null
+++ b/android/CsoundAndroid/jni/Application.mk
@@ -0,0 +1,5 @@
+APP_STL := gnustl_static
+APP_CPPFLAGS += -fexceptions -frtti
+APP_ABI := armeabi armeabi-v7a
+
+
diff --git a/android/CsoundAndroid/jni/rtopensl.c b/android/CsoundAndroid/jni/rtopensl.c
new file mode 100644
index 0000000..d57b3da
--- /dev/null
+++ b/android/CsoundAndroid/jni/rtopensl.c
@@ -0,0 +1,578 @@
+
+/*
+ rtopensl.c
+ OpenSl ES Audio Module for Csound
+
+ Copyright (C) 2011 Victor Lazzarini.
+
+ This file is part of Csound.
+
+ The Csound Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+*/
+#include <SLES/OpenSLES.h>
+#include "SLES/OpenSLES_Android.h"
+#include "csdl.h"
+#include <android/log.h>
+
+typedef struct OPEN_SL_PARAMS_ {
+ CSOUND *csound;
+ // engine interfaces
+ SLObjectItf engineObject;
+ SLEngineItf engineEngine;
+
+// output mix interfaces
+ SLObjectItf outputMixObject;
+
+// buffer queue player interfaces
+ SLObjectItf bqPlayerObject;
+ SLPlayItf bqPlayerPlay;
+ SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
+ SLEffectSendItf bqPlayerEffectSend;
+
+// recorder interfaces
+ SLObjectItf recorderObject;
+ SLRecordItf recorderRecord;
+ SLAndroidSimpleBufferQueueItf recorderBufferQueue;
+
+ int currentInputIndex;
+ int currentOutputIndex;
+
+ int currentOutputBuffer;
+ int currentInputBuffer;
+
+ short *outputBuffer[2];
+ short *inputBuffer[2];
+
+ int outBufSamples;
+ int inBufSamples;
+
+ // locks
+ void *clientLockIn;
+ void *clientLockOut;
+
+ csRtAudioParams outParm;
+ csRtAudioParams inParm;
+
+} open_sl_params;
+
+#define CONV16BIT 32768
+#define CONVMYFLT FL(1./32768.)
+
+// this callback handler is called every time a buffer finishes playing
+void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
+{
+ open_sl_params *params = (open_sl_params *) context;
+ params->csound->NotifyThreadLock(params->clientLockOut);
+
+}
+
+/* put samples to DAC */
+void androidrtplay_(CSOUND *csound, const MYFLT *buffer, int nbytes)
+{
+ open_sl_params *params;
+ int i = 0, samples = nbytes / (int) sizeof(MYFLT);
+ short* openslBuffer;
+
+ params = (open_sl_params *) *(csound->GetRtPlayUserData(csound));
+ openslBuffer = params->outputBuffer[params->currentOutputBuffer];
+ if (params == NULL)
+ return;
+ do {
+ openslBuffer[params->currentOutputIndex++] = (short) (buffer[i]*CONV16BIT);
+ if (params->currentOutputIndex >= params->outBufSamples) {
+ csound->WaitThreadLock(params->clientLockOut, (size_t) 1000);
+ (*params->bqPlayerBufferQueue)->Enqueue(params->bqPlayerBufferQueue,
+ openslBuffer,params->outBufSamples*sizeof(short));
+ params->currentOutputBuffer = (params->currentOutputBuffer ? 0 : 1);
+ params->currentOutputIndex = 0;
+ openslBuffer = params->outputBuffer[params->currentOutputBuffer];
+ }
+ } while (++i < samples);
+}
+
+SLresult openSLCreateEngine(open_sl_params *params)
+{
+ SLresult result;
+
+ // create engine
+ result = slCreateEngine(&(params->engineObject), 0, NULL, 0, NULL, NULL);
+ if(result != SL_RESULT_SUCCESS) goto engine_end;
+
+ // realize the engine
+ result = (*params->engineObject)->Realize(params->engineObject, SL_BOOLEAN_FALSE);
+ if(result != SL_RESULT_SUCCESS) goto engine_end;
+
+ // get the engine interface, which is needed in order to create other objects
+ result = (*params->engineObject)->GetInterface(params->engineObject, SL_IID_ENGINE, &(params->engineEngine));
+ if(result != SL_RESULT_SUCCESS) goto engine_end;
+
+ engine_end:
+ return result;
+}
+
+int openSLPlayOpen(open_sl_params *params)
+{
+ SLresult result;
+ SLuint32 sr = params->outParm.sampleRate;
+
+ // configure audio source
+ SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
+
+ switch(sr){
+
+ case 8000:
+ sr = SL_SAMPLINGRATE_8;
+ break;
+ case 11025:
+ sr = SL_SAMPLINGRATE_11_025;
+ break;
+ case 16000:
+ sr = SL_SAMPLINGRATE_16;
+ break;
+ case 22050:
+ sr = SL_SAMPLINGRATE_22_05;
+ break;
+ case 24000:
+ sr = SL_SAMPLINGRATE_24;
+ break;
+ case 32000:
+ sr = SL_SAMPLINGRATE_32;
+ break;
+ case 44100:
+ sr = SL_SAMPLINGRATE_44_1;
+ break;
+ case 64000:
+ sr = SL_SAMPLINGRATE_64;
+ break;
+ case 88200:
+ sr = SL_SAMPLINGRATE_88_2;
+ break;
+ case 96000:
+ sr = SL_SAMPLINGRATE_96;
+ break;
+ case 192000:
+ sr = SL_SAMPLINGRATE_192;
+ break;
+ default:
+ return -1;
+ }
+
+ const SLInterfaceID ids[] = {SL_IID_VOLUME};
+ const SLboolean req[] = {SL_BOOLEAN_FALSE};
+ result = (*params->engineEngine)->CreateOutputMix(params->engineEngine, &(params->outputMixObject), 1, ids, req);
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // realize the output mix
+ result = (*params->outputMixObject)->Realize(params->outputMixObject, SL_BOOLEAN_FALSE);
+ int chnls = params->csound->GetNchnls(params->csound);
+ int speakers;
+ if(chnls == 1) speakers = SL_SPEAKER_FRONT_CENTER;
+ else speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
+
+ SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, chnls , sr,
+ SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
+ speakers, SL_BYTEORDER_LITTLEENDIAN};
+
+ SLDataSource audioSrc = {&loc_bufq, &format_pcm};
+
+ // configure audio sink
+ SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, params->outputMixObject};
+ SLDataSink audioSnk = {&loc_outmix, NULL};
+
+ // create audio player
+ const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
+ const SLboolean req1[] = {SL_BOOLEAN_TRUE};
+ result = (*params->engineEngine)->CreateAudioPlayer(params->engineEngine, &(params->bqPlayerObject), &audioSrc, &audioSnk,
+ 1, ids1, req1);
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // realize the player
+ result = (*params->bqPlayerObject)->Realize(params->bqPlayerObject, SL_BOOLEAN_FALSE);
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // get the play interface
+ result = (*params->bqPlayerObject)->GetInterface(params->bqPlayerObject, SL_IID_PLAY, &(params->bqPlayerPlay));
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // get the buffer queue interface
+ result = (*params->bqPlayerObject)->GetInterface(params->bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
+ &(params->bqPlayerBufferQueue));
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // register callback on the buffer queue
+ result = (*params->bqPlayerBufferQueue)->RegisterCallback(params->bqPlayerBufferQueue, bqPlayerCallback, params);
+ if(result != SL_RESULT_SUCCESS) goto end_openaudio;
+
+ // set the player's state to playing
+ result = (*params->bqPlayerPlay)->SetPlayState(params->bqPlayerPlay, SL_PLAYSTATE_PLAYING);
+
+ end_openaudio:
+ return result;
+}
+
+int openSLInitOutParams(open_sl_params *params){
+
+ params->clientLockOut = params->csound->CreateThreadLock();
+ if (params->clientLockOut == NULL)
+ goto err_return;
+ params->outBufSamples = params->csound->GetOutputBufferSize(params->csound);
+
+ if((params->outputBuffer[0] = calloc(params->outBufSamples, sizeof(short))) == NULL ||
+ (params->outputBuffer[1] = calloc(params->outBufSamples, sizeof(short))) == NULL ){
+ params->csound->Message(params->csound, "memory allocation failure in opensl module \n");
+ goto err_return;
+ }
+ params->currentInputIndex = 0;
+ params->currentOutputBuffer = 0;
+ return OK;
+
+ err_return:
+ return -1;
+}
+
+/* open for audio output */
+int androidplayopen_(CSOUND *csound, const csRtAudioParams *parm)
+{
+
+ CSOUND *p = csound;
+ open_sl_params *params;
+
+ params = (open_sl_params*) p->QueryGlobalVariable(p, "_openslGlobals");
+ if (params == NULL) {
+ if (p->CreateGlobalVariable(p, "_openslGlobals", sizeof(open_sl_params))
+ != 0)
+ return -1;
+ params = (open_sl_params*) p->QueryGlobalVariable(p, "_openslGlobals");
+ params->csound = p;
+
+ if(openSLCreateEngine(params) != SL_RESULT_SUCCESS) {
+ csound->Message(csound, Str("OpenSL: engine create error \n"));
+ return -1;
+ }
+
+ }
+ memcpy(&(params->outParm), parm, sizeof(csRtAudioParams));
+ *(p->GetRtPlayUserData(p)) = (void*) params;
+
+ if(openSLPlayOpen(params) != SL_RESULT_SUCCESS) return -1;
+
+ int returnVal = openSLInitOutParams(params);
+ params->csound->NotifyThreadLock(params->clientLockOut);
+ return returnVal;
+}
+// ===============================
+
+// this callback handler is called every time a buffer finishes recording
+void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
+{
+ open_sl_params *params = (open_sl_params *) context;
+ params->csound->NotifyThreadLock(params->clientLockIn);
+}
+
+/* get samples from ADC */
+int androidrtrecord_(CSOUND *csound, MYFLT *buffer, int nbytes)
+{
+
+ open_sl_params *params;
+ int i = 0, j = 0, samples = nbytes / (int) sizeof(MYFLT);
+ short *openslBuffer; int nchnls = csound->GetNchnls(csound);
+ params = (open_sl_params*) *(csound->GetRtRecordUserData(csound));
+ openslBuffer = params->inputBuffer[params->currentInputBuffer];
+
+ if (params == NULL) {
+ memset(buffer, 0, nbytes);
+ return nbytes;
+ }
+ do {
+ if (params->currentInputIndex >= params->inBufSamples) {
+ csound->WaitThreadLock(params->clientLockIn, (size_t) 1000);
+ (*params->recorderBufferQueue)->Enqueue(params->recorderBufferQueue,
+ openslBuffer,params->inBufSamples*sizeof(short));
+ params->currentInputBuffer = (params->currentInputBuffer ? 0 : 1);
+ params->currentInputIndex = 0;
+ openslBuffer = params->inputBuffer[params->currentInputBuffer];
+ }
+ for(j = 0; j < nchnls; j++) {
+ buffer[i + j] = (MYFLT) openslBuffer[params->currentInputIndex]*CONVMYFLT;
+ }
+ params->currentInputIndex++;
+ i += nchnls;
+ } while (i < samples);
+
+
+ return nbytes;
+}
+
+int openSLRecOpen(open_sl_params *params){
+
+ SLresult result;
+ SLuint32 sr = params->inParm.sampleRate;
+ int nchnls;
+ switch(sr){
+
+ case 8000:
+ sr = SL_SAMPLINGRATE_8;
+ break;
+ case 11025:
+ sr = SL_SAMPLINGRATE_11_025;
+ break;
+ case 16000:
+ sr = SL_SAMPLINGRATE_16;
+ break;
+ case 22050:
+ sr = SL_SAMPLINGRATE_22_05;
+ break;
+ case 24000:
+ sr = SL_SAMPLINGRATE_24;
+ break;
+ case 32000:
+ sr = SL_SAMPLINGRATE_32;
+ break;
+ case 44100:
+ sr = SL_SAMPLINGRATE_44_1;
+ break;
+ case 64000:
+ sr = SL_SAMPLINGRATE_64;
+ break;
+ case 88200:
+ sr = SL_SAMPLINGRATE_88_2;
+ break;
+ case 96000:
+ sr = SL_SAMPLINGRATE_96;
+ break;
+ case 192000:
+ sr = SL_SAMPLINGRATE_192;
+ break;
+ default:
+ return -1;
+ }
+ nchnls = 1; /* always mono for the moment // params->csound->GetNchnls(params->csound); */
+ // configure audio source
+ SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
+ SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
+ SLDataSource audioSrc = {&loc_dev, NULL};
+
+ // configure audio sink
+ SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
+ SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM,nchnls, sr,
+ SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
+ SL_SPEAKER_FRONT_CENTER, SL_BYTEORDER_LITTLEENDIAN};
+ SLDataSink audioSnk = {&loc_bq, &format_pcm};
+
+ // create audio recorder
+ // (requires the RECORD_AUDIO permission)
+ const SLInterfaceID id[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
+ const SLboolean req[1] = {SL_BOOLEAN_TRUE};
+ result = (*params->engineEngine)->CreateAudioRecorder(params->engineEngine, &(params->recorderObject), &audioSrc,
+ &audioSnk, 1, id, req);
+ if (SL_RESULT_SUCCESS != result) goto end_recopen;
+
+ // realize the audio recorder
+ result = (*params->recorderObject)->Realize(params->recorderObject, SL_BOOLEAN_FALSE);
+ if (SL_RESULT_SUCCESS != result) goto end_recopen;
+
+
+ // get the record interface
+ result = (*params->recorderObject)->GetInterface(params->recorderObject, SL_IID_RECORD, &(params->recorderRecord));
+ if (SL_RESULT_SUCCESS != result) goto end_recopen;
+
+ // get the buffer queue interface
+ result = (*params->recorderObject)->GetInterface(params->recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
+ &(params->recorderBufferQueue));
+ if (SL_RESULT_SUCCESS != result) goto end_recopen;
+
+ // register callback on the buffer queue
+ result = (*params->recorderBufferQueue)->RegisterCallback(params->recorderBufferQueue, bqRecorderCallback,
+ params);
+ if (SL_RESULT_SUCCESS != result) goto end_recopen;
+
+
+ result = (*params->recorderRecord)->SetRecordState(params->recorderRecord, SL_RECORDSTATE_RECORDING);
+
+
+ end_recopen:
+ return result;
+}
+
+int openSLInitInParams(open_sl_params *params){
+ params->clientLockIn = params->csound->CreateThreadLock();
+ if (params->clientLockIn == NULL)
+ return -1;
+ /* input is always mono, so buffer size needs to be adjusted accordingly */
+ params->inBufSamples = params->csound->GetInputBufferSize(params->csound) /
+ params->csound->GetNchnls(params->csound);
+ if((params->inputBuffer[0] = (short *)calloc(params->inBufSamples, sizeof(short))) == NULL ||
+ (params->inputBuffer[1] = (short *)calloc(params->inBufSamples, sizeof(short))) == NULL){
+ params->csound->Message(params->csound, "memory allocation failure in opensl module \n");
+ return -1;
+ }
+ params->currentInputIndex = params->inBufSamples;
+ params->currentInputBuffer = 0;
+ return OK;
+
+}
+/* open for audio input */
+int androidrecopen_(CSOUND *csound, const csRtAudioParams *parm)
+{
+ CSOUND *p = csound; int res;
+ open_sl_params *params;
+ params = (open_sl_params*) p->QueryGlobalVariable(p, "_openslGlobals");
+ if (params == NULL) {
+ if (p->CreateGlobalVariable(p, "_openslGlobals", sizeof(open_sl_params))
+ != 0)
+ return -1;
+ params = (open_sl_params*) p->QueryGlobalVariable(p, "_openslGlobals");
+ params->csound = p;
+
+ if(openSLCreateEngine(params) != SL_RESULT_SUCCESS) {
+ csound->Message(csound, Str("OpenSL: engine create error \n"));
+ return -1;
+ }
+
+ }
+ memcpy(&(params->inParm), parm, sizeof(csRtAudioParams));
+ *(p->GetRtRecordUserData(p)) = (void*) params;
+ if(openSLRecOpen(params) != SL_RESULT_SUCCESS) {
+ csound->Message(csound, Str("OpenSL: input open error \n"));
+ return -1;
+ }
+
+ res = openSLInitInParams(params);
+ if(res == OK) params->csound->NotifyThreadLock(params->clientLockIn);
+ return res;
+}
+
+/* close the I/O device entirely */
+void androidrtclose_(CSOUND *csound)
+{
+
+ open_sl_params *params;
+ params = (open_sl_params *) csound->QueryGlobalVariable(csound,
+ "_openslGlobals");
+ if (params == NULL)
+ return;
+
+ if (params->clientLockIn != NULL) {
+ csound->NotifyThreadLock(params->clientLockIn);
+ csound->DestroyThreadLock(params->clientLockIn);
+ params->clientLockIn = NULL;
+ }
+
+ if (params->clientLockOut != NULL) {
+ csound->NotifyThreadLock(params->clientLockOut);
+ csound->DestroyThreadLock(params->clientLockOut);
+ params->clientLockOut = NULL;
+ }
+
+ if (params->outputBuffer[0] != NULL) {
+ free(params->outputBuffer[0]);
+ params->outputBuffer[0] = NULL;
+ }
+
+ if (params->outputBuffer[1] != NULL) {
+ free(params->outputBuffer[1]);
+ params->outputBuffer[1] = NULL;
+ }
+
+ if (params->inputBuffer[0] != NULL) {
+ free(params->inputBuffer[0]);
+ params->inputBuffer[0] = NULL;
+ }
+
+ if (params->inputBuffer[1] != NULL) {
+ free(params->inputBuffer[1]);
+ params->inputBuffer[1] = NULL;
+ }
+
+ *(csound->GetRtRecordUserData(csound)) = NULL;
+ *(csound->GetRtPlayUserData(csound)) = NULL;
+ csound->DestroyGlobalVariable(csound, "_openslGlobals");
+
+
+// destroy buffer queue audio player object, and invalidate all associated interfaces
+ if (params->bqPlayerObject != NULL) {
+ (*params->bqPlayerObject)->Destroy(params->bqPlayerObject);
+ params->bqPlayerObject = NULL;
+ params->bqPlayerPlay = NULL;
+ params->bqPlayerBufferQueue = NULL;
+ params->bqPlayerEffectSend = NULL;
+ }
+
+ // destroy audio recorder object, and invalidate all associated interfaces
+ if (params->recorderObject != NULL) {
+ (*params->recorderObject)->Destroy(params->recorderObject);
+ params->recorderObject = NULL;
+ params->recorderRecord = NULL;
+ params->recorderBufferQueue = NULL;
+ }
+
+ // destroy output mix object, and invalidate all associated interfaces
+ if (params->outputMixObject != NULL) {
+ (*params->outputMixObject)->Destroy(params->outputMixObject);
+ params->outputMixObject = NULL;
+ }
+
+ // destroy engine object, and invalidate all associated interfaces
+ if (params->engineObject != NULL) {
+ (*params->engineObject)->Destroy(params->engineObject);
+ params->engineObject = NULL;
+ params->engineEngine = NULL;
+ }
+
+}
+
+//PUBLIC int csoundModuleCreate(CSOUND *csound)
+//{
+// /* nothing to do, report success */
+// csound->Message(csound,
+// Str("OpenSL ES real-time audio module for Csound\n"));
+// return 0;
+//}
+//
+//PUBLIC int csoundModuleInit(CSOUND *csound)
+//{
+// char *s, drv[12];
+// int i;
+//
+// if ((s = (char*) csound->QueryGlobalVariable(csound, "_RTAUDIO")) == NULL)
+// return 0;
+// for (i = 0; s[i] != '\0' && i < 11; i++)
+// drv[i] = s[i] & (char) 0xDF;
+// drv[i] = '\0';
+// if (!(strcmp(drv, "OPENSL") == 0 || strcmp(drv, "OSL") == 0 )
+// return 0;
+// csound->Message(csound, Str("rtaudio: OenSL ES module enabled ... "));
+// /* set function pointers */
+// csound->SetPlayopenCallback(csound, playopen_);
+// csound->SetRecopenCallback(csound, recopen_);
+// csound->SetRtplayCallback(csound, rtplay_);
+// csound->SetRtrecordCallback(csound, rtrecord_);
+// csound->SetRtcloseCallback(csound, rtclose_);
+//
+// return 0;
+//}
+//
+//PUBLIC int csoundModuleDestroy(CSOUND *csound)
+//{
+// return 0;
+//}
+//
+//PUBLIC int csoundModuleInfo(void)
+//{
+// return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT));
+//}
+//
diff --git a/android/CsoundAndroid/proguard.cfg b/android/CsoundAndroid/proguard.cfg
new file mode 100644
index 0000000..b1cdf17
--- /dev/null
+++ b/android/CsoundAndroid/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/android/CsoundAndroid/project.properties b/android/CsoundAndroid/project.properties
new file mode 100644
index 0000000..2f8f737
--- /dev/null
+++ b/android/CsoundAndroid/project.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-9
+android.library=true
diff --git a/android/CsoundAndroid/res/drawable-hdpi/ic_launcher.png b/android/CsoundAndroid/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..8074c4c
Binary files /dev/null and b/android/CsoundAndroid/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/CsoundAndroid/res/drawable-ldpi/ic_launcher.png b/android/CsoundAndroid/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..1095584
Binary files /dev/null and b/android/CsoundAndroid/res/drawable-ldpi/ic_launcher.png differ
diff --git a/android/CsoundAndroid/res/drawable-mdpi/ic_launcher.png b/android/CsoundAndroid/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..a07c69f
Binary files /dev/null and b/android/CsoundAndroid/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/CsoundAndroid/src/com/csounds/CsoundObj.java b/android/CsoundAndroid/src/com/csounds/CsoundObj.java
new file mode 100644
index 0000000..e0680aa
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/CsoundObj.java
@@ -0,0 +1,473 @@
+/*
+
+ CsoundObj.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioRecord;
+import android.media.AudioTrack;
+import android.media.MediaRecorder;
+import android.util.Log;
+import android.widget.Button;
+import android.widget.SeekBar;
+
+import com.csounds.valueCacheable.CachedAccelerometer;
+import com.csounds.valueCacheable.CachedButton;
+import com.csounds.valueCacheable.CachedSlider;
+import com.csounds.valueCacheable.CsoundValueCacheable;
+
+import csnd.AndroidCsound;
+import csnd.Csound;
+import csnd.CsoundCallbackWrapper;
+import csnd.CsoundMYFLTArray;
+import csnd.csndConstants;
+
+public class CsoundObj {
+
+ private Csound csound;
+ private ArrayList<CsoundValueCacheable> valuesCache;
+ private ArrayList<CsoundObjCompletionListener> completionListeners;
+ private boolean muted = false;
+ private boolean stopped = false;
+ private Thread thread;
+ private boolean audioInEnabled = false;
+ private boolean messageLoggingEnabled = false;
+ private boolean useAudioTrack = false;
+ int retVal = 0;
+
+ private CsoundCallbackWrapper callbacks;
+
+ public CsoundObj() {
+ valuesCache = new ArrayList<CsoundValueCacheable>();
+ completionListeners = new ArrayList<CsoundObjCompletionListener>();
+ }
+
+ public CsoundObj(boolean useAudioTrack) {
+ valuesCache = new ArrayList<CsoundValueCacheable>();
+ completionListeners = new ArrayList<CsoundObjCompletionListener>();
+ this.useAudioTrack = useAudioTrack;
+ }
+
+ /* VALUE CACHEABLE */
+
+ // -(id<ValueCacheable>)addSwitch:(UISwitch*)uiSwitch
+ // forChannelName:(NSString*)channelName;
+
+ public boolean isAudioInEnabled() {
+ return audioInEnabled;
+ }
+
+ public void setAudioInEnabled(boolean audioInEnabled) {
+ this.audioInEnabled = audioInEnabled;
+ }
+
+ public boolean isMessageLoggingEnabled() {
+ return messageLoggingEnabled;
+ }
+
+ public void setMessageLoggingEnabled(boolean messageLoggingEnabled) {
+ this.messageLoggingEnabled = messageLoggingEnabled;
+ }
+
+ public CsoundValueCacheable addSlider(SeekBar seekBar, String channelName,
+ double min, double max) {
+ CachedSlider cachedSlider = new CachedSlider(seekBar, channelName, min,
+ max);
+ valuesCache.add(cachedSlider);
+
+ return cachedSlider;
+ }
+
+ public CsoundValueCacheable addButton(Button button, String channelName,int type) {
+ CachedButton cachedButton = new CachedButton(button, channelName, type);
+ valuesCache.add(cachedButton);
+
+ return cachedButton;
+ }
+
+ public CsoundValueCacheable addButton(Button button, String channelName) {
+ CachedButton cachedButton = new CachedButton(button, channelName);
+ valuesCache.add(cachedButton);
+
+ return cachedButton;
+ }
+
+
+ // -(id<ValueCacheable>)addButton:(UIButton*)uiButton
+ // forChannelName:(NSString*)channelName;
+
+ public Csound getCsound() {
+ return csound;
+ }
+
+ public boolean isMuted() {
+ return muted;
+ }
+
+ public void setMuted(boolean muted) {
+ this.muted = muted;
+ }
+
+ public void addValueCacheable(CsoundValueCacheable valueCacheable) {
+ valuesCache.add(valueCacheable);
+ }
+
+ public void removeValueCacheable(CsoundValueCacheable valueCacheable) {
+ valuesCache.remove(valueCacheable);
+ }
+
+ public CsoundValueCacheable enableAccelerometer(Context context) {
+ CachedAccelerometer accelerometer = new CachedAccelerometer(context);
+ addValueCacheable(accelerometer);
+ return accelerometer;
+ }
+
+ // -(id<ValueCacheable>)enableGyroscope;
+ // -(id<ValueCacheable>)enableAttitude;
+
+ public CsoundMYFLTArray getInputChannelPtr(String channelName) {
+ CsoundMYFLTArray ptr = new CsoundMYFLTArray(1);
+ getCsound().GetChannelPtr(
+ ptr.GetPtr(),
+ channelName,
+ csndConstants.CSOUND_CONTROL_CHANNEL
+ | csndConstants.CSOUND_INPUT_CHANNEL);
+ return ptr;
+ }
+
+ public void sendScore(String score) {
+ csound.InputMessage(score);
+ }
+
+ public void addCompletionListener(CsoundObjCompletionListener listener) {
+ completionListeners.add(listener);
+ }
+
+ public void startCsound(final File csdFile) {
+ stopped = false;
+ thread = new Thread() {
+ public void run() {
+ setPriority(Thread.MAX_PRIORITY);
+ // android.os.Process
+ // .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
+ if(useAudioTrack == false)
+ runCsoundOpenSL(csdFile);
+ else
+ runCsoundAudioTrack(csdFile);
+ }
+ };
+ thread.start();
+ }
+
+ public void stopCsound() {
+ stopped = true;
+ thread = null;
+ }
+
+ public int getNumChannels() {
+ return csound.GetNchnls();
+ }
+
+ public int getKsmps() {
+ return csound.GetKsmps();
+ }
+
+ public int getError(){
+ return retVal;
+ }
+
+ // -(float*)getInputChannelPtr:(NSString*)channelName;
+ // -(float*)getOutputChannelPtr:(NSString*)channelName;
+ // -(NSData*)getOutSamples;
+
+ /* Render Methods */
+
+ private void runCsoundOpenSL(File f) {
+
+ AndroidCsound c = new AndroidCsound();
+ csound = c;
+ retVal = c.PreCompile();
+
+ Log.d("CsoundAndroid", "Return Value: " + retVal);
+
+ retVal = c.Compile(f.getAbsolutePath());
+ Log.d("CsoundAndroid", "Return Value2: " + retVal);
+
+ if (retVal == 0) {
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.setup(this);
+ }
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesToCsound();
+ }
+
+ while (c.PerformKsmps() == 0 && !stopped) {
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesFromCsound();
+ }
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesToCsound();
+ }
+ }
+
+ c.Stop();
+ c.Cleanup();
+ c.Reset();
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.cleanup();
+ }
+
+ for (CsoundObjCompletionListener listener : completionListeners) {
+ listener.csoundObjComplete(this);
+ }
+
+ } else {
+ for (CsoundObjCompletionListener listener : completionListeners) {
+ listener.csoundObjComplete(this);
+ }
+
+ }
+
+ }
+
+ private void runCsoundAudioTrack(File f) {
+
+ csound = new Csound();
+
+ if (messageLoggingEnabled) {
+ callbacks = new CsoundCallbackWrapper(csound) {
+
+ @Override
+ public void MessageCallback(int attr, String msg) {
+ Log.d("CsoundObj", msg);
+ // super.MessageCallback(attr, msg);
+ }
+
+ };
+ callbacks.SetMessageCallback();
+ }
+ retVal = csound.PreCompile();
+ csound.SetHostImplementedAudioIO(1, 0);
+
+ Log.d("CsoundAndroid", "Return Value: " + retVal);
+
+ retVal = csound.Compile(f.getAbsolutePath());
+ Log.d("CsoundAndroid", "Return Value2: " + retVal);
+
+ if (retVal == 0) {
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.setup(this);
+ }
+
+ int channelConfig = (csound.GetNchnls() == 2) ? AudioFormat.CHANNEL_CONFIGURATION_STEREO
+ : AudioFormat.CHANNEL_CONFIGURATION_MONO;
+
+ int channelInConfig = AudioFormat.CHANNEL_IN_MONO;
+
+ int minSize = AudioTrack.getMinBufferSize((int) csound.GetSr(),
+ channelConfig, AudioFormat.ENCODING_PCM_16BIT);
+
+ if (audioInEnabled) {
+
+ int recordMinSize = AudioRecord.getMinBufferSize(
+ (int) csound.GetSr(), channelInConfig,
+ AudioFormat.ENCODING_PCM_16BIT);
+
+ minSize = (minSize > recordMinSize) ? minSize : recordMinSize;
+
+ }
+
+ AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
+ (int) csound.GetSr(), channelConfig,
+ AudioFormat.ENCODING_PCM_16BIT, minSize,
+ AudioTrack.MODE_STREAM);
+ Log.d("CsoundAndroid", "Buffer Size: " + minSize);
+
+ AudioRecord audioRecord = null;
+ CsoundMYFLTArray audioIn = null;
+
+ if (audioInEnabled) {
+
+ // int channelInConfig = (csound.GetNchnls() == 2) ?
+ // AudioFormat.CHANNEL_IN_STEREO
+ // : AudioFormat.CHANNEL_IN_MONO;
+
+ // int channelInConfig = AudioFormat.CHANNEL_IN_MONO;
+ //
+ // int recordMinSize =
+ // AudioRecord.getMinBufferSize((int)csound.GetSr(),
+ // channelInConfig,
+ // AudioFormat.ENCODING_PCM_16BIT);
+
+ audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
+ (int) csound.GetSr(), channelInConfig,
+ AudioFormat.ENCODING_PCM_16BIT, minSize);
+
+ if (audioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
+ Log.d("CsoundObj",
+ "AudioRecord unable to be initialized. Error "
+ + audioRecord.getState());
+ audioRecord.release();
+ audioRecord = null;
+ } else {
+ try {
+ audioRecord.startRecording();
+ if (audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
+ Log.d("CsoundObj",
+ "AudioRecord unable to be initialized. Error "
+ + audioRecord.getRecordingState());
+
+ }
+ audioIn = new CsoundMYFLTArray();
+ audioIn.SetPtr(csound.GetSpin());
+ } catch (IllegalStateException e) {
+ audioRecord.release();
+ audioRecord = null;
+ audioIn = null;
+ }
+ }
+ }
+
+ audioTrack.play();
+
+ int counter = 0;
+ int nchnls = csound.GetNchnls();
+ int recBufferSize = csound.GetKsmps();
+ int bufferSize = recBufferSize * nchnls;
+
+ short[] samples = new short[bufferSize];
+
+ float multiplier = Short.MAX_VALUE / csound.Get0dBFS();
+ float recMultiplier = 1 / multiplier;
+
+ Log.d("CsoundObj", "Multiplier: " + multiplier + " : "
+ + recMultiplier);
+
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesToCsound();
+ }
+
+ short recordSample[] = new short[recBufferSize];
+
+ if (audioRecord != null) {
+ audioRecord.read(recordSample, 0, recBufferSize);
+ for (int i = 0; i < csound.GetKsmps(); i++) {
+ short sample = recordSample[i];
+
+ if (nchnls == 2) {
+ int index = i * 2;
+ audioIn.SetValues(index,
+ (double) (sample * recMultiplier),
+ (double) (sample * recMultiplier));
+ } else {
+ audioIn.SetValue(i, sample);
+ }
+ }
+ }
+
+ while (csound.PerformKsmps() == 0 && !stopped) {
+
+ for (int i = 0; i < csound.GetKsmps(); i++) {
+ samples[counter++] = (short) (csound.GetSpoutSample(i, 0) * multiplier);
+
+ if (nchnls > 1) {
+ samples[counter++] = (short) (csound.GetSpoutSample(i,
+ 1) * multiplier);
+ }
+ }
+
+ if (counter >= bufferSize) {
+ audioTrack.write(samples, 0, bufferSize);
+ counter = 0;
+ // if(audioTrack.getPlayState() !=
+ // AudioTrack.PLAYSTATE_PLAYING) {
+ // audioTrack.play();
+ //
+ // }
+ }
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesFromCsound();
+ }
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.updateValuesToCsound();
+ }
+
+ if (audioRecord != null) {
+ audioRecord.read(recordSample, 0, recBufferSize);
+ for (int i = 0; i < csound.GetKsmps(); i++) {
+ short sample = recordSample[i];
+
+ if (nchnls == 2) {
+ int index = i * 2;
+ audioIn.SetValues(index,
+ (double) (sample * recMultiplier),
+ (double) (sample * recMultiplier));
+ } else {
+ audioIn.SetValue(i, sample);
+ }
+ }
+ }
+ }
+
+ audioTrack.stop();
+ audioTrack.release();
+
+ if (audioRecord != null) {
+ audioRecord.stop();
+ audioRecord.release();
+ audioIn.Clear();
+ }
+
+ csound.Stop();
+ csound.Cleanup();
+ csound.Reset();
+
+ for (CsoundValueCacheable cacheable : valuesCache) {
+ cacheable.cleanup();
+ }
+
+ for (CsoundObjCompletionListener listener : completionListeners) {
+ listener.csoundObjComplete(this);
+ }
+
+ }
+ else {
+ for (CsoundObjCompletionListener listener : completionListeners) {
+ listener.csoundObjComplete(this);
+ }
+ }
+ }
+}
diff --git a/android/CsoundAndroid/src/com/csounds/CsoundObjCompletionListener.java b/android/CsoundAndroid/src/com/csounds/CsoundObjCompletionListener.java
new file mode 100644
index 0000000..305c819
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/CsoundObjCompletionListener.java
@@ -0,0 +1,30 @@
+/*
+
+ CsoundObjectCompletionListener.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound.
+
+ Csound is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds;
+
+public interface CsoundObjCompletionListener {
+ public void csoundObjComplete(CsoundObj csoundObj);
+}
diff --git a/android/CsoundAndroid/src/com/csounds/valueCacheable/AbstractValueCacheable.java b/android/CsoundAndroid/src/com/csounds/valueCacheable/AbstractValueCacheable.java
new file mode 100644
index 0000000..1b80d3e
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/valueCacheable/AbstractValueCacheable.java
@@ -0,0 +1,45 @@
+/*
+
+ AbstractValueCacheable.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.valueCacheable;
+
+import com.csounds.CsoundObj;
+
+public abstract class AbstractValueCacheable implements CsoundValueCacheable {
+
+ @Override
+ public abstract void setup(CsoundObj csoundObj);
+
+ @Override
+ public void updateValuesToCsound() {
+ }
+
+ @Override
+ public void updateValuesFromCsound() {
+ }
+
+ @Override
+ public abstract void cleanup();
+}
diff --git a/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedAccelerometer.java b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedAccelerometer.java
new file mode 100644
index 0000000..00bd5a3
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedAccelerometer.java
@@ -0,0 +1,123 @@
+/*
+
+ CachedAccelerometer.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.valueCacheable;
+
+import java.util.List;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.util.Log;
+
+import com.csounds.CsoundObj;
+
+import csnd.CsoundMYFLTArray;
+
+public class CachedAccelerometer extends AbstractValueCacheable implements SensorEventListener {
+
+ private static final String CS_ACCEL_X = "accelerometerX";
+ private static final String CS_ACCEL_Y = "accelerometerY";
+ private static final String CS_ACCEL_Z = "accelerometerZ";
+
+ CsoundMYFLTArray channelPtrX;
+ CsoundMYFLTArray channelPtrY;
+ CsoundMYFLTArray channelPtrZ;
+
+ double x, y, z;
+
+ Context context;
+
+ SensorManager sensorManager;
+ Sensor sensor;
+
+ public CachedAccelerometer(Context context) {
+ this.context = context;
+ x = y = z = 0;
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+
+ sensorManager = (SensorManager) context.
+ getSystemService(Context.SENSOR_SERVICE);
+ List<Sensor> sensors = sensorManager.getSensorList(
+ Sensor.TYPE_ACCELEROMETER);
+
+ if(sensors.size() > 0) {
+ sensor = sensors.get(0);
+
+ sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST);
+
+ channelPtrX = csoundObj.getInputChannelPtr(CS_ACCEL_X);
+ channelPtrY = csoundObj.getInputChannelPtr(CS_ACCEL_Y);
+ channelPtrZ = csoundObj.getInputChannelPtr(CS_ACCEL_Z);
+ } else {
+ Log.d("CachedAccelerometer", "Unable to get Accelerometer sensor.");
+ }
+
+ }
+
+ @Override
+ public void updateValuesToCsound() {
+ if(channelPtrX != null) {
+ channelPtrX.SetValue(0, x);
+ channelPtrY.SetValue(0, y);
+ channelPtrZ.SetValue(0, z);
+ }
+ }
+
+ @Override
+ public void cleanup() {
+ if(channelPtrX != null) {
+ channelPtrX.Clear();
+ channelPtrY.Clear();
+ channelPtrZ.Clear();
+
+ channelPtrX = null;
+ channelPtrY = null;
+ channelPtrZ = null;
+
+ sensorManager.unregisterListener(this);
+ }
+ }
+
+ // SENSOR EVENT LISTENER
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+
+ }
+
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ x = event.values[0] / sensor.getMaximumRange();
+ y = event.values[1] / sensor.getMaximumRange();
+ z = event.values[2] / sensor.getMaximumRange();
+ }
+
+}
diff --git a/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedButton.java b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedButton.java
new file mode 100644
index 0000000..91f48a1
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedButton.java
@@ -0,0 +1,132 @@
+/*
+
+ CachedButton.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.valueCacheable;
+
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
+import android.widget.Button;
+
+import com.csounds.CsoundObj;
+
+import csnd.CsoundMYFLTArray;
+
+public class CachedButton extends AbstractValueCacheable {
+
+ private CsoundObj csoundObj;
+ private Button button;
+ private String channelName;
+ private int type;
+ CsoundMYFLTArray ptr, ptrX, ptrY;
+ double xpos, ypos;
+
+ boolean selected = false;
+ boolean cacheDirty = false;
+
+ public CachedButton(Button button, String channelName){
+ this.button = button;
+ this.channelName = channelName;
+ this.type = 0;
+ }
+
+ public CachedButton(Button button, String channelName, int type) {
+ this.button = button;
+ this.channelName = channelName;
+ this.type = type;
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ this.csoundObj = csoundObj;
+
+ if(type == 0){
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ selected = true;
+ cacheDirty = true;
+ }
+ });
+ }
+ else {
+ button.setOnTouchListener(new OnTouchListener(){
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ final int action = event.getAction() & MotionEvent.ACTION_MASK;
+ switch (action){
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_POINTER_DOWN:
+ button.setPressed(true);
+ selected = true;
+ break;
+ case MotionEvent.ACTION_POINTER_UP:
+ case MotionEvent.ACTION_UP:
+ selected = false;
+ button.setPressed(false);
+ break;
+ case MotionEvent.ACTION_MOVE:
+ break;
+ }
+ if (selected){
+ xpos = event.getX()/v.getWidth();
+ ypos = 1. - (event.getY()/v.getHeight());
+ } else xpos = ypos = 0.;
+ return true;
+ }
+ });
+ ptrX = csoundObj.getInputChannelPtr(channelName + ".x");
+ ptrY = csoundObj.getInputChannelPtr(channelName + ".y");
+ }
+ ptr = csoundObj.getInputChannelPtr(channelName);
+ }
+
+
+ @Override
+ public void updateValuesToCsound() {
+ if(type == 0){
+ if (csoundObj != null && cacheDirty) {
+ ptr.SetValue(0, (selected ? 1. : 0.));
+ cacheDirty = selected;
+ selected = false;
+ }
+ } else {
+ ptr.SetValue(0, (selected ? 1. : 0.));
+ ptrX.SetValue(0, xpos);
+ ptrY.SetValue(0, ypos);
+ }
+
+ }
+
+ @Override
+ public void cleanup() {
+ if(type==0) button.setOnClickListener(null);
+ else button.setOnTouchListener(null);
+ ptr.Clear();
+ ptr = null;
+ }
+
+}
diff --git a/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedSlider.java b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedSlider.java
new file mode 100644
index 0000000..821f18c
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/valueCacheable/CachedSlider.java
@@ -0,0 +1,109 @@
+/*
+
+ CachedSlider.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.valueCacheable;
+
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.csounds.CsoundObj;
+
+import csnd.CsoundMYFLTArray;
+
+public class CachedSlider extends AbstractValueCacheable{
+ private SeekBar seekBar;
+ private String channelName;
+ private CsoundObj csoundObj;
+ protected double minValue, maxValue, cachedValue;
+ boolean cacheDirty = true;
+ CsoundMYFLTArray ptr;
+
+ public CachedSlider(SeekBar seekBar, String channelName, double min, double max) {
+ this.seekBar = seekBar;
+ this.channelName = channelName;
+ this.minValue = min;
+ this.maxValue = max;
+
+ seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+
+ if(fromUser) {
+ double percent = progress / (double)seekBar.getMax();
+ double value = (percent * (maxValue - minValue)) + minValue;
+
+ if(value != cachedValue) {
+ cachedValue = value;
+ cacheDirty = true;
+ }
+ }
+
+ }
+ });
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ this.csoundObj = csoundObj;
+
+ double percent = seekBar.getProgress() / (double)seekBar.getMax();
+ cachedValue = (percent * (maxValue - minValue)) + minValue;
+ cacheDirty = true;
+
+ ptr = this.csoundObj.getInputChannelPtr(channelName);
+
+ }
+
+ @Override
+ public void updateValuesToCsound() {
+ if (cacheDirty) {
+ ptr.SetValue(0, this.cachedValue);
+ cacheDirty = false;
+ }
+ }
+
+ @Override
+ public void cleanup() {
+ seekBar.setOnSeekBarChangeListener(null);
+ ptr.Clear();
+ ptr = null;
+ }
+
+
+}
diff --git a/android/CsoundAndroid/src/com/csounds/valueCacheable/CsoundValueCacheable.java b/android/CsoundAndroid/src/com/csounds/valueCacheable/CsoundValueCacheable.java
new file mode 100644
index 0000000..0907a22
--- /dev/null
+++ b/android/CsoundAndroid/src/com/csounds/valueCacheable/CsoundValueCacheable.java
@@ -0,0 +1,40 @@
+/*
+
+ CsoundValueCacheable.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.valueCacheable;
+
+import com.csounds.CsoundObj;
+
+public interface CsoundValueCacheable {
+
+ public void setup(CsoundObj csoundObj);
+
+ public void updateValuesToCsound();
+
+ public void updateValuesFromCsound();
+
+ public void cleanup();
+
+}
diff --git a/android/CsoundAndroidExamples/.classpath b/android/CsoundAndroidExamples/.classpath
new file mode 100644
index 0000000..a4763d1
--- /dev/null
+++ b/android/CsoundAndroidExamples/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/android/CsoundAndroidExamples/.gitignore b/android/CsoundAndroidExamples/.gitignore
new file mode 100644
index 0000000..91e378c
--- /dev/null
+++ b/android/CsoundAndroidExamples/.gitignore
@@ -0,0 +1,10 @@
+*DS_Store
+obj
+libs
+bin
+gen
+src/csnd*
+*swp
+jni/csound_orc*
+jni/csound_prelex.c
+jni/java_interface*
diff --git a/android/CsoundAndroidExamples/.project b/android/CsoundAndroidExamples/.project
new file mode 100644
index 0000000..bf5513d
--- /dev/null
+++ b/android/CsoundAndroidExamples/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CsoundAndroidExamples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/android/CsoundAndroidExamples/AndroidManifest.xml b/android/CsoundAndroidExamples/AndroidManifest.xml
new file mode 100644
index 0000000..7196562
--- /dev/null
+++ b/android/CsoundAndroidExamples/AndroidManifest.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.csounds.examples"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:installLocation="auto">
+
+ <uses-sdk android:minSdkVersion="9" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:label="@string/app_name"
+ android:name=".CsoundAndroidActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait">
+ <intent-filter >
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:label="@string/simple_test_name"
+ android:name=".tests.SimpleTest1Activity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="@string/simple_test2_name"
+ android:name=".tests.SimpleTest2Activity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="Button Test"
+ android:name=".tests.ButtonTestActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="Ping Pong Delay"
+ android:name=".tests.PingPongDelayActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="@string/haiku_name"
+ android:name=".tests.CsoundHaikuIVActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="Harmonizer"
+ android:name=".tests.HarmonizerActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="Accelerometer"
+ android:name=".tests.AccelerometerActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="MultiTouch XY"
+ android:name=".tests.MultiTouchXYActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ <activity
+ android:label="Waveview"
+ android:name=".examples.tests.WaveviewTestActivity"
+ android:configChanges="orientation"
+ android:screenOrientation="portrait"/>
+
+ </application>
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <!-- MODIFY_AUDIO_SETTINGS is needed to use audio effects such as environmental reverb -->
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+</manifest>
\ No newline at end of file
diff --git a/COPYING b/android/CsoundAndroidExamples/COPYING
similarity index 100%
copy from COPYING
copy to android/CsoundAndroidExamples/COPYING
diff --git a/android/CsoundAndroidExamples/proguard-project.txt b/android/CsoundAndroidExamples/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/android/CsoundAndroidExamples/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/android/CsoundAndroidExamples/proguard.cfg b/android/CsoundAndroidExamples/proguard.cfg
new file mode 100644
index 0000000..b1cdf17
--- /dev/null
+++ b/android/CsoundAndroidExamples/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/android/CsoundAndroidExamples/project.properties b/android/CsoundAndroidExamples/project.properties
new file mode 100644
index 0000000..2c31c9b
--- /dev/null
+++ b/android/CsoundAndroidExamples/project.properties
@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-9
+android.library.reference.1=../CsoundAndroid
diff --git a/android/CsoundAndroidExamples/res/drawable-hdpi/ic_launcher.png b/android/CsoundAndroidExamples/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..96a442e
Binary files /dev/null and b/android/CsoundAndroidExamples/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/CsoundAndroidExamples/res/drawable-ldpi/ic_launcher.png b/android/CsoundAndroidExamples/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..9923872
Binary files /dev/null and b/android/CsoundAndroidExamples/res/drawable-ldpi/ic_launcher.png differ
diff --git a/android/CsoundAndroidExamples/res/drawable-mdpi/ic_launcher.png b/android/CsoundAndroidExamples/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..359047d
Binary files /dev/null and b/android/CsoundAndroidExamples/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/CsoundAndroidExamples/res/drawable-xhdpi/ic_launcher.png b/android/CsoundAndroidExamples/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..71c6d76
Binary files /dev/null and b/android/CsoundAndroidExamples/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/android/CsoundAndroidExamples/res/layout/accelerometer_test.xml b/android/CsoundAndroidExamples/res/layout/accelerometer_test.xml
new file mode 100644
index 0000000..bbae0c3
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/accelerometer_test.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:text="ToggleButton" />
+
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/button_test.xml b/android/CsoundAndroidExamples/res/layout/button_test.xml
new file mode 100644
index 0000000..3d2a105
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/button_test.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:text="ToggleButton" />
+
+ <Button
+ android:id="@+id/valueButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/onOffButton"
+ android:text="Value Button" />
+
+ <Button
+ android:id="@+id/eventButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/valueButton"
+ android:text="Event Button" />
+
+ <TextView
+ android:id="@+id/TextView01"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/eventButton"
+ android:padding="5dp"
+ android:text="Duration"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <SeekBar
+ android:id="@+id/durationSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@+id/TextView01"
+ android:layout_alignParentRight="true"
+ android:layout_alignTop="@+id/TextView01"
+ android:padding="5dp" />
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/durationSlider"
+ android:padding="5dp"
+ android:text="ADSR"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <SeekBar
+ android:id="@+id/attackSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/textView2"
+ android:padding="5dp" />
+
+ <SeekBar
+ android:id="@+id/decaySlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/attackSlider"
+ android:padding="5dp" />
+
+ <SeekBar
+ android:id="@+id/sustainSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/decaySlider"
+ android:padding="5dp" />
+
+ <SeekBar
+ android:id="@+id/releaseSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/sustainSlider"
+ android:padding="5dp" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/csound_haiku_iv.xml b/android/CsoundAndroidExamples/res/layout/csound_haiku_iv.xml
new file mode 100644
index 0000000..3988980
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/csound_haiku_iv.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Csound Haiku IV"
+ android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/harmonizer.xml b/android/CsoundAndroidExamples/res/layout/harmonizer.xml
new file mode 100644
index 0000000..98cca64
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/harmonizer.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:text="ToggleButton" />
+
+ <TextView
+ android:id="@+id/harmony_pitch_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Harmony Pitch"
+ android:layout_below="@+id/onOffButton"
+ />
+
+
+ <SeekBar
+ android:id="@+id/harmony_pitch_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/harmony_pitch_label"
+ android:padding="5dp" />
+
+
+ <TextView
+ android:id="@+id/gain_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Gain"
+ android:layout_below="@+id/harmony_pitch_slider"
+ />
+
+
+ <SeekBar
+ android:id="@+id/gain_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/gain_label"
+ android:padding="5dp" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/main.xml b/android/CsoundAndroidExamples/res/layout/main.xml
new file mode 100644
index 0000000..8a18334
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/main.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/list_view">
+
+
+
+</ListView>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/ping_pong_delay.xml b/android/CsoundAndroidExamples/res/layout/ping_pong_delay.xml
new file mode 100644
index 0000000..a7e988e
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/ping_pong_delay.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:text="ToggleButton" />
+
+ <TextView
+ android:id="@+id/left_channel_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Left Channel"
+ android:layout_below="@+id/onOffButton"
+ android:textAppearance="?android:attr/textAppearanceMedium" android:gravity="center"/>
+
+ <TextView
+ android:id="@+id/left_delay_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Delay"
+ android:layout_below="@+id/left_channel_label"
+ />
+
+
+ <SeekBar
+ android:id="@+id/left_delay_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/left_delay_label"
+ android:padding="5dp" />
+
+
+ <TextView
+ android:id="@+id/left_feedback_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Feedback"
+ android:layout_below="@+id/left_delay_slider"
+ />
+
+
+ <SeekBar
+ android:id="@+id/left_feedback_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/left_feedback_label"
+ android:padding="5dp" />
+
+
+ <TextView
+ android:id="@+id/right_channel_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Right Channel"
+ android:layout_below="@+id/left_feedback_slider"
+ android:textAppearance="?android:attr/textAppearanceMedium" android:gravity="center"/>
+
+ <TextView
+ android:id="@+id/right_delay_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Delay"
+ android:layout_below="@+id/right_channel_label"
+ />
+
+
+ <SeekBar
+ android:id="@+id/right_delay_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/right_delay_label"
+ android:padding="5dp" />
+
+
+ <TextView
+ android:id="@+id/right_feedback_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.29"
+ android:text="Feedback"
+ android:layout_below="@+id/right_delay_slider"
+ />
+
+ <SeekBar
+ android:id="@+id/right_feedback_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/right_feedback_label"
+ android:padding="5dp" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/simple_test_1.xml b/android/CsoundAndroidExamples/res/layout/simple_test_1.xml
new file mode 100644
index 0000000..7094db0
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/simple_test_1.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="ToggleButton" />
+
+ <SeekBar
+ android:id="@+id/slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/layout/simple_test_2.xml b/android/CsoundAndroidExamples/res/layout/simple_test_2.xml
new file mode 100644
index 0000000..d36818a
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/layout/simple_test_2.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ToggleButton
+ android:id="@+id/onOffButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:text="ToggleButton" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/onOffButton"
+ android:text="Note Rate" android:padding="5dp" android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+ <TextView
+ android:id="@+id/TextView01"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/textView1"
+ android:text="Duration"
+ android:padding="5dp" android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+ <SeekBar
+ android:id="@+id/noteRateSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@+id/textView1"
+ android:layout_toRightOf="@+id/textView1" android:padding="5dp"/>
+
+ <SeekBar
+ android:id="@+id/durationSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/noteRateSlider"
+ android:layout_alignParentRight="true"
+ android:layout_alignTop="@+id/TextView01"
+ android:padding="5dp" />
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/durationSlider"
+ android:text="ADSR"
+ android:textAppearance="?android:attr/textAppearanceLarge" android:padding="5dp"/>
+
+ <SeekBar
+ android:id="@+id/attackSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/textView2" android:padding="5dp"/>
+
+ <SeekBar
+ android:id="@+id/decaySlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/attackSlider" android:padding="5dp"/>
+
+ <SeekBar
+ android:id="@+id/sustainSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/decaySlider" android:padding="5dp"/>
+
+ <SeekBar
+ android:id="@+id/releaseSlider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/sustainSlider" android:padding="5dp"/>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/res/raw/button_test.csd b/android/CsoundAndroidExamples/res/raw/button_test.csd
new file mode 100644
index 0000000..d1e77ef
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/button_test.csd
@@ -0,0 +1,56 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtaudio=null -d -+msg_color=0 -m0
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+seed 0
+
+instr 1
+
+ktrigger chnget "button1"
+knotedur chnget "duration"
+
+if(ktrigger > 0) then
+ event "i", 2, 0, knotedur
+endif
+
+endin
+
+instr 2
+
+print p3
+
+iattack chnget "attack"
+idecay chnget "decay"
+isustain chnget "sustain"
+irelease chnget "release"
+
+
+;ipchMul rnd31 .5, -0.5
+;ipchMul = ipchMul + .5
+;ipch = 100 + (1000 * ipchMul)
+ipch = 100 + rnd(1000)
+
+;print iattack
+;print idecay
+;print isustain
+;print irelease
+
+a2 linsegr 0, iattack, 1, idecay, isustain, irelease, 0
+a1 oscili a2 * .25, ipch, 1
+outs a1,a1
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i1 0 3600
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/hardware_test.csd b/android/CsoundAndroidExamples/res/raw/hardware_test.csd
new file mode 100644
index 0000000..13ad1c0
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/hardware_test.csd
@@ -0,0 +1,50 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtmidi=null -+rtaudio=null -d -+msg_color=0 -M0 -m0
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+instr 1
+
+kaccelX chnget "accelerometerX"
+kaccelY chnget "accelerometerY"
+kaccelZ chnget "accelerometerZ"
+
+;kgyroX chnget "gyroX"
+;kgyroY chnget "gyroY"
+;kgyroZ chnget "gyroZ"
+
+;kattRoll chnget "attitudeRoll"
+;kattPitch chnget "attitudePitch"
+;kattYaw chnget "attitudeYaw"
+kaccelX port kaccelX*1000, 0.01
+kaccelY port kaccelY*1000, 0.01
+kaccelZ port kaccelZ*1000, 0.01
+
+kcutoff = 5000 + (4000 * kaccelX)
+kresonance = .3 + (.6 * kaccelY)
+kpch = 880 + kaccelX * 220
+
+a1 vco2 (kaccelZ + .5) * 0.2, kpch
+
+a1 moogladder a1, kcutoff, kresonance
+
+aL, aR reverbsc a1, a1, .72, 5000
+
+out aL, aR
+
+
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i1 0 360000
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/harmonizer.csd b/android/CsoundAndroidExamples/res/raw/harmonizer.csd
new file mode 100644
index 0000000..f3b574c
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/harmonizer.csd
@@ -0,0 +1,34 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtaudio=null -dm0 -i adc
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 22050
+
+instr 3
+
+asig,asig1 ins
+
+ksl chnget "slider"
+kgain chnget "gain"
+fsig1 pvsanal asig,2048,256,2048,1
+fsig2 pvscale fsig1,0.75+ksl,1
+fsig3 pvscale fsig1,(0.75+ksl)*1.25,1
+fsig4 pvsmix fsig2, fsig3
+a1 pvsynth fsig4
+
+a1 = a1 * kgain
+ outs a1,a1
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i3 0.1 10000
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/iv.csd b/android/CsoundAndroidExamples/res/raw/iv.csd
new file mode 100644
index 0000000..ebb08eb
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/iv.csd
@@ -0,0 +1,87 @@
+Csound Haiku - IV
+Iain McCurdy, 2011.
+
+<CsoundSynthesizer>
+
+<CsOptions>
+-odac -dm0 -+rtmidi=null -+rtaudio=null -+msg_color=0
+</CsOptions>
+
+<CsInstruments>
+sr = 44100
+ksmps = 64
+nchnls = 2
+0dbfs = 1
+
+gisine ftgen 0, 0, 4096, 10, 1
+gioctfn ftgen 0, 0, 4096, -19, 1, 0.5, 270, 0.5
+gasendL init 0
+gasendR init 0
+ginotes ftgen 0, 0, -100, -17, 0, 8.00, 10, 8.03, 15, 8.04, 25, 8.05, 50, 8.07, 60, 8.08, 73, 8.09, 82, 8.11
+ seed 0
+; alwayson "trigger_notes"
+; alwayson "reverb"
+
+ instr trigger_notes
+krate rspline 0.04, 0.15, 0.05, 0.1
+ktrig metro krate
+gktrans init 0
+gktrans trandom ktrig,-1, 1
+gktrans = semitone(gktrans)
+idur = 15
+ schedkwhen ktrig, 0, 0, "hboscil_note", rnd(2), idur
+ schedkwhen ktrig, 0, 0, "hboscil_note", rnd(2), idur
+ schedkwhen ktrig, 0, 0, "hboscil_note", rnd(2), idur
+ schedkwhen ktrig, 0, 0, "hboscil_note", rnd(2), idur
+ endin
+
+ instr hboscil_note
+ipch table int(rnd(100)),ginotes
+icps = cpspch(ipch)*i(gktrans)*semitone(rnd(0.5)-0.25)
+kamp expseg 0.001,0.02,0.2,p3-0.01,0.001
+ktonemoddep jspline 0.01,0.05,0.2
+ktonemodrte jspline 6,0.1,0.2
+ktone oscil ktonemoddep,ktonemodrte,gisine
+kbrite rspline -2,3,0.0002,3
+ibasfreq init icps
+ioctcnt init 2
+iphs init 0
+a1 hsboscil kamp, ktone, kbrite, ibasfreq, gisine, gioctfn, ioctcnt, iphs
+amod oscil 1, ibasfreq*3.47, gisine
+arm = a1*amod
+kmix expseg 0.001, 0.01, rnd(1), rnd(3)+0.3, 0.001
+a1 ntrpol a1, arm, kmix
+a1 pareq a1/10, 400, 15, .707
+a1 tone a1, 500
+kpanrte jspline 5, 0.05, 0.1
+kpandep jspline 0.9, 0.2, 0.4
+kpan oscil kpandep, kpanrte, gisine
+a1,a2 pan2 a1, kpan
+a1 delay a1, rnd(0.1)
+a2 delay a2, rnd(0.1)
+kenv linsegr 1, 1, 0
+a1 = a1*kenv
+a2 = a2*kenv
+ outs a1, a2
+gasendL = gasendL+a1/5
+gasendR = gasendR+a2/5
+ endin
+
+ instr reverb
+aL, aR reverbsc gasendL, gasendR, 0.9, 10000
+ outs aL, aR
+ clear gasendL, gasendR
+ endin
+
+</CsInstruments>
+
+<CsScore>
+f 0 3600
+i "trigger_notes" 0 3600
+i "reverb" 0 3600
+
+
+e
+</CsScore>
+
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/multitouch_xy.csd b/android/CsoundAndroidExamples/res/raw/multitouch_xy.csd
new file mode 100644
index 0000000..73d6cac
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/multitouch_xy.csd
@@ -0,0 +1,56 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtmidi=null -+rtaudio=null -d -+msg_color=0 -M0 -m0
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+ga1 init 0
+
+instr 1
+itie tival
+i_instanceNum = p4
+S_xName sprintf "touch.%d.x", i_instanceNum
+S_yName sprintf "touch.%d.y", i_instanceNum
+
+kx chnget S_xName
+ky chnget S_yName
+
+kenv linsegr 0, .01, 1, .1, 1, .25, 0
+a1 vco2 ky * .5 * kenv, 60 + (log(1 - kx) * 3000), 0
+
+ga1 = ga1 + a1
+
+endin
+
+instr 2
+
+;kcutoff chnget "cutoff"
+;kresonance chnget "resonance"
+
+kcutoff = 6000
+kresonance = .2
+
+
+a1 moogladder ga1, kcutoff, kresonance
+
+aL, aR reverbsc a1, a1, .72, 5000
+
+outs aL, aR
+
+ga1 = 0
+
+endin
+
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i2 0 360000
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/ping_pong_delay.csd b/android/CsoundAndroidExamples/res/raw/ping_pong_delay.csd
new file mode 100644
index 0000000..dd719f9
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/ping_pong_delay.csd
@@ -0,0 +1,34 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtmidi=null -+rtaudio=null -d -+msg_color=0 -M0 -m0 -i adc
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+instr 1
+
+kldelay chnget "leftDelayTime"
+klfeedback chnget "leftFeedback"
+krdelay chnget "rightDelayTime"
+krfeedback chnget "rightFeedback"
+
+asig,asig1 ins
+a1 init 0
+a2 init 0
+a1 vdelay3 asig+a2*klfeedback, kldelay, 3000
+a2 vdelay3 asig+a1*krfeedback, krdelay, 3000
+outs a2,a1
+
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i1 0 360000
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/test.csd b/android/CsoundAndroidExamples/res/raw/test.csd
new file mode 100644
index 0000000..b700bc0
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/test.csd
@@ -0,0 +1,31 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtaudio=null -d
+</CsOptions>
+<CsInstruments>
+nchnls=1
+0dbfs=1
+ksmps=64
+sr = 44100
+
+instr 1
+
+isl chnget "slider"
+ksl chnget "slider"
+ksl port ksl, 0.01, isl
+a2 expsegr 0.001,0.01,p4,p3-0.01, 0.001, 0.1, 0.001
+a1 oscili a2, p5*(1+ksl), 1
+out a1
+endin
+
+
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+{ 10 CNT
+i1 [$CNT*0.2] 0.5 0.5 [440*(2^[$CNT/12])]
+}
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/test2.csd b/android/CsoundAndroidExamples/res/raw/test2.csd
new file mode 100644
index 0000000..9c26e55
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/test2.csd
@@ -0,0 +1,60 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtaudio=null -d -+msg_color=0 -m0
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+seed 0
+
+instr 1
+
+inoterate chnget "noteRate"
+inotedur chnget "duration"
+
+;print inoterate
+;print inotedur
+
+event_i "i", 1, inoterate, 1
+event_i "i", 2, 0, inotedur
+
+turnoff
+
+endin
+
+instr 2
+
+iattack chnget "attack"
+idecay chnget "decay"
+isustain chnget "sustain"
+irelease chnget "release"
+
+
+;ipchMul rnd31 .5, -0.5
+;ipchMul = ipchMul + .5
+;ipch = 100 + (1000 * ipchMul)
+ipch = 100 + rnd(1000)
+
+;print iattack
+;print idecay
+;print isustain
+;print irelease
+
+a2 linsegr 0, iattack, 1, idecay, isustain, irelease, 0
+a1 oscili a2 * .3, ipch, 1
+outs a1,a1
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i1 0 1
+
+f 0 3600
+
+</CsScore>
+</CsoundSynthesizer>
diff --git a/android/CsoundAndroidExamples/res/raw/trapped.csd b/android/CsoundAndroidExamples/res/raw/trapped.csd
new file mode 100644
index 0000000..37edce7
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/trapped.csd
@@ -0,0 +1,745 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac -dm0 -+rtmidi=null -+rtaudio=null -+msg_color=0
+</CsOptions>
+<CsInstruments>
+;============================================================================;
+;============================================================================;
+;============================================================================;
+; == TRAPPED IN CONVERT == ;
+; Richard Boulanger ;
+;============================================================================;
+;============================================================================;
+; ORCHESTRA ;
+;============================================================================;
+;============================================================================;
+;============================================================================;
+; written July 1979 in music11 ;
+; M.I.T. Experimental Music Studio ;
+; revised June 1986 in Csound ;
+; M.I.T. Media Lab ;
+; revised July 1996 in SHARCsound ;
+; Analog Devices Inc. ;
+;============================================================================;
+;============================================================================;
+;=================================== HEADER =================================;
+;============================================================================;
+sr = 44100
+;kr = 4410
+ksmps = 64
+nchnls = 2
+;============================================================================;
+;=============================== INITIALIZATION =============================;
+;============================================================================;
+garvb init 0
+gadel init 0
+;============================================================================;
+;================================== INSTRUMENTS =============================;
+;============================================================================;
+;==================================== IVORY =================================;
+;============================================================================;
+ instr 1 ; p6 = amp
+ifreq = cpspch(p5) ; p7 = vib rate
+ ; p8 = glis. del time (default < 1)
+aglis expseg 1, p8, 1, p3 - p8, p9 ; p9 = freq drop factor
+
+k1 line 0, p3, 5
+k2 oscil k1, p7, 1
+k3 linseg 0, p3 * .7, p6, p3 * .3, 0
+a1 oscil k3, (ifreq + k2) * aglis, 1
+
+k4 linseg 0, p3 * .6, 6, p3 * .4, 0
+k5 oscil k4, p7 * .9, 1, 1.4
+k6 linseg 0, p3 * .9, p6, p3 * .1, 0
+a3 oscil k6, ((ifreq + .009) + k5) * aglis, 9, .2
+
+k7 linseg 9, p3 * .7, 1, p3 * .3, 1
+k8 oscil k7, p7 * 1.2, 1, .7
+k9 linen p6, p3 * .5, p3, p3 * .333
+a5 oscil k9, ((ifreq + .007) + k8) * aglis, 10, .3
+
+k10 expseg 1, p3 * .99, 3.1, p3 * .01, 3.1
+k11 oscil k10, p7 * .97, 1, .6
+k12 expseg .001, p3 * .8, p6, p3 * .2, .001
+a7 oscil k12,((ifreq + .005) + k11) * aglis, 11, .5
+
+k13 expseg 1, p3 * .4, 3, p3 * .6, .02
+k14 oscil k13, p7 * .99, 1, .4
+k15 expseg .001, p3 *.5, p6, p3 *.1, p6 *.6, p3 *.2, p6 *.97, p3 *.2, .001
+a9 oscil k15, ((ifreq + .003) + k14) * aglis, 12, .8
+
+k16 expseg 4, p3 * .91, 1, p3 * .09, 1
+k17 oscil k16, p7 * 1.4, 1, .2
+k18 expseg .001, p3 *.6, p6, p3 *.2, p6 *.8, p3 *.1, p6 *.98, p3 *.1, .001
+a11 oscil k18, ((ifreq + .001) + k17) * aglis, 13, 1.3
+
+ outs a1 + a3 + a5, a7 + a9 + a11
+ endin
+;============================================================================;
+;==================================== BLUE ==================================;
+;============================================================================;
+ instr 2 ; p6 = amp
+ifreq = cpspch(p5) ; p7 = reverb send factor
+ ; p8 = lfo freq
+k1 randi 1, 30 ; p9 = number of harmonic
+k2 linseg 0, p3 * .5, 1, p3 * .5, 0 ; p10 = sweep rate
+k3 linseg .005, p3 * .71, .015, p3 * .29, .01
+k4 oscil k2, p8, 1,.2
+k5 = k4 + 2
+
+ksweep linseg p9, p3 * p10, 1, p3 * (p3 - (p3 * p10)), 1
+
+kenv expseg .001, p3 * .01, p6, p3 * .99, .001
+asig gbuzz kenv, ifreq + k3, k5, ksweep, k1, 15
+
+ outs asig, asig
+garvb = garvb + (asig * p7)
+ endin
+;============================================================================;
+;================================== VIOLET ==================================;
+;============================================================================;
+ instr 3 ; p6 = amp
+ifreq = cpspch(p5) ; p7 = reverb send factor
+ ; p8 = rand freq
+k3 expseg 1, p3 * .5, 30 ,p3 * .5, 2
+k4 expseg 10, p3 *.7, p8, p3 *.3, 6
+k8 linen p6, p3 * .333, p3, p3 * .333
+k13 line 0, p3, -1
+
+k14 randh k3, k4, .5
+a1 oscil k8, ifreq + (p5 * .05) + k14 + k13, 1, .1
+
+k1 expseg 1, p3 * .8, 6, p3 *.2, 1
+k6 linseg .4, p3 * .9, p8 * .96, p3 * .1, 0
+k7 linseg 8, p3 * .2, 10, p3 * .76, 2
+
+kenv2 expseg .001, p3 * .4, p6 * .99, p3 * .6, .0001
+k15 randh k6, k7
+a2 buzz kenv2, ifreq + (p5 * .009) + k15 + k13, k1, 1, .2
+
+kenv1 linen p6, p3 * .25, p3, p3 * .4
+k16 randh k4 * 1.4, k7 * 2.1, .2
+a3 oscil kenv1, ifreq + (p5 * .1) + k16 + k13, 16, .3
+
+amix = a1 + a2 + a3
+ outs a1 + a3, a2 + a3
+garvb = garvb + (amix * p7)
+ endin
+;============================================================================;
+;==================================== BLACK =================================;
+;============================================================================;
+ instr 4 ; p6 = amp
+ifreq = cpspch(p5) ; p7 = filtersweep strtfreq
+ ; p8 = filtersweep endfreq
+k1 expon p7, p3, p8 ; p9 = bandwidth
+anoise rand 8000 ; p10 = reverb send factor
+a1 reson anoise, k1, k1 / p9, 1
+k2 oscil .6, 11.3, 1, .1
+k3 expseg .001,p3 * .001, p6, p3 * .999, .001
+a2 oscil k3, ifreq + k2, 15
+
+ outs (a1 * .8) + a2, (a1 * .6) + (a2 * .7)
+garvb = garvb + (a2 * p10)
+ endin
+;============================================================================;
+;==================================== GREEN =================================;
+;============================================================================;
+ instr 5 ; p6 = amp
+ifreq = cpspch(p5) ; p7 = reverb send factor
+ ; p8 = pan direction
+k1 line p9, p3, 1 ; ... (1.0 = L -> R, 0.1 = R -> L)
+k2 line 1, p3, p10 ; p9 = carrier freq
+k4 expon 2, p3, p12 ; p10 = modulator freq
+k5 linseg 0, p3 * .8, 8, p3 * .2, 8 ; p11 = modulation index
+k7 randh p11, k4 ; p12 = rand freq
+k6 oscil k4, k5, 1, .3
+
+kenv1 linen p6, .03, p3, .2
+a1 foscil kenv1, ifreq + k6, k1, k2, k7, 1
+
+kenv2 linen p6, .1, p3, .1
+a2 oscil kenv2, ifreq * 1.001, 1
+
+amix = a1 + a2
+kpan linseg int(p8), p3 * .7, frac(p8), p3 * .3, int(p8)
+ outs amix * kpan, amix * (1 - kpan)
+garvb = garvb + (amix * p7)
+ endin
+;============================================================================;
+;================================== COPPER ==================================;
+;============================================================================;
+ instr 6 ; p5 = FilterSweep StartFreq
+ifuncl = 8 ; p6 = FilterSweep EndFreq
+ ; p7 = bandwidth
+k1 phasor p4 ; p8 = reverb send factor
+k2 table k1 * ifuncl, 19 ; p9 = amp
+anoise rand 8000
+k3 expon p5, p3, p6
+a1 reson anoise, k3 * k2, k3 / p7, 1
+
+kenv linen p9, .01, p3, .05
+asig = a1 * kenv
+
+ outs asig, asig
+garvb = garvb + (asig * p8)
+ endin
+;============================================================================;
+;==================================== PEWTER ================================;
+;============================================================================;
+ instr 7 ; p4 = amp
+ifuncl = 512 ; p5 = freq
+ifreq = cpspch(p5) ; p6 = begin phase point
+ ; p7 = end phase point
+a1 oscil 1, ifreq, p10 ; p8 = ctrl osc amp (.1 -> 1)
+k1 linseg p6, p3 * .5, p7, p3 * .5, p6 ; p9 = ctrl osc func
+a3 oscili p8, ifreq + k1, p9 ; p10 = main osc func (f2 or f3)
+a4 phasor ifreq ; ...(function length must be 512!)
+a5 table (a4 + a3) * ifuncl, p10 ; p11 = reverb send factor
+
+kenv linen p4, p3 * .4, p3, p3 * .5
+asig = kenv * ((a1 + a5) * .2)
+
+ outs asig, asig
+garvb = garvb + (asig * p11)
+ endin
+;============================================================================;
+;==================================== RED ===================================;
+;============================================================================;
+ instr 8 ; p4 = amp
+ifuncl = 16 ; p5 = FilterSweep StartFreq
+ ; p6 = FilterSweep EndFreq
+k1 expon p5, p3, p6 ; p7 = bandwidth
+k2 line p8, p3, p8 * .93 ; p8 = cps of rand1
+k3 phasor k2 ; p9 = cps of rand2
+k4 table k3 * ifuncl, 20 ; p10 = reverb send factor
+anoise rand 8000
+aflt1 reson anoise, k1, 20 + (k4 * k1 / p7), 1
+
+k5 linseg p6 * .9, p3 * .8, p5 * 1.4, p3 * .2, p5 * 1.4
+k6 expon p9 * .97, p3, p9
+k7 phasor k6
+k8 tablei k7 * ifuncl, 21
+aflt2 reson anoise, k5, 30 + (k8 * k5 / p7 * .9), 1
+
+abal oscil 1000, 1000, 1
+a3 balance aflt1, abal
+a5 balance aflt2, abal
+
+k11 linen p4, .15, p3, .5
+a3 = a3 * k11
+a5 = a5 * k11
+
+k9 randh 1, k2
+aleft = ((a3 * k9) * .7) + ((a5 * k9) * .3)
+k10 randh 1, k6
+aright = ((a3 * k10) * .3)+((a5 * k10) * .7)
+ outs aleft, aright
+garvb = garvb + (a3 * p10)
+endin
+;============================================================================;
+;==================================== SAND ==================================;
+;============================================================================;
+ instr 9 ; p4 = delay send factor
+ifreq = cpspch(p5) ; p5 = freq
+ ; p6 = amp
+k2 randh p8, p9, .1 ; p7 = reverb send factor
+k3 randh p8 * .98, p9 * .91, .2 ; p8 = rand amp
+k4 randh p8 * 1.2, p9 * .96, .3 ; p9 = rand freq
+k5 randh p8 * .9, p9 * 1.3
+
+kenv linen p6, p3 *.1, p3, p3 * .8
+
+a1 oscil kenv, ifreq + k2, 1, .2
+a2 oscil kenv * .91, (ifreq + .004) + k3, 2, .3
+a3 oscil kenv * .85, (ifreq + .006) + k4, 3, .5
+a4 oscil kenv * .95, (ifreq + .009) + k5, 4, .8
+
+amix = a1 + a2 + a3 + a4
+
+ outs a1 + a3, a2 + a4
+garvb = garvb + (amix * p7)
+gadel = gadel + (amix * p4)
+ endin
+;============================================================================;
+;==================================== TAUPE =================================;
+;============================================================================;
+ instr 10
+ifreq = cpspch(p5) ; p5 = freq
+ ; p6 = amp
+k2 randh p8, p9, .1 ; p7 = reverb send factor
+k3 randh p8 * .98, p9 * .91, .2 ; p8 = rand amp
+k4 randh p8 * 1.2, p9 * .96, .3 ; p9 = rand freq
+k5 randh p8 * .9, p9 * 1.3
+
+kenv linen p6, p3 *.1, p3, p3 * .8
+
+a1 oscil kenv, ifreq + k2, 1, .2
+a2 oscil kenv * .91, (ifreq + .004) + k3, 2, .3
+a3 oscil kenv * .85, (ifreq + .006) + k4, 3, .5
+a4 oscil kenv * .95, (ifreq + .009) + k5, 4, .8
+
+amix = a1 + a2 + a3 + a4
+
+ outs a1 + a3, a2 + a4
+garvb = garvb + (amix * p7)
+ endin
+;============================================================================;
+;==================================== RUST ==================================;
+;============================================================================;
+ instr 11 ; p4 = delay send factor
+ifreq = cpspch(p5) ; p5 = freq
+ ; p6 = amp
+k1 expseg 1, p3 * .5, 40, p3 * .5, 2 ; p7 = reverb send factor
+k2 expseg 10, p3 * .72, 35, p3 * .28, 6
+k3 linen p6, p3* .333, p3, p3 * .333
+k4 randh k1, k2, .5
+a4 oscil k3, ifreq + (p5 * .05) + k4, 1, .1
+
+k5 linseg .4, p3 * .9, 26, p3 * .1, 0
+k6 linseg 8, p3 * .24, 20, p3 * .76, 2
+k7 linen p6, p3 * .5, p3, p3 * .46
+k8 randh k5, k6, .4
+a3 oscil k7, ifreq + (p5 * .03) + k8, 14, .3
+
+k9 expseg 1, p3 * .7, 50, p3 * .3, 2
+k10 expseg 10, p3 * .3, 45, p3 * .7, 6
+k11 linen p6, p3 * .25, p3, p3 * .25
+k12 randh k9, k10, .5
+a2 oscil k11, ifreq + (p5 * .02) + k12, 1, .1
+
+k13 linseg .4, p3 * .6, 46, p3 * .4, 0
+k14 linseg 18, p3 * .1, 50, p3 * .9, 2
+k15 linen p6, p3 * .2, p3, p3 * .3
+k16 randh k13, k14, .8
+a1 oscil k15, ifreq + (p5 * .01) + k16, 14, .3
+
+amix = a1 + a2 + a3 + a4
+ outs a1 + a3, a2 + a4
+garvb = garvb + (amix * p7)
+gadel = gadel + (amix * p4)
+ endin
+;============================================================================;
+;==================================== TEAL ==================================;
+;============================================================================;
+ instr 12 ; p6 = amp
+ifreq = octpch(p5) ; p7 = FilterSweep StartFreq
+ifuncl = 8 ; p8 = FilterSweep PeakFreq
+ ; p9 = bandwdth
+k1 linseg 0, p3 * .8, 9, p3 * .2, 1 ; p10 = reverb send factor
+k2 phasor k1
+k3 table k2 * ifuncl, 22
+k4 expseg p7, p3 * .7, p8, p3 * .3, p7 * .9
+
+anoise rand 8000
+
+aflt reson anoise, k4, k4 / p9, 1
+kenv1 expseg .001, p3 *.1, p6, p3 *.1, p6 *.5, p3 *.3, p6 *.8, p3 *.5,.001
+a3 oscil kenv1, cpsoct(ifreq + k3) + aflt * .8, 1
+
+ outs a3,(a3 * .98) + (aflt * .3)
+garvb = garvb + (anoise * p10)
+ endin
+;============================================================================;
+;==================================== FOAM ==================================;
+;============================================================================;
+ instr 13 ; p6 = amp
+ifreq = octpch(p5) ; p7 = vibrato rate
+ ; p8 = glis. factor
+k1 line 0, p3, p8
+k2 oscil k1, p7, 1
+k3 linseg 0, p3 * .7, p6, p3 * .3, 1
+a1 oscil k3, cpsoct(ifreq + k2), 1
+
+k4 linseg 0, p3 * .6, p8 * .995, p3 * .4, 0
+k5 oscil k4, p7 * .9, 1, .1
+k6 linseg 0, p3 * .9, p6, p3 * .1, 3
+a2 oscil k6, cpsoct((ifreq + .009) + k5), 4, .2
+
+k7 linseg p8 * .985, p3 * .7, 0, p3 * .3, 0
+k8 oscil k7, p7 * 1.2, 1, .7
+k9 linen p6, p3 * .5, p3, p3 * .333
+a3 oscil k6, cpsoct((ifreq + .007) + k8), 5, .5
+
+k10 expseg 1, p3 * .8, p8, p3 * .2, 4
+k11 oscil k10, p7 * .97, 1, .6
+k12 expseg .001, p3 * .99, p6 * .97, p3 * .01, p6 * .97
+a4 oscil k12, cpsoct((ifreq + .005) + k11), 6, .8
+
+k13 expseg .002, p3 * .91, p8 * .99, p3 * .09, p8 * .99
+k14 oscil k13, p7 * .99, 1, .4
+k15 expseg .001, p3 *.5, p6, p3 *.1, p6 *.6, p3 *.2, p6 *.97, p3 *.2, .001
+a5 oscil k15, cpsoct((ifreq + .003) + k14), 7, .9
+
+k16 expseg p8 * .98, p3 * .81, .003, p3 * .19, .003
+k17 oscil k16, p7 * 1.4, 1, .2
+k18 expseg .001, p3 *.6, p6, p3 *.2, p6 *.8, p3 *.1, p6 *.98, p3 *.1, .001
+a6 oscil k18, cpsoct((ifreq + .001) + k17), 8, .1
+
+ outs a1 + a3 + a5, a2 + a4 + a6
+ endin
+;============================================================================;
+;==================================== SMEAR =================================;
+;============================================================================;
+ instr 98
+asig delay gadel, .08
+ outs asig, asig
+gadel = 0
+ endin
+;============================================================================;
+;==================================== SWIRL =================================;
+;============================================================================;
+ instr 99 ; p4 = panrate
+k1 oscil .5, p4, 1
+k2 = .5 + k1
+k3 = 1 - k2
+asig reverb garvb, 2.1
+ outs asig * k2, (asig * k3) * (-1)
+garvb = 0
+ endin
+;============================================================================;
+;============================================================================;
+;============================================================================;
+;============================================================================;
+instr 100
+ ;k0,1,k2 cpumeter 0.3
+ ; printk2 k0
+ ; printk2 k1, 10
+ ; printk2 k2, 20
+endin
+
+</CsInstruments>
+<CsScore>
+;============================================================================;
+;============================================================================;
+; == TRAPPED IN CONVERT == ;
+; Richard Boulanger ;
+;============================================================================;
+;============================================================================;
+; SCORE ;
+;============================================================================;
+;================================= PARAMETERS ===============================;
+;============================================================================;
+; i1: p6=amp,p7=vibrat,p8=glisdeltime (default < 1),p9=frqdrop ;
+; i2: p6=amp,p7=rvbsnd,p8=lfofrq,p9=num of harmonics,p10=sweeprate ;
+; i3: p6=amp,p7=rvbsnd,p8=rndfrq ;
+; i4: p6=amp,p7=fltrswp:strtval,p8=fltrswp:endval,p9=bdwth,p10=rvbsnd ;
+; i5: p6=amp,p7=rvbatn,p8=pan:1.0,p9=carfrq,p10=modfrq,p11=modndx,p12=rndfrq;
+; i6: p5=swpfrq:strt,p6=swpfrq:end,p7=bndwth,p8=rvbsnd,p9=amp ;
+; i7: p4=amp,p5=frq,p6=strtphse,p7=endphse,p8=ctrlamp(.1-1),p9=ctrlfnc ;
+; p10=audfnc(f2,f3,f14,p11=rvbsnd ;
+; i8: p4=amp,p5=swpstrt,p6=swpend,p7=bndwt,p8=rnd1:cps,p9=rnd2:cps,p10=rvbsnd;
+; i9: p4=delsnd,p5=frq,p6=amp,p7=rvbsnd,p8=rndamp,p9=rndfrq ;
+; i10: p4=0,p5=frq,p6=amp,p7=rvbsnd,p8=rndamp,p9=rndfrq ;
+; i11: p4=delsnd,p5=frq,p6=amp,p7=rvbsnd ;
+; i12: p6=amp,p7=swpstrt,p8=swppeak,p9=bndwth,p10=rvbsnd ;
+; i13: p6=amp,p7=vibrat,p8=dropfrq ;
+; i98: p2=strt,p3=dur ;
+; i99: p4=pancps ;
+;============================================================================;
+;========================= FUNCTIONS ========================================;
+;============================================================================;
+f1 0 8192 10 1
+f2 0 512 10 10 8 0 6 0 4 0 1
+f3 0 512 10 10 0 5 5 0 4 3 0 1
+f4 0 2048 10 10 0 9 0 0 8 0 7 0 4 0 2 0 1
+f5 0 2048 10 5 3 2 1 0
+f6 0 2048 10 8 10 7 4 3 1
+f7 0 2048 10 7 9 11 4 2 0 1 1
+f8 0 2048 10 0 0 0 0 7 0 0 0 0 2 0 0 0 1 1
+f9 0 2048 10 10 9 8 7 6 5 4 3 2 1
+f10 0 2048 10 10 0 9 0 8 0 7 0 6 0 5
+f11 0 2048 10 10 10 9 0 0 0 3 2 0 0 1
+f12 0 2048 10 10 0 0 0 5 0 0 0 0 0 3
+f13 0 2048 10 10 0 0 0 0 3 1
+f14 0 512 9 1 3 0 3 1 0 9 .333 180
+f15 0 8192 9 1 1 90
+f16 0 2048 9 1 3 0 3 1 0 6 1 0
+f17 0 9 5 .1 8 1
+f18 0 17 5 .1 10 1 6 .4
+f19 0 16 2 1 7 10 7 6 5 4 2 1 1 1 1 1 1 1 1
+f20 0 16 -2 0 30 40 45 50 40 30 20 10 5 4 3 2 1 0 0 0
+f21 0 16 -2 0 20 15 10 9 8 7 6 5 4 3 2 1 0 0
+f22 0 9 -2 .001 .004 .007 .003 .002 .005 .009 .006
+;============================================================================;
+;========================= SECTION I: 78 SECONDS ===========================;
+;============================================================================;
+i1 0.0 24.12 0 11.057 200 0.001 17.8 0.99
+i1 1.0 21.76 0 11.049 240 0.001 10.2 0.99
+i1 3.6 17.13 0 11.082 390 0.001 11.3 0.99
+i1 6.2 15.02 0 11.075 460 0.001 10.5 0.99
+i1 8.4 13.85 0 11.069 680 0.001 13.8 0.99
+i99 22.0 7.5 5
+i2 22.0 4 0 9.029 600 0.6 23 10 0.52
+i2 22.13 4 0 9.01 600 0.5 20 6 0.66
+i1 26.5 5.6 0 12.019 500 4.0 5.8 0.98
+i1 26.51 6.1 0 12.004 550 5.0 5.5 0.98
+i1 26.52 5.4 0 12.026 600 5.2 5.6 0.98
+i1 26.55 5 0 12.031 660 4.5 5.7 0.98
+i99 31.3 0.7 22
+i4 31.3 1 0 13.045 2200 6000 7000 30 0.5
+i99 32.0 4 11
+i2 32.0 4 0 14.107 900 0.4 19 13 0.21
+i2 32.14 4 0 11.023 750 0.7 21 9 0.19
+i2 32.19 4 0 11.029 589 0.97 20 10 0.22
+i4 35.0 1 0 12.029 1000 4600 6500 33 0.6
+i99 36.0 10 7
+i3 36.0 7.6 0 13.087 800 0.8 57
+i1 39.31 8.1 0 10.024 519 3.0 3.1 0.002
+i1 39.32 8 0 10.031 520 5.1 3.7 0.001
+i1 39.35 7.9 0 10.042 557 3.4 3.5 0.003
+i1 39.37 7.86 0 10.050 547 4.2 3.3 0.004
+i99 46.0 7.3 2
+i5 46.0 0.9 0 4.09 3500 0.2 0.1 3 10 12 27
+i5 49.2 1.1 0 3.07 4500 0.1 1.0 5 3 16 30
+i99 53.3 9.6 5
+i6 53.3 8.5 0.81 3000 17 10 0.6 1.6
+i98 62.9 15.1
+i99 62.9 15.1 3
+i9 62.9 2.9 0.4 4.113 600 0.2 6.2 320
+i9 62.93 2.85 0.43 4.115 640 0.23 6.1 300
+i9 67.1 7.9 0.2 5.004 700 0.4 4.5 289
+i9 67.14 7.78 0.17 5.007 700 0.43 4.4 280
+;s 80
+i100 0 78
+s
+;============================================================================;
+;========================= SECTION II: 49 SECONDS ===========================;
+;============================================================================;
+i98 0 48.5
+i99 0 4.5 1
+i9 0 5 0.4 10.01 1200 0.2 28 39
+i9 0 5 0.3 9.119 1200 0.4 29 37
+i3 0.5 6.5 0 12.067 600 0.6 47
+i99 4.5 2 7
+i6 4.5 4.3 17 6000 9000 100 0.4 0.9
+i99 6.5 9.9 0.7
+i7 6.5 3.2 9999 5.023 0.2 0.7 0.6 2 3 0.12
+i7 8 1.9 9800 5.039 0.01 0.9 1 3 2 0.23
+i7 9 3.8 9900 10.001 0.99 0.1 0.3 3 2 0.12
+i3 9.1 5.5 0 10.017 900 0.5 67
+i7 9.2 2.5 9890 5.052 0.1 1.0 0.7 2 3 0.23
+i8 11 4.6 4 20 8000 590 2 9.9 0.6
+i8 15.5 3.1 3 50 4000 129 8 2.6 0.3
+i8 16.2 4.3 2 10000 9000 200 12 17.9 1
+i99 16.4 10.3 0.3
+i7 16.4 3.5 8000 5.019 0.2 0.7 0.5 2 3 0.1
+i7 19.3 6.4 8000 5.041 0.01 0.9 1 3 2 0.1
+i9 20.2 4 0.4 9.021 1000 0.2 4 100
+i9 21 4.2 0.4 9.099 1100 0.4 4 167
+i9 21.1 8 0.4 9.043 1000 0.6 4 210
+i9 21.25 5 0.4 9.062 1200 0.9 5 200
+i99 26.7 5.3 11
+i9 26.7 1.9 0.5 4.114 3100 0.1 5.9 300
+i9 29.1 2.1 0.1 5.013 2900 0.2 4.2 390
+i99 32 6.2 0.28
+i9 32 9.1 0.34 5.051 2300 0.5 3.8 420
+i9 32.1 9.0 0.4 5.0517 2500 0.4 4 430
+i2 34.2 5 0 9.029 1900 0.3 23 10 0.42
+i2 34.23 5 0 9.01 2100 0.2 20 6 0.29
+i2 36 5 0 13.027 3500 0.5 27 9 0.38
+i2 36.05 5 0 12.119 3399 0.1 21 3 0.30
+i2 36.12 5 0 13.018 3709 0.4 17 12 0.33
+i99 38.2 10.8 2
+i2 38.2 7.3 0 8.062 5900 0.4 19 13 0.26
+i2 38.4 7 0 7.077 4730 0.6 26 21 0.23
+i4 38.9 3.1 0 10.001 2600 2000 3000 46 0.3
+i4 39.7 2.3 0 9.0119 1200 1000 2000 50 0.2
+i100 0 49
+s
+;============================================================================;
+;========================= SECTION III: 56 SECONDS ==========================;
+;============================================================================;
+i98 0 42
+i99 0 42 0.0618
+i9 0 7 0.6 11.031 1100 0.2 30 40
+i9 0.1 7 0.2 11.042 1100 0.9 26 37
+i9 0.3 6.2 0.9 11.049 1105 0.1 32 29
+i9 0.6 5.8 0.4 11.021 1110 0.6 41 34
+i11 3.7 8 0.2 5.02 2200 0.2
+i13 7.0 4.5 0.4 11.064 1500 40.0 7
+i9 9.3 9 0.8 7.098 1300 0.3 33 27
+i9 9.8 7 0.2 7.087 1400 0.7 39 31
+i2 10.9 4 0.2 8.113 5000 0.9 45 20 1
+i11 12 5 0.2 4.101 3300 0.3
+i2 12.9 5 0.2 9.108 5900 0.4 59 14 0.6
+i8 15 4.7 2.5 8600 8900 900 13 11.1 0.7
+i11 17.9 7 0.4 4.091 3000 0.1
+i9 22 7 0.6 10.031 1000 0.2 30 40
+i9 22.1 7 0.2 10.042 1000 0.9 26 37
+i9 22.3 6.2 0.9 10.049 1005 0.1 32 29
+i9 22.6 5.8 0.4 10.021 1010 0.6 41 34
+i11 25.2 5.3 0.3 5.111 2500 0.2
+i11 26.9 5.1 0.2 4.093 2330 0.1
+i13 27.1 4 0.4 12.064 2000 40 7
+i13 28.9 4 0.4 11.117 2000 30.0 5
+i9 29.3 9 0.8 8.098 1000 0.3 33 27
+i9 30.8 7 0.2 8.087 1200 0.7 39 31
+i9 31.2 7.2 0.9 8.071 1400 0.9 29 40
+i2 32.9 5 0.9 8.113 5000 0.8 45 20 1
+i8 33.1 7 2 5000 6000 1000 17 15 0.3
+i2 33.3 6 0.9 7.097 5100 0.5 51 18 0.3
+i11 34 5 0.3 4.111 2000 0.5
+i8 34.5 6 2 3000 100 500 8.3 9.8 0.1
+i2 34.9 6 0.9 9.108 2900 0.4 59 14 0.4
+i2 35 5 0.9 8.042 2800 0.6 39 20 0.3
+i11 36.1 5 0.5 3.119 1200 0.4
+i11 36.8 7 0.2 5.118 1800 0.4
+i11 38 6 0.2 4.031 2000 0.2
+i11 39 4 0.3 6.003 1300 0.1
+i99 42 3.6 8.3
+i4 42 1 9.6 13.061 3000 8000 20 10 0.9
+i4 42 0.99 9.6 13.013 3110 6000 30 6 0.3
+i4 42 1.01 9.6 12.119 2999 10000 25 15 0.7
+i5 43 1.1 9.6 3.106 2500 0.4 1.0 8 3 17 34
+i5 43.1 1 9.6 4.034 2500 0.2 0.1 2 7 19 29
+i99 45.6 4.9 3.2
+i5 45.6 3 3.2 4.022 2300 0.3 1.0 11 4 20 37
+i5 46.1 2.4 3.2 3.049 2400 0.2 0.1 5 8 19 27
+i99 50.5 5.5 8.3
+i4 50.5 0.7 11 11.059 3000 7000 40 9 0.9
+i4 50.5 0.7 11 10.038 3000 10000 20 20 0.7
+i4 50.5 0.71 11 13.077 3000 9500 25 5 0.8
+i4 50.52 0.64 11 12.016 3000 8500 18 14 0.5
+i5 51 1.5 11 4.011 2000 0.1 1.0 3 11 13 28
+i5 51 1.5 11 3.106 2000 0.4 0.1 7 5 15 34
+i100 0 56
+s
+;============================================================================;
+;========================= SECTION IV: 100 SECONDS =========================;
+;============================================================================;
+;========================= VARIABLE TEMPO ===================================;
+t 0 60 40 60 45 30 49 40 52 90 55 100 58 160 59 200 61 230 65 270 78 40
+;============================================================================;
+i99 0 1 2.8
+i4 0 1 6.8 12.013 3700 9000 40 17 0.5
+i4 0.01 1 6.8 12.061 3501 8500 30 20 0.3
+i4 0.02 1 6.8 11.119 3399 7780 32 22 0.8
+i4 0.03 1 6.8 12.042 3010 8600 41 27 0.45
+i99 1 3.4 9.8
+i12 1 3 6.8 5.06 1000 100 7000 16 0.2
+i12 1.03 2.9 6.8 5.02 1000 60 6000 30 0.2
+i99 4.4 3.6 4.8
+i12 4.4 2.6 6.8 11.09 2000 1000 200 5 0.1
+i99 8 2.1 7
+i4 8 0.9 11 10.013 3000 9000 40 17 0.9
+i4 8.1 0.9 11 10.061 3001 8500 30 20 0.8
+i4 8.2 0.9 11 10.119 2999 7780 32 22 0.7
+i99 10.1 1.1 21
+i12 10.1 0.6 11 11.02 1000 1500 300 4 0.2
+i99 11.2 6.8 2
+i10 11.2 6 0 4.092 3000 0.3 6.9 200
+i10 11.2 10 0 4.113 3000 0.1 7.2 278
+i12 13 1.6 0.3 10.01 3000 2000 500 5.2 0.2
+i10 13 1.6 0.4 9.012 3000 0.3 21 31
+i4 15 0.7 0.4 13.023 5000 9000 40 17 0.9
+i4 15 0.7 0.4 13.081 5001 8500 30 20 0.3
+i4 15 0.7 0.4 13.019 4999 7780 32 22 0.7
+i4 15 0.7 0.4 13.079 4550 9699 50 30 0.5
+i4 15.7 1 0.4 9.013 1101 9000 40 17 0.9
+i4 15.7 1 0.4 10.051 1051 8500 30 20 0.6
+i4 15.7 1 0.4 7.119 1111 7780 32 22 0.2
+i4 15.7 1 0.4 8.099 1100 10000 100 27 0.8
+i12 17 2 0.4 9.02 3000 3000 1000 4 0.3
+i99 18 3 9.3
+i10 18 5 0 11.09 900 0.4 23 33
+i10 18.1 5 0 11.08 900 0.4 20 40
+i10 18.3 5 0 11.073 900 0.4 30 27
+i10 18.6 5 0 11.068 900 0.4 33 33
+i10 19 10 0 11.001 500 0.8 8 200
+i10 20 9 0 11.022 500 0.8 9 300
+i10 20.4 8.6 0 11.091 500 0.8 5 223
+i99 21 56 0.15
+i10 21 18 0 11.115 500 0.8 6.4 311
+i10 21.6 17.4 0 12.041 500 0.8 7 276
+i10 21.9 2.9 0 5.002 2000 0.3 4.1 200
+i10 25.3 3.5 0 5.031 2300 0.5 3.6 160
+i10 30.9 3.9 0 5.017 2500 0.7 3 100
+i10 36.3 6.1 0 4.097 1770 0.8 4 200
+i10 42 34.09 0 4.0017 6000 0.19 4.1 310
+i8 45 26.9 0.79 190 500 11 1.9 2.7 0.1
+i8 49 22.9 0.80 10000 8000 300 11 12.6 0.2
+i8 52 19.1 0.85 7000 10000 16 4.1 4.8 0.3
+i8 55 16.9 0.91 500 190 10 2.9 1.3 0.2
+i8 58 13.9 0.98 40 9000 379 33 19 0.1
+i8 60 12.9 0.99 3600 11000 19 17 22 0.3
+i8 61 11.9 1.01 2000 3000 30 4 18.8 0.2
+i99 77 23 0.09
+i4 77 1.7 0.3 13.079 850 9699 50 30 0.8
+i10 77.1 2.14 0 13.03 600 0.5 60 26
+i10 77.6 2.3 0 13.02 800 0.6 62 24
+i10 78.3 9.9 0 5.004 900 0.2 4.1 160
+i10 78.7 9.8 0 5.001 800 0.3 1.4 220
+i2 80.4 9 0 7.077 930 0.8 26 21 0.23
+i2 80.7 8 0 8.077 830 0.7 24 19 0.13
+i4 81.9 1.9 0.7 11.079 950 7699 40 20 0.7
+i4 82 2.8 0.5 10.079 850 5699 60 40 0.5
+i10 82.11 5.3 0 3.053 1800 0.1 4.0 210
+i10 82.14 3.8 0 4.048 1100 0.2 71 33
+i10 82.32 3.1 0 5.049 1000 0.2 68 27
+i10 82.06 2.9 0 5.051 900 0.2 72 31
+i10 84.04 9.9 0 4.003 1800 0.1 4.1 160
+i10 84.06 9.8 0 4.002 1900 0.3 1.4 220
+i10 84.618 9.8 0 5.005 900 0.4 4.1 180
+i100 0 100
+e
+;============================================================================;
+;======================= TOTAL TIME: 283 SECONDS ============================;
+;============================================================================;
+
+
+
+
+
+</CsScore>
+</CsoundSynthesizer>
+<bsbPanel>
+ <label>Widgets</label>
+ <objectName/>
+ <x>966</x>
+ <y>366</y>
+ <width>400</width>
+ <height>201</height>
+ <visible>true</visible>
+ <uuid/>
+ <bgcolor mode="nobackground">
+ <r>231</r>
+ <g>46</g>
+ <b>255</b>
+ </bgcolor>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider1</objectName>
+ <x>5</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{86b9ad70-540b-4d5b-b0b9-07fa3da7466b}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+</bsbPanel>
+<bsbPresets>
+</bsbPresets>
+<MacOptions>
+Version: 3
+Render: Real
+Ask: Yes
+Functions: ioObject
+Listing: Window
+WindowBounds: 966 366 400 201
+CurrentView: io
+IOViewEdit: On
+Options:
+</MacOptions>
+
+<MacGUI>
+ioView nobackground {59367, 11822, 65535}
+ioSlider {5, 5} {20, 100} 0.000000 1.000000 0.000000 slider1
+</MacGUI>
diff --git a/android/CsoundAndroidExamples/res/raw/waveviewtest.csd b/android/CsoundAndroidExamples/res/raw/waveviewtest.csd
new file mode 100644
index 0000000..01e465e
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/raw/waveviewtest.csd
@@ -0,0 +1,63 @@
+<CsoundSynthesizer>
+<CsOptions>
+-o dac -+rtmidi=null -+rtaudio=null -d -+msg_color=0 -M0 -m0 -i adc
+</CsOptions>
+<CsInstruments>
+nchnls=2
+0dbfs=1
+ksmps=64
+sr = 44100
+
+instr 1
+
+
+
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1
+
+i1 0 360000
+
+</CsScore>
+</CsoundSynthesizer>
+<bsbPanel>
+ <label>Widgets</label>
+ <objectName/>
+ <x>1036</x>
+ <y>61</y>
+ <width>396</width>
+ <height>744</height>
+ <visible>true</visible>
+ <uuid/>
+ <bgcolor mode="nobackground">
+ <r>231</r>
+ <g>46</g>
+ <b>255</b>
+ </bgcolor>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider1</objectName>
+ <x>5</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{ea2b771b-3cad-462f-b9df-a821dbfeaaf8}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+</bsbPanel>
+<bsbPresets>
+</bsbPresets>
+<MacGUI>
+ioView nobackground {59367, 11822, 65535}
+ioSlider {5, 5} {20, 100} 0.000000 1.000000 0.000000 slider1
+</MacGUI>
diff --git a/android/CsoundAndroidExamples/res/values/strings.xml b/android/CsoundAndroidExamples/res/values/strings.xml
new file mode 100644
index 0000000..57e2efa
--- /dev/null
+++ b/android/CsoundAndroidExamples/res/values/strings.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, CsoundAndroidActivity!</string>
+ <string name="app_name">CsoundAndroid</string>
+ <string name="simple_test_name">Simple Test 1</string>
+ <string name="simple_test2_name">Simple Test 2</string>
+ <string name="haiku_name">Csound Haiku IV</string>
+
+</resources>
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/BaseCsoundActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/BaseCsoundActivity.java
new file mode 100644
index 0000000..60d56a4
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/BaseCsoundActivity.java
@@ -0,0 +1,102 @@
+/*
+
+ BaseCsoundActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+
+package com.csounds.examples;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.widget.SeekBar;
+
+import com.csounds.CsoundObj;
+
+public class BaseCsoundActivity extends Activity {
+
+ protected CsoundObj csoundObj = new CsoundObj();
+ protected Handler handler = new Handler();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ // TODO Auto-generated method stub
+ super.onDestroy();
+ csoundObj.stopCsound();
+
+ }
+
+ public void setSeekBarValue(SeekBar seekBar, double min, double max, double value) {
+ double range = max - min;
+ double percent = (value - min) / range;
+
+ seekBar.setProgress((int)(percent * seekBar.getMax()));
+ }
+
+
+ protected String getResourceFileAsString(int resId) {
+ StringBuilder str = new StringBuilder();
+
+ InputStream is = getResources().openRawResource(resId);
+ BufferedReader r = new BufferedReader(new InputStreamReader(is));
+ String line;
+
+ try {
+ while ((line = r.readLine()) != null) {
+ str.append(line).append("\n");
+ }
+ } catch (IOException ios) {
+
+ }
+
+ return str.toString();
+ }
+
+ protected File createTempFile(String csd) {
+ File f = null;
+
+ try {
+ f = File.createTempFile("temp", ".csd", this.getCacheDir());
+ FileOutputStream fos = new FileOutputStream(f);
+ fos.write(csd.getBytes());
+ fos.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return f;
+ }
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/CsoundAndroidActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/CsoundAndroidActivity.java
new file mode 100644
index 0000000..6c5473c
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/CsoundAndroidActivity.java
@@ -0,0 +1,86 @@
+/*
+
+ CsoundBaseActivity.java:
+
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples;
+
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.tests.AccelerometerActivity;
+import com.csounds.examples.tests.ButtonTestActivity;
+import com.csounds.examples.tests.CsoundHaikuIVActivity;
+import com.csounds.examples.tests.HarmonizerActivity;
+import com.csounds.examples.tests.MultiTouchXYActivity;
+import com.csounds.examples.tests.PingPongDelayActivity;
+import com.csounds.examples.tests.SimpleTest1Activity;
+import com.csounds.examples.tests.SimpleTest2Activity;
+import com.csounds.examples.tests.WaveviewTestActivity;
+
+public class CsoundAndroidActivity extends BaseCsoundActivity {
+
+ String[] testNames = new String[] { "Simple Test 1", "Simple Test 2", "Button Test",
+ "Ping Pong Delay", "Harmonizer", "Accelerometer", "Csound Haiku IV", "MultiTouch XY", "Waveview"};
+ @SuppressWarnings("rawtypes")
+ Class[] activities = new Class[] { SimpleTest1Activity.class, SimpleTest2Activity.class,
+ ButtonTestActivity.class, PingPongDelayActivity.class, HarmonizerActivity.class,
+ AccelerometerActivity.class, CsoundHaikuIVActivity.class, MultiTouchXYActivity.class,
+ WaveviewTestActivity.class};
+
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ ListView listView = (ListView) findViewById(R.id.list_view);
+
+ listView.setAdapter(new ArrayAdapter<String>(this,
+ android.R.layout.simple_list_item_1,
+ testNames));
+ listView.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1,
+ int position, long arg3) {
+
+
+ startActivity(new Intent(CsoundAndroidActivity.this,
+ activities[position]));
+
+
+ }
+ });
+
+ }
+
+}
\ No newline at end of file
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/AccelerometerActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/AccelerometerActivity.java
new file mode 100644
index 0000000..05dc961
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/AccelerometerActivity.java
@@ -0,0 +1,83 @@
+/*
+
+ AccelerometerActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+
+public class AccelerometerActivity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.accelerometer_test);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+
+ startStopButton
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ String csd = getResourceFileAsString(R.raw.hardware_test);
+ File f = createTempFile(csd);
+
+ csoundObj.enableAccelerometer(AccelerometerActivity.this);
+
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/ButtonTestActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/ButtonTestActivity.java
new file mode 100644
index 0000000..05d6eeb
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/ButtonTestActivity.java
@@ -0,0 +1,138 @@
+/*
+
+ ButtonTestActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.SeekBar;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+
+public class ButtonTestActivity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+
+ Button eventButton;
+ Button valueButton;
+
+ SeekBar durationSlider;
+ SeekBar attackSlider;
+ SeekBar decaySlider;
+ SeekBar sustainSlider;
+ SeekBar releaseSlider;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.button_test);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+
+ eventButton = (Button) findViewById(R.id.eventButton);
+ valueButton = (Button) findViewById(R.id.valueButton);
+
+ durationSlider = (SeekBar) findViewById(R.id.durationSlider);
+ attackSlider = (SeekBar) findViewById(R.id.attackSlider);
+ decaySlider = (SeekBar) findViewById(R.id.decaySlider);
+ sustainSlider = (SeekBar) findViewById(R.id.sustainSlider);
+ releaseSlider = (SeekBar) findViewById(R.id.releaseSlider);
+
+ setSeekBarValue(durationSlider, .5, 4, 1.5);
+ setSeekBarValue(attackSlider, .001, 2, .05);
+ setSeekBarValue(decaySlider, .05, 2, .05);
+ setSeekBarValue(sustainSlider, 0, 1, .7);
+ setSeekBarValue(releaseSlider, .05, 4, 1.5);
+
+ startStopButton
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ String csd = getResourceFileAsString(R.raw.button_test);
+ File f = createTempFile(csd);
+
+ csoundObj.addSlider(durationSlider, "duration", .5,
+ 4);
+ csoundObj.addSlider(attackSlider, "attack", 0, 2);
+ csoundObj.addSlider(decaySlider, "decay", .05, 2);
+ csoundObj.addSlider(sustainSlider, "sustain", 0, 1);
+ csoundObj.addSlider(releaseSlider, "release", 0, 4);
+
+ csoundObj.addButton(valueButton, "button1");
+
+ eventButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ Log.d("TEST", "Event Button");
+
+ float value = durationSlider.getProgress() / (float)durationSlider.getMax();
+ float min = .5f;
+ float max = 4f;
+ float range = max - min;
+ value = (value * range) + min;
+ String event = String.format("i2 0 %f", value);
+
+ csoundObj.sendScore(event);
+ }
+ });
+
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/CsoundHaikuIVActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/CsoundHaikuIVActivity.java
new file mode 100644
index 0000000..bf84802
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/CsoundHaikuIVActivity.java
@@ -0,0 +1,51 @@
+/*
+
+CsoundHaikuIVActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+
+public class CsoundHaikuIVActivity extends BaseCsoundActivity {
+
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.csound_haiku_iv);
+
+ String csd = getResourceFileAsString(R.raw.iv);
+ File f = createTempFile(csd);
+ //csoundObj.setMessageLoggingEnabled(true);
+ csoundObj.startCsound(f);
+
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/HarmonizerActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/HarmonizerActivity.java
new file mode 100644
index 0000000..9d26b33
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/HarmonizerActivity.java
@@ -0,0 +1,101 @@
+/*
+
+ HarmonizerActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.SeekBar;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+
+
+public class HarmonizerActivity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+
+ SeekBar harmonyPitchSlider;
+ SeekBar gainSlider;
+
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.harmonizer);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+
+ harmonyPitchSlider = (SeekBar) findViewById(R.id.harmony_pitch_slider);
+ gainSlider = (SeekBar) findViewById(R.id.gain_slider);
+
+
+ setSeekBarValue(harmonyPitchSlider, 0, 1, .5);
+ setSeekBarValue(gainSlider, .5, 3, 1.5);
+
+ startStopButton
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ String csd = getResourceFileAsString(R.raw.harmonizer);
+ File f = createTempFile(csd);
+
+ csoundObj.addSlider(harmonyPitchSlider,
+ "slider", 0, 1);
+ csoundObj.addSlider(gainSlider,
+ "gain", .5, 3);
+
+ csoundObj.setAudioInEnabled(true);
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/MultiTouchXYActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/MultiTouchXYActivity.java
new file mode 100644
index 0000000..583cec4
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/MultiTouchXYActivity.java
@@ -0,0 +1,200 @@
+/*
+
+ MultiTouchXYActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+import com.csounds.valueCacheable.CsoundValueCacheable;
+
+import csnd.CsoundMYFLTArray;
+
+public class MultiTouchXYActivity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener, CsoundValueCacheable {
+
+ public View multiTouchView;
+
+ int touchIds[] = new int[10];
+ float touchX[] = new float[10];
+ float touchY[] = new float[10];
+ CsoundMYFLTArray touchXPtr[] = new CsoundMYFLTArray[10];
+ CsoundMYFLTArray touchYPtr[] = new CsoundMYFLTArray[10];
+
+ protected int getTouchIdAssignment() {
+ for(int i = 0; i < touchIds.length; i++) {
+ if(touchIds[i] == -1) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ protected int getTouchId(int touchId) {
+ for(int i = 0; i < touchIds.length; i++) {
+ if(touchIds[i] == touchId) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ for(int i = 0; i < touchIds.length; i++) {
+ touchIds[i] = -1;
+ touchX[i] = -1;
+ touchY[i] = -1;
+ }
+
+ multiTouchView = new View(this);
+
+ multiTouchView.setOnTouchListener(new OnTouchListener() {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ final int action = event.getAction() & MotionEvent.ACTION_MASK;
+ switch(action) {
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_POINTER_DOWN:
+
+ for(int i = 0; i < event.getPointerCount(); i++) {
+ int pointerId = event.getPointerId(i);
+ int id = getTouchId(pointerId);
+
+ if(id == -1) {
+
+ id = getTouchIdAssignment();
+
+ if(id != -1) {
+ touchIds[id] = pointerId;
+ touchX[id] = event.getX(i) / multiTouchView.getWidth();
+ touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight());
+
+ if(touchXPtr[id] != null) {
+ touchXPtr[id].SetValue(0, touchX[id]);
+ touchYPtr[id].SetValue(0, touchY[id]);
+
+ csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id));
+ }
+ }
+ }
+
+ }
+
+ break;
+ case MotionEvent.ACTION_MOVE:
+
+ for(int i = 0; i < event.getPointerCount(); i++) {
+ int pointerId = event.getPointerId(i);
+ int id = getTouchId(pointerId);
+
+ if(id != -1) {
+ touchX[id] = event.getX(i) / multiTouchView.getWidth();
+ touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight());
+ }
+
+ }
+ break;
+ case MotionEvent.ACTION_POINTER_UP:
+ case MotionEvent.ACTION_UP:
+ {
+ int activePointerIndex = event.getActionIndex();
+ int pointerId = event.getPointerId(activePointerIndex);
+
+ int id = getTouchId(pointerId);
+ if(id != -1) {
+ touchIds[id] = -1;
+ csoundObj.sendScore(String.format("i-1.%d 0 0 %d", id, id));
+ }
+
+ }
+ break;
+ }
+ return true;
+ }
+
+ });
+
+ setContentView(multiTouchView);
+
+ String csd = getResourceFileAsString(R.raw.multitouch_xy);
+ File f = createTempFile(csd);
+
+ csoundObj.addValueCacheable(this);
+
+ csoundObj.startCsound(f);
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+
+ }
+
+ // VALUE CACHEABLE
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ for(int i = 0; i < touchIds.length; i++) {
+ touchXPtr[i] = csoundObj.getInputChannelPtr(String.format("touch.%d.x", i));
+ touchYPtr[i] = csoundObj.getInputChannelPtr(String.format("touch.%d.y", i));
+ }
+ }
+
+ @Override
+ public void updateValuesToCsound() {
+ for(int i = 0; i < touchX.length; i++) {
+ touchXPtr[i].SetValue(0, touchX[i]);
+ touchYPtr[i].SetValue(0, touchY[i]);
+ }
+
+ }
+
+ @Override
+ public void updateValuesFromCsound() {
+ }
+
+ @Override
+ public void cleanup() {
+ for(int i = 0; i < touchIds.length; i++) {
+ touchXPtr[i].Clear();
+ touchXPtr[i] = null;
+ touchYPtr[i].Clear();
+ touchYPtr[i] = null;
+ }
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/PingPongDelayActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/PingPongDelayActivity.java
new file mode 100644
index 0000000..9629c94
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/PingPongDelayActivity.java
@@ -0,0 +1,108 @@
+/*
+
+ PingPongDelayActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.SeekBar;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+
+public class PingPongDelayActivity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+
+ SeekBar leftDelaySlider;
+ SeekBar leftFeedbackSlider;
+ SeekBar rightDelaySlider;
+ SeekBar rightFeedbackSlider;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.ping_pong_delay);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+
+ leftDelaySlider = (SeekBar) findViewById(R.id.left_delay_slider);
+ leftFeedbackSlider = (SeekBar) findViewById(R.id.left_feedback_slider);
+ rightDelaySlider = (SeekBar) findViewById(R.id.right_delay_slider);
+ rightFeedbackSlider = (SeekBar) findViewById(R.id.right_feedback_slider);
+
+ setSeekBarValue(leftDelaySlider, 50, 3000, 300);
+ setSeekBarValue(leftFeedbackSlider, 0, .8, .5);
+ setSeekBarValue(rightDelaySlider, 50, 3000, 300);
+ setSeekBarValue(rightFeedbackSlider, 0, .8, .5);
+
+ startStopButton
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ String csd = getResourceFileAsString(R.raw.ping_pong_delay);
+ File f = createTempFile(csd);
+
+ csoundObj.addSlider(leftDelaySlider,
+ "leftDelayTime", 50, 3000);
+ csoundObj.addSlider(leftFeedbackSlider,
+ "leftFeedback", 0, .8);
+ csoundObj.addSlider(rightDelaySlider,
+ "rightDelayTime", 50, 3000);
+ csoundObj.addSlider(rightFeedbackSlider,
+ "rightFeedback", 0, .8);
+
+ csoundObj.setAudioInEnabled(true);
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest1Activity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest1Activity.java
new file mode 100644
index 0000000..b0f8497
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest1Activity.java
@@ -0,0 +1,111 @@
+/*
+
+ SimpleTest1Activity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.SeekBar;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+import com.csounds.valueCacheable.CsoundValueCacheable;
+
+public class SimpleTest1Activity extends BaseCsoundActivity implements CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+ SeekBar fSlider;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.simple_test_1);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+ fSlider = (SeekBar) findViewById(R.id.slider);
+ startStopButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if(isChecked) {
+ String csd = getResourceFileAsString(R.raw.test);
+ File f = createTempFile(csd);
+ csoundObj.addSlider(fSlider, "slider", 0.,
+ 1.);
+ csoundObj.addCompletionListener(SimpleTest1Activity.this);
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+
+
+ csoundObj.addValueCacheable(new CsoundValueCacheable() {
+
+ @Override
+ public void updateValuesToCsound() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateValuesFromCsound() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ Log.d("CsoundAndroidActivity", "ValueCacheable setup called");
+ }
+
+ @Override
+ public void cleanup() {
+ Log.d("CsoundAndroidActivity", "ValueCacheable cleanup called");
+ }
+ });
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest2Activity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest2Activity.java
new file mode 100644
index 0000000..c68b221
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest2Activity.java
@@ -0,0 +1,139 @@
+/*
+
+ SimpleTest2Activity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.SeekBar;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.CsoundObjCompletionListener;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+import com.csounds.valueCacheable.CsoundValueCacheable;
+
+public class SimpleTest2Activity extends BaseCsoundActivity implements
+ CsoundObjCompletionListener {
+
+ ToggleButton startStopButton = null;
+
+ SeekBar noteRateSlider;
+ SeekBar durationSlider;
+ SeekBar attackSlider;
+ SeekBar decaySlider;
+ SeekBar sustainSlider;
+ SeekBar releaseSlider;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.simple_test_2);
+
+ startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
+
+ noteRateSlider = (SeekBar) findViewById(R.id.noteRateSlider);
+ durationSlider = (SeekBar) findViewById(R.id.durationSlider);
+ attackSlider = (SeekBar) findViewById(R.id.attackSlider);
+ decaySlider = (SeekBar) findViewById(R.id.decaySlider);
+ sustainSlider = (SeekBar) findViewById(R.id.sustainSlider);
+ releaseSlider = (SeekBar) findViewById(R.id.releaseSlider);
+
+ setSeekBarValue(noteRateSlider, 1, 4, 1.5);
+ setSeekBarValue(durationSlider, .5, 4, 1.5);
+ setSeekBarValue(attackSlider, .001, 2, .05);
+ setSeekBarValue(decaySlider, .05, 2, .05);
+ setSeekBarValue(sustainSlider, 0, 1, .7);
+ setSeekBarValue(releaseSlider, .05, 4, 1.5);
+
+ startStopButton
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ String csd = getResourceFileAsString(R.raw.test2);
+ File f = createTempFile(csd);
+
+ csoundObj.addSlider(noteRateSlider, "noteRate", 1,
+ 4);
+ csoundObj.addSlider(durationSlider, "duration", .5,
+ 4);
+ csoundObj.addSlider(attackSlider, "attack", 0, 2);
+ csoundObj.addSlider(decaySlider, "decay", .05, 2);
+ csoundObj.addSlider(sustainSlider, "sustain", 0, 1);
+ csoundObj.addSlider(releaseSlider, "release", 0, 4);
+
+ csoundObj.startCsound(f);
+ } else {
+ csoundObj.stopCsound();
+ }
+
+ }
+ });
+
+ csoundObj.addValueCacheable(new CsoundValueCacheable() {
+
+ @Override
+ public void updateValuesToCsound() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateValuesFromCsound() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ Log.d("CsoundAndroidActivity", "ValueCacheable setup called");
+ }
+
+ @Override
+ public void cleanup() {
+ Log.d("CsoundAndroidActivity", "ValueCacheable cleanup called");
+ }
+ });
+ }
+
+ @Override
+ public void csoundObjComplete(CsoundObj csoundObj) {
+ handler.post(new Runnable() {
+ public void run() {
+ startStopButton.setChecked(false);
+ }
+ });
+ }
+
+}
diff --git a/android/CsoundAndroidExamples/src/com/csounds/examples/tests/WaveviewTestActivity.java b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/WaveviewTestActivity.java
new file mode 100644
index 0000000..c8fc3fc
--- /dev/null
+++ b/android/CsoundAndroidExamples/src/com/csounds/examples/tests/WaveviewTestActivity.java
@@ -0,0 +1,169 @@
+/*
+
+ WaveviewTestActivity.java:
+
+ Copyright (C) 2011 Victor Lazzarini, Steven Yi
+
+ This file is part of Csound Android Examples.
+
+ The Csound Android Examples is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ Csound is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Csound; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ */
+
+package com.csounds.examples.tests;
+
+import java.io.File;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ToggleButton;
+
+import com.csounds.CsoundObj;
+import com.csounds.examples.BaseCsoundActivity;
+import com.csounds.examples.R;
+import com.csounds.valueCacheable.CsoundValueCacheable;
+
+import csnd.Csound;
+import csnd.CsoundMYFLTArray;
+
+public class WaveviewTestActivity extends BaseCsoundActivity {
+
+ ToggleButton startStopButton = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final WaveView view = new WaveView(this);
+
+ setContentView(view);
+
+ String csd = getResourceFileAsString(R.raw.waveviewtest);
+ File f = createTempFile(csd);
+
+ csoundObj.addValueCacheable(view);
+
+ csoundObj.startCsound(f);
+
+ }
+
+ class WaveView extends View implements CsoundValueCacheable {
+
+ boolean tableLoaded = false;
+ CsoundObj csoundObj = null;
+ double[] tableData = null;
+ int[] points = null;
+
+ Paint paint;
+
+ public WaveView(Context context) {
+ super(context);
+ paint = new Paint();
+ paint.setDither(true);
+ paint.setColor(0xFFFFFF00);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeJoin(Paint.Join.ROUND);
+ paint.setStrokeCap(Paint.Cap.ROUND);
+ paint.setStrokeWidth(3);
+ }
+
+ @Override
+ public void setup(CsoundObj csoundObj) {
+ tableLoaded = false;
+ this.csoundObj = csoundObj;
+ }
+
+ @Override
+ public void updateValuesToCsound() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateValuesFromCsound() {
+ if (!tableLoaded) {
+ Csound csound = csoundObj.getCsound();
+ CsoundMYFLTArray table = new CsoundMYFLTArray();
+ int length = csound.TableLength(1);
+ csound.GetTable(table.GetPtr(), 1);
+ tableData = new double[length];
+
+ for (int i = 0; i < length; i++) {
+ tableData[i] = table.GetValue(i);
+ }
+
+ tableLoaded = true;
+
+ new Thread() {
+ @Override
+ public void run() {
+
+ int width = getWidth();
+ int height = getHeight();
+ int middle = height / 2;
+
+ points = new int[width];
+
+ int tableLength = tableData.length;
+
+ for (int i = 0; i < width; i++) {
+ float percent = i / (float) (width);
+ int index = (int) (percent * tableLength);
+ points[i] = (int) ((tableData[index] * middle) + middle);
+ }
+
+ postInvalidate();
+
+ }
+ }.start();
+ }
+ }
+
+ @Override
+ public void cleanup() {
+ csoundObj = null;
+ tableData = null;
+ points = null;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if(points == null || points.length == 0) {
+ return;
+ }
+
+ int currentX = 0;
+ int currentY = points[0];
+
+ for(int i = 1;i < points.length; i++) {
+ int nextX = i;
+ int nextY = points[i];
+
+ canvas.drawLine(currentX, currentY, nextX, nextY, paint);
+ currentX = nextX;
+ currentY = nextY;
+ }
+
+ }
+
+ }
+
+}
diff --git a/build-linux-double.sh b/build-linux-double.sh
index b8c84ff..18244c9 100755
--- a/build-linux-double.sh
+++ b/build-linux-double.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-scons usePortMIDI=0 custom=custom-linux-mkg.py buildLuaWrapper=1 buildLuaOpcodes=1 buildPythonWrapper=1 useJack=1 buildCsoundVST=0 buildvst4cs=0 buildInterfaces=1 buildCsoundAC=1 buildJavaWrapper=0 useOSC=1 buildPythonOpcodes=1 buildLoris=0 buildStkOpcodes=1 buildWinsound=1 noFLTKThreads=0 useLrint=1 usePortAudio=0 buildPDClass=1 buildVirtual=1 buildTclcsound=1 buildLua=1 useDouble=1 dynamicCsoundLibrary=1 buildRelease=0 buildDSSI=1 noDebug=0 gcc4opt=atom $1 $2 $3 $4
+scons usePortMIDI=0 custom=custom-linux-mkg.py buildLuaWrapper=1 buildLuaOpcodes=1 buildPythonWrapper=1 useJack=1 buildCsoundVST=0 buildvst4cs=0 buildInterfaces=1 buildCsoundAC=1 buildJavaWrapper=0 useOSC=1 buildPythonOpcodes=1 buildLoris=0 buildStkOpcodes=1 buildWinsound=1 noFLTKThreads=0 useLrint=1 usePortAudio=0 buildPDClass=1 buildVirtual=1 buildTclcsound=1 buildLua=1 useDouble=1 dynamicCsoundLibrary=1 buildRelease=0 buildDSSI=1 noDebug=0 gcc4opt=corei7 $1 $2 $3 $4
# doxygen
diff --git a/examples/CsoundAC.csd b/examples/CsoundAC.csd
index 517e787..5c8d641 100644
--- a/examples/CsoundAC.csd
+++ b/examples/CsoundAC.csd
@@ -167,7 +167,7 @@ gitonewheel6 ftgen 0, 0, 65537, 8 -.8, 336,
; Table for Reed Physical Model
gireedtable ftgen 0, 0, 256, 7, 1, 80, 1, 156, -1, 40, -1
; Tables for simple granular synthesis
-gigrtab ftgen 0, 0, 65537, 10, 1, 0.3, .1 0, .2, .02, 0, .1, .04
+gigrtab ftgen 0, 0, 65537, 10, 1, .3, .1, 0, .2, .02, 0, .1, .04
giwintab ftgen 0, 0, 65537, 10, 1, 0, .5, 0, .33, 0, .25, 0, .2, 0, .167
; Tables for waveshaping drone
giharmonics ftgen 0, 0, 65537, 10, 1, 0, 2, 0, 0, 1
@@ -541,7 +541,7 @@ amp2 = aamp2 * (1 + adev2)
aamp3 linseg 0,.001,3000,.001,1000,.0017,12000,.0013,3700,.001,12500,.0018,3000,.0012,1200,.001,1400,.0017,6000,.0023,200,.001,3000,.001,1200,.0015,8000,.001,1800,.0015,6000,.08,1200,.2,200,.2,40,.2,10,.4,0,1,0
adevamp3 linseg 0, .02, .8, idur - .02, 0
adev3 poscil adevamp3, 70, gisine ,0
-amp3 = aamp3 * (1 + adev3),
+amp3 = aamp3 * (1 + adev3)
awt1 poscil amp1, kfreq, gisine
awt2 poscil amp2, 2.7 * kfreq, gisine
awt3 poscil amp3, 4.95 * kfreq, gisine
@@ -1027,7 +1027,7 @@ asignal = kenvelope * (agleft + adelayleft
asignal1 butterhp asignal, 32.0
asignal2 balance asignal1, asignal
aleft, aright Pan p7, asignal2 * iamplitude
-p3, aleft, aright Declick 0 .006, p3, 0.06, aleft, aright
+p3, aleft, aright Declick 0.006, p3, 0.06, aleft, aright
AssignSend p1, 0.0, 0.0, 0.2, 1
SendOut p1, aleft, aright
endin
@@ -1903,7 +1903,7 @@ p3, aleft, aright Declick 0.003, p3, .05, aleft, aright
; Low level implementation
; of the classic Karplus-Strong algorithm
; fixed pitches : no vibratos or glissandi !
- ; implemented by Josep M Comajuncosas / Aug´98
+ ; implemented by Josep M Comajuncosas / Aug\B498
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Initialised with a wide pulse (buzz)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/examples/CsoundVST.csd b/examples/CsoundVST.csd
index 1b0387e..5f26906 100644
--- a/examples/CsoundVST.csd
+++ b/examples/CsoundVST.csd
@@ -1,6 +1,6 @@
<CsoundSynthesizer>
<CsOptions>
-csound -f -h -+rtmidi=null -M0 -d -n -m7 --midi-key-oct=4 --midi-velocity=5 temp.orc temp.sco
+csound -f -h -+rtmidi=null -M0 -d -n -m7 --midi-key=4 --midi-velocity=5 temp.orc temp.sco
</CsOptions>
<CsInstruments>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -18,7 +18,7 @@ sr = 44100
ksmps = 30
nchnls = 2
; Adjust 0dbfs to allow for MIDI velocity as decibels.
-0dbfs = 32000
+0dbfs = 10000000
; Note that -1 dB for float is 29205.
@@ -26,9 +26,9 @@ nchnls = 2
; Channel to instrument assignments.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- massign 1,24
- massign 2,13
- massign 3,24
+ massign 1,14
+ ;massign 2,2
+ ;massign 3,17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Tables
@@ -58,7 +58,7 @@ gitonewheel3 ftgen 0, 0, 8193, 7, 0, 110,
gitonewheel4 ftgen 0, 0, 8193, 7, 0, 80, 0.2, 16, 1, 64, 1, 16, 0.2, 80, 0
; Distortion Tables
gitonewheel5 ftgen 0, 0, 8193, 8, -.8, 336, -.78, 800, -.7, 5920, 0.7, 800, 0.78, 336, 0.8
-gitonewheel6 ftgen 0, 0, 8193, 8 -.8, 336, -.76, 3000, -.7, 1520, 0.7, 3000, 0.76, 336, 0.8
+gitonewheel6 ftgen 0, 0, 8193, 8, -.8, 336, -.76, 3000, -.7, 1520, 0.7, 3000, 0.76, 336, 0.8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Instruments
@@ -67,7 +67,7 @@ gitonewheel6 ftgen 0, 0, 8193, 8 -.8, 336
instr 1 ; Tone wheel organ by Mikelson
pset 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0
; Pitch.
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Amplitude.
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 16.0
@@ -119,9 +119,9 @@ ishift = 0.00666667 ;shift it 8/1200.
ipch = cpspch(p5) ;convert parameter 5 to cps.
ioct = octpch(p5) ;convert parameter 5 to oct.
kvib oscili 1/120, ipch/50, gisine ;vibrato
-ag pluck 2000, cpsoct(ioct+kvib), 1000, 1, 1
-agleft pluck 2000, cpsoct(ioct+ishift), 1000, 1, 1
-agright pluck 2000, cpsoct(ioct-ishift), 1000, 1, 1
+ag pluck 2000, cpsmidinn(ioct+kvib), 1000, 1, 1
+agleft pluck 2000, cpsmidinn(ioct+ishift), 1000, 1, 1
+agright pluck 2000, cpsmidinn(ioct-ishift), 1000, 1, 1
kf1 expon 0.1, p3, 1.0 ;exponential from 0.1 to 1.0
kf2 expon 1.0, p3, 0.1 ;exponential from 1.0 to 0.1
adump delayr 2.0 ;set delay line of 2.0 sec
@@ -135,7 +135,7 @@ ad2 deltap 1.1 ;delay 1.1 sec.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
instr 2 ; Xanadu instr 1
- pset 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0
+ ; pset 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0
; Envelope initialization.
iattack = 0.005
isustain = p3
@@ -144,7 +144,7 @@ irelease = 0.05
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
iduration = p3 + iattack + irelease
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 2000.
ijunk6 = p6
@@ -174,9 +174,9 @@ iattack = 0.05
isustain = p3
irelease = 0.05
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ag pluck 1000, cpsoct(ioct + kvib), 1000,gisine, 1
-agleft pluck 1000, cpsoct(ioct+ishift), 1000,gisine, 1
-agright pluck 1000, cpsoct(ioct-ishift), 1000,gisine, 1
+ag pluck 1000, cpsmidinn(ioct + kvib), 1000,gisine, 1
+agleft pluck 1000, cpsmidinn(ioct+ishift), 1000,gisine, 1
+agright pluck 1000, cpsmidinn(ioct-ishift), 1000,gisine, 1
adump delayr 0.4 ;set delay line of 0.3 sec
ad1 deltap 0.1 ;delay 100 msec.
ad2 deltap 0.2 ;delay 200 msec.
@@ -195,7 +195,7 @@ irelease = 0.05
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
iduration = p3 + iattack + irelease
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 600.
ijunk6 = p6
@@ -230,8 +230,8 @@ a3 tablei a1ndx,giln, 1 ;lookup tbl in f3, normal inde
ao1 oscili a1, ipch, gicosine ;cosine
a4 = exp(-0.5*a3+ao1)
ao2 oscili a2*ipch, ipch, gicosine ;cosine
-aoutl oscili 1000*kadsr*a4, ao2+cpsoct(ioct+ishift), gisine ;fnl outleft
-aoutr oscili 1000*kadsr*a4, ao2+cpsoct(ioct-ishift), gisine ;fnl outright
+aoutl oscili 1000*kadsr*a4, ao2+cpsmidinn(ioct+ishift), gisine ;fnl outleft
+aoutr oscili 1000*kadsr*a4, ao2+cpsmidinn(ioct-ishift), gisine ;fnl outright
outs aoutl, aoutr
endin
@@ -246,7 +246,7 @@ irelease = 0.05
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
iduration = p3 + iattack + irelease
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 2400.
ijunk6 = p6
@@ -271,7 +271,7 @@ asig2 = asig2 * kdamping * ileftgain
instr 5 ; Tone wheel organ by Mikelson
pset 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0
; Pitch.
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Amplitude.
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 16.0
@@ -324,7 +324,7 @@ isustain = p3
irelease = 0.05
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 5
ijunk6 = p6
@@ -348,7 +348,7 @@ af3 reson asig, 440, 80
aout balance 0.6 * af1+ af2 + 0.6 * af3 + 0.4 * asig, asigcomp
kexp expseg 1.0, iattack, 2.0, isustain, 1.0, irelease, 1.0
kenv = kexp - 1.0
-asig1 = aout * ileftgain * kenv * kdamping,
+asig1 = aout * ileftgain * kenv * kdamping
asig2 = aout* irightgain * kenv * kdamping
outs asig1, asig2
endin
@@ -364,7 +364,7 @@ irelease = 0.05
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
iduration = p3 + iattack + irelease
-ifrequency = cpsoct(p4 + 1)
+ifrequency = cpsmidinn(p4 + 1)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 2.0
ijunk6 = p6
@@ -413,7 +413,7 @@ ifn2 = giexponentialrise
ifn3 = githirteen
ifn4 = gisine
ivibefn = gicosine
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 32.0
ijunk6 = p6
@@ -455,8 +455,8 @@ irelease = 0.06
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ioctave = p4
-ifrequency = cpsoct(ioctave)
+ikeyin = p4
+ifrequency = cpsmidinn(ikeyin)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 875.0
iphase = p6
@@ -494,7 +494,7 @@ amp2 = aamp2 * (1 + kdev2)
aamp3 linsegr 0,.001,3000,.001,1000,.0017,12000,.0013,3700,.001,12500,.0018,3000,.0012,1200,.001,1400,.0017,6000,.0023,200,.001,3000,.001,1200,.0015,8000,.001,1800,.0015,6000,.08,1200,.2,200,.2,40,.2,10,.4,0,1,0
kdevamp3 linsegr 0, 0.02, 0.8, idur - 0.02, 0
kdev3 oscili kdevamp3, 70, gisine ,0
-amp3 = aamp3 * (1 + kdev3),
+amp3 = aamp3 * (1 + kdev3)
awt1 oscili amp1, ifreq, gisine
awt2 oscili amp2, 2.7 * ifreq, gisine
@@ -538,7 +538,7 @@ ijunk11 = p11
; shift it.
ishift = 4.0 / 12000
; convert parameter 5 to cps.
-ipch = cpsoct(p4)
+ipch = cpsmidinn(p4)
; convert parameter 5 to oct.
ioct = p4
; KONTROL
@@ -559,9 +559,9 @@ a4 = exp(-0.5 * a3 + ao1)
; Cosine
ao2 oscili a2 * ipch, ipch, gicosine
; Final output left
-aoutl oscili iamplitude * kadsr * a4, ao2 + cpsoct(ioct + ishift), gisine
+aoutl oscili iamplitude * kadsr * a4, ao2 + cpsmidinn(ioct + ishift), gisine
; Final output right
-aoutr oscili iamplitude * kadsr * a4, ao2 + cpsoct(ioct - ishift), gisine
+aoutr oscili iamplitude * kadsr * a4, ao2 + cpsmidinn(ioct - ishift), gisine
asig1 = ileftpan * aoutl * kdamping
asig2 = irightpan * aoutr * kdamping
outs asig1, asig2
@@ -583,7 +583,7 @@ asig2 = irightpan * aoutr * kdamping
ij9=p9
ij10=p10
ij11=p11
- ihz = cpsoct(p4)
+ ihz = cpsmidinn(p4)
idb = p5
ipos = p7
iamp = ampdb(idb) * 1.5
@@ -639,8 +639,8 @@ ip5 = gibergeman
ip3 = p3
ip6 = p3 * 0.25
ip7 = p3 * 0.75
-ip8 = cpsoct(p4 - 0.01)
-ip9 = cpsoct(p4 + 0.01)
+ip8 = cpsmidinn(p4 - 0.01)
+ip9 = cpsmidinn(p4 + 0.01)
ip10 = p10
isc = idb * 0.333
k1 line 40, p3, 800
@@ -682,7 +682,7 @@ irelease = 0.075
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 1.25
ijunk6 = p6
@@ -726,7 +726,7 @@ ifn2 = gicosine
ifn3 = gisine
ifn4 = gicookblank
ivibefn = gisine
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 1.25
ijunk6 = p6
@@ -765,7 +765,7 @@ ifn2 = gicook3
ifn3 = gisine
ifn4 = gisine
ivibefn = gicosine
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 2.0
; Constant-power pan.
@@ -799,7 +799,7 @@ irelease = 0.05
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
ifrequencyb = ifrequency * 1.003
icarrierb = icarrier * 1.004
; Normalize so iamplitude for p5 of 80 == ampdb(80).
@@ -840,7 +840,7 @@ irelease = 0.05
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
ifrequencyb = ifrequency * 1.003
icarrierb = icarrier * 1.004
; Normalize so iamplitude for p5 of 80 == ampdb(80).
@@ -879,7 +879,7 @@ irelease = 0.05
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ifrequency = cpsoct(p4)
+ifrequency = cpsmidinn(p4)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 5
ijunk6 = p6
@@ -903,7 +903,7 @@ af3 reson asig, 440, 80
aout balance 0.6 * af1+ af2 + 0.6 * af3 + 0.4 * asig, asigcomp
kexp expseg 1.0, iattack, 2.0, isustain, 1.0, irelease, 1.0
kenv = kexp - 1.0
-asig1 = aout * ileftgain * kenv * kdamping,
+asig1 = aout * ileftgain * kenv * kdamping
asig2 = aout* irightgain * kenv * kdamping
outs asig1, asig2
endin
@@ -915,8 +915,8 @@ asig2 = aout* irightgain * kenv * kdampi
; mididefault 60, p3
; midinoteonoct p4, p5
; Do some phasing.
-icpsp1 = cpsoct(p4 - 0.0002)
-icpsp2 = cpsoct(p4 + 0.0002)
+icpsp1 = cpsmidinn(p4 - 0.0002)
+icpsp2 = cpsmidinn(p4 + 0.0002)
; Normalize to 80 dB = ampdb(80).
ip6 = ampdb(p5)
ijunk6 = p6
@@ -994,12 +994,12 @@ irelease = 0.15
; xtratim iattack + irelease
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ioctave = p4
-ihertz = cpsoct(ioctave)
+ikeyin = p4
+ihertz = cpsmidinn(ikeyin)
; Detuning of strings by 4 cents each way.
idetune = 4.0 / 1200.0
-ihertzleft = cpsoct(ioctave + idetune)
-ihertzright = cpsoct(ioctave - idetune)
+ihertzleft = cpsmidinn(ikeyin + idetune)
+ihertzright = cpsmidinn(ikeyin - idetune)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5)
ijunk6 = p6
@@ -1022,7 +1022,7 @@ kvibrato oscili 1.0 / 120.0, 7.0, 1
; AUDIO
kexponential expseg 1.0, p3 + iattack, 0.0001, irelease, 0.0001
kenvelope = (kexponential - 0.0001) * kdamping
-ag pluck iamplitude, cpsoct(ioctave + kvibrato), 200, igenleft, 1
+ag pluck iamplitude, cpsmidinn(ikeyin + kvibrato), 200, igenleft, 1
agleft pluck iamplitude, ihertzleft, 200, igenleft, 1
agright pluck iamplitude, ihertzright, 200, igenright, 1
imsleft = 0.2 * 1000
@@ -1045,7 +1045,7 @@ asig2 = irightpan * asignal * kdamping
; mididefault 60, p3
; midinoteonoct p4, p5
; Pitch.
-i1 = cpsoct(p4)
+i1 = cpsmidinn(p4)
; Amplitude.
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) * 1.0 / 5000.0
@@ -1107,8 +1107,8 @@ isustain = p3
irelease = 0.06
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ioctave = p4
-ifrequency = cpsoct(ioctave)
+ikeyin = p4
+ifrequency = cpsmidinn(ikeyin)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 3
iphase = p6
@@ -1128,9 +1128,9 @@ idur = 15
iamp = iamplitude
ifenv = giffitch2 ; BELL SETTINGS:
ifdyn = giffitch3 ; AMP AND INDEX ENV ARE EXPONENTIAL
-ifq1 = cpsoct(p4 - 1) * 5 ; DECREASING, N1:N2 IS 5:7, imax=10
+ifq1 = cpsmidinn(p4 - 1) * 5 ; DECREASING, N1:N2 IS 5:7, imax=10
if1 = giffitch1 ; DURATION = 15 sec
-ifq2 = cpsoct(p4 - 1) * 7
+ifq2 = cpsmidinn(p4 - 1) * 7
if2 = giffitch1
imax = 10
aenv oscili iamp, 1 / idur, ifenv ; ENVELOPE
@@ -1161,8 +1161,8 @@ isustain = p3
irelease = 0.06
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ioctave = p4
-ifrequency = cpsoct(ioctave)
+ikeyin = p4
+ifrequency = cpsmidinn(ikeyin)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 3
iphase = p6
@@ -1194,8 +1194,8 @@ isustain = p3
irelease = 0.06
p3 = isustain + iattack + irelease
kdamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
-ioctave = p4
-ifrequency = cpsoct(ioctave)
+ikeyin = p4
+ifrequency = cpsmidinn(ikeyin)
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude = ampdb(p5) / 3
iphase = p6
@@ -1221,5 +1221,7 @@ asig2 = asignal * irightgain * kdamping
<CsScore>
f 0 3600
+
+
</CsScore>
</CsoundSynthesizer>
diff --git a/examples/hommage.csd b/examples/hommage.csd
index b79b039..c19abef 100644
--- a/examples/hommage.csd
+++ b/examples/hommage.csd
@@ -1,7 +1,5 @@
<CsoundSynthesizer>
-
<CsOptions>
--odac
</CsOptions>
<CsInstruments>
@@ -14,7 +12,8 @@ nchnls= 2
instr 1
-
+ii active 0
+print ii
kfreq expon p5, p3, p6
kinterval expon p7, p3, p8
kglissdur line p9, p3, p10
@@ -116,6 +115,8 @@ endin
instr 2
+ii active 2
+print ii
kfreq expon p5, p3, p6
kinterval expon p7, p3, p8
@@ -232,6 +233,8 @@ endin
instr 3
+ii active 0
+print ii
kfreq0 expon p5, p3, p6
kinterval expon p7, p3, p8
@@ -368,13 +371,120 @@ i3 125 6 -20 800 850 1.1 1.3 6 6 -1 .5 22 3 500 0 0
</CsScore>
</CsoundSynthesizer>
+<bsbPanel>
+ <label>Widgets</label>
+ <objectName/>
+ <x>755</x>
+ <y>61</y>
+ <width>297</width>
+ <height>497</height>
+ <visible>true</visible>
+ <uuid/>
+ <bgcolor mode="nobackground">
+ <r>212</r>
+ <g>208</g>
+ <b>200</b>
+ </bgcolor>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider1</objectName>
+ <x>5</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{c337f225-a9f2-4de2-9e9d-e5cef5316d07}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider2</objectName>
+ <x>45</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{dfc06bbd-8563-4f7e-8ae3-845b96d54c38}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider3</objectName>
+ <x>85</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{e3c628a3-55e7-4178-8529-2a65308e2429}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider4</objectName>
+ <x>125</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{d594b856-3e0f-4f15-9838-6cffc5f12288}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider5</objectName>
+ <x>165</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{a710f9ee-5cc2-4dea-91b6-187b0dd8eac5}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+</bsbPanel>
+<bsbPresets>
+</bsbPresets>
<MacOptions>
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
Listing: Window
-WindowBounds: 1040 71 400 535
+WindowBounds: 755 61 297 497
CurrentView: io
IOViewEdit: On
Options:
@@ -387,4 +497,3 @@ ioSlider {85, 5} {20, 100} 0.000000 1.000000 0.000000 slider3
ioSlider {125, 5} {20, 100} 0.000000 1.000000 0.000000 slider4
ioSlider {165, 5} {20, 100} 0.000000 1.000000 0.000000 slider5
</MacGUI>
-
diff --git a/examples/opcode_demos/lua_scoregen.csd b/examples/opcode_demos/lua_scoregen.csd
index 8c2dbe7..76375c4 100644
--- a/examples/opcode_demos/lua_scoregen.csd
+++ b/examples/opcode_demos/lua_scoregen.csd
@@ -12,7 +12,7 @@ lua_exec {{
local ffi = require("ffi")
local math = require("math")
local string = require("string")
-local csoundApi = ffi.load('csound64')
+local csoundApi = ffi.load('C:\\utah\\opt\\Csound\\bin\\csound64.dll')
-- Declare the parts of the Csound API that we need.
ffi.cdef[[
int csoundGetKsmps(void *);
@@ -72,3 +72,38 @@ e 4.0
</CsScore>
</CsoundSynthesizer>
+<bsbPanel>
+ <label>Widgets</label>
+ <objectName/>
+ <x>0</x>
+ <y>0</y>
+ <width>30</width>
+ <height>105</height>
+ <visible>true</visible>
+ <uuid/>
+ <bgcolor mode="nobackground">
+ <r>231</r>
+ <g>46</g>
+ <b>255</b>
+ </bgcolor>
+ <bsbObject version="2" type="BSBVSlider">
+ <objectName>slider1</objectName>
+ <x>5</x>
+ <y>5</y>
+ <width>20</width>
+ <height>100</height>
+ <uuid>{930dd6dd-5342-4be2-969c-8a8e68d109c4}</uuid>
+ <visible>true</visible>
+ <midichan>0</midichan>
+ <midicc>-3</midicc>
+ <minimum>0.00000000</minimum>
+ <maximum>1.00000000</maximum>
+ <value>0.00000000</value>
+ <mode>lin</mode>
+ <mouseControl act="jump">continuous</mouseControl>
+ <resolution>-1.00000000</resolution>
+ <randomizable group="0">false</randomizable>
+ </bsbObject>
+</bsbPanel>
+<bsbPresets>
+</bsbPresets>
diff --git a/examples/python/Lindenmayer.py b/examples/python/Lindenmayer.py
index 8d16693..1c85554 100644
--- a/examples/python/Lindenmayer.py
+++ b/examples/python/Lindenmayer.py
@@ -44,7 +44,7 @@ filename = os.path.abspath('Lindenmayer.py')
print 'Filename:', filename
model.setConformPitches(True)
csound.load('../CsoundAC.csd')
-csound.setCommand("csound --old-parser -m3 -RWZdfo" + filename + ".wav " + filename + ".orc " + filename + ".sco")
+csound.setCommand("csound -m3 -RWZdfo" + filename + ".wav " + filename + ".orc " + filename + ".sco")
csound.setFilename(filename)
score = model.getScore()
print 'Events in generated score:', len(score)
diff --git a/examples/python/StrangeAtrractor.py b/examples/python/StrangeAtrractor.py
index bd2fcd0..43b802b 100644
--- a/examples/python/StrangeAtrractor.py
+++ b/examples/python/StrangeAtrractor.py
@@ -51,7 +51,7 @@ model.addChild(rescale)
model.setTonesPerOctave(12.0)
model.generate()
-csound.load("./CsoundAC.csd")
+csound.load("../CsoundAC.csd")
csound.setCommand("csound -RWdfo StrangeAttractor.wav StrangeAttractor.orc StrangeAttractor.sco")
score = model.getScore()
print 'Events in generated score:', len(score)
diff --git a/frontends/CMakeLists.txt b/frontends/CMakeLists.txt
index 94bd35b..fd65a80 100644
--- a/frontends/CMakeLists.txt
+++ b/frontends/CMakeLists.txt
@@ -63,6 +63,7 @@ if(BUILD_CSBEATS)
ADD_FLEX_BISON_DEPENDENCY(csbeats_SCANNER csbeats_PARSER)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/beats)
set(csbeats_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/beats/main.c
diff --git a/frontends/CsoundAC/CMakeLists.txt b/frontends/CsoundAC/CMakeLists.txt
index c7a350e..4b0891e 100644
--- a/frontends/CsoundAC/CMakeLists.txt
+++ b/frontends/CsoundAC/CMakeLists.txt
@@ -71,6 +71,7 @@ if(BUILD_CSOUND_AC)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_OUTDIR ${BUILD_LIB_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+ list(APPEND CMAKE_SWIG_FLAGS "-includeall" "-verbose")
endif()
if(BUILD_CSOUND_AC_PYTHON_INTERFACE)
diff --git a/frontends/CsoundAC/ChordLindenmayer.cpp b/frontends/CsoundAC/ChordLindenmayer.cpp
index 03c34ac..6f1ac72 100644
--- a/frontends/CsoundAC/ChordLindenmayer.cpp
+++ b/frontends/CsoundAC/ChordLindenmayer.cpp
@@ -140,30 +140,7 @@ namespace csound
void ChordLindenmayer::tieOverlappingNotes()
{
- // If the score contains two notes of the same pitch
- // and loudness greater than 0 that overlap in time,
- // extend the earlier note and discard the later note.
- // Retain the instrument number of the earlier note.
- score.sort();
- for (int laterI = score.size() - 1; laterI > 1; --laterI) {
- Event &laterEvent = score[laterI];
- for (int earlierI = laterI - 1; earlierI > 0; --earlierI) {
- Event &earlierEvent = score[earlierI];
- if (earlierEvent.getKeyNumber() != laterEvent.getKeyNumber()) {
- continue;
- }
- if (earlierEvent.getVelocity() <= 0.0 || laterEvent.getVelocity() <= 0.0) {
- continue;
- }
- if (earlierEvent.getOffTime() < laterEvent.getTime()) {
- continue;
- }
- // Ok, must be tied.
- earlierEvent.setOffTime(laterEvent.getOffTime());
- score.erase(score.begin() + laterI);
- break;
- }
- }
+ score.tieOverlappingNotes();
}
void ChordLindenmayer::applyVoiceleadingOperations()
diff --git a/frontends/CsoundAC/ChordLindenmayer.hpp b/frontends/CsoundAC/ChordLindenmayer.hpp
index 93d6acd..a076a1d 100644
--- a/frontends/CsoundAC/ChordLindenmayer.hpp
+++ b/frontends/CsoundAC/ChordLindenmayer.hpp
@@ -63,9 +63,9 @@ using namespace boost::numeric;
namespace csound
{
- extern void printChord(std::ostream &stream, std::string label, const std::vector<double> &chord);
+ extern void SILENCE_PUBLIC printChord(std::ostream &stream, std::string label, const std::vector<double> &chord);
- struct Turtle
+ struct SILENCE_PUBLIC Turtle
{
Event note;
Event step;
@@ -170,7 +170,7 @@ namespace csound
}
};
- struct Command
+ struct SILENCE_PUBLIC Command
{
char operation;
char target;
@@ -302,7 +302,7 @@ namespace csound
* </ul>
*/
- class ChordLindenmayer :
+ class SILENCE_PUBLIC ChordLindenmayer :
public VoiceleadingNode
{
public:
diff --git a/frontends/CsoundAC/ChordSpace.cpp b/frontends/CsoundAC/ChordSpace.cpp
new file mode 100644
index 0000000..8d06c9a
--- /dev/null
+++ b/frontends/CsoundAC/ChordSpace.cpp
@@ -0,0 +1,2729 @@
+local Silencio = require("Silencio")
+local metalua_serialize = require("metalua_serialize")
+local io = require("io")
+local string = require("string")
+
+local ChordSpace = {}
+
+function ChordSpace.help()
+print [[
+
+C H O R D S P A C E
+
+Copyright 2010, 2011 by Michael Gogins.
+
+This software is licensed under the terms of the GNU Lesser General Public
+License.
+
+This package, part of Silencio, implements a geometric approach to some common
+operations on chords in neo-Riemannian music theory for use in score
+generating procedures:
+
+-- Identifying whether a chord belongs to some equivalence class of music
+ theory, or sending a chord to its equivalent within a representative
+ fundamental domain of some equivalence class. The equivalence classes are
+ octave (O), permutational (P), transpositional, (T), inversional (I), and
+ their compounds OP, OPT (set-class or chord type), and OPTI (prime form).
+
+-- Causing chord progressions to move strictly within an orbifold that
+ generates some equivalence class.
+
+-- Implementing chord progressions based on the L, P, R, D, K, and Q
+ operations of neo-Riemannian theory (thus implementing some aspects of
+ "harmony").
+
+-- Implementing chord progressions performed within a more abstract
+ equivalence class by means of the best-formed voice-leading within a less
+ abstract equivalence class (thus implementing some fundamentals of
+ "counterpoint").
+
+The associated ChordSpaceView package can display these chord spaces and
+operations for trichords in an interactive 3-dimensional view.
+
+DEFINITIONS
+
+Pitch is the perception of a distinct sound frequency. It is a logarithmic
+perception; octaves, which sound 'equivalent' in some sense, represent
+doublings or halvings of frequency.
+
+Pitches and intervals are represented as real numbers. Middle C is 60 and the
+octave is 12. Our usual system of 12-tone equal temperament, as well as MIDI
+key numbers, are completely represented by the whole numbers; any and all
+other pitches can be represented simply by using fractions.
+
+A voice is a distinct sound that is heard as having a pitch.
+
+A chord is simply a set of voices heard at the same time, represented here
+as a point in a chord space having one dimension of pitch for each voice
+in the chord.
+
+For the purposes of algorithmic composition in Silencio, a score is considered
+as a sequence of more or less fleeting chords.
+
+EQUIVALENCE CLASSES
+
+An equivalence class identifies elements of a set. Operations that send one
+equivalent point to another induce quotient spaces or orbifolds, where the
+equivalence operation identifies points on one face of the orbifold with
+points on an opposing face. The fundamental domain of the equivalence class
+is the space "within" the orbifold.
+
+Plain chord space has no equivalence classes. Ordered chords are represented
+as vectors in parentheses (p1, ..., pN). Unordered chords are represented as
+sorted vectors in braces {p1, ..., pN}. Unordering is itself an equivalence
+class.
+
+The following equivalence classes apply to pitches and chords, and exist in
+different orbifolds. Equivalence classes can be combined (Callendar, Quinn,
+and Tymoczko, "Generalized Voice-Leading Spaces," _Science_ 320, 2008), and
+the more equivalence classes are combined, the more abstract is the resulting
+orbifold compared to the parent space.
+
+In most cases, a chord space can be divided into a number, possibly
+infinite, of geometrically equivalent fundamental domains for the same
+equivalence class. Therefore, here we use the notion of 'representative'
+fundamental domain. For example, the representative fundamental domain of
+unordered sequences, out of all possible orderings, consists of all sequences
+in their ordinary sorted order. It is important, in the following, to identify
+representative fundamental domains that combine properly, e.g. such that the
+representative fundamental domain of OP / the representative fundamental
+domain of PI equals the representative fundamental domain of OPI. And this in
+turn may require accounting for duplicate elements of the representative
+fundamental domain caused by reflections or singularities in the orbifold.
+
+C Cardinality equivalence, e.g. {1, 1, 2} == {1, 2}. _Not_ assuming
+ cardinality equivalence ensures that there is a proto-metric in plain
+ chord space that is inherited by all child chord spaces. Cardinality
+ equivalence is never assumed here, because we are working in chord
+ spaces of fixed dimensionality; e.g. we represent the note middle C
+ not as {60}, but as {60, 60, ..., 60}.
+
+O Octave equivalence. The fundamental domain is defined by the pitches
+ in a chord spanning the range of an octave or less, and summing to
+ an octave or less.
+
+P Permutational equivalence. The fundamental domain is defined by a
+ "wedge" of plain chord space in which th#e voices of a chord are always
+ sorted by pitch.
+
+T Transpositional equivalence, e.g. {1, 2} == {7, 8}. The fundamental
+ domain is defined as a plane in chord space at right angles to the
+ diagonal of unison chords. Represented by the chord always having a
+ sum of pitches equal to 0.
+
+I Inversional equivalence. Care is needed to distinguish the
+ mathematician's sense of 'invert', which means 'pitch-space inversion'
+ or 'reflect in a point', from the musician's sense of 'invert', which
+ varies according to context but in practice often means 'registral
+ inversion' or 'revoice by adding an octave to the lowest tone of a
+ chord.' Here, we use 'invert' and 'inversion' in the mathematician's
+ sense, and we use the terms 'revoice' and 'voicing' for the musician's
+ 'invert' and 'inversion'. The inversion point for any inversion lies
+ on the unison diagonal. A fundamental domain is defined as any half of
+ chord space that is bounded by a plane containing the inversion point.
+ Represented as the chord having the first interval between voices be
+ smaller than or equal to the final interval (recursing for chords of
+ more than 3 voices).
+
+PI Inversional equivalence with permutational equivalence. The
+ 'inversion flat' of unordered chord space is a hyperplane consisting
+ of all those unordered chords that are invariant under inversion. A
+ fundamental domain is defined by any half space bounded by a
+ hyperplane containing the inversion flat. It is represented as that
+ half of the space on or lower than the hyperplane defined by the
+ inversion flat and the unison diagonal.
+
+OP Octave equivalence with permutational equivalence. Tymoczko's orbifold
+ for chords; i.e. chords with a fixed number of voices in a harmonic
+ context. The fundamental domain is defined as a hyperprism one octave
+ long with as many sides as voices and the ends identified by octave
+ equivalence and one cyclical permutation of voices, modulo the
+ unordering. In OP for trichords in 12TET, the augmented triads run up
+ the middle of the prism, the major and minor triads are in 6
+ alternating columns around the augmented triads, the two-pitch chords
+ form the 3 sides, and the one-pitch chords form the 3 edges that join
+ the sides.
+
+OPT The layer of the OP prism as close as possible to the origin, modulo
+ the number of voices. Chord type. Note that CM and Cm are different
+ OPT. Because the OP prism is canted down from the origin, at least one
+ pitch in each OPT chord (excepting the origin itself) is negative.
+
+OPI The OP prism modulo inversion, i.e. 1/2 of the OP prism. The
+ representative fundamental consits of those chords less than or equal
+ to their inversions modulo OP.
+
+OPTI The OPT layer modulo inversion, i.e. 1/2 of the OPT layer.
+ Set-class. Note that CM and Cm are the same OPTI.
+
+OPERATIONS
+
+Each of the above equivalence classes is, of course, an operation that sends
+chords outside the fundamental domain to chords inside the fundamental domain.
+And we define the following additional operations:
+
+T(p, x) Translate p by x.
+
+I(p [, x]) Reflect p in x, by default the origin.
+
+P Send a major triad to the minor triad with the same root,
+ or vice versa (Riemann's parallel transformation).
+
+L Send a major triad to the minor triad one major third higher,
+ or vice versa (Riemann's Leittonwechsel or leading-tone
+ exchange transformation).
+
+R Send a major triad to the minor triad one minor third lower,
+ or vice versa (Riemann's relative transformation).
+
+D Send a triad to the next triad a perfect fifth lower
+ (dominant transformation).
+
+P, L, and R have been extended as follows, see Fiore and Satyendra,
+"Generalized Contextual Groups", _Music Theory Online_ 11, August 2008:
+
+K(c) Interchange by inversion;
+ K(c) := I(c, c[1] + c[2]).
+ This is a generalized form of P; for major and minor triads,
+ it is exactly the same as P, but it also works with other
+ chord types.
+
+Q(c, n, m) Contexual transposition;
+ Q(c, n, m) := T(c, n) if c is a T-form of m,
+ or T(c, -n) if c is an I-form of M. Not a generalized form
+ of L or R; but, like them, K and Q generate the T-I group.
+
+]]
+end
+--[[
+
+LOG
+
+2011-Sep-07
+
+Redoing this package from scratch using GVLS formulas.
+
+2011-Sep-09
+
+There are definite problems with side effects in these tests. The first test
+passes, but not when in series with another test.
+
+Is there a bug in "~=" for Lua and/or LuaJIT?
+
+2011-Sep-10
+
+There is definitely one or more bugs in LuaJIT vs. Lua. Tests run to 4 or 5
+voices in Lua that do not work in LuaJIT. There appear to be false temporaries
+or something in LuaJIT.
+
+2011-Sep-11
+
+I am going to redo the equivalence formulas in sets: vanilla GVLS, GVLS with
+my modifications, and mine. This seems like the only way of sorting out the
+mess.
+
+2011-Sep-22
+
+It may be that my R, P, T, and I do not fit together to make OPTI because my I
+does not use the inversion flat.
+
+[2011-Sep-28: Not so, but because my T was aligned on 12-TET.]
+
+2011-Sep-27
+
+Redo tests of equivalences. [2011-Sep-28: They pass up to 5 voices.]
+
+2011-Sep-28
+
+First, some lessons learned painfully. I can still think quite well, but I AM
+slower, and I have to ALLOW for that. So I actually need to think MORE
+CAREFULLY (which takes longer) in order to make sure tests and logic are quite
+clear, as this will save yet more time in testing and debugging. E.g., if I
+had had my current unit tests in place when I began to rewrite this code,
+I would have been where I am now four or five months ago. It wouldn't hurt,
+either, to ask for help sooner rather than later -- DT's advice was extremely
+helpful.
+
+OK, I get it now. My prior attempts to combine representative fundamental
+domains were ill-advised.
+
+The fundamental domain formulas are now as correct as the tests I have written
+can tell, although I should try to come up with some additional tests. Yet
+there still may be problems...
+
+2011-Oct-11
+
+RPTT and RPTTI need unit tests. The definitions in :information and in
+ChordSpaceGroup are not consistent, this is why ChordSpaceGroup is failing.
+
+2011-Oct-13
+
+I have redone ChordSpaceGroup using different orbifolds and equivalences that
+keep operations in OPTI, I, and T strictly within equal temperament. I do not
+use the GVLS fundamental domains directly for this at all. The symmetries of
+the operations are all I need musically, so I simply put the GVLS OPTIs into
+equal temperament and enumerate them for my set-class group (OPTTI). I do this
+by taking the floor of the OPTI and then transposing it up by one unit of
+transposition.
+
+2011-Oct-16
+
+Problems with ChordSpaceGroup:toChord and :fromChord. Look at voicing number
+and transposition.
+
+2011-Oct-17
+
+Problems, e.g. {-4, 0, 4} transposed 4 is also eOP {-4, 0, 4}, ditto
+transposed 8 and 12. The inversion flat would behave similiarly.
+
+In other words, for some chords ChordSpaceGroup:toChord will give the same
+chord for several different P, I, T, V, but ChordSpaceGroup:fromChord can only
+give the same P, I, T, V for all of those chords. This is correct, but it
+means that in unit testing from and should compare only chords, not numbers.
+
+2011-Oct-19
+
+In 1 dimension, all pitches under OP equivalence fall in the fundamental
+domain {[0, 12)}; there are no duplicate equivalents.
+
+In 2 dimensions, all chords under OP equivalence fall in the fundamental
+domain {[-6, 6], [-6, 6], [12, 0], [0, 12]}; there are duplicate
+equivalents, because otherwise the chord {11, 11} has no equivalent in
+the domain (it is actually {-1, 11}).
+
+2011-Oct-20
+
+DD'OOOOHHHHHHHHHHHHH.... -0 and 0 are messing up chord comparators and hashes.
+Hence the sets of OPTTI are wrong. Hence the ChordSpaceGroup is wrong. But,
+now I know what the problem is!
+
+2011-Oct-24
+
+"allOf" fails for OPT and OPTI because of fractional pitches. This must be
+dealt with, but is not so serious right now.
+
+More urgently, there is still a problem with OPI for 5 voices. I should
+capture the offending chord and test it in solitary confinement. Well, here
+it is:
+
+TESTING CHORDS OF 5 VOICES...
+
+pitches: { -13.0000 -13.0000 -13.0000 -8.0000 -6.0000}
+I: { 13.0000 13.0000 13.0000 8.0000 6.0000}
+eO: { -1.0000 -1.0000 -1.0000 4.0000 6.0000} iseO: false
+eP: { -13.0000 -13.0000 -13.0000 -8.0000 -6.0000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseT: false
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eI: { -13.0000 -13.0000 -13.0000 -8.0000 -6.0000} iseI: true
+eV: { -13.0000 -13.0000 -13.0000 -8.0000 -6.0000} iseV: true
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eOP: { -1.0000 -1.0000 -1.0000 4.0000 6.0000} iseOP: false
+pcs: { 4.0000 6.0000 11.0000 11.0000 11.0000}
+eOPT: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseOPT: false
+eOPTT: { -2.0000 -2.0000 -2.0000 3.0000 5.0000}
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eOPI: { -4.0000 1.0000 1.0000 1.0000 6.0000} iseOPI: false
+eOPTI: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseOPTI: false
+eOPTTI: { -2.0000 -2.0000 -2.0000 3.0000 5.0000}
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+layer: -53.00
+pitches: { -2.4000 -2.4000 -2.4000 2.6000 4.6000}
+I: { 2.4000 2.4000 2.4000 -2.6000 -4.6000}
+eO: { -2.4000 -2.4000 9.6000 2.6000 4.6000} iseO: true
+eP: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseT: true
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eI: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseI: true
+eV: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseV: true
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eOP: { -2.4000 -2.4000 2.6000 4.6000 9.6000} iseOP: true
+pcs: { 2.6000 4.6000 9.6000 9.6000 9.6000}
+eOPT: { -4.6000 -2.6000 2.4000 2.4000 2.4000} iseOPT: true
+eOPTT: { -4.0000 -2.0000 3.0000 3.0000 3.0000}
+ { 0.0000 2.0000 7.0000 7.0000 7.0000}
+eOPI: { -2.6000 2.4000 2.4000 2.4000 7.4000} iseOPI: false
+eOPTI: { -4.6000 -2.6000 2.4000 2.4000 2.4000} iseOPTI: false
+eOPTTI: { -4.0000 -2.0000 3.0000 3.0000 3.0000}
+ { 0.0000 2.0000 7.0000 7.0000 7.0000}
+layer: 0.00
+========================================================================
+FAILED: chord:eOPTI():iseOPTI() == true
+========================================================================
+pitches: { -13.0000 -13.0000 -13.0000 -8.0000 6.0000}
+I: { 13.0000 13.0000 13.0000 8.0000 -6.0000}
+eO: { -1.0000 -1.0000 -1.0000 4.0000 6.0000} iseO: false
+eP: { -13.0000 -13.0000 -13.0000 -8.0000 6.0000} iseP: true
+eT: { -4.8000 -4.8000 -4.8000 0.2000 14.2000} iseT: false
+ { 0.0000 0.0000 0.0000 5.0000 19.0000}
+eI: { -13.0000 -13.0000 -13.0000 -8.0000 6.0000} iseI: true
+eV: { -8.0000 6.0000 -13.0000 -13.0000 -13.0000} iseV: false
+ { 5.0000 19.0000 0.0000 0.0000 0.0000}
+eOP: { -1.0000 -1.0000 -1.0000 4.0000 6.0000} iseOP: false
+pcs: { 4.0000 6.0000 11.0000 11.0000 11.0000}
+eOPT: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseOPT: false
+eOPTT: { -2.0000 -2.0000 -2.0000 3.0000 5.0000}
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eOPI: { -4.0000 1.0000 1.0000 1.0000 6.0000} iseOPI: false
+eOPTI: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseOPTI: false
+eOPTTI: { -2.0000 -2.0000 -2.0000 3.0000 5.0000}
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+layer: -41.00
+pitches: { -2.4000 -2.4000 -2.4000 2.6000 4.6000}
+I: { 2.4000 2.4000 2.4000 -2.6000 -4.6000}
+eO: { -2.4000 -2.4000 9.6000 2.6000 4.6000} iseO: true
+eP: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseT: true
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eI: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseI: true
+eV: { -2.4000 -2.4000 -2.4000 2.6000 4.6000} iseV: true
+ { 0.0000 0.0000 0.0000 5.0000 7.0000}
+eOP: { -2.4000 -2.4000 2.6000 4.6000 9.6000} iseOP: true
+pcs: { 2.6000 4.6000 9.6000 9.6000 9.6000}
+eOPT: { -4.6000 -2.6000 2.4000 2.4000 2.4000} iseOPT: true
+eOPTT: { -4.0000 -2.0000 3.0000 3.0000 3.0000}
+ { 0.0000 2.0000 7.0000 7.0000 7.0000}
+eOPI: { -2.6000 2.4000 2.4000 2.4000 7.4000} iseOPI: false
+eOPTI: { -4.6000 -2.6000 2.4000 2.4000 2.4000} iseOPTI: false
+eOPTTI: { -4.0000 -2.0000 3.0000 3.0000 3.0000}
+ { 0.0000 2.0000 7.0000 7.0000 7.0000}
+layer: 0.00
+========================================================================
+FAILED: chord:eOPTI():iseOPTI() == true
+========================================================================
+pitches: { -13.0000 -13.0000 -13.0000 -7.0000 -7.0000}
+I: { 13.0000 13.0000 13.0000 7.0000 7.0000}
+eO: { -1.0000 -1.0000 -1.0000 5.0000 5.0000} iseO: false
+eP: { -13.0000 -13.0000 -13.0000 -7.0000 -7.0000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseT: false
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eI: { -13.0000 -13.0000 -13.0000 -7.0000 -7.0000} iseI: true
+eV: { -13.0000 -13.0000 -13.0000 -7.0000 -7.0000} iseV: true
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eOP: { -1.0000 -1.0000 -1.0000 5.0000 5.0000} iseOP: false
+pcs: { 5.0000 5.0000 11.0000 11.0000 11.0000}
+eOPT: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseOPT: false
+eOPTT: { -2.0000 -2.0000 -2.0000 4.0000 4.0000}
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eOPI: { -5.0000 1.0000 1.0000 1.0000 7.0000} iseOPI: false
+eOPTI: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseOPTI: false
+eOPTTI: { -2.0000 -2.0000 -2.0000 4.0000 4.0000}
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+layer: -53.00
+pitches: { -2.4000 -2.4000 -2.4000 3.6000 3.6000}
+I: { 2.4000 2.4000 2.4000 -3.6000 -3.6000}
+eO: { -2.4000 -2.4000 9.6000 3.6000 3.6000} iseO: true
+eP: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseT: true
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eI: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseI: true
+eV: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseV: true
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eOP: { -2.4000 -2.4000 3.6000 3.6000 9.6000} iseOP: true
+pcs: { 3.6000 3.6000 9.6000 9.6000 9.6000}
+eOPT: { -3.6000 -3.6000 2.4000 2.4000 2.4000} iseOPT: true
+eOPTT: { -3.0000 -3.0000 3.0000 3.0000 3.0000}
+ { 0.0000 0.0000 6.0000 6.0000 6.0000}
+eOPI: { -3.6000 2.4000 2.4000 2.4000 8.4000} iseOPI: false
+eOPTI: { -3.6000 -3.6000 2.4000 2.4000 2.4000} iseOPTI: false
+eOPTTI: { -3.0000 -3.0000 3.0000 3.0000 3.0000}
+ { 0.0000 0.0000 6.0000 6.0000 6.0000}
+layer: 0.00
+========================================================================
+FAILED: chord:eOPTI():iseOPTI() == true
+========================================================================
+pitches: { -13.0000 -13.0000 -13.0000 -7.0000 5.0000}
+I: { 13.0000 13.0000 13.0000 7.0000 -5.0000}
+eO: { -1.0000 -1.0000 -1.0000 5.0000 5.0000} iseO: false
+eP: { -13.0000 -13.0000 -13.0000 -7.0000 5.0000} iseP: true
+eT: { -4.8000 -4.8000 -4.8000 1.2000 13.2000} iseT: false
+ { 0.0000 0.0000 0.0000 6.0000 18.0000}
+eI: { -13.0000 -13.0000 -13.0000 -7.0000 5.0000} iseI: true
+eV: { -13.0000 -13.0000 -7.0000 5.0000 -13.0000} iseV: false
+ { 0.0000 0.0000 6.0000 18.0000 0.0000}
+eOP: { -1.0000 -1.0000 -1.0000 5.0000 5.0000} iseOP: false
+pcs: { 5.0000 5.0000 11.0000 11.0000 11.0000}
+eOPT: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseOPT: false
+eOPTT: { -2.0000 -2.0000 -2.0000 4.0000 4.0000}
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eOPI: { -5.0000 1.0000 1.0000 1.0000 7.0000} iseOPI: false
+eOPTI: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseOPTI: false
+eOPTTI: { -2.0000 -2.0000 -2.0000 4.0000 4.0000}
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+layer: -41.00
+pitches: { -2.4000 -2.4000 -2.4000 3.6000 3.6000}
+I: { 2.4000 2.4000 2.4000 -3.6000 -3.6000}
+eO: { -2.4000 -2.4000 9.6000 3.6000 3.6000} iseO: true
+eP: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseP: true
+eT: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseT: true
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eI: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseI: true
+eV: { -2.4000 -2.4000 -2.4000 3.6000 3.6000} iseV: true
+ { 0.0000 0.0000 0.0000 6.0000 6.0000}
+eOP: { -2.4000 -2.4000 3.6000 3.6000 9.6000} iseOP: true
+pcs: { 3.6000 3.6000 9.6000 9.6000 9.6000}
+eOPT: { -3.6000 -3.6000 2.4000 2.4000 2.4000} iseOPT: true
+eOPTT: { -3.0000 -3.0000 3.0000 3.0000 3.0000}
+ { 0.0000 0.0000 6.0000 6.0000 6.0000}
+eOPI: { -3.6000 2.4000 2.4000 2.4000 8.4000} iseOPI: false
+eOPTI: { -3.6000 -3.6000 2.4000 2.4000 2.4000} iseOPTI: false
+eOPTTI: { -3.0000 -3.0000 3.0000 3.0000 3.0000}
+ { 0.0000 0.0000 6.0000 6.0000 6.0000}
+layer: 0.00
+========================================================================
+FAILED: chord:eOPTI():iseOPTI() == true
+========================================================================
+
+It looks like the real culprit is this eV thing.
+
+2011-Oct-25
+
+Regarding eV, it's tricky because to start with a voicing and permute doesn't
+give the same permutations as starting with a chord and permuting. So the
+permutations have always to be in the same order. This may be my whole problem
+all along.
+
+I think eV may be the first permutation that is the closest to the unison
+diagonal.
+
+2011-Oct-27
+
+It's official:
+
+From: 5 0 0 0
+ { -3.0000 0.0000 4.0000}
+fromChord: chord: { -3.0000 0.0000 4.0000} true
+fromChord: op: { -3.0000 0.0000 4.0000}
+fromChord: optt: { -3.0000 0.0000 4.0000}
+fromChord: optt_t: { -3.0000 0.0000 4.0000} 0
+equals
+fromChord: optti: { -3.0000 0.0000 4.0000} -3,1.6653345369377e-016,4
+fromChord: voicing: { 0.0000 0.0000 0.0000} 0
+fromChord: nil 0 0 0
+To: nil 0 0 0
+c:\utah\opt\Csound\bin\luajit.exe: .\ChordSpace.lua:2477: attempt to perform arithmetic on local 'P' (a nil value)
+stack traceback:
+ .\ChordSpace.lua:2477: in function 'toChord'
+ ChordSpaceTest.lua:205: in main chunk
+ [C]: ?
+
+Hashing will need clamping. That might need a global g.
+
+TODO:
+
+-- Redo basic unit tests to ensure nothing has been broken.
+
+-- Compute and save a chord space group file if the requested group does not
+ exist; always load a chord space group from a file. This saves simply
+ oodles of time.
+
+-- Display the fundamental domains in the viewer much more clearly.
+
+-- Display various temperament systems to see how harmony might work with
+ voiceleading around the central diagonal. Alternatively, set up columns
+ or lattices of chords that are in interesting relations, and see how they
+ sound and work together.
+
+-- Implement Rachel Hall, "Linear Contextual Transformations," 2009,
+ which seems to further extend the Generalized Contextual Group using
+ affine transformations in chord space, and Maxx Cho, "The Voice-Leading
+ Automorphism and Riemannian Operators," 2009, which may show that tonality
+ arises from a voice-leading automorphism in the Riemannian group.
+
+-- Implement various scales found in 20th and 21st century harmony
+ along with 'splitting' and 'merging' operations.
+]]
+
+ChordSpace.help()
+
+-- Returns n!
+
+function ChordSpace.factorial (n)
+ if n == 0 then
+ return 1
+ else
+ return n * ChordSpace.factorial(n - 1)
+ end
+end
+
+-- For taking numerical errors into account.
+
+ChordSpace.EPSILON = 1
+local epsilonFactor = 1000
+
+while true do
+ ChordSpace.EPSILON = ChordSpace.EPSILON / 2
+ local nextEpsilon = ChordSpace.EPSILON / 2
+ local onePlusNextEpsilon = 1 + nextEpsilon
+ if onePlusNextEpsilon == 1 then
+ print(string.format('ChordSpace.EPSILON: %g', ChordSpace.EPSILON))
+ break
+ end
+end
+
+function ChordSpace.eq_epsilon(a, b, factor)
+ factor = factor or epsilonFactor
+ if (math.abs(a - b) < (ChordSpace.EPSILON * factor)) then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.gt_epsilon(a, b, factor)
+ factor = factor or epsilonFactor
+ local eq = ChordSpace.eq_epsilon(a, b, factor)
+ if eq then
+ return false
+ end
+ if a > b then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.lt_epsilon(a, b, factor)
+ factor = factor or epsilonFactor
+ local eq = ChordSpace.eq_epsilon(a, b, factor)
+ if eq then
+ return false
+ end
+ if a < b then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.ge_epsilon(a, b, factor)
+ factor = factor or epsilonFactor
+ local eq = ChordSpace.eq_epsilon(a, b, factor)
+ if eq then
+ return true
+ end
+ if a > b then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.le_epsilon(a, b, factor)
+ factor = factor or epsilonFactor
+ local eq = ChordSpace.eq_epsilon(a, b, factor)
+ if eq then
+ return true
+ end
+ if a < b then
+ return true
+ end
+ return false
+end
+
+-- The size of the octave, defined to be consistent with
+-- 12 tone equal temperament and MIDI.
+
+ChordSpace.OCTAVE = 12
+
+-- Middle C.
+
+ChordSpace.MIDDLE_C = 60
+ChordSpace.C4 = ChordSpace.MIDDLE_C
+
+-- Returns the pitch transposed by semitones, which may be any scalar.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+local function T(pitch, semitones)
+ return pitch + semitones
+end
+
+-- Returns the pitch reflected in the center, which may be any pitch.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+local function I(pitch, center)
+ center = center or 0
+ return center - pitch
+end
+
+-- Returns the Euclidean distance between chords a and b,
+-- which must have the same number of voices.
+
+function ChordSpace.euclidean(a, b)
+ local sumOfSquaredDifferences = 0
+ for voice = 1, #a do
+ sumOfSquaredDifferences = sumOfSquaredDifferences + math.pow((a[voice] - b[voice]), 2)
+ end
+ return math.sqrt(sumOfSquaredDifferences)
+end
+
+-- Chords represent simultaneously sounding pitches.
+-- The pitches are represented as semitones with 0 at the origin
+-- and middle C as 60.
+
+Chord = {}
+
+-- Returns a new chord object with no voices.
+
+function Chord:new(o)
+ o = o or {duration = {}, channel = {}, velocity = {}, pan = {}}
+ if not o.duration then
+ o.duration = {}
+ end
+ if not o.channel then
+ o.channel = {}
+ end
+ if not o.velocity then
+ o.velocity = {}
+ end
+ if not o.pan then
+ o.pan = {}
+ end
+ setmetatable(o, self)
+ self.__index = self
+ return o
+end
+
+-- Returns a string representation of the chord.
+-- Quadratic complexity, but short enough not to matter.
+
+function Chord:__tostring()
+ local buffer = '{'
+ for voice = 1, #self do
+ buffer = buffer .. string.format('%12.7f', self[voice])
+ end
+ buffer = buffer .. '}'
+ return buffer
+end
+
+-- Resizes a chord to the specified number of voices.
+-- Existing voices are not changed. Extra voices are removed.
+-- New voices are initialized to 0.
+
+function Chord:resize(voices)
+ while #self < voices do
+ table.insert(self, 0)
+ table.insert(self.duration, 0)
+ table.insert(self.channel, 0)
+ table.insert(self.velocity, 0)
+ table.insert(self.pan, 0)
+ end
+ while #self > voices do
+ table.remove(self)
+ table.remove(self.duration)
+ table.remove(self.channel)
+ table.remove(self.velocity)
+ table.remove(self.pan)
+ end
+end
+
+function Chord:setDuration(value)
+ for i = 1, #self do
+ self.duration[i] = value
+ end
+end
+
+function Chord:getDuration(voice)
+ voice = voice or 1
+ return self.duration[voice]
+end
+
+function Chord:setChannel(value)
+ for i = 1, #self do
+ self.channel[i] = value
+ end
+end
+
+function Chord:getChannel(voice)
+ voice = voice or 1
+ return self.channel[voice]
+end
+
+function Chord:setVelocity(value)
+ for i = 1, #self do
+ self.velocity[i] = value
+ end
+end
+
+function Chord:getVelocity(voice)
+ voice = voice or 1
+ return self.velocity[voice]
+end
+
+function Chord:setPan(value)
+ for i = 1, #self do
+ self.pan[i] = value
+ end
+end
+
+function Chord:getPan(voice)
+ voice = voice or 1
+ return self.pan[voice]
+end
+
+function Chord:count(pitch)
+ local n = 0
+ for voice = 1, #self do
+ if self[voice] == pitch then
+ n = n + 1
+ end
+ end
+ return n
+end
+
+-- Redefines the metamethod to implement value semantics
+-- for ==, for the pitches in this only.
+
+function Chord:__eq(other)
+ if not (#self == #other) then
+ return false
+ end
+ for voice = 1, #self do
+ --if not (self[voice] == other[voice]) then
+ if not (ChordSpace.eq_epsilon(self[voice], other[voice])) then
+ return false
+ end
+ end
+ return true
+end
+
+function Chord:__eq_epsilon(other)
+ if not (#self == #other) then
+ return false
+ end
+ for voice = 1, #self do
+ if not (ChordSpace.eq_epsilon(self[voice], other[voice])) then
+ return false
+ end
+ end
+ return true
+end
+
+-- This hash function is used to give chords value semantics for sets.
+
+function Chord:__hash()
+ local buffer = ''
+ local comma = ','
+ for voice = 1, #self do
+ local digit = tostring(self[voice])
+ if voice == 1 then
+ buffer = buffer .. digit
+ else
+ buffer = buffer .. comma .. digit
+ end
+ end
+ return buffer
+end
+
+-- Redefines the metamethod to implement value semantics
+-- for <, for the pitches in this only.
+
+function Chord:__lt(other)
+ local voices = math.min(#self, #other)
+ for voice = 1, voices do
+ if ChordSpace.lt_epsilon(self[voice], other[voice]) then
+ return true
+ end
+ if ChordSpace.gt_epsilon(self[voice], other[voice]) then
+ return false
+ end
+ end
+ if #self < #other then
+ return true
+ end
+ return false
+end
+
+function Chord:__le(other)
+ if self:__eq(other) then
+ return true
+ end
+ return self:__lt(other)
+end
+
+-- Returns whether or not the chord contains the pitch.
+
+function Chord:contains(pitch)
+ for voice, pitch_ in ipairs(self) do
+ if pitch_ == pitch then
+ return true
+ end
+ end
+ return false
+end
+
+-- Returns the lowest pitch in the chord,
+-- and also its voice index.
+
+function Chord:min()
+ local lowestVoice = 1
+ local lowestPitch = self[lowestVoice]
+ for voice = 2, #self do
+ if self[voice] < lowestPitch then
+ lowestPitch = self[voice]
+ lowestVoice = voice
+ end
+ end
+ return lowestPitch, lowestVoice
+end
+
+-- Returns the minimum interval in the chord.
+
+function Chord:minimumInterval()
+ local minimumInterval = math.abs(self[1] - self[2])
+ for v1 = 1, #self do
+ for v2 = 1, #self do
+ if t (v1 == v2) then
+ local interval = math.abs(self[v1] - self[v2])
+ if interval < minimumInterval then
+ minimumInterval = interval
+ end
+ end
+ end
+ end
+ return minimumInterval
+end
+
+-- Returns the highest pitch in the chord,
+-- and also its voice index.
+
+function Chord:max()
+ local highestVoice = 1
+ local highestPitch = self[highestVoice]
+ for voice = 2, #self do
+ if self[voice] > highestPitch then
+ highestPitch = self[voice]
+ highestVoice = voice
+ end
+ end
+ return highestPitch, highestVoice
+end
+
+-- Returns the maximum interval in the chord.
+
+function Chord:maximumInterval()
+ return self:max() - self:min()
+end
+
+-- Returns a new chord whose pitches are the floors of this chord's pitches.
+
+function Chord:floor()
+ local chord = self:clone()
+ for voice = 1, #self do
+ chord[voice] = math.floor(self[voice])
+ end
+ return chord
+end
+
+-- Returns a new chord whose pitches are the ceilings of this chord's pitches.
+
+function Chord:ceil()
+ local chord = self:clone()
+ for voice = 1, #self do
+ chord[voice] = math.ceil(self[voice])
+ end
+ return chord
+end
+
+-- Returns a value copy of the chord.
+
+function Chord:clone()
+ local clone_ = Chord:new()
+ for voice, pitch in ipairs(self) do
+ clone_[voice] = pitch
+ end
+ for voice, value in ipairs(self.duration) do
+ clone_.duration[voice] = value
+ end
+ for voice, value in ipairs(self.channel) do
+ clone_.channel[voice] = value
+ end
+ for voice, value in ipairs(self.velocity) do
+ clone_.velocity[voice] = value
+ end
+ for voice, value in ipairs(self.pan) do
+ clone_.pan[voice] = value
+ end
+ return clone_
+end
+
+-- Returns the origin of the chord's space.
+
+function Chord:origin()
+ local clone_ = self:clone()
+ for voice = 1, #clone_ do
+ clone_[voice] = 0
+ end
+ return clone_
+end
+
+function Chord:distanceToOrigin()
+ local origin = self:origin()
+ return ChordSpace.euclidean(self, origin)
+end
+
+function Chord:distanceToUnisonDiagonal()
+ local unison = self:origin()
+ local pitch = self:layer() / #self
+ for voice = 1, #self do
+ unison[voice] = pitch
+ end
+ return ChordSpace.euclidean(self, unison)
+end
+
+-- Returns the maximally even chord in the chord's space,
+-- e.g. the augmented triad for 3 dimensions.
+
+function Chord:maximallyEven()
+ local clone_ = self:clone()
+ local g = ChordSpace.OCTAVE / #clone_
+ for i = 1, #clone_ do
+ clone_[i] = (i - 1) * g
+ end
+ return clone_
+end
+
+-- Returns the sum of the pitches in the chord.
+
+function Chord:layer()
+ local s = 0
+ for voice, pitch in ipairs(self) do
+ s = s + pitch
+ end
+ return s
+end
+
+-- Transposes the chord by the indicated interval (may be a fraction).
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:T(interval)
+ local clone_ = self:clone()
+ for voice = 1, #clone_ do
+ clone_[voice] = T(clone_[voice], interval)
+ end
+ return clone_
+end
+
+-- Inverts the chord by another chord that is on the unison diagonal, by
+-- default the origin. NOTE: Does NOT return the result under any equivalence
+-- class.
+
+function Chord:I(center)
+ center = center or 0
+ local inverse = self:clone()
+ for voice = 1, #inverse do
+ inverse[voice] = I(self[voice], center)
+ end
+ return inverse
+end
+
+-- Returns the equivalent of the pitch under pitch-class equivalence, i.e.
+-- the pitch is in the interval [0, OCTAVE).
+
+function ChordSpace.epc(pitch)
+ --while pitch < 0 do
+ while ChordSpace.lt_epsilon(pitch, 0) do
+ pitch = pitch + ChordSpace.OCTAVE
+ end
+ --while pitch >= ChordSpace.OCTAVE do
+ while ChordSpace.ge_epsilon(pitch, ChordSpace.OCTAVE) do
+ pitch = pitch - ChordSpace.OCTAVE
+ end
+ return pitch
+end
+
+-- Returns whether the chord is within the fundamental domain of
+-- pitch-class equivalence, i.e. is a pitch-class set.
+
+function Chord:isepcs()
+ for voice = 1, #chord do
+ --if not (self[voice] == ChordSpace.epc(chord[voice])) then
+ if not ChordSpace.eq_epsilon(self[voice], ChordSpace.epc(chord[voice])) then
+ return false
+ end
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord under pitch-class equivalence,
+-- i.e. the pitch-class set of the chord.
+
+function Chord:epcs()
+ local chord = self:clone()
+ for voice = 1, #chord do
+ chord[voice] = ChordSpace.epc(chord[voice])
+ end
+ return chord
+end
+
+-- Returns whether the chord is within the fundamental domain of
+-- transposition to 0.
+
+function Chord:iset()
+ local et = self:et()
+ if not (et == self) then
+ return false
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the fundamental domain of
+-- transposition to 0.
+
+function Chord:et()
+ local min_ = self:min()
+ return self:T(-min_)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of the indicated range equivalence.
+
+function Chord:iseR(range)
+ --[[ GVLS:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not (max_ <= (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not ((0 <= layer_) and (layer_ <= range)) then
+ return false
+ end
+ return true
+ --]]
+ --[[ GVLS modified:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not ChordSpace.le_epsilon(max_, (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not (ChordSpace.le_epsilon(0, layer_) and ChordSpace.le_epsilon(layer_, range)) then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG several equivalents of boundary points in domain:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not ChordSpace.le_epsilon(max_, (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not (ChordSpace.le_epsilon(0, layer_) and ChordSpace.le_epsilon(layer_, range)) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave equivalence.
+
+function Chord:iseO()
+ return self:iseR(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of a range equivalence.
+
+function Chord:eR(range)
+ local chord = self:clone()
+ --if chord:iseR(range) then
+ -- return chord
+ --end
+ -- The clue here is that at least one voice must be >= 0,
+ -- but no voice can be > range.
+ -- First, move all pitches inside the interval [0, OCTAVE),
+ -- which is not the same as the fundamental domain.
+ chord = self:epcs()
+ -- Then, reflect voices that are outside of the fundamental domain
+ -- back into it, which will revoice the chord, i.e.
+ -- the sum of pitches is in [0, OCTAVE].
+ --while chord:layer() > range do
+ while ChordSpace.gt_epsilon(chord:layer(), range) do
+ local maximumPitch, maximumVoice = chord:max()
+ -- Because no voice is above the range,
+ -- any voices that need to be revoiced will now be negative.
+ chord[maximumVoice] = maximumPitch - ChordSpace.OCTAVE
+ end
+ return chord
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave equivalence.
+
+function Chord:eO()
+ return self:eR(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of permutational equivalence.
+
+function Chord:iseP()
+ for voice = 2, #self do
+ --if not (self[voice - 1] <= self[voice]) then
+ if not ChordSpace.le_epsilon(self[voice - 1], self[voice]) then
+ return false
+ end
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of permutational equivalence.
+
+function Chord:eP()
+ clone_ = self:clone()
+ table.sort(clone_)
+ return clone_
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of transpositional equivalence.
+
+function Chord:iseT()
+ ----[[ GVLS:
+ local layer_ = self:layer()
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ return true
+ --]]
+ --[[ MKG:
+ g = g or 1
+ local ep = self:eP()
+ if not (ep == ep:eT(g):eP()) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of transpositonal equivalence.
+
+function Chord:eT()
+ ----[[ GVLS:
+ local layer_ = self:layer()
+ local sumPerVoice = layer_ / #self
+ return self:T(-sumPerVoice)
+ --]]
+ --[[ MKG:
+ g = g or 1
+ local iterator = self
+ -- Transpose down to layer 0 or just below.
+ while iterator:layer() > 0 do
+ iterator = iterator:T(-g)
+ end
+ -- Transpose up to layer 0 or just above.
+ while iterator:layer() < 0 do
+ iterator = iterator:T(g)
+ end
+ return iterator
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of transpositonal equivalence and the equal temperament generated
+-- by g. I.e., returns the chord transposed such that its layer is 0 or, under
+-- transposition, the positive layer closest to 0. NOTE: Does NOT return the
+-- result under any other equivalence class.
+
+function Chord:eTT(g)
+ g = g or 1
+ local et = self:eT()
+ local transposition = math.ceil(et[1]) - et[1]
+ local ett = et:T(transposition)
+ return ett
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of translational equivalence and the equal temperament generated by g.
+
+function Chord:iseTT(g)
+ g = g or 1
+ local ep = self:eP()
+ if not (ep == ep:eTT(g)) then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of inversional equivalence.
+
+function Chord:iseI(inverse)
+ --[[ GLVS:
+ local chord = self:clone()
+ local lowerVoice = 2
+ local upperVoice = #chord
+ while lowerVoice < upperVoice do
+ -- GVLS: tests only 1 interval: x[2] - x[1] <= x[#x] - x[#x - 1]
+ local lowerInterval = chord[lowerVoice] - chord[lowerVoice - 1]
+ local upperInterval = chord[upperVoice] - chord[upperVoice - 1]
+ if lowerInterval < upperInterval then
+ return true
+ end
+ if lowerInterval > upperInterval then
+ return false
+ end
+ lowerVoice = lowerVoice + 1
+ upperVoice = upperVoice - 1
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ inverse = inverse or self:I()
+ if not self:__le(inverse) then
+ return false
+ end
+ return true
+ --]]
+ --[[ MKG:
+ inverse = self:I()
+ if not self:__le(inverse) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of inversional equivalence.
+
+function Chord:eI()
+ if self:iseI() then
+ return self:clone()
+ end
+ return self:I()
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range and permutational equivalence.
+
+function Chord:iseRP(range)
+ --[[ GVLS:
+ for voice = 2, #self do
+ if not (self[voice - 1] <= self[voice]) then
+ return false
+ end
+ end
+ if not (self[#self] <= (self[1] + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not ((0 <= layer_) and (layer_ <= range)) then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseP() then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave and permutational equivalence.
+
+function Chord:iseOP()
+ return self:iseRP(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range and permutational equivalence.
+
+function Chord:eRP(range)
+ return self:eR(range):eP()
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave and permutational equivalence.
+
+function Chord:eOP()
+ return self:eRP(ChordSpace.OCTAVE)
+end
+
+-- Returns a copy of the chord cyclically permuted by a stride, by default 1.
+-- The direction of rotation is the same as musicians' first inversion, second
+-- inversion, and so on.
+
+function Chord:cycle(stride)
+ stride = stride or 1
+ local clone_ = self:clone()
+ if stride < 0 then
+ for i = 1, stride do
+ local tail = table.remove(clone_)
+ table.insert(clone_, 1, tail)
+ end
+ return chord
+ end
+ if stride > 0 then
+ for i = 1, math.abs(stride) do
+ local head = table.remove(clone_, 1)
+ table.insert(clone_, head)
+ end
+ end
+ return clone_
+end
+
+-- Returns the permutations of the pitches in a chord. The permutations from
+-- each particular permutation are always returned in the same order.
+
+function Chord:permutations()
+ local chord = self:clone()
+ local permutations_ = {}
+ permutations_[1] = chord
+ for i = 2, #self do
+ chord = chord:cycle()
+ permutations_[i] = chord
+ end
+ table.sort(permutations_)
+ return permutations_
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of voicing equivalence.
+
+function Chord:iseV()
+ local eV = self:eV()
+ --print(string.format('chord: %s eV: %s', tostring(self), tostring(eV)))
+ if not (self == eV) then
+ return false
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of voicing equivalence.
+
+function Chord:eV()
+ ----[[
+ for index, voicing in ipairs(self:permutations()) do
+ local wraparound = voicing[1] + ChordSpace.OCTAVE - voicing[#voicing]
+ local iseV_ = true
+ for voice = 1, #voicing - 1 do
+ local inner = voicing[voice + 1] - voicing[voice]
+ if not ChordSpace.ge_epsilon(wraparound, inner) then
+ --if inner > wraparound then
+ iseV_ = false
+ end
+ end
+ if iseV_ then
+ return voicing
+ end
+ end
+ --]]
+ --[[
+ local voicings = self:permutations()
+ local distancesForIndexes = {}
+ for i = 1, #voicings do
+ distancesForIndexes[i] = voicings[i]:distanceToUnisonDiagonal()
+ end
+ local minimumDistanceToUnisonDiagonal = distancesForIndexes[1]
+ for i = 2, #voicings do
+ if distancesForIndexes[i] < minimumDistanceToUnisonDiagonal then
+ minimumDistanceToUnisonDiagonal = distancesForIndexes[i]
+ end
+ end
+ for i = 1, #voicings do
+ if distancesForIndexes[i] == minimumDistanceToUnisonDiagonal then
+ return voicings[i]
+ end
+ end
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, and transpositional equivalence.
+
+function Chord:iseRPT(range)
+ --[[ GVLS:
+ -- GVLS: if not (self[#self] <= self[1] + ChordSpace.OCTAVE) then
+ if not (ChordSpace.le_epsilon(self[#self], (self[1] + range))) then
+ return false
+ end
+ local layer_ = self:layer()
+ -- GVLS: if not (layer_ == 0) then
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ if #self < 2 then
+ return true
+ end
+ local wraparound = self[1] + range - self[#self]
+ for voice = 1, #self - 1 do
+ local inner = self[voice + 1] - self[voice]
+ if not ChordSpace.le_epsilon(wraparound, inner) then
+ return false
+ end
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseP() then
+ return false
+ end
+ if not self:iseT() then
+ return false
+ end
+ if not self:iseV() then
+ return false
+ end
+ return true
+ --]]
+end
+
+function Chord:iseRPTT(range)
+ if not self:iseP() then
+ return false
+ end
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseTT() then
+ return false
+ end
+ if not self:iseV() then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, and transpositional equivalence.
+
+function Chord:iseOPT()
+ return self:iseRPT(ChordSpace.OCTAVE)
+end
+
+function Chord:iseOPTT()
+ return self:iseRPTT(ChordSpace.OCTAVE)
+end
+
+-- Returns a copy of the chord 'inverted' in the musician's sense,
+-- i.e. revoiced by cyclically permuting the chord and
+-- adding (or subtracting) an octave to the highest (or lowest) voice.
+-- The revoicing will move the chord up or down in pitch.
+-- A positive direction is the same as a musician's first inversion,
+-- second inversion, etc.
+
+function Chord:v(direction)
+ direction = direction or 1
+ local chord = self:clone()
+ while direction > 0 do
+ chord = chord:cycle(1)
+ chord[#chord] = chord[#chord] + ChordSpace.OCTAVE
+ direction = direction - 1
+ end
+ while direction < 0 do
+ chord = chord:cycle(-1)
+ chord[1] = chord[1] - ChordSpace.OCTAVE
+ direction = direction + 1
+ end
+ return chord
+end
+
+-- Returns all the 'inversions' (in the musician's sense)
+-- or octavewise revoicings of the chord.
+
+function Chord:voicings()
+ local chord = self:clone()
+ local voicings = {}
+ voicings[1] = chord
+ for i = 2, #self do
+ chord = chord:v()
+ voicings[i] = chord
+ end
+ return voicings
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, and transpositional equivalence; the same
+-- as set-class type, or chord type.
+
+function Chord:eRPT(range)
+ --[[
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]:eT()
+ if voicing:iseV() then
+ return voicing
+ end
+ end
+ print('ERROR: Chord:eRPT() should not come here: ' .. tostring(self))
+ --]]
+ ----[[
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]
+ if voicing:iseV() then
+ return voicing:eT()
+ end
+ end
+ print('ERROR: Chord:eRPT() should not come here: ' .. tostring(self))
+ --]]
+end
+
+function Chord:eRPTT(range)
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]:eTT()
+ if voicing:iseV() then
+ return voicing
+ end
+ end
+ print('ERROR: Chord:eRPTT() should not come here: ' .. tostring(self))
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave, permutational, and transpositional equivalence.
+
+function Chord:eOPT()
+ return self:eRPT(ChordSpace.OCTAVE)
+end
+
+function Chord:eOPTT()
+ return self:eRPTT(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, and inversional equivalence.
+
+function Chord:iseRPI(range)
+ if not self:iseRP(range) then
+ return false
+ end
+ local inverse = self:I():eRP(range)
+ assert(inverse, 'Inverse is nil.')
+ if not self:iseI(inverse) then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, and inversional equivalence.
+
+function Chord:iseOPI()
+ return self:iseRPI(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, and inversional equivalence.
+
+function Chord:eRPI(range)
+ local erp = self:eRP(range)
+ if erp:iseRPI(range) then
+ return erp
+ end
+ return erp:I():eRP(range)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave, permutational, and inversional equivalence.
+
+function Chord:eOPI()
+ return self:eRPI(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, transpositional, and inversional equivalence.
+
+function Chord:iseRPTI(range)
+ --[[ GVLS:
+ -- GVLS: if not (self[#self] <= self[1] + ChordSpace.OCTAVE) then
+ if not ChordSpace.le_epsilon(self[#self], (self[1] + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ -- GVLS: if not (layer_ == 0) then
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ if #self <= 2 then
+ return true
+ end
+ local wraparound = self[1] + range - self[#self]
+ for voice = 1, #self - 1 do
+ local inner = self[voice + 1] - self[voice]
+ if not ChordSpace.le_epsilon(wraparound, inner) then
+ return false
+ end
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseRPT(range) then
+ return false
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+ --]]
+end
+
+function Chord:iseRPTTI(range)
+ if not self:iseRPTT(range) then
+ return false
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, transpositional, and inversional equivalence.
+
+function Chord:iseOPTI()
+ return self:iseRPTI(ChordSpace.OCTAVE)
+end
+
+function Chord:iseOPTTI()
+ return self:iseRPTTI(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, transpositional, and inversional
+-- equivalence.
+
+function Chord:eRPTI(range)
+ local rpt = self:eRPT(range)
+ if rpt:iseI() then
+ return rpt
+ end
+ return rpt:I():eRPT(range)
+end
+
+function Chord:eRPTTI(range)
+ local rpt = self:eRPTT(range)
+ if rpt:iseRPTTI(range) then
+ return rpt
+ end
+ return rpt:I():eRPTT(range)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, transpositional, and inversional
+-- equivalence.
+
+function Chord:eOPTI()
+ return self:eRPTI(ChordSpace.OCTAVE)
+end
+
+function Chord:eOPTTI()
+ return self:eRPTTI(ChordSpace.OCTAVE)
+end
+
+function Chord:name()
+ local chordName = ChordSpace.namesForChords[self:__hash()]
+ if chordName == nil then
+ chordName = ''
+ end
+ return chordName
+end
+
+-- Returns a formatted string with information about the chord.
+
+function Chord:information()
+ local et = self:eT():et()
+ local evt = self:eV():et()
+ local eopt = self:eOPT():et()
+ local epcs = self:epcs():eP()
+ local eopti = self:eOPTI():et()
+ local eOP = self:eOP()
+ chordName = eOP:name()
+ return string.format([[pitches: %s %s
+I: %s
+eO: %s iseO: %s
+eP: %s iseP: %s
+eT: %s iseT: %s
+ %s
+eI: %s iseI: %s
+eV: %s iseV: %s
+ %s
+eOP: %s iseOP: %s
+pcs: %s
+eOPT: %s iseOPT: %s
+eOPTT: %s
+ %s
+eOPI: %s iseOPI: %s
+eOPTI: %s iseOPTI: %s
+eOPTTI: %s
+ %s
+layer: %6.2f]],
+tostring(self), chordName,
+tostring(self:I()),
+tostring(self:eO()), tostring(self:iseO()),
+tostring(self:eP()), tostring(self:iseP()),
+tostring(self:eT()), tostring(self:iseT()),
+tostring(et),
+tostring(self:eI()), tostring(self:iseI()),
+tostring(self:eV()), tostring(self:iseV()),
+tostring(evt),
+tostring(self:eOP()), tostring(self:iseOP()),
+tostring(epcs),
+tostring(self:eOPT()), tostring(self:iseOPT()),
+tostring(self:eOPTT()),
+tostring(eopt),
+tostring(self:eOPI()), tostring(self:iseOPI()),
+tostring(self:eOPTI()), tostring(self:iseOPTI()),
+tostring(self:eOPTTI()),
+tostring(eopti),
+self:layer())
+end
+
+function ChordSpace.set(collection)
+ local set_ = {}
+ for key, value in pairs(collection) do
+ set_[value:__hash()] = value
+ end
+ return set_
+end
+
+function ChordSpace.sortedSet(collection)
+ local set_ = ChordSpace.set(collection)
+ local sortedSet_ = {}
+ for key, value in pairs(set_) do
+ table.insert(sortedSet_, value)
+ end
+ table.sort(sortedSet_)
+ return sortedSet_
+end
+
+function ChordSpace.zeroBasedSet(sortedSet)
+ local zeroBasedSet = {}
+ for index, value in pairs(sortedSet) do
+ zeroBasedSet[index - 1] = value
+ end
+ return zeroBasedSet
+end
+
+function ChordSpace.setContains(setA, x)
+ if setA[x:__hash()] == x then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.setInsert(setA, x)
+ if not ChordSpace.setContains(setA, x) then
+ setA[x:__hash()] = x
+ end
+end
+
+function ChordSpace.sortedEquals(sortedA, sortedB)
+ if not (#sortedA == #sortedB) then
+ return false
+ end
+ for i = 1, #sortedA do
+ if not (sortedA[i] == sortedB[i]) then
+ return false
+ end
+ end
+ return true
+end
+
+function ChordSpace.setIntersection(A, setB)
+ local result = {}
+ for index, value in pairs(A) do
+ if ChordSpace.setContains(setB, value) then
+ ChordSpace.setInsert(result, value)
+ end
+ end
+ return result
+end
+
+function ChordSpace.union(A, B)
+ local result = {}
+ for index, value in pairs(A) do
+ ChordSpace.setInsert(result, value)
+ end
+ for index, value in pairs(B) do
+ ChordSpace.setInsert(result, value)
+ end
+ return result
+end
+
+ChordSpace.pitchClassesForNames = {}
+
+ChordSpace.pitchClassesForNames["C" ] = 0
+ChordSpace.pitchClassesForNames["C#"] = 1
+ChordSpace.pitchClassesForNames["Db"] = 1
+ChordSpace.pitchClassesForNames["D" ] = 2
+ChordSpace.pitchClassesForNames["D#"] = 3
+ChordSpace.pitchClassesForNames["Eb"] = 3
+ChordSpace.pitchClassesForNames["E" ] = 4
+ChordSpace.pitchClassesForNames["F" ] = 5
+ChordSpace.pitchClassesForNames["F#"] = 6
+ChordSpace.pitchClassesForNames["Gb"] = 6
+ChordSpace.pitchClassesForNames["G" ] = 7
+ChordSpace.pitchClassesForNames["G#"] = 8
+ChordSpace.pitchClassesForNames["Ab"] = 8
+ChordSpace.pitchClassesForNames["A" ] = 9
+ChordSpace.pitchClassesForNames["A#"] = 10
+ChordSpace.pitchClassesForNames["Bb"] = 10
+ChordSpace.pitchClassesForNames["B" ] = 11
+
+ChordSpace.chordsForNames = {}
+ChordSpace.namesForChords = {}
+
+local function fill(rootName, rootPitch, typeName, typePitches)
+ local chordName = rootName .. typeName
+ local chord = Chord:new()
+ local splitPitches = Silencio.split(typePitches)
+ chord:resize(#splitPitches)
+ for voice, pitchName in ipairs(splitPitches) do
+ local pitch = ChordSpace.pitchClassesForNames[pitchName]
+ chord[voice] = rootPitch + pitch
+ end
+ chord = chord:eOP()
+ ChordSpace.chordsForNames[chordName] = chord
+ ChordSpace.namesForChords[chord:__hash()] = chordName
+end
+
+for rootName, rootPitch in pairs(ChordSpace.pitchClassesForNames) do
+ fill(rootName, rootPitch, " minor second", "C C# ")
+ fill(rootName, rootPitch, " major second", "C D ")
+ fill(rootName, rootPitch, " minor third", "C Eb ")
+ fill(rootName, rootPitch, " major third", "C E ")
+ fill(rootName, rootPitch, " perfect fourth", "C F ")
+ fill(rootName, rootPitch, " tritone", "C F# ")
+ fill(rootName, rootPitch, " perfect fifth", "C G ")
+ fill(rootName, rootPitch, " augmented fifth", "C G# ")
+ fill(rootName, rootPitch, " sixth", "C A ")
+ fill(rootName, rootPitch, " minor seventh ", "C Bb ")
+ fill(rootName, rootPitch, " major seventh", "C B")
+ -- Scales.
+ fill(rootName, rootPitch, " major", "C D E F G A B")
+ fill(rootName, rootPitch, " minor", "C D Eb F G Ab Bb ")
+ fill(rootName, rootPitch, " natural minor", "C D Eb F G Ab Bb ")
+ fill(rootName, rootPitch, " harmonic minor", "C D Eb F G Ab B")
+ fill(rootName, rootPitch, " chromatic", "C C# D D# E F F# G G# A A# B")
+ fill(rootName, rootPitch, " whole tone", "C D E F# G# A# ")
+ fill(rootName, rootPitch, " diminished", "C D D# F F# G# A B")
+ fill(rootName, rootPitch, " pentatonic", "C D E G A ")
+ fill(rootName, rootPitch, " pentatonic major", "C D E G A ")
+ fill(rootName, rootPitch, " pentatonic minor", "C Eb F G Bb ")
+ fill(rootName, rootPitch, " augmented", "C Eb E G Ab Bb ")
+ fill(rootName, rootPitch, " Lydian dominant", "C D E Gb G A Bb ")
+ fill(rootName, rootPitch, " 3 semitone", "C D# F# A ")
+ fill(rootName, rootPitch, " 4 semitone", "C E G# ")
+ fill(rootName, rootPitch, " blues", "C D Eb F Gb G Bb ")
+ fill(rootName, rootPitch, " bebop", "C D E F G A Bb B")
+ -- Major chords.
+ fill(rootName, rootPitch, "M", "C E G ")
+ fill(rootName, rootPitch, "6", "C E G A ")
+ fill(rootName, rootPitch, "69", "C D E G A ")
+ fill(rootName, rootPitch, "69b5", "C D E Gb A ")
+ fill(rootName, rootPitch, "M7", "C E G B")
+ fill(rootName, rootPitch, "M9", "C D E G B")
+ fill(rootName, rootPitch, "M11", "C D E F G B")
+ fill(rootName, rootPitch, "M#11", "C D E F# G B")
+ fill(rootName, rootPitch, "M13", "C D E F G A B")
+ -- Minor chords.
+ fill(rootName, rootPitch, "m", "C Eb G ")
+ fill(rootName, rootPitch, "m6", "C Eb G A ")
+ fill(rootName, rootPitch, "m69", "C D Eb G A ")
+ fill(rootName, rootPitch, "m7", "C Eb G Bb ")
+ fill(rootName, rootPitch, "m#7", "C Eb G B")
+ fill(rootName, rootPitch, "m7b5", "C Eb Gb Bb ")
+ fill(rootName, rootPitch, "m9", "C D Eb G Bb ")
+ fill(rootName, rootPitch, "m9#7", "C D Eb G B")
+ fill(rootName, rootPitch, "m11", "C D Eb F G Bb ")
+ fill(rootName, rootPitch, "m13", "C D Eb F G A Bb ")
+ -- Augmented chords.
+ fill(rootName, rootPitch, "+", "C E G# ")
+ fill(rootName, rootPitch, "7#5", "C E G# Bb ")
+ fill(rootName, rootPitch, "7b9#5", "C Db E G# Bb ")
+ fill(rootName, rootPitch, "9#5", "C D E G# Bb ")
+ -- Diminished chords.
+ fill(rootName, rootPitch, "o", "C Eb Gb ")
+ fill(rootName, rootPitch, "o7", "C Eb Gb A ")
+ -- Suspended chords.
+ fill(rootName, rootPitch, "6sus", "C F G A ")
+ fill(rootName, rootPitch, "69sus", "C D F G A ")
+ fill(rootName, rootPitch, "7sus", "C F G Bb ")
+ fill(rootName, rootPitch, "9sus", "C D F G Bb ")
+ fill(rootName, rootPitch, "M7sus", "C F G B")
+ fill(rootName, rootPitch, "M9sus", "C D F G B")
+ -- Dominant chords.
+ fill(rootName, rootPitch, "7", "C E G Bb ")
+ fill(rootName, rootPitch, "7b5", "C E Gb Bb ")
+ fill(rootName, rootPitch, "7b9", "C Db E G Bb ")
+ fill(rootName, rootPitch, "7b9b5", "C Db E Gb Bb ")
+ fill(rootName, rootPitch, "9", "C D E G Bb ")
+ fill(rootName, rootPitch, "9#11", "C D E F# G Bb ")
+ fill(rootName, rootPitch, "13", "C D E F G A Bb ")
+ fill(rootName, rootPitch, "13#11", "C D E F# G A Bb ")
+end
+
+table.sort(ChordSpace.chordsForNames)
+table.sort(ChordSpace.namesForChords)
+
+-- Increment a chord voicewise through chord space,
+-- from a low point on the unison diagonal through a high point
+-- on the unison diagonal. g is the generator of transposition.
+-- It may be necessary to set the chord to the low point to start.
+
+function ChordSpace.next(odometer, low, high, g)
+ local voices = #odometer
+ odometer[voices] = odometer[voices] + g
+ -- "Carry."
+ for voice = voices, 2, -1 do
+ if odometer[voice] > high then
+ odometer[voice] = low
+ odometer[voice - 1] = odometer[voice - 1] + g
+ end
+ end
+ if odometer[1] > high then
+ return false
+ end
+ return true
+end
+
+function ChordSpace.allOfEquivalenceClass(voices, equivalence, g)
+ g = g or 1
+ local equivalenceMapper = nil
+ if equivalence == 'OP' then
+ equivalenceMapper = Chord.iseOP
+ end
+ if equivalence == 'OPT' then
+ equivalenceMapper = Chord.iseOPT
+ end
+ if equivalence == 'OPTT' then
+ equivalenceMapper = Chord.iseOPT
+ end
+ if equivalence == 'OPI' then
+ equivalenceMapper = Chord.iseOPI
+ end
+ if equivalence == 'OPTI' then
+ equivalenceMapper = Chord.iseOPTI
+ end
+ if equivalence == 'OPTTI' then
+ equivalenceMapper = Chord.iseOPTTI
+ end
+ local equivalentChords = {}
+ -- Enumerate all chords in [-O, O].
+ local iterator = ChordSpace.iterator(voices, -13)
+ -- print('iterator:', tostring(iterator))
+ while ChordSpace.next(iterator, -13, 13, g) == true do
+ if iterator:iseP() == true then
+ local eP = iterator:clone()
+ if equivalenceMapper(eP) then
+ ChordSpace.setInsert(equivalentChords, eP)
+ end
+ end
+ end
+ local equivalentChords = ChordSpace.sortedSet(equivalentChords)
+ local zeroBasedChords = ChordSpace.zeroBasedSet(equivalentChords)
+ return zeroBasedChords, equivalentChords
+end
+
+-- Returns a chord with the specified number of voices all set to a first
+-- pitch, useful as an iterator.
+
+function ChordSpace.iterator(voices, first)
+ local odometer = Chord:new()
+ odometer:resize(voices)
+ for voice = 1, voices do
+ odometer[voice] = first
+ end
+ return odometer
+end
+
+-- Returns a collection of all chords for the specified number of voices in a
+-- range, by default the octave. g is the generator of transposition, by default the
+-- semitone.
+
+function ChordSpace.allChordsInRange(voices, first, last, g)
+ first = first or 0
+ last = last or ChordSpace.OCTAVE
+ g = g or 1
+ -- Enumerate all chords in the range.
+ local chordset = {}
+ local iterator = ChordSpace.iterator(voices, first)
+ while ChordSpace.next(iterator, first, last, g) do
+ local chord = iterator:clone()
+ chordset[chord:__hash()] = chord
+ end
+ return ChordSpace.sortedSet(chordset)
+end
+
+-- Move 1 voice of the chord,
+-- optionally under range equivalence
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:move(voice, interval)
+ local chord = self:clone()
+ chord[voice] = T(chord[voice], interval)
+ return chord
+end
+
+-- Performs the neo-Riemannian Lettonwechsel transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrL()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[1] = cv[1] - 1
+ else
+ if cvt[2] == 3 then
+ cv[3] = cv[3] + 1
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian parallel transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrP()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[2] = cv[2] - 1
+ else
+ if cvt[2] == 3 then
+ cv[2] = cv[2] + 1
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian relative transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrR()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[3] = cv[3] + 2
+ else
+ if cvt[2] == 3 then
+ cv[1] = cv[1] - 2
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian dominant transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrD()
+ return self:eep():T(-7)
+end
+
+-- Returns the chord inverted by the sum of its first two voices.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:K(range)
+ range = range or ChordSpace.OCTAVE
+ local chord = self:clone()
+ if #chord < 2 then
+ return chord
+ end
+ local ep = chord:eP()
+ local x = ep[1] + ep[2]
+ return self:I(x)
+end
+
+-- Returns whether the chord is a transpositional form of Y with interval size g.
+-- Only works in equal temperament.
+
+function Chord:Tform(Y, g)
+ local eopx = self:epcs()
+ local i = 0
+ while i < ChordSpace.OCTAVE do
+ local ty = Y:T(i)
+ local eopty = ty:epcs()
+ if eopx == eopty then
+ return true
+ end
+ i = i + g
+ end
+ return false
+end
+
+-- Returns whether the chord is an inversional form of Y with interval size g.
+-- Only works in equal temperament.
+
+function Chord:Iform(Y, g)
+ local eopx = self:epcs()
+ local i = 0
+ while i < ChordSpace.OCTAVE do
+ local iy = Y:I(i)
+ local eopiy = iy:epcs()
+ if eopx == eopiy then
+ return true
+ end
+ i = i + g
+ end
+ return false
+end
+
+-- Returns the contextual transposition of the chord by x with respect to m
+-- with minimum interval size g.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:Q(x, m, g)
+ g = g or 1
+ if self:Tform(m, g) then
+ return self:T(x)
+ end
+ if self:Iform(m, g) then
+ return self:T(-x)
+ end
+ return self:clone()
+end
+
+-- Returns the voice-leading between chords a and b,
+-- i.e. what you have to add to a to get b, as a
+-- chord of directed intervals.
+
+function ChordSpace.voiceleading(a, b)
+ local voiceleading = a:clone()
+ for voice = 1, #voiceleading do
+ voiceleading[voice] = b[voice] - a[voice]
+ end
+ return voiceleading
+end
+
+-- Returns whether the voiceleading
+-- between chords a and b contains a parallel fifth.
+
+function ChordSpace.parallelFifth(a, b)
+ local v = ChordSpace.voiceleading(a, b)
+ if v:count(7) > 1 then
+ return true
+ else
+ return false
+ end
+end
+
+-- Returns the smoothness of the voiceleading between
+-- chords a and b by L1 norm.
+
+function ChordSpace.voiceleadingSmoothness(a, b)
+ local L1 = 0
+ for voice = 1, #a do
+ L1 = L1 + math.abs(b[voice] - a[voice])
+ end
+ return L1
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the smoother (shortest moves), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingSmoother(source, d1, d2, avoidParallels, range)
+ range = range or ChordSpace.OCTAVE
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local s1 = ChordSpace.voiceleadingSmoothness(source, d1)
+ local s2 = ChordSpace.voiceleadingSmoothness(source, d2)
+ if s1 <= s2 then
+ return d1
+ else
+ return d2
+ end
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the simpler (fewest moves), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingSimpler(source, d1, d2, avoidParallels)
+ avoidParallels = avoidParallels or false
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local v1 = ChordSpace.voiceleading(source, d1):eP()
+ local v2 = ChordSpace.voiceleading(source, d2):eP()
+ for voice = #v1, 1, -1 do
+ if v1[voice] < v2[voice] then
+ return d1
+ end
+ if v2[voice] < v1[voice] then
+ return d2
+ end
+ end
+ return d1
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the closer (first smoother, then simpler), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingCloser(source, d1, d2, avoidParallels)
+ avoidParallels = avoidParallels or false
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local s1 = ChordSpace.voiceleadingSmoothness(source, d1)
+ local s2 = ChordSpace.voiceleadingSmoothness(source, d2)
+ if s1 < s2 then
+ return d1
+ end
+ if s1 > s2 then
+ return d2
+ end
+ return ChordSpace.voiceleadingSimpler(source, d1, d2, avoidParallels)
+end
+
+-- Returns the voicing of the destination which has the closest voice-leading
+-- from the source within the range, optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingClosestRange(source, destination, range, avoidParallels)
+ local destinationeOP = destination:eOP()
+ local d = destinationeOP:clone()
+ local odometer = source:origin()
+ while ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE) == true do
+ local revoicing = odometer:clone()
+ for voice = 1, #revoicing do
+ revoicing[voice] = revoicing[voice] + destinationeOP[voice]
+ end
+ d = ChordSpace.voiceleadingCloser(source, d, revoicing, avoidParallels)
+ end
+ return d
+end
+
+-- Creates a complete Silencio "note on" event for the
+-- indicated voice of the chord. The other parameters are used
+-- if the internal duration, channel, velocity, and pan of the
+-- chord are nil.
+
+function Chord:note(voice_, time_, duration_, channel_, velocity_, pan_)
+ local note_ = Event:new()
+ note_[TIME] = time_
+ note_[DURATION] = duration_ or self.duration[voice_]
+ note_[CHANNEL] = channel_ or self.channel[voice_]
+ note_[KEY] = self[voice_]
+ note_[VELOCITY] = velocity_ or self.velocity[voice_]
+ note_[PAN] = pan_ or self.pan[voice_]
+ return note_
+end
+
+-- Returns an individual note for each voice of the chord.
+-- The chord's duration, instrument, and loudness are used if present,
+-- if not the specified values are used.
+
+function Chord:notes(time_, duration_, channel_, velocity_, pan_)
+ local notes_ = Score:new()
+ for voice, key in ipairs(self) do
+ table.insert(notes_, self:note(voice, time_, duration_, channel_, velocity_, pan_))
+ end
+ return notes_
+end
+
+function Chord:toScore(score, time_, duration_, channel_, velocity_, pan_)
+ for voice, key in ipairs(self) do
+ score:append(self:note(voice, time_, duration_, channel_, velocity_, pan_))
+ end
+ return score
+end
+
+-- If the event is a note, moves its pitch
+-- to the closest pitch of the chord.
+-- If octaveEquivalence is true (the default),
+-- the pitch-class of the note is moved to the closest pitch-class
+-- of the chord; otherwise, the pitch of the note is moved to the closest
+-- absolute pitch of the chord.
+
+function conformToChord(event, chord, octaveEquivalence)
+ octaveEquivalence = octaveEquivalence or true
+ if event[STATUS] ~= 144 then
+ return
+ else
+ local pitch = event[KEY]
+ if octaveEquivalence then
+ local pitchClass = pitch % ChordSpace.OCTAVE
+ local octave = pitch - pitchClass
+ local chordPitchClass = chord[1] % ChordSpace.OCTAVE
+ local distance = math.abs(chordPitchClass - pitchClass)
+ local closestPitchClass = chordPitchClass
+ local minimumDistance = distance
+ for voice = 2, #chord do
+ chordPitchClass = chord[voice] % ChordSpace.OCTAVE
+ distance = math.abs(chordPitchClass - pitchClass)
+ if distance < minimumDistance then
+ minimumDistance = distance
+ closestPitchClass = chordPitchClass
+ end
+ end
+ event[KEY] = octave + closestPitchClass
+ else
+ local chordPitch = chord[1]
+ local distance = math.abs(chordPitch - pitch)
+ local closestPitch = chordPitch
+ local minimumDistance = distance
+ for voice = 2, #chord do
+ chordPitch = chord[voice]
+ distance = math.abs(chordPitch - pitch)
+ if distance < minimumDistance then
+ minimumDistance = distance
+ closestPitch = chordPitch
+ end
+ end
+ event[KEY] = closestPitch
+ end
+ end
+end
+
+-- Inserts the notes of the chord into the score at the specified time.
+-- The internal duration, instrument, and loudness are used if present,
+-- if not the specified values are used.
+
+function ChordSpace.insert(score, chord, time_, duration, channel, velocity, pan)
+ -- print(score, chord, time_, duration, channel, velocity, pan)
+ for voice = 1, #chord do
+ local event = chord:note(voice, time_, duration, channel, velocity, pan)
+ table.insert(score, event)
+ end
+end
+
+-- For all the notes in the score
+-- beginning at or later than the start time,
+-- and up to but not including the end time,
+-- moves the pitch of the note to belong to the chord, using the
+-- conformToChord function.
+
+function ChordSpace.apply(score, chord, start, end_, octaveEquivalence)
+ octaveEquivalence = octaveEquivalence or true
+ local slice = score:slice(start, end_)
+ for index, event in ipairs(slice) do
+ conformToChord(event, chord, octaveEquivalence)
+ end
+end
+
+-- Returns a chord containing all the pitches of the score
+-- beginning at or later than the start time,
+-- and up to but not including the end time.
+
+function gather(score, start, end_)
+ local chord = Chord:new()
+ local slice = score:slice(start, end_)
+ for index, event in ipairs(slice) do
+ local pitch = event[KEY]
+ if not chord:contains(pitch) then
+ table.insert(chord, pitch)
+ end
+ end
+ return chord
+end
+
+-- Orthogonal additive groups for unordered chords of given arity under range
+-- equivalence (RP): prime form or P, inversion or I, transposition or T, and
+-- voicing or V. P x I x T = OP, P x I x T x V = RP. Therefore, an
+-- operation on P, I, T, or V may be used to independently transform the
+-- respective symmetry of any chord. Some of these operations will reflect
+-- in RP.
+
+ChordSpaceGroup = {}
+
+-- N is the number of voices in the chord space, g is the generator of
+-- transposition, range is the size of chord space,
+-- optis is an ordered table of all OPTI chords for g,
+-- voicings is an ordered table of all octavewise permutations in RP.
+
+function ChordSpaceGroup:new(o)
+ local o = o or {optisForIndexes = {}, indexesForOptis = {}, voicingsForIndexes = {}, indexesForVoicings = {}}
+ setmetatable(o, self)
+ self.__index = self
+ return o
+end
+
+function ChordSpace.octavewiseRevoicings(chord, range)
+ range = range or ChordSpace.OCTAVE
+ local voices = #chord
+ local odometer = chord:origin()
+ -- Enumerate the permutations.
+ -- iterator[1] is the most significant voice, and
+ -- iterator[N] is the least significant voice.
+ local voicings = 0
+ while ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE) == true do
+ voicings = voicings + 1
+ end
+ return voicings
+end
+
+function ChordSpace.octavewiseRevoicing(chord, index, range)
+ local voices = #chord
+ local odometer = chord:origin()
+ local eop = chord:eOP()
+ -- Enumerate the permutations.
+ -- iterator[1] is the most significant voice, and
+ -- iterator[N] is the least significant voice.
+ local voicings = 0
+ for v = 1, index do
+ ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE)
+ -- Wrap around?
+ if odometer[1] > range then
+ odometer = chord:origin()
+ end
+ voicings = voicings + 1
+ end
+ for voice = 1, #chord do
+ odometer[voice] = odometer[voice] + eop[voice]
+ end
+ return odometer
+end
+
+-- Returns the ith arpeggiation, current voice, and corresponding revoicing
+-- of the chord. Positive arpeggiations start with the lowest voice of the
+-- chord and revoice up; negative arpeggiations start with the highest voice
+-- of the chord and revoice down.
+
+function Chord:a(arpeggiation)
+ local chord = self:v(arpeggiation)
+ if arpeggiation < 0 then
+ return chord[#chord], #chord, chord
+ end
+ return chord[1], 1, chord
+end
+
+function ChordSpaceGroup:initialize(voices, range, g)
+ self.voices = voices or 3
+ self.range = range or 60
+ self.g = g or 1
+ self.countP = 0
+ self.countI = 2
+ self.countT = ChordSpace.OCTAVE / self.g
+ local chord = Chord:new()
+ chord:resize(voices)
+ self.countV = ChordSpace.octavewiseRevoicings(chord, self.range)
+ self.indexesForOptis = {}
+ self.optisForIndexes = ChordSpace.allOfEquivalenceClass(voices, 'OPTTI')
+ for index, optti in pairs(self.optisForIndexes) do
+ self.indexesForOptis[optti:__hash()] = index
+ self.countP = self.countP + 1
+ end
+ self:list()
+end
+
+function ChordSpace.createFilename(voices, range, g, extension)
+ extension = extension or '.lua'
+ local gstring = string.format('g%.6f', g)
+ gstring = string.gsub(gstring, '%.', '_')
+ local filename = string.format('ChordSpaceGroup_V%d_R%d_%s%s', voices, range, gstring, extension)
+ return filename
+end
+
+-- Loads the group if found, creates and saves it otherwise.
+
+function ChordSpace.createChordSpaceGroup(voices, range, g)
+ local filename = ChordSpace.createFilename(voices, range, 1)
+ local file, message, error = io.open(filename, 'r')
+ if file == nil then
+ print(string.format('File "%s" not found, creating...', filename))
+ chordSpaceGroup = ChordSpaceGroup:new()
+ chordSpaceGroup:initialize(voices, range, g)
+ chordSpaceGroup:save()
+ return chordSpaceGroup
+ else
+ print(string.format('Loading ChordSpaceGroup from file "%s"...', filename))
+ return ChordSpace.load(voices, range, g)
+ end
+end
+
+function ChordSpace.load(voices, range, g)
+ local filename = ChordSpace.createFilename(voices, range, 1)
+ print('Loading:', filename)
+ local deserialized = ChordSpaceGroup.load(filename)
+ return deserialized
+end
+
+function ChordSpaceGroup:save(filename)
+ filename = filename or ChordSpace.createFilename(self.voices, self.range, self.g, '.lua')
+ local text = serialize(self)
+ local writer = io.open(filename, 'w+')
+ writer:write(text)
+ writer:close()
+end
+
+function ChordSpaceGroup.load(filename)
+ local reader = io.open(filename)
+ local text = reader:read("*all")
+ -- What's deserialized is a function, which needs to be called.
+ local object = loadstring(text)()
+ -- Fix up metatable.
+ local chordSpaceGroup = ChordSpaceGroup:new(object)
+ -- Fix up metatables of chords too.
+ for index, opti in pairs(chordSpaceGroup.optisForIndexes) do
+ chordSpaceGroup.optisForIndexes[index] = Chord:new(opti)
+ end
+ return chordSpaceGroup
+end
+
+-- Returns the chord for the indices of prime form, inversion,
+-- transposition, and voicing. The chord is not in RP; rather, each voice of
+-- the chord's OP may have zero or more octaves added to it.
+
+function ChordSpaceGroup:toChord(P, I, T, V, printme)
+ printme = printme or false
+ P = P % self.countP
+ I = I % 2
+ T = T % ChordSpace.OCTAVE
+ V = V % self.countV
+ if printme then
+ print('toChord: ', P, I, T, V)
+ end
+ local optti = self.optisForIndexes[P]
+ if printme then
+ print('toChord: optti: ', optti, optti:__hash())
+ end
+ local optt = nil
+ if I == 0 then
+ optt = optti
+ else
+ optt = optti:I():eOPTT()
+ end
+ if printme then
+ print('toChord: optt: ', optt)
+ end
+ local optt_t = optt:T(T)
+ if printme then
+ print('toChord: optt_t: ', optt_t)
+ end
+ local op = optt_t:eOP()
+ if printme then
+ print('toChord: op: ', op)
+ end
+ V = V % self.countV
+ local revoicing = ChordSpace.octavewiseRevoicing(op, V, self.range)
+ if printme then
+ print('toChord: revoicing:', revoicing)
+ end
+ return revoicing, opti, op
+end
+
+-- Returns the indices of prime form, inversion, transposition,
+-- and voicing for a chord.
+
+function ChordSpaceGroup:fromChord(chord, printme)
+ printme = printme or false
+ if printme then
+ print('fromChord: chord: ', chord, chord:iseOP())
+ end
+ local op = nil
+ if chord:iseOP() then
+ op = chord:clone()
+ else
+ op = chord:eOP()
+ end
+ if printme then
+ print('fromChord: op: ', op)
+ end
+ local optt = chord:eOPTT()
+ if printme then
+ print('fromChord: optt: ', optt)
+ end
+ local T = 0
+ for t = 0, ChordSpace.OCTAVE - 1, self.g do
+ local optt_t = optt:T(t):eOP()
+ if printme then
+ print('fromChord: optt_t: ', optt_t, t)
+ end
+ if optt_t:__eq_epsilon(op) == true then
+ if printme then
+ print('equals')
+ end
+ T = t
+ break
+ end
+ end
+ local optti = chord:eOPTTI()
+ if printme then
+ print('fromChord: optti: ', optti, optti:__hash())
+ end
+ local P = self.indexesForOptis[optti:__hash()]
+ local I = 0
+ if optti ~= optt then
+ I = 1
+ local optt_i_optt = optt:I():eOPTT()
+ if optt_i_optt ~= optti then
+ print("Error: OPTT(I(OPTT)) must equal OPTTI.")
+ print('optt_i_optt:', optt_i_optt:information())
+ print('optti: ', optti:information())
+ os.exit()
+ end
+ end
+ local voicing = ChordSpace.voiceleading(op, chord)
+ V = self.indexesForVoicings[voicing:__hash()]
+ if printme then
+ print('fromChord: voicing: ', voicing, V)
+ print('fromChord: ', P, I, T, V)
+ end
+ return P, I, T, V
+end
+
+function ChordSpaceGroup:list(listheader, listopttis, listvoicings)
+ listheader = listheader or true
+ listopttis = listopttis or false
+ listvoicings = listvoicings or false
+ if listheader then
+ print(string.format('ChordSpaceGroup.voices: %8d', self.voices))
+ print(string.format('ChordSpaceGroup.range : %8d', self.range))
+ print(string.format('ChordSpaceGroup.g : %13.4f', self.g))
+ print(string.format('ChordSpaceGroup.countP: %8d', self.countP))
+ print(string.format('ChordSpaceGroup.countI: %8d', self.countI))
+ print(string.format('ChordSpaceGroup.countT: %8d', self.countT))
+ print(string.format('ChordSpaceGroup.countV: %8d', self.countV))
+ end
+ if listopttis then
+ for index, opti in pairs(self.optisForIndexes) do
+ print(string.format('index: %5d opti: %s index from opti: %s', index, tostring(opti), self.indexesForOptis[opti:__hash()]))
+ end
+ for index = 0, #self.optisForIndexes - 1 do
+ print(string.format('opti from index: %s index: %5d', tostring(self.optisForIndexes[index]), index))
+ end
+ end
+ if listvoicings then
+ for index, voicing in pairs(self.voicingsForIndexes) do
+ print(string.format('voicing index: %5d voicing: %s index from voicing: %5d', index, tostring(voicing), self.indexesForVoicings[voicing:__hash()]))
+ end
+ end
+end
+
+function ChordSpaceGroup:printChords()
+ for index, opti in pairs(self.optisForIndexes) do
+ print(string.format('index: %5d opti: %s %s', index, tostring(opti), opti:name()))
+ end
+end
+
+function ChordSpaceGroup:printNamedChords()
+ for index, opti in pairs(self.optisForIndexes) do
+ local name = opti:name()
+ if name ~= '' then
+ print(string.format('index: %5d opti: %s %s', index, tostring(opti), opti:name()))
+ end
+ end
+end
+
+return ChordSpace
diff --git a/frontends/CsoundAC/ChordSpace.hpp b/frontends/CsoundAC/ChordSpace.hpp
new file mode 100644
index 0000000..79836a0
--- /dev/null
+++ b/frontends/CsoundAC/ChordSpace.hpp
@@ -0,0 +1,2373 @@
+/*
+ * C S O U N D
+ *
+ * L I C E N S E
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCORE_H
+#define SCORE_H
+#include "Platform.hpp"
+#ifdef SWIG
+%module CsoundAC
+% {
+#include <eigen3/Eigen/Dense>
+#include "Event.hpp"
+#include <iostream>
+#include <sstream>
+#include <vector>
+ %
+}
+%include "std_string.i"
+%include "std_vector.i"
+#else
+#include <eigen3/Eigen/Dense>
+#include "Event.hpp"
+#include <iostream>
+#include <sstream>
+#include <vector>
+#endif
+
+namespace csound {
+/**
+This class, part of CsoundAC, implements a geometric approach to some common
+operations on chords in neo-Riemannian music theory for use in score
+generating procedures:
+
+-- Identifying whether a chord belongs to some equivalence class of music
+ theory, or sending a chord to its equivalent within a representative
+ fundamental domain of some equivalence class. The equivalence classes are
+ octave (O), permutational (P), transpositional, (T), inversional (I), and
+ their compounds OP, OPT (set-class or chord type), and OPTI (prime form).
+
+-- Causing chord progressions to move strictly within an orbifold that
+ generates some equivalence class.
+
+-- Implementing chord progressions based on the L, P, R, D, K, and Q
+ operations of neo-Riemannian theory (thus implementing some aspects of
+ "harmony").
+
+-- Implementing chord progressions performed within a more abstract
+ equivalence class by means of the best-formed voice-leading within a less
+ abstract equivalence class (thus implementing some fundamentals of
+ "counterpoint").
+
+The associated ChordSpaceView package can display these chord spaces and
+operations for trichords in an interactive 3-dimensional view.
+
+DEFINITIONS
+
+Pitch is the perception of a distinct sound frequency. It is a logarithmic
+perception; octaves, which sound 'equivalent' in some sense, represent
+doublings or halvings of frequency.
+
+Pitches and intervals are represented as real numbers. Middle C is 60 and the
+octave is 12. Our usual system of 12-tone equal temperament, as well as MIDI
+key numbers, are completely represented by the whole numbers; any and all
+other pitches can be represented simply by using fractions.
+
+A voice is a distinct sound that is heard as having a pitch.
+
+A chord is simply a set of voices heard at the same time, represented here
+as a point in a chord space having one dimension of pitch for each voice
+in the chord.
+
+For the purposes of algorithmic composition in CsoundAC, a score is considered
+as a sequence of more or less fleeting chords.
+
+EQUIVALENCE CLASSES
+
+An equivalence class identifies elements of a set. Operations that send one
+equivalent point to another induce quotient spaces or orbifolds, where the
+equivalence operation identifies points on one face of the orbifold with
+points on an opposing face. The fundamental domain of the equivalence class
+is the space "within" the orbifold.
+
+Plain chord space has no equivalence classes. Ordered chords are represented
+as vectors in parentheses (p1, ..., pN). Unordered chords are represented as
+sorted vectors in braces {p1, ..., pN}. Unordering is itself an equivalence
+class.
+
+The following equivalence classes apply to pitches and chords, and exist in
+different orbifolds. Equivalence classes can be combined (Callendar, Quinn,
+and Tymoczko, "Generalized Voice-Leading Spaces," _Science_ 320, 2008), and
+the more equivalence classes are combined, the more abstract is the resulting
+orbifold compared to the parent space.
+
+In most cases, a chord space can be divided into a number, possibly
+infinite, of geometrically equivalent fundamental domains for the same
+equivalence class. Therefore, here we use the notion of 'representative'
+fundamental domain. For example, the representative fundamental domain of
+unordered sequences, out of all possible orderings, consists of all sequences
+in their ordinary sorted order. It is important, in the following, to identify
+representative fundamental domains that combine properly, e.g. such that the
+representative fundamental domain of OP / the representative fundamental
+domain of PI equals the representative fundamental domain of OPI. And this in
+turn may require accounting for duplicate elements of the representative
+fundamental domain caused by reflections or singularities in the orbifold.
+
+C Cardinality equivalence, e.g. {1, 1, 2} == {1, 2}. _Not_ assuming
+ cardinality equivalence ensures that there is a proto-metric in plain
+ chord space that is inherited by all child chord spaces. Cardinality
+ equivalence is never assumed here, because we are working in chord
+ spaces of fixed dimensionality; e.g. we represent the note middle C
+ not as {60}, but as {60, 60, ..., 60}.
+
+O Octave equivalence. The fundamental domain is defined by the pitches
+ in a chord spanning the range of an octave or less, and summing to
+ an octave or less.
+
+P Permutational equivalence. The fundamental domain is defined by a
+ "wedge" of plain chord space in which the voices of a chord are always
+ sorted by pitch.
+
+T Transpositional equivalence, e.g. {1, 2} == {7, 8}. The fundamental
+ domain is defined as a plane in chord space at right angles to the
+ diagonal of unison chords. Represented by the chord always having a
+ sum of pitches equal to 0.
+
+I Inversional equivalence. Care is needed to distinguish the
+ mathematician's sense of 'invert', which means 'pitch-space inversion'
+ or 'reflect in a point', from the musician's sense of 'invert', which
+ varies according to context but in practice often means 'registral
+ inversion' or 'revoice by adding an octave to the lowest tone of a
+ chord.' Here, we use 'invert' and 'inversion' in the mathematician's
+ sense, and we use the terms 'revoice' and 'voicing' for the musician's
+ 'invert' and 'inversion'. The inversion point for any inversion lies
+ on the unison diagonal. A fundamental domain is defined as any half of
+ chord space that is bounded by a plane containing the inversion point.
+ Represented as the chord having the first interval between voices be
+ smaller than or equal to the final interval (recursing for chords of
+ more than 3 voices).
+
+PI Inversional equivalence with permutational equivalence. The
+ 'inversion flat' of unordered chord space is a hyperplane consisting
+ of all those unordered chords that are invariant under inversion. A
+ fundamental domain is defined by any half space bounded by a
+ hyperplane containing the inversion flat. It is represented as that
+ half of the space on or lower than the hyperplane defined by the
+ inversion flat and the unison diagonal.
+
+OP Octave equivalence with permutational equivalence. Tymoczko's orbifold
+ for chords; i.e. chords with a fixed number of voices in a harmonic
+ context. The fundamental domain is defined as a hyperprism one octave
+ long with as many sides as voices and the ends identified by octave
+ equivalence and one cyclical permutation of voices, modulo the
+ unordering. In OP for trichords in 12TET, the augmented triads run up
+ the middle of the prism, the major and minor triads are in 6
+ alternating columns around the augmented triads, the two-pitch chords
+ form the 3 sides, and the one-pitch chords form the 3 edges that join
+ the sides.
+
+OPT The layer of the OP prism as close as possible to the origin, modulo
+ the number of voices. Chord type. Note that CM and Cm are different
+ OPT. Because the OP prism is canted down from the origin, at least one
+ pitch in each OPT chord (excepting the origin itself) is negative.
+
+OPI The OP prism modulo inversion, i.e. 1/2 of the OP prism. The
+ representative fundamental consits of those chords less than or equal
+ to their inversions modulo OP.
+
+OPTI The OPT layer modulo inversion, i.e. 1/2 of the OPT layer.
+ Set-class. Note that CM and Cm are the same OPTI.
+
+OPERATIONS
+
+Each of the above equivalence classes is, of course, an operation that sends
+chords outside the fundamental domain to chords inside the fundamental domain.
+And we define the following additional operations:
+
+T(p, x) Translate p by x.
+
+I(p [, x]) Reflect p in x, by default the origin.
+
+P Send a major triad to the minor triad with the same root,
+ or vice versa (Riemann's parallel transformation).
+
+L Send a major triad to the minor triad one major third higher,
+ or vice versa (Riemann's Leittonwechsel or leading-tone
+ exchange transformation).
+
+R Send a major triad to the minor triad one minor third lower,
+ or vice versa (Riemann's relative transformation).
+
+D Send a triad to the next triad a perfect fifth lower
+ (dominant transformation).
+
+P, L, and R have been extended as follows, see Fiore and Satyendra,
+"Generalized Contextual Groups", _Music Theory Online_ 11, August 2008:
+
+K(c) Interchange by inversion;
+ K(c) := I(c, c[1] + c[2]).
+ This is a generalized form of P; for major and minor triads,
+ it is exactly the same as P, but it also works with other
+ chord types.
+
+Q(c, n, m) Contexual transposition;
+ Q(c, n, m) := T(c, n) if c is a T-form of m,
+ or T(c, -n) if c is an I-form of M. Not a generalized form
+ of L or R; but, like them, K and Q generate the T-I group.
+ */
+
+/**
+ * Returns n!
+ */
+double factorial(double n) {
+ if (n == 0) {
+ return 1;
+ } else {
+ return n * factorial(n = 1.0);
+ }
+}
+
+double EPSILON() {
+ static double epsilon = 1.0;
+ if (epsilon == 1.0) {
+ for (;;) {
+ epsilon = epsilon / 2.0;
+ double nextEpsilon = epsilon / 2.0;
+ double onePlusNextEpsilon = 1.0 + nextEpsilon;
+ if (onePlusNextEpsilon == 1.0) {
+ break;
+ }
+ }
+ }
+ return epsilon;
+}
+
+double &epsilonFactor() {
+ static double epsilonFactor = 1.0;
+ return epsilonFactor;
+}
+
+bool eq_epsilon(double a, double b) {
+ if (std::abs(a - b) < (EPSILON() * epsilonFactor())) {
+ return true;
+ } else {
+ return false;
+ }
+
+}
+
+double gt_epsilon(double a, double b) {
+ if (eq_epsilon(a, b)) {
+ return false;
+ } else {
+ return (a > b);
+ }
+}
+
+double lt_epsilon(double a, double b) {
+ if (eq_epsilon(a, b)) {
+ return false;
+ } else {
+ return (a < b);
+ }
+}
+
+double ge_epsilon(double a, double b) {
+ if (eq_epsilon(a, b)) {
+ return true;
+ } else {
+ return (a > b);
+ }
+}
+
+double le_epsilon(double a, double b) {
+ if (eq_epsilon(a, b)) {
+ return true;
+ } else {
+ return (a < b);
+ }
+}
+
+/**
+ * The size of the octave, defined to be consistent with
+ * 12 tone equal temperament and MIDI.
+ */
+double OCTAVE() {
+ return 12.0;
+}
+
+double MIDDLE_C() {
+ return 60.0;
+}
+
+double C4() {
+ return MIDDLE_C();
+}
+
+/**
+ * Returns the pitch transposed by semitones, which may be any scalar.
+ * NOTE: Does NOT return the result under any equivalence class.
+ */
+double T(double pitch, double semitones) {
+ return pitch + semitones;
+}
+
+/**
+ * Returns the pitch reflected in the center, which may be any pitch.
+ * NOTE: Does NOT return the result under any equivalence class.
+ */
+double I(double pitch, double center = 0.0) {
+ return center - pitch;
+}
+
+/**
+ * Chords represent simultaneously sounding pitches. The pitches are
+ * represented as semitones with 0 at the origin and middle C as 60.
+ * Each voice also has a duration, velocity, channel, and pan.
+ */
+class SILENCE_PUBLIC Chord : public Eigen::MatrixXd {
+public:
+ enum {
+ PITCH = 0,
+ DURATION = 1,
+ LOUDNESS = 2,
+ INSTRUMENT = 3,
+ PAN = 4,
+ COUNT = 5
+ };
+ Chord() {
+ resize(3);
+ }
+ virtual ~Chord() {
+ }
+ virtual size_t voices() const {
+ return rows();
+ }
+ virtual void resize(size_t voices) {
+ Eigen::MatrixXd::resize(voices, COUNT);
+ }
+ /**
+ * Returns a string representation of the chord.
+ * Quadratic complexity, but short enough not to matter.
+ */
+ virtual std::string toString() const {
+ char buffer[0x100];
+ std::stringstream stream;
+ for (size_t i = 0, n = rows(); i < n; ++i) {
+ std::snprintf(buffer, 0x100, "%12.7f", getPitch(i));
+ if (i > 0) {
+ stream << " ";
+ }
+ stream << buffer;
+ }
+ return stream.str();
+ }
+ virtual double getPitch(int voice) const {
+ return coeff(voice, PITCH);
+ }
+ virtual void setPitch(double value, int voice) {
+ coeffRef(voice, PITCH) = value;
+ }
+ virtual double getDuration(int voice = 0) const {
+ return coeff(voice, DURATION);
+ }
+ virtual void setDuration(double value, int voice = -1) {
+ if (voice == -1) {
+ for (voice = 0; voice < rows(); ++voice) {
+ coeffRef(voice, DURATION) = value;
+ }
+ } else {
+ coeffRef(voice, DURATION) = value;
+ }
+ }
+ virtual double getLoudness(int voice = 0) const {
+ return coeff(voice, LOUDNESS);
+ }
+ virtual void setLoudness(double value, int voice = -1) {
+ if (voice == -1) {
+ for (voice = 0; voice < rows(); ++voice) {
+ coeffRef(voice, LOUDNESS) = value;
+ }
+ } else {
+ coeffRef(voice, LOUDNESS) = value;
+ }
+ }
+ virtual double getInstrument(int voice = 0) const {
+ return coeff(voice, INSTRUMENT);
+ }
+ virtual void setInstrument(double value, int voice = -1) {
+ if (voice == -1) {
+ for (voice = 0; voice < rows(); ++voice) {
+ coeffRef(voice, INSTRUMENT) = value;
+ }
+ } else {
+ coeffRef(voice, INSTRUMENT) = value;
+ }
+ }
+ virtual double getPan(int voice = 0) const {
+ return coeff(voice, PAN);
+ }
+ virtual void setPan(double value, int voice = -1) {
+ if (voice == -1) {
+ for (voice = 0; voice < rows(); ++voice) {
+ coeffRef(voice, PAN) = value;
+ }
+ } else {
+ coeffRef(voice, PAN) = value;
+ }
+ }
+ virtual size_t count(double pitch) const {
+ size_t n = 0;
+ for (size_t voice = 0; voice < voices(); ++voice) {
+ if (eq_epsilon(getPitch(voice), pitch)) {
+ n++;
+ }
+ }
+ return n;
+ }
+ virtual bool operator == (const Chord &other) {
+ if (rows() != other.voices()) {
+ return false;
+ }
+ for (size_t voice = 0; voice < rows(); ++voice) {
+ if (!eq_epsilon(getPitch(voice), other.getPitch(voice))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ virtual bool operator < (const Chord &other) {
+ if (rows() != other.voices()) {
+ return false;
+ }
+ for (size_t voice = 0; voice < rows(); ++voice) {
+ if (!lt_epsilon(getPitch(voice), other.getPitch(voice))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+};
+
+/**
+ * Returns the Euclidean distance between chords a and b,
+ * which must have the same number of voices.
+ */
+double euclidean(const Chord &a, const Chord &b) {
+ double sumOfSquaredDifferences = 0.0;
+ for (size_t voice = 0, voices = a.voices(); voice < voices; ++voice) {
+ sumOfSquaredDifferences += std::pow((a.getPitch(voice) - b.getPitch(voice)), 2.0);
+ }
+ return std::sqrt(sumOfSquaredDifferences);
+}
+
+}
+#endif
+/*
+
+
+function Chord:__le(other)
+ if self:__eq(other) then
+ return true
+ end
+ return self:__lt(other)
+end
+
+-- Returns whether or not the chord contains the pitch.
+
+function Chord:contains(pitch)
+ for voice, pitch_ in ipairs(self) do
+ if pitch_ == pitch then
+ return true
+ end
+ end
+ return false
+end
+
+-- Returns the lowest pitch in the chord,
+-- and also its voice index.
+
+function Chord:min()
+ local lowestVoice = 1
+ local lowestPitch = self[lowestVoice]
+ for voice = 2, #self do
+ if self[voice] < lowestPitch then
+ lowestPitch = self[voice]
+ lowestVoice = voice
+ end
+ end
+ return lowestPitch, lowestVoice
+end
+
+-- Returns the minimum interval in the chord.
+
+function Chord:minimumInterval()
+ local minimumInterval = math.abs(self[1] - self[2])
+ for v1 = 1, #self do
+ for v2 = 1, #self do
+ if t (v1 == v2) then
+ local interval = math.abs(self[v1] - self[v2])
+ if interval < minimumInterval then
+ minimumInterval = interval
+ end
+ end
+ end
+ end
+ return minimumInterval
+end
+
+-- Returns the highest pitch in the chord,
+-- and also its voice index.
+
+function Chord:max()
+ local highestVoice = 1
+ local highestPitch = self[highestVoice]
+ for voice = 2, #self do
+ if self[voice] > highestPitch then
+ highestPitch = self[voice]
+ highestVoice = voice
+ end
+ end
+ return highestPitch, highestVoice
+end
+
+-- Returns the maximum interval in the chord.
+
+function Chord:maximumInterval()
+ return self:max() - self:min()
+end
+
+-- Returns a new chord whose pitches are the floors of this chord's pitches.
+
+function Chord:floor()
+ local chord = self:clone()
+ for voice = 1, #self do
+ chord[voice] = math.floor(self[voice])
+ end
+ return chord
+end
+
+-- Returns a new chord whose pitches are the ceilings of this chord's pitches.
+
+function Chord:ceil()
+ local chord = self:clone()
+ for voice = 1, #self do
+ chord[voice] = math.ceil(self[voice])
+ end
+ return chord
+end
+
+-- Returns a value copy of the chord.
+
+function Chord:clone()
+ local clone_ = Chord:new()
+ for voice, pitch in ipairs(self) do
+ clone_[voice] = pitch
+ end
+ for voice, value in ipairs(self.duration) do
+ clone_.duration[voice] = value
+ end
+ for voice, value in ipairs(self.channel) do
+ clone_.channel[voice] = value
+ end
+ for voice, value in ipairs(self.velocity) do
+ clone_.velocity[voice] = value
+ end
+ for voice, value in ipairs(self.pan) do
+ clone_.pan[voice] = value
+ end
+ return clone_
+end
+
+-- Returns the origin of the chord's space.
+
+function Chord:origin()
+ local clone_ = self:clone()
+ for voice = 1, #clone_ do
+ clone_[voice] = 0
+ end
+ return clone_
+end
+
+function Chord:distanceToOrigin()
+ local origin = self:origin()
+ return ChordSpace.euclidean(self, origin)
+end
+
+function Chord:distanceToUnisonDiagonal()
+ local unison = self:origin()
+ local pitch = self:layer() / #self
+ for voice = 1, #self do
+ unison[voice] = pitch
+ end
+ return ChordSpace.euclidean(self, unison)
+end
+
+-- Returns the maximally even chord in the chord's space,
+-- e.g. the augmented triad for 3 dimensions.
+
+function Chord:maximallyEven()
+ local clone_ = self:clone()
+ local g = ChordSpace.OCTAVE / #clone_
+ for i = 1, #clone_ do
+ clone_[i] = (i - 1) * g
+ end
+ return clone_
+end
+
+-- Returns the sum of the pitches in the chord.
+
+function Chord:layer()
+ local s = 0
+ for voice, pitch in ipairs(self) do
+ s = s + pitch
+ end
+ return s
+end
+
+-- Transposes the chord by the indicated interval (may be a fraction).
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:T(interval)
+ local clone_ = self:clone()
+ for voice = 1, #clone_ do
+ clone_[voice] = T(clone_[voice], interval)
+ end
+ return clone_
+end
+
+-- Inverts the chord by another chord that is on the unison diagonal, by
+-- default the origin. NOTE: Does NOT return the result under any equivalence
+-- class.
+
+function Chord:I(center)
+ center = center or 0
+ local inverse = self:clone()
+ for voice = 1, #inverse do
+ inverse[voice] = I(self[voice], center)
+ end
+ return inverse
+end
+
+-- Returns the equivalent of the pitch under pitch-class equivalence, i.e.
+-- the pitch is in the interval [0, OCTAVE).
+
+function ChordSpace.epc(pitch)
+ --while pitch < 0 do
+ while ChordSpace.lt_epsilon(pitch, 0) do
+ pitch = pitch + ChordSpace.OCTAVE
+ end
+ --while pitch >= ChordSpace.OCTAVE do
+ while ChordSpace.ge_epsilon(pitch, ChordSpace.OCTAVE) do
+ pitch = pitch - ChordSpace.OCTAVE
+ end
+ return pitch
+end
+
+-- Returns whether the chord is within the fundamental domain of
+-- pitch-class equivalence, i.e. is a pitch-class set.
+
+function Chord:isepcs()
+ for voice = 1, #chord do
+ --if not (self[voice] == ChordSpace.epc(chord[voice])) then
+ if not ChordSpace.eq_epsilon(self[voice], ChordSpace.epc(chord[voice])) then
+ return false
+ end
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord under pitch-class equivalence,
+-- i.e. the pitch-class set of the chord.
+
+function Chord:epcs()
+ local chord = self:clone()
+ for voice = 1, #chord do
+ chord[voice] = ChordSpace.epc(chord[voice])
+ end
+ return chord
+end
+
+-- Returns whether the chord is within the fundamental domain of
+-- transposition to 0.
+
+function Chord:iset()
+ local et = self:et()
+ if not (et == self) then
+ return false
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the fundamental domain of
+-- transposition to 0.
+
+function Chord:et()
+ local min_ = self:min()
+ return self:T(-min_)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of the indicated range equivalence.
+
+function Chord:iseR(range)
+ --[[ GVLS:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not (max_ <= (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not ((0 <= layer_) and (layer_ <= range)) then
+ return false
+ end
+ return true
+ --]]
+ --[[ GVLS modified:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not ChordSpace.le_epsilon(max_, (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not (ChordSpace.le_epsilon(0, layer_) and ChordSpace.le_epsilon(layer_, range)) then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG several equivalents of boundary points in domain:
+ local max_ = self:max()
+ local min_ = self:min()
+ if not ChordSpace.le_epsilon(max_, (min_ + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not (ChordSpace.le_epsilon(0, layer_) and ChordSpace.le_epsilon(layer_, range)) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave equivalence.
+
+function Chord:iseO()
+ return self:iseR(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of a range equivalence.
+
+function Chord:eR(range)
+ local chord = self:clone()
+ --if chord:iseR(range) then
+ -- return chord
+ --end
+ -- The clue here is that at least one voice must be >= 0,
+ -- but no voice can be > range.
+ -- First, move all pitches inside the interval [0, OCTAVE),
+ -- which is not the same as the fundamental domain.
+ chord = self:epcs()
+ -- Then, reflect voices that are outside of the fundamental domain
+ -- back into it, which will revoice the chord, i.e.
+ -- the sum of pitches is in [0, OCTAVE].
+ --while chord:layer() > range do
+ while ChordSpace.gt_epsilon(chord:layer(), range) do
+ local maximumPitch, maximumVoice = chord:max()
+ -- Because no voice is above the range,
+ -- any voices that need to be revoiced will now be negative.
+ chord[maximumVoice] = maximumPitch - ChordSpace.OCTAVE
+ end
+ return chord
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave equivalence.
+
+function Chord:eO()
+ return self:eR(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of permutational equivalence.
+
+function Chord:iseP()
+ for voice = 2, #self do
+ --if not (self[voice - 1] <= self[voice]) then
+ if not ChordSpace.le_epsilon(self[voice - 1], self[voice]) then
+ return false
+ end
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of permutational equivalence.
+
+function Chord:eP()
+ clone_ = self:clone()
+ table.sort(clone_)
+ return clone_
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of transpositional equivalence.
+
+function Chord:iseT()
+ ----[[ GVLS:
+ local layer_ = self:layer()
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ return true
+ --]]
+ --[[ MKG:
+ g = g or 1
+ local ep = self:eP()
+ if not (ep == ep:eT(g):eP()) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of transpositonal equivalence.
+
+function Chord:eT()
+ ----[[ GVLS:
+ local layer_ = self:layer()
+ local sumPerVoice = layer_ / #self
+ return self:T(-sumPerVoice)
+ --]]
+ --[[ MKG:
+ g = g or 1
+ local iterator = self
+ -- Transpose down to layer 0 or just below.
+ while iterator:layer() > 0 do
+ iterator = iterator:T(-g)
+ end
+ -- Transpose up to layer 0 or just above.
+ while iterator:layer() < 0 do
+ iterator = iterator:T(g)
+ end
+ return iterator
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of transpositonal equivalence and the equal temperament generated
+-- by g. I.e., returns the chord transposed such that its layer is 0 or, under
+-- transposition, the positive layer closest to 0. NOTE: Does NOT return the
+-- result under any other equivalence class.
+
+function Chord:eTT(g)
+ g = g or 1
+ local et = self:eT()
+ local transposition = math.ceil(et[1]) - et[1]
+ local ett = et:T(transposition)
+ return ett
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of translational equivalence and the equal temperament generated by g.
+
+function Chord:iseTT(g)
+ g = g or 1
+ local ep = self:eP()
+ if not (ep == ep:eTT(g)) then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of inversional equivalence.
+
+function Chord:iseI(inverse)
+ --[[ GLVS:
+ local chord = self:clone()
+ local lowerVoice = 2
+ local upperVoice = #chord
+ while lowerVoice < upperVoice do
+ -- GVLS: tests only 1 interval: x[2] - x[1] <= x[#x] - x[#x - 1]
+ local lowerInterval = chord[lowerVoice] - chord[lowerVoice - 1]
+ local upperInterval = chord[upperVoice] - chord[upperVoice - 1]
+ if lowerInterval < upperInterval then
+ return true
+ end
+ if lowerInterval > upperInterval then
+ return false
+ end
+ lowerVoice = lowerVoice + 1
+ upperVoice = upperVoice - 1
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ inverse = inverse or self:I()
+ if not self:__le(inverse) then
+ return false
+ end
+ return true
+ --]]
+ --[[ MKG:
+ inverse = self:I()
+ if not self:__le(inverse) then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of inversional equivalence.
+
+function Chord:eI()
+ if self:iseI() then
+ return self:clone()
+ end
+ return self:I()
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range and permutational equivalence.
+
+function Chord:iseRP(range)
+ --[[ GVLS:
+ for voice = 2, #self do
+ if not (self[voice - 1] <= self[voice]) then
+ return false
+ end
+ end
+ if not (self[#self] <= (self[1] + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ if not ((0 <= layer_) and (layer_ <= range)) then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseP() then
+ return false
+ end
+ return true
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave and permutational equivalence.
+
+function Chord:iseOP()
+ return self:iseRP(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range and permutational equivalence.
+
+function Chord:eRP(range)
+ return self:eR(range):eP()
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave and permutational equivalence.
+
+function Chord:eOP()
+ return self:eRP(ChordSpace.OCTAVE)
+end
+
+-- Returns a copy of the chord cyclically permuted by a stride, by default 1.
+-- The direction of rotation is the same as musicians' first inversion, second
+-- inversion, and so on.
+
+function Chord:cycle(stride)
+ stride = stride or 1
+ local clone_ = self:clone()
+ if stride < 0 then
+ for i = 1, stride do
+ local tail = table.remove(clone_)
+ table.insert(clone_, 1, tail)
+ end
+ return chord
+ end
+ if stride > 0 then
+ for i = 1, math.abs(stride) do
+ local head = table.remove(clone_, 1)
+ table.insert(clone_, head)
+ end
+ end
+ return clone_
+end
+
+-- Returns the permutations of the pitches in a chord. The permutations from
+-- each particular permutation are always returned in the same order.
+
+function Chord:permutations()
+ local chord = self:clone()
+ local permutations_ = {}
+ permutations_[1] = chord
+ for i = 2, #self do
+ chord = chord:cycle()
+ permutations_[i] = chord
+ end
+ table.sort(permutations_)
+ return permutations_
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of voicing equivalence.
+
+function Chord:iseV()
+ local eV = self:eV()
+ --print(string.format('chord: %s eV: %s', tostring(self), tostring(eV)))
+ if not (self == eV) then
+ return false
+ end
+ return true
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of voicing equivalence.
+
+function Chord:eV()
+ ----[[
+ for index, voicing in ipairs(self:permutations()) do
+ local wraparound = voicing[1] + ChordSpace.OCTAVE - voicing[#voicing]
+ local iseV_ = true
+ for voice = 1, #voicing - 1 do
+ local inner = voicing[voice + 1] - voicing[voice]
+ if not ChordSpace.ge_epsilon(wraparound, inner) then
+ --if inner > wraparound then
+ iseV_ = false
+ end
+ end
+ if iseV_ then
+ return voicing
+ end
+ end
+ --]]
+ --[[
+ local voicings = self:permutations()
+ local distancesForIndexes = {}
+ for i = 1, #voicings do
+ distancesForIndexes[i] = voicings[i]:distanceToUnisonDiagonal()
+ end
+ local minimumDistanceToUnisonDiagonal = distancesForIndexes[1]
+ for i = 2, #voicings do
+ if distancesForIndexes[i] < minimumDistanceToUnisonDiagonal then
+ minimumDistanceToUnisonDiagonal = distancesForIndexes[i]
+ end
+ end
+ for i = 1, #voicings do
+ if distancesForIndexes[i] == minimumDistanceToUnisonDiagonal then
+ return voicings[i]
+ end
+ end
+ --]]
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, and transpositional equivalence.
+
+function Chord:iseRPT(range)
+ --[[ GVLS:
+ -- GVLS: if not (self[#self] <= self[1] + ChordSpace.OCTAVE) then
+ if not (ChordSpace.le_epsilon(self[#self], (self[1] + range))) then
+ return false
+ end
+ local layer_ = self:layer()
+ -- GVLS: if not (layer_ == 0) then
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ if #self < 2 then
+ return true
+ end
+ local wraparound = self[1] + range - self[#self]
+ for voice = 1, #self - 1 do
+ local inner = self[voice + 1] - self[voice]
+ if not ChordSpace.le_epsilon(wraparound, inner) then
+ return false
+ end
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseP() then
+ return false
+ end
+ if not self:iseT() then
+ return false
+ end
+ if not self:iseV() then
+ return false
+ end
+ return true
+ --]]
+end
+
+function Chord:iseRPTT(range)
+ if not self:iseP() then
+ return false
+ end
+ if not self:iseR(range) then
+ return false
+ end
+ if not self:iseTT() then
+ return false
+ end
+ if not self:iseV() then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, and transpositional equivalence.
+
+function Chord:iseOPT()
+ return self:iseRPT(ChordSpace.OCTAVE)
+end
+
+function Chord:iseOPTT()
+ return self:iseRPTT(ChordSpace.OCTAVE)
+end
+
+-- Returns a copy of the chord 'inverted' in the musician's sense,
+-- i.e. revoiced by cyclically permuting the chord and
+-- adding (or subtracting) an octave to the highest (or lowest) voice.
+-- The revoicing will move the chord up or down in pitch.
+-- A positive direction is the same as a musician's first inversion,
+-- second inversion, etc.
+
+function Chord:v(direction)
+ direction = direction or 1
+ local chord = self:clone()
+ while direction > 0 do
+ chord = chord:cycle(1)
+ chord[#chord] = chord[#chord] + ChordSpace.OCTAVE
+ direction = direction - 1
+ end
+ while direction < 0 do
+ chord = chord:cycle(-1)
+ chord[1] = chord[1] - ChordSpace.OCTAVE
+ direction = direction + 1
+ end
+ return chord
+end
+
+-- Returns all the 'inversions' (in the musician's sense)
+-- or octavewise revoicings of the chord.
+
+function Chord:voicings()
+ local chord = self:clone()
+ local voicings = {}
+ voicings[1] = chord
+ for i = 2, #self do
+ chord = chord:v()
+ voicings[i] = chord
+ end
+ return voicings
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, and transpositional equivalence; the same
+-- as set-class type, or chord type.
+
+function Chord:eRPT(range)
+ --[[
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]:eT()
+ if voicing:iseV() then
+ return voicing
+ end
+ end
+ print('ERROR: Chord:eRPT() should not come here: ' .. tostring(self))
+ --]]
+ ----[[
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]
+ if voicing:iseV() then
+ return voicing:eT()
+ end
+ end
+ print('ERROR: Chord:eRPT() should not come here: ' .. tostring(self))
+ --]]
+end
+
+function Chord:eRPTT(range)
+ local erp = self:eRP(range)
+ local voicings_ = erp:voicings()
+ for voice = 1, #voicings_ do
+ local voicing = voicings_[voice]:eTT()
+ if voicing:iseV() then
+ return voicing
+ end
+ end
+ print('ERROR: Chord:eRPTT() should not come here: ' .. tostring(self))
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave, permutational, and transpositional equivalence.
+
+function Chord:eOPT()
+ return self:eRPT(ChordSpace.OCTAVE)
+end
+
+function Chord:eOPTT()
+ return self:eRPTT(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, and inversional equivalence.
+
+function Chord:iseRPI(range)
+ if not self:iseRP(range) then
+ return false
+ end
+ local inverse = self:I():eRP(range)
+ assert(inverse, 'Inverse is nil.')
+ if not self:iseI(inverse) then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, and inversional equivalence.
+
+function Chord:iseOPI()
+ return self:iseRPI(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, and inversional equivalence.
+
+function Chord:eRPI(range)
+ local erp = self:eRP(range)
+ if erp:iseRPI(range) then
+ return erp
+ end
+ return erp:I():eRP(range)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of octave, permutational, and inversional equivalence.
+
+function Chord:eOPI()
+ return self:eRPI(ChordSpace.OCTAVE)
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of range, permutational, transpositional, and inversional equivalence.
+
+function Chord:iseRPTI(range)
+ --[[ GVLS:
+ -- GVLS: if not (self[#self] <= self[1] + ChordSpace.OCTAVE) then
+ if not ChordSpace.le_epsilon(self[#self], (self[1] + range)) then
+ return false
+ end
+ local layer_ = self:layer()
+ -- GVLS: if not (layer_ == 0) then
+ if not ChordSpace.eq_epsilon(layer_, 0) then
+ return false
+ end
+ if #self <= 2 then
+ return true
+ end
+ local wraparound = self[1] + range - self[#self]
+ for voice = 1, #self - 1 do
+ local inner = self[voice + 1] - self[voice]
+ if not ChordSpace.le_epsilon(wraparound, inner) then
+ return false
+ end
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+ --]]
+ ----[[ MKG:
+ if not self:iseRPT(range) then
+ return false
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+ --]]
+end
+
+function Chord:iseRPTTI(range)
+ if not self:iseRPTT(range) then
+ return false
+ end
+ if not self:iseI() then
+ return false
+ end
+ return true
+end
+
+-- Returns whether the chord is within the representative fundamental domain
+-- of octave, permutational, transpositional, and inversional equivalence.
+
+function Chord:iseOPTI()
+ return self:iseRPTI(ChordSpace.OCTAVE)
+end
+
+function Chord:iseOPTTI()
+ return self:iseRPTTI(ChordSpace.OCTAVE)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, transpositional, and inversional
+-- equivalence.
+
+function Chord:eRPTI(range)
+ local rpt = self:eRPT(range)
+ if rpt:iseI() then
+ return rpt
+ end
+ return rpt:I():eRPT(range)
+end
+
+function Chord:eRPTTI(range)
+ local rpt = self:eRPTT(range)
+ if rpt:iseRPTTI(range) then
+ return rpt
+ end
+ return rpt:I():eRPTT(range)
+end
+
+-- Returns the equivalent of the chord within the representative fundamental
+-- domain of range, permutational, transpositional, and inversional
+-- equivalence.
+
+function Chord:eOPTI()
+ return self:eRPTI(ChordSpace.OCTAVE)
+end
+
+function Chord:eOPTTI()
+ return self:eRPTTI(ChordSpace.OCTAVE)
+end
+
+function Chord:name()
+ local chordName = ChordSpace.namesForChords[self:__hash()]
+ if chordName == nil then
+ chordName = ''
+ end
+ return chordName
+end
+
+-- Returns a formatted string with information about the chord.
+
+function Chord:information()
+ local et = self:eT():et()
+ local evt = self:eV():et()
+ local eopt = self:eOPT():et()
+ local epcs = self:epcs():eP()
+ local eopti = self:eOPTI():et()
+ local eOP = self:eOP()
+ chordName = eOP:name()
+ return string.format([[pitches: %s %s
+I: %s
+eO: %s iseO: %s
+eP: %s iseP: %s
+eT: %s iseT: %s
+ %s
+eI: %s iseI: %s
+eV: %s iseV: %s
+ %s
+eOP: %s iseOP: %s
+pcs: %s
+eOPT: %s iseOPT: %s
+eOPTT: %s
+ %s
+eOPI: %s iseOPI: %s
+eOPTI: %s iseOPTI: %s
+eOPTTI: %s
+ %s
+layer: %6.2f]],
+tostring(self), chordName,
+tostring(self:I()),
+tostring(self:eO()), tostring(self:iseO()),
+tostring(self:eP()), tostring(self:iseP()),
+tostring(self:eT()), tostring(self:iseT()),
+tostring(et),
+tostring(self:eI()), tostring(self:iseI()),
+tostring(self:eV()), tostring(self:iseV()),
+tostring(evt),
+tostring(self:eOP()), tostring(self:iseOP()),
+tostring(epcs),
+tostring(self:eOPT()), tostring(self:iseOPT()),
+tostring(self:eOPTT()),
+tostring(eopt),
+tostring(self:eOPI()), tostring(self:iseOPI()),
+tostring(self:eOPTI()), tostring(self:iseOPTI()),
+tostring(self:eOPTTI()),
+tostring(eopti),
+self:layer())
+end
+
+function ChordSpace.set(collection)
+ local set_ = {}
+ for key, value in pairs(collection) do
+ set_[value:__hash()] = value
+ end
+ return set_
+end
+
+function ChordSpace.sortedSet(collection)
+ local set_ = ChordSpace.set(collection)
+ local sortedSet_ = {}
+ for key, value in pairs(set_) do
+ table.insert(sortedSet_, value)
+ end
+ table.sort(sortedSet_)
+ return sortedSet_
+end
+
+function ChordSpace.zeroBasedSet(sortedSet)
+ local zeroBasedSet = {}
+ for index, value in pairs(sortedSet) do
+ zeroBasedSet[index - 1] = value
+ end
+ return zeroBasedSet
+end
+
+function ChordSpace.setContains(setA, x)
+ if setA[x:__hash()] == x then
+ return true
+ end
+ return false
+end
+
+function ChordSpace.setInsert(setA, x)
+ if not ChordSpace.setContains(setA, x) then
+ setA[x:__hash()] = x
+ end
+end
+
+function ChordSpace.sortedEquals(sortedA, sortedB)
+ if not (#sortedA == #sortedB) then
+ return false
+ end
+ for i = 1, #sortedA do
+ if not (sortedA[i] == sortedB[i]) then
+ return false
+ end
+ end
+ return true
+end
+
+function ChordSpace.setIntersection(A, setB)
+ local result = {}
+ for index, value in pairs(A) do
+ if ChordSpace.setContains(setB, value) then
+ ChordSpace.setInsert(result, value)
+ end
+ end
+ return result
+end
+
+function ChordSpace.union(A, B)
+ local result = {}
+ for index, value in pairs(A) do
+ ChordSpace.setInsert(result, value)
+ end
+ for index, value in pairs(B) do
+ ChordSpace.setInsert(result, value)
+ end
+ return result
+end
+
+ChordSpace.pitchClassesForNames = {}
+
+ChordSpace.pitchClassesForNames["C" ] = 0
+ChordSpace.pitchClassesForNames["C#"] = 1
+ChordSpace.pitchClassesForNames["Db"] = 1
+ChordSpace.pitchClassesForNames["D" ] = 2
+ChordSpace.pitchClassesForNames["D#"] = 3
+ChordSpace.pitchClassesForNames["Eb"] = 3
+ChordSpace.pitchClassesForNames["E" ] = 4
+ChordSpace.pitchClassesForNames["F" ] = 5
+ChordSpace.pitchClassesForNames["F#"] = 6
+ChordSpace.pitchClassesForNames["Gb"] = 6
+ChordSpace.pitchClassesForNames["G" ] = 7
+ChordSpace.pitchClassesForNames["G#"] = 8
+ChordSpace.pitchClassesForNames["Ab"] = 8
+ChordSpace.pitchClassesForNames["A" ] = 9
+ChordSpace.pitchClassesForNames["A#"] = 10
+ChordSpace.pitchClassesForNames["Bb"] = 10
+ChordSpace.pitchClassesForNames["B" ] = 11
+
+ChordSpace.chordsForNames = {}
+ChordSpace.namesForChords = {}
+
+local function fill(rootName, rootPitch, typeName, typePitches)
+ local chordName = rootName .. typeName
+ local chord = Chord:new()
+ local splitPitches = Silencio.split(typePitches)
+ chord:resize(#splitPitches)
+ for voice, pitchName in ipairs(splitPitches) do
+ local pitch = ChordSpace.pitchClassesForNames[pitchName]
+ chord[voice] = rootPitch + pitch
+ end
+ chord = chord:eOP()
+ ChordSpace.chordsForNames[chordName] = chord
+ ChordSpace.namesForChords[chord:__hash()] = chordName
+end
+
+for rootName, rootPitch in pairs(ChordSpace.pitchClassesForNames) do
+ fill(rootName, rootPitch, " minor second", "C C# ")
+ fill(rootName, rootPitch, " major second", "C D ")
+ fill(rootName, rootPitch, " minor third", "C Eb ")
+ fill(rootName, rootPitch, " major third", "C E ")
+ fill(rootName, rootPitch, " perfect fourth", "C F ")
+ fill(rootName, rootPitch, " tritone", "C F# ")
+ fill(rootName, rootPitch, " perfect fifth", "C G ")
+ fill(rootName, rootPitch, " augmented fifth", "C G# ")
+ fill(rootName, rootPitch, " sixth", "C A ")
+ fill(rootName, rootPitch, " minor seventh ", "C Bb ")
+ fill(rootName, rootPitch, " major seventh", "C B")
+ -- Scales.
+ fill(rootName, rootPitch, " major", "C D E F G A B")
+ fill(rootName, rootPitch, " minor", "C D Eb F G Ab Bb ")
+ fill(rootName, rootPitch, " natural minor", "C D Eb F G Ab Bb ")
+ fill(rootName, rootPitch, " harmonic minor", "C D Eb F G Ab B")
+ fill(rootName, rootPitch, " chromatic", "C C# D D# E F F# G G# A A# B")
+ fill(rootName, rootPitch, " whole tone", "C D E F# G# A# ")
+ fill(rootName, rootPitch, " diminished", "C D D# F F# G# A B")
+ fill(rootName, rootPitch, " pentatonic", "C D E G A ")
+ fill(rootName, rootPitch, " pentatonic major", "C D E G A ")
+ fill(rootName, rootPitch, " pentatonic minor", "C Eb F G Bb ")
+ fill(rootName, rootPitch, " augmented", "C Eb E G Ab Bb ")
+ fill(rootName, rootPitch, " Lydian dominant", "C D E Gb G A Bb ")
+ fill(rootName, rootPitch, " 3 semitone", "C D# F# A ")
+ fill(rootName, rootPitch, " 4 semitone", "C E G# ")
+ fill(rootName, rootPitch, " blues", "C D Eb F Gb G Bb ")
+ fill(rootName, rootPitch, " bebop", "C D E F G A Bb B")
+ -- Major chords.
+ fill(rootName, rootPitch, "M", "C E G ")
+ fill(rootName, rootPitch, "6", "C E G A ")
+ fill(rootName, rootPitch, "69", "C D E G A ")
+ fill(rootName, rootPitch, "69b5", "C D E Gb A ")
+ fill(rootName, rootPitch, "M7", "C E G B")
+ fill(rootName, rootPitch, "M9", "C D E G B")
+ fill(rootName, rootPitch, "M11", "C D E F G B")
+ fill(rootName, rootPitch, "M#11", "C D E F# G B")
+ fill(rootName, rootPitch, "M13", "C D E F G A B")
+ -- Minor chords.
+ fill(rootName, rootPitch, "m", "C Eb G ")
+ fill(rootName, rootPitch, "m6", "C Eb G A ")
+ fill(rootName, rootPitch, "m69", "C D Eb G A ")
+ fill(rootName, rootPitch, "m7", "C Eb G Bb ")
+ fill(rootName, rootPitch, "m#7", "C Eb G B")
+ fill(rootName, rootPitch, "m7b5", "C Eb Gb Bb ")
+ fill(rootName, rootPitch, "m9", "C D Eb G Bb ")
+ fill(rootName, rootPitch, "m9#7", "C D Eb G B")
+ fill(rootName, rootPitch, "m11", "C D Eb F G Bb ")
+ fill(rootName, rootPitch, "m13", "C D Eb F G A Bb ")
+ -- Augmented chords.
+ fill(rootName, rootPitch, "+", "C E G# ")
+ fill(rootName, rootPitch, "7#5", "C E G# Bb ")
+ fill(rootName, rootPitch, "7b9#5", "C Db E G# Bb ")
+ fill(rootName, rootPitch, "9#5", "C D E G# Bb ")
+ -- Diminished chords.
+ fill(rootName, rootPitch, "o", "C Eb Gb ")
+ fill(rootName, rootPitch, "o7", "C Eb Gb A ")
+ -- Suspended chords.
+ fill(rootName, rootPitch, "6sus", "C F G A ")
+ fill(rootName, rootPitch, "69sus", "C D F G A ")
+ fill(rootName, rootPitch, "7sus", "C F G Bb ")
+ fill(rootName, rootPitch, "9sus", "C D F G Bb ")
+ fill(rootName, rootPitch, "M7sus", "C F G B")
+ fill(rootName, rootPitch, "M9sus", "C D F G B")
+ -- Dominant chords.
+ fill(rootName, rootPitch, "7", "C E G Bb ")
+ fill(rootName, rootPitch, "7b5", "C E Gb Bb ")
+ fill(rootName, rootPitch, "7b9", "C Db E G Bb ")
+ fill(rootName, rootPitch, "7b9b5", "C Db E Gb Bb ")
+ fill(rootName, rootPitch, "9", "C D E G Bb ")
+ fill(rootName, rootPitch, "9#11", "C D E F# G Bb ")
+ fill(rootName, rootPitch, "13", "C D E F G A Bb ")
+ fill(rootName, rootPitch, "13#11", "C D E F# G A Bb ")
+end
+
+table.sort(ChordSpace.chordsForNames)
+table.sort(ChordSpace.namesForChords)
+
+-- Increment a chord voicewise through chord space,
+-- from a low point on the unison diagonal through a high point
+-- on the unison diagonal. g is the generator of transposition.
+-- It may be necessary to set the chord to the low point to start.
+
+function ChordSpace.next(odometer, low, high, g)
+ local voices = #odometer
+ odometer[voices] = odometer[voices] + g
+ -- "Carry."
+ for voice = voices, 2, -1 do
+ if odometer[voice] > high then
+ odometer[voice] = low
+ odometer[voice - 1] = odometer[voice - 1] + g
+ end
+ end
+ if odometer[1] > high then
+ return false
+ end
+ return true
+end
+
+function ChordSpace.allOfEquivalenceClass(voices, equivalence, g)
+ g = g or 1
+ local equivalenceMapper = nil
+ if equivalence == 'OP' then
+ equivalenceMapper = Chord.iseOP
+ end
+ if equivalence == 'OPT' then
+ equivalenceMapper = Chord.iseOPT
+ end
+ if equivalence == 'OPTT' then
+ equivalenceMapper = Chord.iseOPT
+ end
+ if equivalence == 'OPI' then
+ equivalenceMapper = Chord.iseOPI
+ end
+ if equivalence == 'OPTI' then
+ equivalenceMapper = Chord.iseOPTI
+ end
+ if equivalence == 'OPTTI' then
+ equivalenceMapper = Chord.iseOPTTI
+ end
+ local equivalentChords = {}
+ -- Enumerate all chords in [-O, O].
+ local iterator = ChordSpace.iterator(voices, -13)
+ -- print('iterator:', tostring(iterator))
+ while ChordSpace.next(iterator, -13, 13, g) == true do
+ if iterator:iseP() == true then
+ local eP = iterator:clone()
+ if equivalenceMapper(eP) then
+ ChordSpace.setInsert(equivalentChords, eP)
+ end
+ end
+ end
+ local equivalentChords = ChordSpace.sortedSet(equivalentChords)
+ local zeroBasedChords = ChordSpace.zeroBasedSet(equivalentChords)
+ return zeroBasedChords, equivalentChords
+end
+
+-- Returns a chord with the specified number of voices all set to a first
+-- pitch, useful as an iterator.
+
+function ChordSpace.iterator(voices, first)
+ local odometer = Chord:new()
+ odometer:resize(voices)
+ for voice = 1, voices do
+ odometer[voice] = first
+ end
+ return odometer
+end
+
+-- Returns a collection of all chords for the specified number of voices in a
+-- range, by default the octave. g is the generator of transposition, by default the
+-- semitone.
+
+function ChordSpace.allChordsInRange(voices, first, last, g)
+ first = first or 0
+ last = last or ChordSpace.OCTAVE
+ g = g or 1
+ -- Enumerate all chords in the range.
+ local chordset = {}
+ local iterator = ChordSpace.iterator(voices, first)
+ while ChordSpace.next(iterator, first, last, g) do
+ local chord = iterator:clone()
+ chordset[chord:__hash()] = chord
+ end
+ return ChordSpace.sortedSet(chordset)
+end
+
+-- Move 1 voice of the chord,
+-- optionally under range equivalence
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:move(voice, interval)
+ local chord = self:clone()
+ chord[voice] = T(chord[voice], interval)
+ return chord
+end
+
+-- Performs the neo-Riemannian Lettonwechsel transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrL()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[1] = cv[1] - 1
+ else
+ if cvt[2] == 3 then
+ cv[3] = cv[3] + 1
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian parallel transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrP()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[2] = cv[2] - 1
+ else
+ if cvt[2] == 3 then
+ cv[2] = cv[2] + 1
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian relative transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrR()
+ local cv = self:eV()
+ local cvt = self:eV():et()
+ if cvt[2] == 4 then
+ cv[3] = cv[3] + 2
+ else
+ if cvt[2] == 3 then
+ cv[1] = cv[1] - 2
+ end
+ end
+ return cv
+end
+
+-- Performs the neo-Riemannian dominant transformation.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:nrD()
+ return self:eep():T(-7)
+end
+
+-- Returns the chord inverted by the sum of its first two voices.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:K(range)
+ range = range or ChordSpace.OCTAVE
+ local chord = self:clone()
+ if #chord < 2 then
+ return chord
+ end
+ local ep = chord:eP()
+ local x = ep[1] + ep[2]
+ return self:I(x)
+end
+
+-- Returns whether the chord is a transpositional form of Y with interval size g.
+-- Only works in equal temperament.
+
+function Chord:Tform(Y, g)
+ local eopx = self:epcs()
+ local i = 0
+ while i < ChordSpace.OCTAVE do
+ local ty = Y:T(i)
+ local eopty = ty:epcs()
+ if eopx == eopty then
+ return true
+ end
+ i = i + g
+ end
+ return false
+end
+
+-- Returns whether the chord is an inversional form of Y with interval size g.
+-- Only works in equal temperament.
+
+function Chord:Iform(Y, g)
+ local eopx = self:epcs()
+ local i = 0
+ while i < ChordSpace.OCTAVE do
+ local iy = Y:I(i)
+ local eopiy = iy:epcs()
+ if eopx == eopiy then
+ return true
+ end
+ i = i + g
+ end
+ return false
+end
+
+-- Returns the contextual transposition of the chord by x with respect to m
+-- with minimum interval size g.
+-- NOTE: Does NOT return the result under any equivalence class.
+
+function Chord:Q(x, m, g)
+ g = g or 1
+ if self:Tform(m, g) then
+ return self:T(x)
+ end
+ if self:Iform(m, g) then
+ return self:T(-x)
+ end
+ return self:clone()
+end
+
+-- Returns the voice-leading between chords a and b,
+-- i.e. what you have to add to a to get b, as a
+-- chord of directed intervals.
+
+function ChordSpace.voiceleading(a, b)
+ local voiceleading = a:clone()
+ for voice = 1, #voiceleading do
+ voiceleading[voice] = b[voice] - a[voice]
+ end
+ return voiceleading
+end
+
+-- Returns whether the voiceleading
+-- between chords a and b contains a parallel fifth.
+
+function ChordSpace.parallelFifth(a, b)
+ local v = ChordSpace.voiceleading(a, b)
+ if v:count(7) > 1 then
+ return true
+ else
+ return false
+ end
+end
+
+-- Returns the smoothness of the voiceleading between
+-- chords a and b by L1 norm.
+
+function ChordSpace.voiceleadingSmoothness(a, b)
+ local L1 = 0
+ for voice = 1, #a do
+ L1 = L1 + math.abs(b[voice] - a[voice])
+ end
+ return L1
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the smoother (shortest moves), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingSmoother(source, d1, d2, avoidParallels, range)
+ range = range or ChordSpace.OCTAVE
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local s1 = ChordSpace.voiceleadingSmoothness(source, d1)
+ local s2 = ChordSpace.voiceleadingSmoothness(source, d2)
+ if s1 <= s2 then
+ return d1
+ else
+ return d2
+ end
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the simpler (fewest moves), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingSimpler(source, d1, d2, avoidParallels)
+ avoidParallels = avoidParallels or false
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local v1 = ChordSpace.voiceleading(source, d1):eP()
+ local v2 = ChordSpace.voiceleading(source, d2):eP()
+ for voice = #v1, 1, -1 do
+ if v1[voice] < v2[voice] then
+ return d1
+ end
+ if v2[voice] < v1[voice] then
+ return d2
+ end
+ end
+ return d1
+end
+
+-- Returns which of the voiceleadings (source to d1, source to d2)
+-- is the closer (first smoother, then simpler), optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingCloser(source, d1, d2, avoidParallels)
+ avoidParallels = avoidParallels or false
+ if avoidParallels then
+ if ChordSpace.parallelFifth(source, d1) then
+ return d2
+ end
+ if ChordSpace.parallelFifth(source, d2) then
+ return d1
+ end
+ end
+ local s1 = ChordSpace.voiceleadingSmoothness(source, d1)
+ local s2 = ChordSpace.voiceleadingSmoothness(source, d2)
+ if s1 < s2 then
+ return d1
+ end
+ if s1 > s2 then
+ return d2
+ end
+ return ChordSpace.voiceleadingSimpler(source, d1, d2, avoidParallels)
+end
+
+-- Returns the voicing of the destination which has the closest voice-leading
+-- from the source within the range, optionally avoiding parallel fifths.
+
+function ChordSpace.voiceleadingClosestRange(source, destination, range, avoidParallels)
+ local destinationeOP = destination:eOP()
+ local d = destinationeOP:clone()
+ local odometer = source:origin()
+ while ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE) == true do
+ local revoicing = odometer:clone()
+ for voice = 1, #revoicing do
+ revoicing[voice] = revoicing[voice] + destinationeOP[voice]
+ end
+ d = ChordSpace.voiceleadingCloser(source, d, revoicing, avoidParallels)
+ end
+ return d
+end
+
+-- Creates a complete Silencio "note on" event for the
+-- indicated voice of the chord. The other parameters are used
+-- if the internal duration, channel, velocity, and pan of the
+-- chord are nil.
+
+function Chord:note(voice_, time_, duration_, channel_, velocity_, pan_)
+ local note_ = Event:new()
+ note_[TIME] = time_
+ note_[DURATION] = duration_ or self.duration[voice_]
+ note_[CHANNEL] = channel_ or self.channel[voice_]
+ note_[KEY] = self[voice_]
+ note_[VELOCITY] = velocity_ or self.velocity[voice_]
+ note_[PAN] = pan_ or self.pan[voice_]
+ return note_
+end
+
+-- Returns an individual note for each voice of the chord.
+-- The chord's duration, instrument, and loudness are used if present,
+-- if not the specified values are used.
+
+function Chord:notes(time_, duration_, channel_, velocity_, pan_)
+ local notes_ = Score:new()
+ for voice, key in ipairs(self) do
+ table.insert(notes_, self:note(voice, time_, duration_, channel_, velocity_, pan_))
+ end
+ return notes_
+end
+
+function Chord:toScore(score, time_, duration_, channel_, velocity_, pan_)
+ for voice, key in ipairs(self) do
+ score:append(self:note(voice, time_, duration_, channel_, velocity_, pan_))
+ end
+ return score
+end
+
+-- If the event is a note, moves its pitch
+-- to the closest pitch of the chord.
+-- If octaveEquivalence is true (the default),
+-- the pitch-class of the note is moved to the closest pitch-class
+-- of the chord; otherwise, the pitch of the note is moved to the closest
+-- absolute pitch of the chord.
+
+function conformToChord(event, chord, octaveEquivalence)
+ octaveEquivalence = octaveEquivalence or true
+ if event[STATUS] ~= 144 then
+ return
+ else
+ local pitch = event[KEY]
+ if octaveEquivalence then
+ local pitchClass = pitch % ChordSpace.OCTAVE
+ local octave = pitch - pitchClass
+ local chordPitchClass = chord[1] % ChordSpace.OCTAVE
+ local distance = math.abs(chordPitchClass - pitchClass)
+ local closestPitchClass = chordPitchClass
+ local minimumDistance = distance
+ for voice = 2, #chord do
+ chordPitchClass = chord[voice] % ChordSpace.OCTAVE
+ distance = math.abs(chordPitchClass - pitchClass)
+ if distance < minimumDistance then
+ minimumDistance = distance
+ closestPitchClass = chordPitchClass
+ end
+ end
+ event[KEY] = octave + closestPitchClass
+ else
+ local chordPitch = chord[1]
+ local distance = math.abs(chordPitch - pitch)
+ local closestPitch = chordPitch
+ local minimumDistance = distance
+ for voice = 2, #chord do
+ chordPitch = chord[voice]
+ distance = math.abs(chordPitch - pitch)
+ if distance < minimumDistance then
+ minimumDistance = distance
+ closestPitch = chordPitch
+ end
+ end
+ event[KEY] = closestPitch
+ end
+ end
+end
+
+-- Inserts the notes of the chord into the score at the specified time.
+-- The internal duration, instrument, and loudness are used if present,
+-- if not the specified values are used.
+
+function ChordSpace.insert(score, chord, time_, duration, channel, velocity, pan)
+ -- print(score, chord, time_, duration, channel, velocity, pan)
+ for voice = 1, #chord do
+ local event = chord:note(voice, time_, duration, channel, velocity, pan)
+ table.insert(score, event)
+ end
+end
+
+-- For all the notes in the score
+-- beginning at or later than the start time,
+-- and up to but not including the end time,
+-- moves the pitch of the note to belong to the chord, using the
+-- conformToChord function.
+
+function ChordSpace.apply(score, chord, start, end_, octaveEquivalence)
+ octaveEquivalence = octaveEquivalence or true
+ local slice = score:slice(start, end_)
+ for index, event in ipairs(slice) do
+ conformToChord(event, chord, octaveEquivalence)
+ end
+end
+
+-- Returns a chord containing all the pitches of the score
+-- beginning at or later than the start time,
+-- and up to but not including the end time.
+
+function gather(score, start, end_)
+ local chord = Chord:new()
+ local slice = score:slice(start, end_)
+ for index, event in ipairs(slice) do
+ local pitch = event[KEY]
+ if not chord:contains(pitch) then
+ table.insert(chord, pitch)
+ end
+ end
+ return chord
+end
+
+-- Orthogonal additive groups for unordered chords of given arity under range
+-- equivalence (RP): prime form or P, inversion or I, transposition or T, and
+-- voicing or V. P x I x T = OP, P x I x T x V = RP. Therefore, an
+-- operation on P, I, T, or V may be used to independently transform the
+-- respective symmetry of any chord. Some of these operations will reflect
+-- in RP.
+
+ChordSpaceGroup = {}
+
+-- N is the number of voices in the chord space, g is the generator of
+-- transposition, range is the size of chord space,
+-- optis is an ordered table of all OPTI chords for g,
+-- voicings is an ordered table of all octavewise permutations in RP.
+
+function ChordSpaceGroup:new(o)
+ local o = o or {optisForIndexes = {}, indexesForOptis = {}, voicingsForIndexes = {}, indexesForVoicings = {}}
+ setmetatable(o, self)
+ self.__index = self
+ return o
+end
+
+function ChordSpace.octavewiseRevoicings(chord, range)
+ range = range or ChordSpace.OCTAVE
+ local voices = #chord
+ local odometer = chord:origin()
+ -- Enumerate the permutations.
+ -- iterator[1] is the most significant voice, and
+ -- iterator[N] is the least significant voice.
+ local voicings = 0
+ while ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE) == true do
+ voicings = voicings + 1
+ end
+ return voicings
+end
+
+function ChordSpace.octavewiseRevoicing(chord, index, range)
+ local voices = #chord
+ local odometer = chord:origin()
+ local eop = chord:eOP()
+ -- Enumerate the permutations.
+ -- iterator[1] is the most significant voice, and
+ -- iterator[N] is the least significant voice.
+ local voicings = 0
+ for v = 1, index do
+ ChordSpace.next(odometer, 0, range, ChordSpace.OCTAVE)
+ -- Wrap around?
+ if odometer[1] > range then
+ odometer = chord:origin()
+ end
+ voicings = voicings + 1
+ end
+ for voice = 1, #chord do
+ odometer[voice] = odometer[voice] + eop[voice]
+ end
+ return odometer
+end
+
+-- Returns the ith arpeggiation, current voice, and corresponding revoicing
+-- of the chord. Positive arpeggiations start with the lowest voice of the
+-- chord and revoice up; negative arpeggiations start with the highest voice
+-- of the chord and revoice down.
+
+function Chord:a(arpeggiation)
+ local chord = self:v(arpeggiation)
+ if arpeggiation < 0 then
+ return chord[#chord], #chord, chord
+ end
+ return chord[1], 1, chord
+end
+
+function ChordSpaceGroup:initialize(voices, range, g)
+ self.voices = voices or 3
+ self.range = range or 60
+ self.g = g or 1
+ self.countP = 0
+ self.countI = 2
+ self.countT = ChordSpace.OCTAVE / self.g
+ local chord = Chord:new()
+ chord:resize(voices)
+ self.countV = ChordSpace.octavewiseRevoicings(chord, self.range)
+ self.indexesForOptis = {}
+ self.optisForIndexes = ChordSpace.allOfEquivalenceClass(voices, 'OPTTI')
+ for index, optti in pairs(self.optisForIndexes) do
+ self.indexesForOptis[optti:__hash()] = index
+ self.countP = self.countP + 1
+ end
+ self:list()
+end
+
+function ChordSpace.createFilename(voices, range, g, extension)
+ extension = extension or '.lua'
+ local gstring = string.format('g%.6f', g)
+ gstring = string.gsub(gstring, '%.', '_')
+ local filename = string.format('ChordSpaceGroup_V%d_R%d_%s%s', voices, range, gstring, extension)
+ return filename
+end
+
+-- Loads the group if found, creates and saves it otherwise.
+
+function ChordSpace.createChordSpaceGroup(voices, range, g)
+ local filename = ChordSpace.createFilename(voices, range, 1)
+ local file, message, error = io.open(filename, 'r')
+ if file == nil then
+ print(string.format('File "%s" not found, creating...', filename))
+ chordSpaceGroup = ChordSpaceGroup:new()
+ chordSpaceGroup:initialize(voices, range, g)
+ chordSpaceGroup:save()
+ return chordSpaceGroup
+ else
+ print(string.format('Loading ChordSpaceGroup from file "%s"...', filename))
+ return ChordSpace.load(voices, range, g)
+ end
+end
+
+function ChordSpace.load(voices, range, g)
+ local filename = ChordSpace.createFilename(voices, range, 1)
+ print('Loading:', filename)
+ local deserialized = ChordSpaceGroup.load(filename)
+ return deserialized
+end
+
+function ChordSpaceGroup:save(filename)
+ filename = filename or ChordSpace.createFilename(self.voices, self.range, self.g, '.lua')
+ local text = serialize(self)
+ local writer = io.open(filename, 'w+')
+ writer:write(text)
+ writer:close()
+end
+
+function ChordSpaceGroup.load(filename)
+ local reader = io.open(filename)
+ local text = reader:read("*all")
+ -- What's deserialized is a function, which needs to be called.
+ local object = loadstring(text)()
+ -- Fix up metatable.
+ local chordSpaceGroup = ChordSpaceGroup:new(object)
+ -- Fix up metatables of chords too.
+ for index, opti in pairs(chordSpaceGroup.optisForIndexes) do
+ chordSpaceGroup.optisForIndexes[index] = Chord:new(opti)
+ end
+ return chordSpaceGroup
+end
+
+-- Returns the chord for the indices of prime form, inversion,
+-- transposition, and voicing. The chord is not in RP; rather, each voice of
+-- the chord's OP may have zero or more octaves added to it.
+
+function ChordSpaceGroup:toChord(P, I, T, V, printme)
+ printme = printme or false
+ P = P % self.countP
+ I = I % 2
+ T = T % ChordSpace.OCTAVE
+ V = V % self.countV
+ if printme then
+ print('toChord: ', P, I, T, V)
+ end
+ local optti = self.optisForIndexes[P]
+ if printme then
+ print('toChord: optti: ', optti, optti:__hash())
+ end
+ local optt = nil
+ if I == 0 then
+ optt = optti
+ else
+ optt = optti:I():eOPTT()
+ end
+ if printme then
+ print('toChord: optt: ', optt)
+ end
+ local optt_t = optt:T(T)
+ if printme then
+ print('toChord: optt_t: ', optt_t)
+ end
+ local op = optt_t:eOP()
+ if printme then
+ print('toChord: op: ', op)
+ end
+ V = V % self.countV
+ local revoicing = ChordSpace.octavewiseRevoicing(op, V, self.range)
+ if printme then
+ print('toChord: revoicing:', revoicing)
+ end
+ return revoicing, opti, op
+end
+
+-- Returns the indices of prime form, inversion, transposition,
+-- and voicing for a chord.
+
+function ChordSpaceGroup:fromChord(chord, printme)
+ printme = printme or false
+ if printme then
+ print('fromChord: chord: ', chord, chord:iseOP())
+ end
+ local op = nil
+ if chord:iseOP() then
+ op = chord:clone()
+ else
+ op = chord:eOP()
+ end
+ if printme then
+ print('fromChord: op: ', op)
+ end
+ local optt = chord:eOPTT()
+ if printme then
+ print('fromChord: optt: ', optt)
+ end
+ local T = 0
+ for t = 0, ChordSpace.OCTAVE - 1, self.g do
+ local optt_t = optt:T(t):eOP()
+ if printme then
+ print('fromChord: optt_t: ', optt_t, t)
+ end
+ if optt_t:__eq_epsilon(op) == true then
+ if printme then
+ print('equals')
+ end
+ T = t
+ break
+ end
+ end
+ local optti = chord:eOPTTI()
+ if printme then
+ print('fromChord: optti: ', optti, optti:__hash())
+ end
+ local P = self.indexesForOptis[optti:__hash()]
+ local I = 0
+ if optti ~= optt then
+ I = 1
+ local optt_i_optt = optt:I():eOPTT()
+ if optt_i_optt ~= optti then
+ print("Error: OPTT(I(OPTT)) must equal OPTTI.")
+ print('optt_i_optt:', optt_i_optt:information())
+ print('optti: ', optti:information())
+ os.exit()
+ end
+ end
+ local voicing = ChordSpace.voiceleading(op, chord)
+ V = self.indexesForVoicings[voicing:__hash()]
+ if printme then
+ print('fromChord: voicing: ', voicing, V)
+ print('fromChord: ', P, I, T, V)
+ end
+ return P, I, T, V
+end
+
+function ChordSpaceGroup:list(listheader, listopttis, listvoicings)
+ listheader = listheader or true
+ listopttis = listopttis or false
+ listvoicings = listvoicings or false
+ if listheader then
+ print(string.format('ChordSpaceGroup.voices: %8d', self.voices))
+ print(string.format('ChordSpaceGroup.range : %8d', self.range))
+ print(string.format('ChordSpaceGroup.g : %13.4f', self.g))
+ print(string.format('ChordSpaceGroup.countP: %8d', self.countP))
+ print(string.format('ChordSpaceGroup.countI: %8d', self.countI))
+ print(string.format('ChordSpaceGroup.countT: %8d', self.countT))
+ print(string.format('ChordSpaceGroup.countV: %8d', self.countV))
+ end
+ if listopttis then
+ for index, opti in pairs(self.optisForIndexes) do
+ print(string.format('index: %5d opti: %s index from opti: %s', index, tostring(opti), self.indexesForOptis[opti:__hash()]))
+ end
+ for index = 0, #self.optisForIndexes - 1 do
+ print(string.format('opti from index: %s index: %5d', tostring(self.optisForIndexes[index]), index))
+ end
+ end
+ if listvoicings then
+ for index, voicing in pairs(self.voicingsForIndexes) do
+ print(string.format('voicing index: %5d voicing: %s index from voicing: %5d', index, tostring(voicing), self.indexesForVoicings[voicing:__hash()]))
+ end
+ end
+end
+
+function ChordSpaceGroup:printChords()
+ for index, opti in pairs(self.optisForIndexes) do
+ print(string.format('index: %5d opti: %s %s', index, tostring(opti), opti:name()))
+ end
+end
+
+function ChordSpaceGroup:printNamedChords()
+ for index, opti in pairs(self.optisForIndexes) do
+ local name = opti:name()
+ if name ~= '' then
+ print(string.format('index: %5d opti: %s %s', index, tostring(opti), opti:name()))
+ end
+ end
+end
+
+return ChordSpace
+*/
diff --git a/frontends/CsoundAC/Composition.cpp b/frontends/CsoundAC/Composition.cpp
index 6e2ecfa..3cfe374 100644
--- a/frontends/CsoundAC/Composition.cpp
+++ b/frontends/CsoundAC/Composition.cpp
@@ -26,191 +26,208 @@
namespace csound
{
-Composition::Composition() :
+ Composition::Composition() :
tonesPerOctave(12.0),
conformPitches(false)
-{
-}
+ {
+ }
-Composition::~Composition()
-{
-}
+ Composition::~Composition()
+ {
+ }
-void Composition::render()
-{
+ int Composition::render()
+ {
clear();
- generate();
+ int errorStatus = generate();
timestamp = makeTimestamp();
- perform();
-}
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = perform();
+ return errorStatus;
+ }
-void Composition::renderAll()
-{
+ int Composition::renderAll()
+ {
clear();
- generate();
- performAll();
-}
-
-void Composition::perform()
-{
-}
-
-void Composition::generate()
-{
-}
-
-void Composition::clear()
-{
+ int errorStatus = generate();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = performAll();
+ return errorStatus;
+ }
+
+ int Composition::perform()
+ {
+ return 0;
+ }
+
+ int Composition::generate()
+ {
+ return 0;
+ }
+
+ void Composition::clear()
+ {
score.clear();
-}
+ }
-Score &Composition::getScore()
-{
+ Score &Composition::getScore()
+ {
return score;
-}
+ }
-void Composition::write(const char *text)
-{
+ void Composition::write(const char *text)
+ {
System::message(text);
-}
+ }
-void Composition::setTonesPerOctave(double tonesPerOctave)
-{
+ void Composition::setTonesPerOctave(double tonesPerOctave)
+ {
this->tonesPerOctave = tonesPerOctave;
-}
+ }
-double Composition::getTonesPerOctave() const
-{
+ double Composition::getTonesPerOctave() const
+ {
return tonesPerOctave;
-}
+ }
-void Composition::setConformPitches(bool conformPitches)
-{
+ void Composition::setConformPitches(bool conformPitches)
+ {
this->conformPitches = conformPitches;
-}
+ }
-bool Composition::getConformPitches() const
-{
+ bool Composition::getConformPitches() const
+ {
return conformPitches;
-}
+ }
-std::string Composition::getFilename() const
-{
+ std::string Composition::getFilename() const
+ {
return filename;
-}
+ }
-void Composition::setFilename(std::string filename)
-{
+ void Composition::setFilename(std::string filename)
+ {
this->filename = filename;
-}
+ }
-std::string Composition::generateFilename()
-{
+ std::string Composition::generateFilename()
+ {
char buffer[0x100];
snprintf(buffer, 0x100, "silence.%s.py", makeTimestamp().c_str());
return buffer;
-}
+ }
-std::string Composition::getMidiFilename()
-{
+ std::string Composition::getMidiFilename() const
+ {
std::string name = getFilename();
name.append(".mid");
return name;
-}
-
-std::string Composition::getOutputSoundfileName()
-{
- std::string name = getFilename();
- name.append(".wav");
- return name;
-}
-
-std::string Composition::getNormalizedSoundfileName()
-{
+ }
+
+ std::string Composition::getOutputSoundfileName() const
+ {
+ if (outputFilename.empty())
+ {
+ std::string name_ = getFilename();
+ name_.append(".wav");
+ return name_;
+ }
+ else
+ {
+ return outputFilename;
+ }
+ }
+
+ std::string Composition::getNormalizedSoundfileName() const
+ {
std::string name = getFilename();
name.append(".norm.wav");
return name;
-}
+ }
-std::string Composition::getCdSoundfileName()
-{
+ std::string Composition::getCdSoundfileName() const
+ {
std::string name = getFilename();
name.append(".cd.wav");
return name;
-}
+ }
-std::string Composition::getMp3SoundfileName()
-{
+ std::string Composition::getMp3SoundfileName() const
+ {
std::string name = getFilename();
name.append(".mp3");
return name;
-}
+ }
-std::string Composition::getMusicXmlFilename()
-{
+ std::string Composition::getMusicXmlFilename() const
+ {
std::string name = getFilename();
name.append(".xml");
return name;
-}
+ }
-std::string Composition::getFomusFilename()
-{
+ std::string Composition::getFomusFilename() const
+ {
std::string name = getFilename();
name.append(".fms");
return name;
-}
+ }
-std::string Composition::getLilypondFilename()
-{
+ std::string Composition::getLilypondFilename() const
+ {
std::string name = getFilename();
name.append(".ly");
return name;
-}
+ }
-std::string Composition::makeTimestamp()
-{
+ std::string Composition::makeTimestamp()
+ {
time_t time_ = 0;
time(&time_);
struct tm* tm_ = gmtime(&time_);
char buffer[0x100];
strftime(buffer, 0x100, "%Y-%m-%d.%H-%M-%S", tm_);
return buffer;
-}
+ }
-std::string Composition::getTimestamp() const
-{
+ std::string Composition::getTimestamp() const
+ {
return timestamp;
-}
+ }
-void tagFile(Composition &composition, std::string filename)
-{
+ int Composition::tagFile(std::string filename) const
+ {
std::string command = "bwfmetaedit";
- command = command + " --OriginationDate=" + composition.getTimestamp().substr(0, 10);
- command = command + " --ICRD=" + composition.getTimestamp().substr(0, 10);
- if (composition.getTitle().length() > 1) {
- command = command + " --Description=" + composition.getTitle();
- command = command + " --INAM=" + composition.getTitle();
+ command = command + " --OriginationDate=" + getTimestamp().substr(0, 10);
+ command = command + " --ICRD=" + getTimestamp().substr(0, 10);
+ if (getTitle().length() > 1) {
+ command = command + " --Description=" + getTitle();
+ command = command + " --INAM=" + getTitle();
}
- if (composition.getCopyright().length() > 1) {
- command = command + " --ICOP=" + composition.getCopyright();
+ if (getCopyright().length() > 1) {
+ command = command + " --ICOP=" + getCopyright();
}
- if (composition.getArtist().length() > 1) {
- command = command + " --Originator=" + composition.getArtist();
- command = command + " --IART=" + composition.getArtist();
+ if (getArtist().length() > 1) {
+ command = command + " --Originator=" + getArtist();
+ command = command + " --IART=" + getArtist();
}
- if (composition.getAlbum().length() > 1) {
- command = command + " --IPRD=" + composition.getAlbum();
+ if (getAlbum().length() > 1) {
+ command = command + " --IPRD=" + getAlbum();
}
- if (composition.getLicense().length() > 1) {
- command = command + " --ICMT=" + composition.getLicense();
+ if (getLicense().length() > 1) {
+ command = command + " --ICMT=" + getLicense();
}
command = command + " " + filename.c_str();
System::inform("tagFile(): %s\n", command.c_str());
- int result = std::system(command.c_str());
-}
+ return std::system(command.c_str());
+ }
-void Composition::performMaster()
-{
+ int Composition::performMaster()
+ {
System::inform("BEGAN Composition::performMaster()...\n");
timestamp = makeTimestamp();
score.save(getMidiFilename());
@@ -218,122 +235,146 @@ void Composition::performMaster()
//score.save(getMusicXmlFilename());
// Would often take too long!...
//translateToNotation();
- perform();
+ int errorStatus = perform();
System::inform("ENDED Composition::performMaster().\n");
-}
+ return errorStatus;
+ }
-void Composition::performAll()
-{
+ int Composition::performAll()
+ {
System::inform("BEGAN Composition::performAll()...\n");
- performMaster();
- translateMaster();
+ int errorStatus = performMaster();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = translateMaster();
System::inform("ENDED Composition::performAll().\n");
-}
+ return errorStatus;
+ }
-void Composition::translateMaster()
-{
+ int Composition::translateMaster()
+ {
System::inform("ENDED Composition::translateMaster().\n");
- tagFile(*this, getOutputSoundfileName());
- normalizeOutputSoundfile();
- translateToCdAudio();
- translateToMp3();
+ int errorStatus = tagFile(getOutputSoundfileName());
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = normalizeOutputSoundfile();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = translateToCdAudio();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = translateToMp3();
System::inform("ENDED Composition::translateMaster().\n");
-}
+ return errorStatus;
+ }
-void Composition::normalizeOutputSoundfile(double levelDb)
-{
+ int Composition::normalizeOutputSoundfile(double levelDb)
+ {
char buffer[0x100];
std::snprintf(buffer,
- 0x100,
- "sox %s -V3 -b 32 -e floating-point %s gain -n %f\n",
- getOutputSoundfileName().c_str(),
- getNormalizedSoundfileName().c_str(),
- levelDb);
- int result = std::system(buffer);
+ 0x100,
+ "sox %s -V3 -b 32 -e floating-point %s gain -n %f\n",
+ getOutputSoundfileName().c_str(),
+ getNormalizedSoundfileName().c_str(),
+ levelDb);
+ int errorStatus = std::system(buffer);
+ if (errorStatus) {
+ return errorStatus;
+ }
System::inform("Composition::normalizeOutputSoundfile(): %s", buffer);
- tagFile(*this, getNormalizedSoundfileName());
-}
+ errorStatus = tagFile(getNormalizedSoundfileName());
+ return errorStatus;
+ }
-void Composition::translateToCdAudio(double levelDb)
-{
+ int Composition::translateToCdAudio(double levelDb)
+ {
char buffer[0x100];
std::snprintf(buffer, 0x100, "sox %s -V3 -b 16 %s gain -n %f rate 44100\n",
- getOutputSoundfileName().c_str(),
- getCdSoundfileName().c_str(),
- levelDb);
+ getOutputSoundfileName().c_str(),
+ getCdSoundfileName().c_str(),
+ levelDb);
System::inform("Composition::translateToCdAudio(): %s", buffer);
- int result = std::system(buffer);
- tagFile(*this, getCdSoundfileName());
-}
+ int errorStatus = std::system(buffer);
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = tagFile(getCdSoundfileName());
+ return errorStatus;
+ }
-void Composition::translateToMp3(double bitrate, double levelDb)
-{
+ int Composition::translateToMp3(double bitrate, double levelDb)
+ {
char buffer[0x100];
std::snprintf(buffer,
- 0x100,
- "lame --verbose --disptime 2 --nohist --preset cd --tt %s --ta %s --tl %s --tc %s %s %s\n",
- getTitle().c_str(),
- getArtist().c_str(),
- getAlbum().c_str(),
- getCopyright().c_str(),
- getCdSoundfileName().c_str(),
- getMp3SoundfileName().c_str());
+ 0x100,
+ "lame --verbose --disptime 2 --nohist --preset cd --tt %s --ta %s --tl %s --tc %s %s %s\n",
+ getTitle().c_str(),
+ getArtist().c_str(),
+ getAlbum().c_str(),
+ getCopyright().c_str(),
+ getCdSoundfileName().c_str(),
+ getMp3SoundfileName().c_str());
System::inform("Composition::translateToMp3(): %s", buffer);
- int result = std::system(buffer);
-}
+ int errorStatus = std::system(buffer);
+ return errorStatus;
+ }
-std::string Composition::getArtist() const
-{
+ std::string Composition::getArtist() const
+ {
return artist;
-}
+ }
-void Composition::setArtist(std::string value)
-{
+ void Composition::setArtist(std::string value)
+ {
artist = value;
-}
+ }
-std::string Composition::getTitle() const
-{
+ std::string Composition::getTitle() const
+ {
return title;
-}
+ }
-void Composition::setTitle(std::string value)
-{
+ void Composition::setTitle(std::string value)
+ {
title = value;
-}
+ }
-std::string Composition::getCopyright() const
-{
+ std::string Composition::getCopyright() const
+ {
return copyright;
-}
+ }
-void Composition::setCopyright(std::string value)
-{
+ void Composition::setCopyright(std::string value)
+ {
copyright = value;
-}
+ }
-std::string Composition::getAlbum() const
-{
+ std::string Composition::getAlbum() const
+ {
return album;
-}
+ }
-void Composition::setAlbum(std::string value)
-{
+ void Composition::setAlbum(std::string value)
+ {
album = value;
-}
+ }
-std::string Composition::getLicense() const
-{
+ std::string Composition::getLicense() const
+ {
return license;
-}
+ }
-void Composition::setLicense(std::string value)
-{
+ void Composition::setLicense(std::string value)
+ {
license = value;
-}
+ }
-void Composition::translateToNotation(const std::vector<std::string> partNames, std::string header)
-{
+ int Composition::translateToNotation(const std::vector<std::string> partNames, std::string header)
+ {
std::string filename = getFomusFilename();
std::ofstream stream;
stream.open(filename.c_str(), std::ifstream::binary);
@@ -341,42 +382,71 @@ void Composition::translateToNotation(const std::vector<std::string> partNames,
std::sprintf(buffer, "title = \"%s\"\n", getTitle().c_str());
stream << buffer;
if (getArtist().length() > 1) {
- std::sprintf(buffer, "author = \"%s\"\n", getArtist().c_str());
- stream << buffer;
+ std::sprintf(buffer, "author = \"%s\"\n", getArtist().c_str());
+ stream << buffer;
}
stream << "beat = 1/64" << std::endl;
stream << "timesig (4 4)" << std::endl;
stream << "lily-papersize = 11x17" << std::endl;
if (header.size() > 1) {
- stream << header.c_str();
+ stream << header.c_str();
}
if (partNames.size() > 0) {
- for (size_t partI = 0, partN = partNames.size(); partI < partN; ++partI) {
- std::sprintf(buffer, "part <id = %d name = %s>\n", partI, partNames[partI].c_str());
- stream << buffer;
- }
+ for (size_t partI = 0, partN = partNames.size(); partI < partN; ++partI) {
+ std::sprintf(buffer, "part <id = %d name = %s>\n", partI, partNames[partI].c_str());
+ stream << buffer;
+ }
} else {
- for (size_t partI = 0, partN = 100; partI < partN; ++partI) {
- std::sprintf(buffer, "part <id = %d name = Part%d>\n", partI, partI);
- stream << buffer;
- }
+ for (size_t partI = 0, partN = 100; partI < partN; ++partI) {
+ std::sprintf(buffer, "part <id = %d name = Part%d>\n", partI, partI);
+ stream << buffer;
+ }
}
for (size_t eventI = 0, eventN = score.size(); eventI < eventN; ++eventI) {
- const Event &event = score[eventI];
- if (event.isNoteOn()) {
- double duration = event.getDuration() * 32.0;
- duration = Conversions::round(duration);
- if (duration > 0) {
- std::sprintf(buffer, "part %g time %g dur %g pitch %g;\n", event.getInstrument() + 1, event.getTime() * 32.0, duration, event.getKey());
- stream << buffer;
- }
+ const Event &event = score[eventI];
+ if (event.isNoteOn()) {
+ double duration = event.getDuration() * 32.0;
+ duration = Conversions::round(duration);
+ if (duration > 0) {
+ std::sprintf(buffer, "part %g time %g dur %g pitch %g;\n", event.getInstrument() + 1, event.getTime() * 32.0, duration, event.getKey());
+ stream << buffer;
}
+ }
}
stream.close();
std::sprintf(buffer, "fomus -i %s -o %s.ly", getFomusFilename().c_str(), getTitle().c_str());
- int result;
- result = std::system(buffer);
+ int errorStatus;
+ errorStatus = std::system(buffer);
+ if (errorStatus) {
+ return errorStatus;
+ }
std::sprintf(buffer, "lilypond -fpdf %s.ly", getTitle().c_str());
- result = std::system(buffer);
-}
+ errorStatus = std::system(buffer);
+ return errorStatus;
+ }
+
+ int Composition::processArgv(int argc, const char **argv)
+ {
+ std::vector<std::string> args;
+ for (int i = 0; i < argc; ++i)
+ {
+ args.push_back(argv[i]);
+ }
+ return processArgs(args);
+ }
+
+ int Composition::processArgs(const std::vector<std::string> &args)
+ {
+ return renderAll();
+ }
+
+ void Composition::setOutputSoundfileName(std::string name)
+ {
+ outputFilename = name;
+ }
+
+ void Composition::clearOutputSoundfileName()
+ {
+ outputFilename.clear();
+ }
}
diff --git a/frontends/CsoundAC/Composition.hpp b/frontends/CsoundAC/Composition.hpp
index 804d9fd..2b07c9d 100644
--- a/frontends/CsoundAC/Composition.hpp
+++ b/frontends/CsoundAC/Composition.hpp
@@ -25,21 +25,21 @@
%module CsoundAC
%{
#include "Score.hpp"
-%}
+ %}
#else
#include "Score.hpp"
#endif
namespace csound
{
-/**
- * Base class for user-defined musical compositions.
- * Contains a Score object for collecting generated Events
- * such as notes and control messages.
- */
-class Composition
-{
-public:
+ /**
+ * Base class for user-defined musical compositions.
+ * Contains a Score object for collecting generated Events
+ * such as notes and control messages.
+ */
+ class SILENCE_PUBLIC Composition
+ {
+ public:
Composition();
virtual ~Composition();
/**
@@ -66,57 +66,60 @@ public:
virtual std::string getTimestamp() const;
/**
* Returns a soundfile name based on the filename
- * of this, by appending ".wav" to the filename.
+ * of this, by appending ".wav" to the filename,
+ * which is the default, or a non-default ouput name
+ * which need not be a file but must be set using
+ * setOutputSoundfileName().
*/
- virtual std::string getOutputSoundfileName();
+ virtual std::string getOutputSoundfileName() const;
/**
* Returns a soundfile name based on the filename
* of this, by appending ".norm.wav" to the filename.
*/
- virtual std::string getNormalizedSoundfileName();
+ virtual std::string getNormalizedSoundfileName() const;
/**
* Returns a soundfile name for a CD audio track based on the filename
* of this, by appending ".cd.wav" to the filename.
*/
- virtual std::string getCdSoundfileName();
+ virtual std::string getCdSoundfileName() const;
/**
* Returns a soundfile name for an MP3 file based on the filename
* of this, by appending ".mp3" to the filename.
*/
- virtual std::string getMp3SoundfileName();
+ virtual std::string getMp3SoundfileName() const;
/**
* Returns a MIDI filename based on the filename
* of this, by appending ".mid" to the filename.
*/
- virtual std::string getMidiFilename();
+ virtual std::string getMidiFilename() const;
/**
* Returns a MusicXML filename based on the filename
* of this, by appending ".xml" to the filename.
*/
- virtual std::string getMusicXmlFilename();
+ virtual std::string getMusicXmlFilename() const;
/**
* Returns a MusicXML filename based on the filename
* of this, by appending ".fms" to the filename.
*/
- virtual std::string getFomusFilename();
+ virtual std::string getFomusFilename() const;
/**
* Returns a MusicXML filename based on the filename
* of this, by appending ".ly" to the filename.
*/
- virtual std::string getLilypondFilename();
+ virtual std::string getLilypondFilename() const;
/**
* Generate performance events and store them in the score.
* Must be overidden in derived classes.
*/
- virtual void generate();
+ virtual int generate();
/**
* Convenience function that calls clear(), generate(), perform().
*/
- virtual void render();
+ virtual int render();
/**
* Convenience function that calls clear(), generate(), performAll().
*/
- virtual void renderAll();
+ virtual int renderAll();
/**
* Performs the current score to create an output soundfile,
* which should be tagged with author, timestamp, copyright,
@@ -124,36 +127,36 @@ public:
* The default implementation does nothing.
* Must be overridden in derived classes.
*/
- virtual void perform();
+ virtual int perform();
/**
* Convenience function that calls saveMidi(), saveMusicXML(), and perform().
*/
- virtual void performMaster();
+ virtual int performMaster();
/**
- * Convenience function that calls rescaleOutputSoundfile(),
+ * Convenience function that calls rescaleOutputSoundfile(),
* translateToCdAudio(), and translateToMp3().
*/
- virtual void translateMaster();
+ virtual int translateMaster();
/**
* Convenience function that calls performMaster(),
* and translateMaster().
*/
- virtual void performAll();
+ virtual int performAll();
/**
* Assuming the score has been rendered,
* uses sox to translate the output soundfile to a normalized soundfile.
*/
- virtual void normalizeOutputSoundfile(double levelDb = -3.0);
+ virtual int normalizeOutputSoundfile(double levelDb = -3.0);
/**
* Assuming the score has been rendered,
* uses sox to translate the output soundfile to normalized CD-audio format.
*/
- virtual void translateToCdAudio(double levelDb = -3.0);
+ virtual int translateToCdAudio(double levelDb = -3.0);
/**
* Assuming the score has been rendered,
* uses sox and LAME to translate the output soundfile to normalized MP3 format.
*/
- virtual void translateToMp3(double bitrate = 256.01, double levelDb = -3.0);
+ virtual int translateToMp3(double bitrate = 256.01, double levelDb = -3.0);
/**
* Clear all contents of this. Probably should be overridden
* in derived classes.
@@ -193,12 +196,12 @@ public:
virtual bool getConformPitches() const;
/**
* Saves the generated score in Fomus format
- * and uses Fomus and Lilypond to translate that
+ * and uses Fomus and Lilypond to translate that
* to a PDF of music notation. A meter of 4/4
- * and a tempo of MM 120 is assumed.
+ * and a tempo of MM 120 is assumed.
* A vector of part names may be supplied.
*/
- virtual void translateToNotation(const std::vector<std::string> partNames = std::vector<std::string>(), std::string header = "");
+ virtual int translateToNotation(const std::vector<std::string> partNames = std::vector<std::string>(), std::string header = "");
virtual std::string getArtist() const;
virtual void setArtist(std::string value);
virtual std::string getTitle() const;
@@ -209,7 +212,26 @@ public:
virtual void setAlbum(std::string value);
virtual std::string getLicense() const;
virtual void setLicense(std::string value);
- protected:
+ virtual int tagFile(std::string filename) const;
+ /**
+ * Pass the invoking program's command-line arguments to processArgs()
+ * and it will perform with possibly back-end-dependent options.
+ * Default implementation calls the std::string overload.
+ */
+ virtual int processArgv(int argc, const char **argv);
+ /**
+ * Pass the invoking program's command-line arguments to processArgs()
+ * and it will perform with possibly back-end-dependent options.
+ * Additional arguments can be added to the args before the call.
+ * Default implementation calls renderAll().
+ */
+ virtual int processArgs(const std::vector<std::string> &args);
+ /**
+ * Sets a non-default output name (could be an audio device not a file).
+ */
+ virtual void setOutputSoundfileName(std::string name);
+ virtual void clearOutputSoundfileName();
+ protected:
Score score;
double tonesPerOctave;
bool conformPitches;
@@ -220,7 +242,7 @@ public:
std::string copyright;
std::string album;
std::string license;
-};
+ std::string outputFilename;
+ };
}
#endif
-
diff --git a/frontends/CsoundAC/Conversions.hpp b/frontends/CsoundAC/Conversions.hpp
index 72c48a1..d11b88f 100644
--- a/frontends/CsoundAC/Conversions.hpp
+++ b/frontends/CsoundAC/Conversions.hpp
@@ -55,7 +55,7 @@ namespace csound
* All loudness conversions are driven by sample word size, which must be set before use;
* the default is 4 (float samples).
*/
- class Conversions
+ class SILENCE_PUBLIC Conversions
{
static bool initialized_;
static std::map<std::string, double> pitchClassSetsForNames;
@@ -115,19 +115,19 @@ namespace csound
static int swapInt(int Source);
static short swapShort(short Source);
/**
- * Translate the string value to a boolean value,
+ * Translate the string value to a boolean value,
* returning the default if the string value is empty.
*/
static bool stringToBool(std::string value, bool default_=false);
static std::string boolToString(bool value);
/**
- * Translate the string value to an integer value,
+ * Translate the string value to an integer value,
* returning the default if the string value is empty.
*/
static int stringToInt(std::string value, int default_=0);
static std::string intToString(int value);
/**
- * Translate the string value to a double-precision value,
+ * Translate the string value to a double-precision value,
* returning the default if the string value is empty.
*/
static double stringToDouble(std::string value, double default_=0.0);
diff --git a/frontends/CsoundAC/Counterpoint.hpp b/frontends/CsoundAC/Counterpoint.hpp
index e8af5e8..4efab0c 100644
--- a/frontends/CsoundAC/Counterpoint.hpp
+++ b/frontends/CsoundAC/Counterpoint.hpp
@@ -73,7 +73,7 @@
using namespace boost::numeric;
#endif
-class Counterpoint
+class SILENCE_PUBLIC Counterpoint
{
public:
void (*messageCallback)(CSOUND *csound, int attribute, const char *format, va_list valist);
diff --git a/frontends/CsoundAC/CounterpointNode.hpp b/frontends/CsoundAC/CounterpointNode.hpp
index d9f3d97..52c99c4 100644
--- a/frontends/CsoundAC/CounterpointNode.hpp
+++ b/frontends/CsoundAC/CounterpointNode.hpp
@@ -49,7 +49,7 @@ namespace csound
* or (b) attempt to correct the voice leading for species 1, 2, or 3
* counterpoint in notes generated by child nodes.
*/
- class CounterpointNode :
+ class SILENCE_PUBLIC CounterpointNode :
public Node,
public Counterpoint
{
diff --git a/frontends/CsoundAC/Event.cpp b/frontends/CsoundAC/Event.cpp
index 974fee4..553f2bb 100644
--- a/frontends/CsoundAC/Event.cpp
+++ b/frontends/CsoundAC/Event.cpp
@@ -248,8 +248,8 @@ namespace csound
return (*this)[TIME] + (*this)[DURATION];
}
}
-
- void Event::setOffTime(double offTime)
+
+ void Event::setOffTime(double offTime)
{
setDuration(offTime - getTime());
}
diff --git a/frontends/CsoundAC/Event.hpp b/frontends/CsoundAC/Event.hpp
index 1f7b077..5a232f8 100644
--- a/frontends/CsoundAC/Event.hpp
+++ b/frontends/CsoundAC/Event.hpp
@@ -69,7 +69,7 @@ namespace csound
* but they are always real-time score statements at time 0, suitable
* for use with Csound's -L or line event option.
*/
- class Event :
+ class SILENCE_PUBLIC Event :
public ublas::vector<double>
{
public:
diff --git a/frontends/CsoundAC/Exception.hpp b/frontends/CsoundAC/Exception.hpp
index 02dfaf7..b96b9e8 100644
--- a/frontends/CsoundAC/Exception.hpp
+++ b/frontends/CsoundAC/Exception.hpp
@@ -34,7 +34,7 @@ namespace csound
/**
* Base class for C++ exceptions in the Silence system.
*/
- class Exception
+ class SILENCE_PUBLIC Exception
{
std::string message;
public:
diff --git a/frontends/CsoundAC/Hocket.hpp b/frontends/CsoundAC/Hocket.hpp
index dfd56b8..f746535 100644
--- a/frontends/CsoundAC/Hocket.hpp
+++ b/frontends/CsoundAC/Hocket.hpp
@@ -36,7 +36,7 @@ namespace csound
/**
* Simplifies constructing complex hocketted scores.
*/
- class Hocket :
+ class SILENCE_PUBLIC Hocket :
public ScoreNode
{
public:
diff --git a/frontends/CsoundAC/ImageToScore.hpp b/frontends/CsoundAC/ImageToScore.hpp
index 3c0fe74..775a399 100644
--- a/frontends/CsoundAC/ImageToScore.hpp
+++ b/frontends/CsoundAC/ImageToScore.hpp
@@ -39,7 +39,7 @@ namespace csound
* Translates images in various RGB formats to scores.
* Hue is mapped to instrument, value is mapped to loudness.
*/
- class ImageToScore : public ScoreNode
+ class SILENCE_PUBLIC ImageToScore : public ScoreNode
{
protected:
std::string imageFilename;
diff --git a/frontends/CsoundAC/Lindenmayer.hpp b/frontends/CsoundAC/Lindenmayer.hpp
index 5069a1c..9bc65d3 100644
--- a/frontends/CsoundAC/Lindenmayer.hpp
+++ b/frontends/CsoundAC/Lindenmayer.hpp
@@ -86,7 +86,7 @@ namespace csound
* <li>s = pitch-class set as Mason number</li>
* </ol>
*/
- class Lindenmayer :
+ class SILENCE_PUBLIC Lindenmayer :
public ScoreNode
{
protected:
diff --git a/frontends/CsoundAC/MCRM.hpp b/frontends/CsoundAC/MCRM.hpp
index 78cb065..42b05e7 100644
--- a/frontends/CsoundAC/MCRM.hpp
+++ b/frontends/CsoundAC/MCRM.hpp
@@ -34,7 +34,7 @@
namespace csound
{
- class MCRM :
+ class SILENCE_PUBLIC MCRM :
public ScoreNode
{
// Hutchinson operator.
diff --git a/frontends/CsoundAC/Midifile.cpp b/frontends/CsoundAC/Midifile.cpp
index e0259cd..4af33c1 100644
--- a/frontends/CsoundAC/Midifile.cpp
+++ b/frontends/CsoundAC/Midifile.cpp
@@ -381,7 +381,7 @@ namespace csound
}
return false;
}
-
+
bool MidiEvent::isNoteOff() const
{
if(getStatusNybble() == MidiFile::CHANNEL_NOTE_OFF) {
@@ -396,7 +396,7 @@ namespace csound
}
return false;
}
-
+
bool MidiEvent::matchesNoteOffEvent(const MidiEvent &offEvent) const
{
if(!isNoteOn()) {
diff --git a/frontends/CsoundAC/Midifile.hpp b/frontends/CsoundAC/Midifile.hpp
index c822198..cb8b870 100644
--- a/frontends/CsoundAC/Midifile.hpp
+++ b/frontends/CsoundAC/Midifile.hpp
@@ -48,9 +48,9 @@ namespace csound
{
typedef unsigned char csound_u_char;
- class MidiFile;
+ class SILENCE_PUBLIC MidiFile;
- class Chunk
+ class SILENCE_PUBLIC Chunk
{
public:
int id;
@@ -70,7 +70,7 @@ namespace csound
virtual void markChunkEnd(std::ostream &stream);
};
- class MidiHeader : public Chunk
+ class SILENCE_PUBLIC MidiHeader : public Chunk
{
public:
short type;
@@ -88,7 +88,7 @@ namespace csound
/**
* This class is used to store ALL Midi messages.
*/
- class MidiEvent : public std::vector<csound_u_char>
+ class SILENCE_PUBLIC MidiEvent : public std::vector<csound_u_char>
{
public:
int ticks;
@@ -116,7 +116,7 @@ namespace csound
friend bool operator < (const MidiEvent &a, const MidiEvent &b);
};
- class MidiTrack : public Chunk, public std::vector<MidiEvent>
+ class SILENCE_PUBLIC MidiTrack : public Chunk, public std::vector<MidiEvent>
{
public:
MidiTrack();
@@ -126,7 +126,7 @@ namespace csound
MidiTrack &operator = (const MidiTrack &a);
};
- class TempoMap : public std::map<int, double>
+ class SILENCE_PUBLIC TempoMap : public std::map<int, double>
{
public:
double getCurrentSecondsPerTick(int tick);
@@ -135,7 +135,7 @@ namespace csound
/**
* Reads and writes format 0 and format 1 standard MIDI files.
*/
- class MidiFile
+ class SILENCE_PUBLIC MidiFile
{
public:
typedef enum {
@@ -236,9 +236,9 @@ namespace csound
virtual void dump(std::ostream &stream);
};
- bool operator < (const MidiEvent &a, const MidiEvent &b);
+ bool SILENCE_PUBLIC operator < (const MidiEvent &a, const MidiEvent &b);
- struct MidiEventComparator
+ struct SILENCE_PUBLIC MidiEventComparator
{
bool operator()(const MidiEvent &a, const MidiEvent &b)
{
diff --git a/frontends/CsoundAC/MusicModel.cpp b/frontends/CsoundAC/MusicModel.cpp
index d859f10..f6b28cf 100644
--- a/frontends/CsoundAC/MusicModel.cpp
+++ b/frontends/CsoundAC/MusicModel.cpp
@@ -21,6 +21,8 @@
#include "Exception.hpp"
#include "Composition.hpp"
#include "System.hpp"
+#include <cstdio>
+#include <cstdlib>
namespace csound
{
@@ -38,20 +40,26 @@ namespace csound
{
}
- void MusicModel::generate()
+ int MusicModel::generate()
{
+ int errorStatus = 0;
cppSound->removeScore();
if (children.size()) {
score.clear();
}
traverse(getLocalCoordinates(), score);
System::message("Generated %d events.\n", score.size());
+ return errorStatus;
}
- void MusicModel::render()
+ int MusicModel::render()
{
- generate();
- perform();
+ int errorStatus = generate();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ errorStatus = perform();
+ return errorStatus;
}
void MusicModel::createCsoundScore(std::string addToScore, double extendSeconds)
@@ -65,15 +73,24 @@ namespace csound
char buffer[0x100];
std::sprintf(buffer, "\ns %9.3f", extendSeconds);
cppSound->addScoreLine(buffer);
- std::sprintf(buffer, "\ne %9.3f", extendSeconds);
- cppSound->addScoreLine(buffer);
+ //std::sprintf(buffer, "\ne %9.3f", extendSeconds);
+ //cppSound->addScoreLine(buffer);
cppSound->exportForPerformance();
}
- void MusicModel::perform()
+ int MusicModel::perform()
{
+ int errorStatus = 0;
+ cppSound->setCommand(getCsoundCommand());
createCsoundScore(csoundScoreHeader);
- cppSound->perform();
+ errorStatus = cppSound->perform();
+ if (errorStatus == 1) {
+ errorStatus = 0;
+ }
+ // The Csound command is managed from MusicModel,
+ // not from CppSound. So we clear out what we set.
+ cppSound->setCommand("");
+ return errorStatus;
}
void MusicModel::clear()
@@ -126,16 +143,16 @@ namespace csound
}
void MusicModel::arrange(int oldInstrumentNumber,
- int newInstrumentNumber,
- double gain)
+ int newInstrumentNumber,
+ double gain)
{
score.arrange(oldInstrumentNumber, newInstrumentNumber, gain);
}
void MusicModel::arrange(int oldInstrumentNumber,
- int newInstrumentNumber,
- double gain,
- double pan)
+ int newInstrumentNumber,
+ double gain,
+ double pan)
{
score.arrange(oldInstrumentNumber, newInstrumentNumber, gain, pan);
}
@@ -150,7 +167,7 @@ namespace csound
{
int csoundInstrumentNumber = cppSound->getInstrumentNumber(csoundInstrumentName);
arrange(silenceInstrumentNumber, csoundInstrumentNumber, gain);
- }
+ }
void MusicModel::arrange(int silenceInstrumentNumber, std::string csoundInstrumentName, double gain, double pan)
{
@@ -170,7 +187,23 @@ namespace csound
std::string MusicModel::getCsoundCommand() const
{
- return cppSound->getCommand();
+ std::string command_ = cppSound->getCommand();
+ if (command_.size() == 0)
+ {
+ const char *temp_path = std::getenv("TEMP");
+ if (temp_path == 0)
+ {
+ temp_path = "";
+ }
+ std::string orcname = std::tmpnam(0);
+ std::string sconame = std::tmpnam(0);
+ char buffer[0x200];
+ std::sprintf(buffer,
+ "csound --midi-key=4 --midi-velocity=5 -m167 -RWdfo %s %s%s.orc %s%s.sco",
+ getOutputSoundfileName().c_str(), temp_path, orcname.c_str(), temp_path, sconame.c_str());
+ command_ = buffer;
+ }
+ return command_;
}
long MusicModel::getThis()
@@ -183,5 +216,80 @@ namespace csound
return (Node *)this;
}
-}
+ int MusicModel::processArgs(const std::vector<std::string> &args)
+ {
+ System::inform("BEGAN MusicModel::processArgv()...\n");
+ std::map<std::string, std::string> argsmap;
+ std::string key;
+ for (size_t i = 0, n = args.size(); i < n; ++i)
+ {
+ const std::string token = args[i];
+ std::string value = "";
+ if (token.find("--") == 0)
+ {
+ key = token;
+ }
+ else
+ {
+ value = token;
+ }
+ argsmap[key] = value;
+ System::inform("argument[%2d]: %s = %s\n", i, key.c_str(), value.c_str());
+ }
+ char command[0x200];
+ int errorStatus = 0;
+ bool postPossible = false;
+ std::string playSoundfileName = getOutputSoundfileName();
+ if ((argsmap.find("--midi") != argsmap.end()) && !errorStatus)
+ {
+ errorStatus = generate();
+ if (errorStatus) {
+ return errorStatus;
+ }
+ getScore().save(getMidiFilename().c_str());
+ }
+ if ((argsmap.find("--csound") != argsmap.end()) && !errorStatus)
+ {
+ postPossible = true;
+ errorStatus = render();
+ }
+ if ((argsmap.find("--pianoteq") != argsmap.end()) && !errorStatus)
+ {
+ std::sprintf(command, "Pianoteq --midi %s\n", getMidiFilename().c_str());
+ System::inform("Executing command: %s", command);
+ errorStatus = std::system(command);
+ }
+ if ((argsmap.find("--pianoteq-wav") != argsmap.end()) && !errorStatus)
+ {
+ postPossible = true;
+ std::sprintf(command, "Pianoteq --headless --midi %s --rate 48000 --wav %s\n", getMidiFilename().c_str(), getOutputSoundfileName().c_str());
+ System::inform("Executing command: %s", command);
+ errorStatus = std::system(command);
+ }
+ if ((argsmap.find("--playmidi") != argsmap.end()) && !errorStatus)
+ {
+ std::sprintf(command, "%s %s\n", argsmap["--playmidi"].c_str(), getMidiFilename().c_str());
+ System::inform("Executing command: %s", command);
+ errorStatus = std::system(command);
+ }
+ if ((argsmap.find("--post") != argsmap.end()) && !errorStatus && postPossible)
+ {
+ errorStatus = translateMaster();
+ playSoundfileName = getNormalizedSoundfileName();
+ }
+ if ((argsmap.find("--playwav") != argsmap.end()) && !errorStatus)
+ {
+ std::sprintf(command, "%s %s\n", argsmap["--playwav"].c_str(), playSoundfileName.c_str());
+ System::inform("Executing command: %s", command);
+ errorStatus = std::system(command);
+ }
+ System::inform("ENDED MusicModel::processArgv().\n");
+ return errorStatus;
+ }
+ void MusicModel::stop()
+ {
+ std::cout << "MusicModel::stop()..." << std::endl;
+ cppSound->stop();
+ }
+}
diff --git a/frontends/CsoundAC/MusicModel.hpp b/frontends/CsoundAC/MusicModel.hpp
index d020abf..abd8384 100644
--- a/frontends/CsoundAC/MusicModel.hpp
+++ b/frontends/CsoundAC/MusicModel.hpp
@@ -43,14 +43,14 @@ namespace csound
* A ScoreModel that uses Csound to render generated scores,
* via the CppSound class.
*/
- class MusicModel :
+ class SILENCE_PUBLIC MusicModel :
public ScoreModel
{
public:
MusicModel();
virtual ~MusicModel();
virtual void initialize();
- virtual void generate();
+ virtual int generate();
virtual long getThis();
virtual Node *getThisNode();
/**
@@ -65,11 +65,12 @@ namespace csound
* appends optional text to it,
* invokes generate(), invokes createCsoundScore(), and invokes perform().
*/
- virtual void render();
+ virtual int render();
+ virtual void stop();
/**
* Uses csound to perform the current score.
*/
- virtual void perform();
+ virtual int perform();
/**
* Clear all contents of this.
*/
@@ -157,6 +158,22 @@ namespace csound
* (convenience wrapper for CppSound::getCommand()).
*/
virtual std::string getCsoundCommand() const;
+ /**
+ * Pass the invoking program's command-line arguments to processArgs()
+ * and it will perform the following commands:
+ *
+ * --csound Render generated score using set Csound orchestra.
+ * --midi Render generated score as MIDI file and play it (default).
+ * --pianoteq Play generated MIDI sequence file with Pianoteq.
+ * --pianoteq-wav Render score to soundfile using Pianoteq,
+ * post-process it, and play it.
+ * --playmidi Play generated MIDI filev
+ * post-process it, and play it.
+ * --playwav Play rendered or normalized output soundfile.
+ * --post Post-process Csound output soundfile:
+ * normalize, CD, MP3, tag, and play it.
+ */
+ virtual int processArgs(const std::vector<std::string> &args);
protected:
/**
* Self-contained Csound object.
diff --git a/frontends/CsoundAC/Node.hpp b/frontends/CsoundAC/Node.hpp
index 610cb3c..293df60 100644
--- a/frontends/CsoundAC/Node.hpp
+++ b/frontends/CsoundAC/Node.hpp
@@ -45,7 +45,7 @@ namespace csound
* Nodes can transform silence::Events produced by child nodes.
* Nodes can produce silence::Events.
*/
- class Node
+ class SILENCE_PUBLIC Node
{
protected:
ublas::matrix<double> localCoordinates;
@@ -69,8 +69,8 @@ namespace csound
Score &score);
/**
* The default implementation does nothing.
- * Derived nodes that produce notes from scratch should
- * transform them using the composite transformation of
+ * Derived nodes that produce notes from scratch should
+ * transform them using the composite transformation of
* coordinate system, which is passed in from the traverse() function.
*/
virtual void produceOrTransform(Score &score,
@@ -84,19 +84,18 @@ namespace csound
virtual void addChild(Node *node);
};
typedef Node* NodePtr;
-
+
/**
* Removes all duplicate events produced by the child nodes of this.
*/
- class RemoveDuplicates : public Node
+ class SILENCE_PUBLIC RemoveDuplicates : public Node
{
public:
virtual void produceOrTransform(Score &score,
size_t beginAt,
size_t endAt,
const ublas::matrix<double> &compositeCordinates);
-
+
};
}
#endif
-
diff --git a/frontends/CsoundAC/OrchestraNode.hpp b/frontends/CsoundAC/OrchestraNode.hpp
index 2af1aa0..bd2a53f 100644
--- a/frontends/CsoundAC/OrchestraNode.hpp
+++ b/frontends/CsoundAC/OrchestraNode.hpp
@@ -5,7 +5,7 @@ class Timebase;
class Event;
class Audio;
-class OrchestraNode
+class SILENCE_PUBLIC OrchestraNode
{
public:
OrchestraNode();
diff --git a/frontends/CsoundAC/Random.cpp b/frontends/CsoundAC/Random.cpp
index aedf1de..e59d70c 100644
--- a/frontends/CsoundAC/Random.cpp
+++ b/frontends/CsoundAC/Random.cpp
@@ -126,9 +126,9 @@ namespace csound
}
return transformation;
}
- void Random::produceOrTransform(Score &score,
- size_t beginAt,
- size_t endAt,
+ void Random::produceOrTransform(Score &score,
+ size_t beginAt,
+ size_t endAt,
const ublas::matrix<double> &compositeCoordinates)
{
createDistribution(distribution);
@@ -149,7 +149,7 @@ namespace csound
}
score.push_back(transformedEvent);
}
- // Apply the global transformation of coordinate system
+ // Apply the global transformation of coordinate system
// to all child events produced by this node.
size_t finalEndAt = score.size();
for (size_t i = endAt; i < finalEndAt; i++) {
@@ -170,4 +170,3 @@ namespace csound
mersenneTwister.seed((unsigned int) s);
}
}
-
diff --git a/frontends/CsoundAC/Random.hpp b/frontends/CsoundAC/Random.hpp
index 6cfa749..28ff3e3 100644
--- a/frontends/CsoundAC/Random.hpp
+++ b/frontends/CsoundAC/Random.hpp
@@ -47,7 +47,7 @@ namespace csound
* for each of eventCount samples,
* which will be transformed by the newly sampled local coordinates.
*/
- class Random :
+ class SILENCE_PUBLIC Random :
public Node
{
protected:
@@ -85,7 +85,7 @@ namespace csound
virtual double sample() const;
virtual ublas::matrix<double> getRandomCoordinates() const;
virtual void createDistribution(std::string distribution);
- virtual void produceOrTransform(Score &score, size_t beginAt, size_t endAt,
+ virtual void produceOrTransform(Score &score, size_t beginAt, size_t endAt,
const ublas::matrix<double> &compositeCoordinates);
static void seed(int s);
};
diff --git a/frontends/CsoundAC/Rescale.cpp b/frontends/CsoundAC/Rescale.cpp
index a54cab7..fa2fff0 100644
--- a/frontends/CsoundAC/Rescale.cpp
+++ b/frontends/CsoundAC/Rescale.cpp
@@ -57,13 +57,13 @@ namespace csound
{
for(int i = 0; i < Event::ELEMENT_COUNT; i++)
{
- score_.setScale(score_,
- i,
- score.rescaleMinima[i],
- score.rescaleRanges[i],
- beginAt,
- endAt,
- score.scaleTargetMinima[i],
+ score_.setScale(score_,
+ i,
+ score.rescaleMinima[i],
+ score.rescaleRanges[i],
+ beginAt,
+ endAt,
+ score.scaleTargetMinima[i],
score.scaleTargetRanges[i]);
}
}
diff --git a/frontends/CsoundAC/Rescale.hpp b/frontends/CsoundAC/Rescale.hpp
index d609b1f..63a03f6 100644
--- a/frontends/CsoundAC/Rescale.hpp
+++ b/frontends/CsoundAC/Rescale.hpp
@@ -38,7 +38,7 @@ namespace csound
* No, some, or all dimensions may be rescaled to fit the minimum alone,
* the range alone, or both the minimum and the range.
*/
- class Rescale :
+ class SILENCE_PUBLIC Rescale :
public ScoreNode
{
static bool initialized;
diff --git a/frontends/CsoundAC/Score.cpp b/frontends/CsoundAC/Score.cpp
index e1a44f6..f7d873e 100644
--- a/frontends/CsoundAC/Score.cpp
+++ b/frontends/CsoundAC/Score.cpp
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "CppSound.hpp"
-#include "Midifile.hpp"
+// #include "Midifile.hpp"
#include "Score.hpp"
#include "System.hpp"
#include "Conversions.hpp"
@@ -32,6 +32,8 @@
#include <fstream>
#include <sstream>
+#include <allegro.h>
+
#if defined(HAVE_MUSICXML2)
#if defined(EXP)
#undef EXP
@@ -50,7 +52,7 @@ using namespace MusicXML2;
namespace csound
{
-void printChord(std::ostream &stream, std::string label, const std::vector<double> &chord)
+void SILENCE_PUBLIC printChord(std::ostream &stream, std::string label, const std::vector<double> &chord)
{
if (!( (System::getMessageLevel() & System::INFORMATION_LEVEL) == System::INFORMATION_LEVEL) ) {
return;
@@ -65,7 +67,7 @@ void printChord(std::ostream &stream, std::string label, const std::vector<doubl
stream << "]" << std::endl;
}
-void printChord(std::string label, const std::vector<double> &chord)
+void SILENCE_PUBLIC printChord(std::string label, const std::vector<double> &chord)
{
if (!( (System::getMessageLevel() & System::INFORMATION_LEVEL) == System::INFORMATION_LEVEL) ) {
return;
@@ -172,9 +174,25 @@ void Score::load(std::string filename)
void Score::load(std::istream &stream)
{
- MidiFile midiFile;
- midiFile.read(stream);
- load(midiFile);
+ Alg_seq seq(stream, true);
+ seq.convert_to_seconds();
+ Alg_iterator iterator(&seq, false);
+ iterator.begin();
+ for(;;) {
+ Alg_event *event = iterator.next();
+ if (!event) {
+ break;
+ }
+ append(event->get_start_time(),
+ event->get_duration(),
+ double(144),
+ double(event->chan),
+ event->get_pitch(),
+ event->get_loud());
+ }
+ // MidiFile midiFile;
+ // midiFile.read(stream);
+ // load(midiFile);
}
#if defined(HAVE_MUSICXML2)
@@ -299,7 +317,7 @@ void Score::save(std::string filename)
System::inform("BEGAN Score::save(%s)...\n", filename.c_str());
std::ofstream stream;
//stream.open(filename.c_str(), std::ios_base::binary);
- stream.open(filename.c_str(), std::ifstream::binary);
+ stream.open(filename.c_str(), std::ios::out | std::ios::binary);
if (filename.find(".mid") != std::string::npos ||
filename.find(".MID") != std::string::npos) {
save(stream);
@@ -333,8 +351,32 @@ void Score::save(std::string filename)
void Score::save(std::ostream &stream)
{
- save(midifile);
- midifile.write(stream);
+ Alg_seq seq;
+ for (size_t i = 0, n = size(); i < n; ++i) {
+ const Event &event = at(i);
+ if (event.isNoteOn()) {
+ int channel = event.getChannel();
+ double time = event.getTime();
+ double duration = event.getDuration();
+ float pitch = event.getKey();
+ float loudness = event.getVelocity();
+ int identifier = i;
+ Alg_note *note = seq.create_note(time,
+ channel,
+ pitch,
+ pitch,
+ loudness,
+ duration);
+ // Does nothing if the track already exists.
+ seq.add_track(channel);
+ seq.add_event(note, channel);
+ }
+ }
+ // Write with time in seconds.
+ seq.write(std::cout, true);
+ seq.smf_write(stream);
+ // save(midifile);
+ // midifile.write(stream);
}
static double max(double a, double b)
@@ -470,7 +512,7 @@ void Score::rescale(Event &event)
}
}
}
-
+/*
void Score::load(MidiFile &midiFile)
{
std::vector<Event>::clear();
@@ -504,7 +546,9 @@ void Score::load(MidiFile &midiFile)
findScale();
sort();
}
+*/
+/*
void Score::save(MidiFile &midiFile)
{
findScale();
@@ -555,6 +599,7 @@ void Score::save(MidiFile &midiFile)
}
midiFile.midiHeader.trackCount = midiFile.midiTracks.size();
}
+ */
void Score::dump(std::ostream &stream)
{
@@ -1279,4 +1324,38 @@ void Score::remove(size_t index)
{
erase(begin() + index);
}
+void Score::tieOverlappingNotes(bool considerInstrumentNumber)
+{
+ sort();
+ for (int laterI = size() - 1; laterI > 1; --laterI) {
+ Event &laterEvent = (*this)[laterI];
+ for (int earlierI = laterI - 1; earlierI > 0; --earlierI) {
+ Event &earlierEvent = (*this)[earlierI];
+ if (earlierEvent.getKeyNumber() != laterEvent.getKeyNumber()) {
+ continue;
+ }
+ if (earlierEvent.getVelocity() <= 0.0 || laterEvent.getVelocity() <= 0.0) {
+ continue;
+ }
+ if (earlierEvent.getOffTime() < laterEvent.getTime()) {
+ continue;
+ }
+ if (considerInstrumentNumber && (earlierEvent.getChannel() != laterEvent.getChannel())) {
+ continue;
+ }
+ // Ok, must be tied.
+ earlierEvent.setOffTime(laterEvent.getOffTime());
+ erase(begin() + laterI);
+ break;
+ }
+ }
+}
+
+void Score::temper(double tonesPerOctave)
+{
+ for (size_t i = 0, n = size(); i < n; ++i) {
+ (*this)[i].temper(tonesPerOctave);
+ }
}
+}
+
diff --git a/frontends/CsoundAC/Score.hpp b/frontends/CsoundAC/Score.hpp
index 2f43f92..23da8df 100644
--- a/frontends/CsoundAC/Score.hpp
+++ b/frontends/CsoundAC/Score.hpp
@@ -24,7 +24,7 @@
%module CsoundAC
%{
#include "Event.hpp"
-#include "Midifile.hpp"
+ // #include "Midifile.hpp"
#include <iostream>
#include <vector>
%}
@@ -32,7 +32,7 @@
%include "std_vector.i"
#else
#include "Event.hpp"
-#include "Midifile.hpp"
+ // #include "Midifile.hpp"
#include <iostream>
#include <vector>
#endif
@@ -46,7 +46,7 @@ namespace csound
* The implementation is a std::vector of Events.
* The elements of the vector are value objects, not references.
*/
- class Score :
+ class SILENCE_PUBLIC Score :
public std::vector<csound::Event>
{
protected:
@@ -75,10 +75,10 @@ namespace csound
*/
virtual void load(std::string filename);
virtual void load(std::istream &stream);
- virtual void load(MidiFile &midiFile);
+ //virtual void load(MidiFile &midiFile);
/**
* Save as a MIDI file, format 1 (.mid) file,
- * or as a partwise MusicXML (.xml) file,
+ * or as a partwise MusicXML (.xml) file,
* or as a Fomus music notation (.fms) file.
* Only sounding data is saved.
*/
@@ -90,7 +90,7 @@ namespace csound
/**
* Save as a MIDI file, format 1.
*/
- virtual void save(MidiFile &midiFile);
+ //virtual void save(MidiFile &midiFile);
static void getScale(std::vector<Event> &score, int dimension, size_t beginAt, size_t endAt, double &minimum, double &range);
static void setScale(std::vector<Event> &score, int dimension, bool rescaleMinimum, bool rescaleRange, size_t beginAt, size_t endAt, double targetMinimum, double targetRange);
virtual void findScale();
@@ -294,24 +294,24 @@ namespace csound
*/
virtual void setVoicing(size_t begin, size_t end, const std::vector<double> &voicing, double range, size_t divisionsPerOctave = 12);
/**
- * Find the non-unique pitch-class set of the prior segment;
- * invert the set such that the inversion's first two pitch-classes
+ * Find the non-unique pitch-class set of the prior segment;
+ * invert the set such that the inversion's first two pitch-classes
* are exchanged from the origina; conform the pitches of the
* current segment to that inversion.
*/
virtual void setK(size_t priorBegin, size_t begin, size_t end, double base, double range);
/**
- * Find the non-unique pitch-class set of the prior segment;
- * invert the set such that the inversion's first two pitch-classes
- * are exchanged from the original; conform the pitches of the
+ * Find the non-unique pitch-class set of the prior segment;
+ * invert the set such that the inversion's first two pitch-classes
+ * are exchanged from the original; conform the pitches of the
* current segment to that inversion, with voicing V.
*/
virtual void setKV(size_t priorBegin, size_t begin, size_t end, double V, double base, double range);
/**
- * Find the non-unique pitch-class set of the prior segment;
- * invert the set such that the inversion's first two pitch-classes
- * are exchanged from the original; conform the pitches of the
- * current segment to that inversion, using the closest voice-leading
+ * Find the non-unique pitch-class set of the prior segment;
+ * invert the set such that the inversion's first two pitch-classes
+ * are exchanged from the original; conform the pitches of the
+ * current segment to that inversion, using the closest voice-leading
* from the pitches of the prior segment, optionally avoiding parallel fifths.
*/
virtual void setKL(size_t priorBegin, size_t begin, size_t end, double base, double range, bool avoidParallels = true);
@@ -332,7 +332,7 @@ namespace csound
/**
* Find the non-unique pitch-class set of the prior segment; transpose the set up by Q
* if the set is a T-form of the context, or down by Q if the set is an I-form of the context;
- * then conform the pitches of the segment to that set, using the closest voice-leading
+ * then conform the pitches of the segment to that set, using the closest voice-leading
* from the pitches of the prior segment, optionally avoiding parallel fifths.
* The context will be reduced or doubled as required to match the cardinality of the set.
*/
@@ -342,6 +342,17 @@ namespace csound
* stretch or shrink musical time.
*/
virtual void setDuration(double targetDuration);
+ /**
+ * If the score contains two notes of the same pitch
+ * and loudness greater than 0 that overlap in time,
+ * extend the earlier note and discard the later note.
+ */
+ virtual void tieOverlappingNotes(bool considerInstrumentNumber = false);
+ /**
+ * Confirm pitches in this score to the closest pitch in the indicated
+ * system of equal temperament.
+ */
+ virtual void temper(double tonesPerOctave = 12.0);
};
}
#endif
diff --git a/frontends/CsoundAC/ScoreModel.cpp b/frontends/CsoundAC/ScoreModel.cpp
index 430cc19..b7b07fd 100644
--- a/frontends/CsoundAC/ScoreModel.cpp
+++ b/frontends/CsoundAC/ScoreModel.cpp
@@ -37,13 +37,14 @@ namespace csound
{
}
- void ScoreModel::generate()
+ int ScoreModel::generate()
{
if (children.size()) {
score.clear();
}
traverse(getLocalCoordinates(), score);
System::message("Generated %d events.\n", score.size());
+ return 0;
}
void ScoreModel::clear()
diff --git a/frontends/CsoundAC/ScoreModel.hpp b/frontends/CsoundAC/ScoreModel.hpp
index d9c964d..f49e9e2 100644
--- a/frontends/CsoundAC/ScoreModel.hpp
+++ b/frontends/CsoundAC/ScoreModel.hpp
@@ -49,7 +49,7 @@ namespace csound {
* with the coordinate system of its parent to derive a new local coordinate system,
* which is applied to all child events.
*/
-class ScoreModel :
+class SILENCE_PUBLIC ScoreModel :
public Composition,
public Node {
public:
@@ -60,7 +60,7 @@ public:
* Generates a score based on a music graph defined
* by the child nodes of this.
*/
- virtual void generate();
+ virtual int generate();
/**
* Clears the score.
*/
diff --git a/frontends/CsoundAC/ScoreNode.cpp b/frontends/CsoundAC/ScoreNode.cpp
index 58d522c..45ef7c1 100644
--- a/frontends/CsoundAC/ScoreNode.cpp
+++ b/frontends/CsoundAC/ScoreNode.cpp
@@ -29,9 +29,9 @@ namespace csound
{
}
- void ScoreNode::produceOrTransform(Score &score_,
- size_t beginAt,
- size_t endAt,
+ void ScoreNode::produceOrTransform(Score &score_,
+ size_t beginAt,
+ size_t endAt,
const ublas::matrix<double> &compositeCoordinates)
{
if(importFilename.length() > 0)
@@ -44,7 +44,7 @@ namespace csound
const Event &event = *it;
score_.push_back(event);
}
- // Apply the global transformation of coordinate system
+ // Apply the global transformation of coordinate system
// to all child events produced by this node.
size_t finalEndAt = score_.size();
for (size_t i = endAt; i < finalEndAt; i++) {
diff --git a/frontends/CsoundAC/ScoreNode.hpp b/frontends/CsoundAC/ScoreNode.hpp
index dc264ba..4f45684 100644
--- a/frontends/CsoundAC/ScoreNode.hpp
+++ b/frontends/CsoundAC/ScoreNode.hpp
@@ -39,7 +39,7 @@ namespace csound
* Node class that produces events from the contained score,
* which can be built up programmatically or imported from a standard MIDI file.
*/
- class ScoreNode :
+ class SILENCE_PUBLIC ScoreNode :
public Node
{
protected:
diff --git a/frontends/CsoundAC/Sequence.hpp b/frontends/CsoundAC/Sequence.hpp
index 459aae9..fc01bea 100644
--- a/frontends/CsoundAC/Sequence.hpp
+++ b/frontends/CsoundAC/Sequence.hpp
@@ -36,7 +36,7 @@ namespace csound
/**
* Node that creates a temporal sequence of child nodes.
*/
- class Sequence :
+ class SILENCE_PUBLIC Sequence :
public Node
{
public:
diff --git a/frontends/CsoundAC/Shell.hpp b/frontends/CsoundAC/Shell.hpp
index 7bdde47..6bf54c5 100644
--- a/frontends/CsoundAC/Shell.hpp
+++ b/frontends/CsoundAC/Shell.hpp
@@ -54,7 +54,7 @@ namespace csound
* so if Python is not present, this module
* will still link and load, but not function.
*/
- class Shell
+ class SILENCE_PUBLIC Shell
{
protected:
static void *pythonLibrary;
diff --git a/frontends/CsoundAC/Silence.hpp b/frontends/CsoundAC/Silence.hpp
index f40f779..9566bf3 100644
--- a/frontends/CsoundAC/Silence.hpp
+++ b/frontends/CsoundAC/Silence.hpp
@@ -21,20 +21,20 @@
#define SILENCE_H
/** \namespace csound
- * The csound namespace contains classes for doing algorithmic composition,
- * and for rendering audio from algorithmically generated scores,
- * especially using Csound.
+ * The csound namespace contains classes for doing algorithmic composition,
+ * and for rendering audio from algorithmically generated scores,
+ * especially using Csound.
*
* There should be one header file for each class declared in CsoundAC,
* and that header file should be #included in Silence.hpp.
- *
+ *
* SWIG is run on Silence.hpp to generate wrappers for all CsoundAC classes
* in other languages, especially scripting languages such as Python,
* Therefore, all framework headers must be included in this header,
* and all framework headers must use #ifdef SWIG to declare
* the module and make other SWIG declarations (see Node.h for an extensive example).
* The order of declaration is important to SWIG!
- *
+ *
* It is also expected that doxygen will be used to generate documentation
* from comments in the framework header files.
*/
@@ -87,4 +87,3 @@
#include "ChordLindenmayer.hpp"
#endif
-
diff --git a/frontends/CsoundAC/Soundfile.hpp b/frontends/CsoundAC/Soundfile.hpp
index 0e024a3..e960d94 100644
--- a/frontends/CsoundAC/Soundfile.hpp
+++ b/frontends/CsoundAC/Soundfile.hpp
@@ -83,7 +83,7 @@ namespace csound
* See http://www.mega-nerd.com/libsndfile for more information
* on the underlying libsndfile library.
*/
- class Soundfile
+ class SILENCE_PUBLIC Soundfile
{
SNDFILE *sndfile;
SF_INFO sf_info;
diff --git a/frontends/CsoundAC/StrangeAttractor.hpp b/frontends/CsoundAC/StrangeAttractor.hpp
index 3ea6301..8c37465 100644
--- a/frontends/CsoundAC/StrangeAttractor.hpp
+++ b/frontends/CsoundAC/StrangeAttractor.hpp
@@ -52,7 +52,7 @@ namespace csound
* as the order of iteration, or as a dimension of the attractor.
* See Julien C. Sprott's book "Strange Attractors".
*/
- class StrangeAttractor :
+ class SILENCE_PUBLIC StrangeAttractor :
public ScoreNode
{
protected:
diff --git a/frontends/CsoundAC/System.hpp b/frontends/CsoundAC/System.hpp
index c06f0b8..5352277 100644
--- a/frontends/CsoundAC/System.hpp
+++ b/frontends/CsoundAC/System.hpp
@@ -40,7 +40,7 @@
namespace csound
{
- class Logger
+ class SILENCE_PUBLIC Logger
{
public:
Logger();
@@ -53,7 +53,7 @@ namespace csound
/**
* Abstraction layer for a minimal set of system services.
*/
- class System
+ class SILENCE_PUBLIC System
{
static void *userdata_;
static int messageLevel;
diff --git a/frontends/CsoundAC/Voicelead.cpp b/frontends/CsoundAC/Voicelead.cpp
index 5399fd9..93e5507 100644
--- a/frontends/CsoundAC/Voicelead.cpp
+++ b/frontends/CsoundAC/Voicelead.cpp
@@ -299,7 +299,7 @@ namespace csound
double pc_ = pc(chord[i]);
if (std::find(uniquepcs.begin(), uniquepcs.end(), pc_) == uniquepcs.end()) {
uniquepcs.push_back(pc_);
- }
+ }
}
sort(uniquepcs);
return uniquepcs;
@@ -770,10 +770,10 @@ namespace csound
return result;
}
- bool Voicelead::addOctave(const std::vector<double>
- &lowestVoicing,
- std::vector<double> &newVoicing,
- size_t maximumPitch,
+ bool Voicelead::addOctave(const std::vector<double>
+ &lowestVoicing,
+ std::vector<double> &newVoicing,
+ size_t maximumPitch,
size_t divisionsPerOctave)
{
for (size_t voice = 0, voices = lowestVoicing.size(); voice < voices; voice++) {
diff --git a/frontends/CsoundAC/Voicelead.hpp b/frontends/CsoundAC/Voicelead.hpp
index 320c2b5..c67a042 100644
--- a/frontends/CsoundAC/Voicelead.hpp
+++ b/frontends/CsoundAC/Voicelead.hpp
@@ -46,7 +46,7 @@ namespace csound
*
* See: http://ruccas.org/pub/Gogins/music_atoms.pdf
*/
- class Voicelead
+ class SILENCE_PUBLIC Voicelead
{
public:
/**
@@ -434,19 +434,19 @@ namespace csound
static std::vector<double> K(const std::vector<double> &c);
/**
- * Return whether chord Y is a transposed form of chord X; g is the generator of
+ * Return whether chord Y is a transposed form of chord X; g is the generator of
* transpositions.
*/
static bool Tform(const std::vector<double> &X, const std::vector<double> &Y, double g=1.0);
/**
- * Return whether chord Y is an inverted form of chord X; g is the generator of
+ * Return whether chord Y is an inverted form of chord X; g is the generator of
* inversions.
*/
static bool Iform(const std::vector<double> &X, const std::vector<double> &Y, double g=1.0);
/**
- * Contextually transpose chord c with respect to chord s by n semitones; g is the generator of
+ * Contextually transpose chord c with respect to chord s by n semitones; g is the generator of
* transpositions.
*/
static std::vector<double> Q(const std::vector<double> &c, double n, const std::vector<double> &s, double g=1.0);
@@ -458,4 +458,3 @@ namespace csound
};
}
#endif
-
diff --git a/frontends/CsoundAC/VoiceleadingNode.cpp b/frontends/CsoundAC/VoiceleadingNode.cpp
index e26500b..a2c2ad3 100644
--- a/frontends/CsoundAC/VoiceleadingNode.cpp
+++ b/frontends/CsoundAC/VoiceleadingNode.cpp
@@ -28,9 +28,9 @@
namespace csound
{
- extern void printChord(std::ostream &stream, std::string label, const std::vector<double> &chord);
+ extern void SILENCE_PUBLIC printChord(std::ostream &stream, std::string label, const std::vector<double> &chord);
- extern void printChord(std::string label, const std::vector<double> &chord);
+ extern void SILENCE_PUBLIC printChord(std::string label, const std::vector<double> &chord);
/**
* Utility class for storing voice-leading operations.
@@ -153,7 +153,7 @@ namespace csound
modality,
base,
range);
- } else if ((operation.V != DBL_MAX) && (!operation.L)) {
+ } else if ((operation.V != DBL_MAX) && (!operation.L)) {
System::inform("Operation: QV\n");
score.setQV(priorOperation.begin,
operation.begin,
@@ -394,13 +394,13 @@ namespace csound
operations[time].avoidParallels = avoidParallels;
}
- void VoiceleadingNode::produceOrTransform(Score &score,
- size_t beginAt,
- size_t endAt,
+ void VoiceleadingNode::produceOrTransform(Score &score,
+ size_t beginAt,
+ size_t endAt,
const ublas::matrix<double> &compositeCoordinates)
{
transform(score, rescaleTimes);
- // Apply the global transformation of coordinate system
+ // Apply the global transformation of coordinate system
// to all child events produced by this node.
size_t finalEndAt = score.size();
for (size_t i = endAt; i < finalEndAt; i++) {
@@ -428,7 +428,7 @@ namespace csound
}
ops.push_back(&it->second);
}
-
+
if (rescaleTimes_) {
if (operationMaxTime > 0.0) {
timeScale = scoreMaxTime / operationMaxTime;
diff --git a/frontends/CsoundAC/VoiceleadingNode.hpp b/frontends/CsoundAC/VoiceleadingNode.hpp
index 48a1052..d734202 100644
--- a/frontends/CsoundAC/VoiceleadingNode.hpp
+++ b/frontends/CsoundAC/VoiceleadingNode.hpp
@@ -41,7 +41,7 @@ namespace csound
* Utility class for storing voice-leading operations
* within a VoiceleadNode for future application.
*/
- class VoiceleadingOperation
+ class SILENCE_PUBLIC VoiceleadingOperation
{
public:
VoiceleadingOperation();
@@ -106,7 +106,7 @@ namespace csound
bool avoidParallels;
};
- std::ostream &operator << (std::ostream &stream, const VoiceleadingOperation &operation);
+ std::ostream SILENCE_PUBLIC &operator << (std::ostream &stream, const VoiceleadingOperation &operation);
/**
* This node class imposes
@@ -118,7 +118,7 @@ namespace csound
* prime chord (P),
* transpose (T),
* unordered pitch-class set (C, equivalent to PT),
- * contextual inversion (K),
+ * contextual inversion (K),
* contextual transposition (Q),
* voicing (V) within a specified range of pitches,
* and voice-lead (L).
@@ -138,7 +138,7 @@ namespace csound
* The consistent combinations of operations are thus:
* PT, PTV, PTL, C, CV, CL, K, KV, KL, Q, QV, QL, V, and L.
*/
- class VoiceleadingNode :
+ class SILENCE_PUBLIC VoiceleadingNode :
public Node
{
public:
@@ -234,7 +234,7 @@ namespace csound
* or the end of the score, whichever comes first,
* conform notes produced by this node or its children
* to the specified prime chord and transposition.
- * Note that C (equivalent to PT) specifies what musicians normally
+ * Note that C (equivalent to PT) specifies what musicians normally
* call a chord.
*/
virtual void C(double time, double C_);
@@ -265,14 +265,14 @@ namespace csound
virtual void CL(double time, std::string C_, bool avoidParallels = true);
/**
* Find the C of the previous segment, and contextually invert it; apply
- * the resulting C to the current segment. Contextual inversion is
+ * the resulting C to the current segment. Contextual inversion is
* that inversion of C in which the first two pitch-classes are exchanged.
*/
virtual void K(double time);
/**
* Find the C of the previous segment, and contextually invert it; apply
- * the resulting C to the current segment with voicing V. Contextual
- * inversion is that inversion of C in which the first two pitch-classes
+ * the resulting C to the current segment with voicing V. Contextual
+ * inversion is that inversion of C in which the first two pitch-classes
* are exchanged.
*/
virtual void KV(double time, double V_);
@@ -280,28 +280,28 @@ namespace csound
* Find the C of the previous segment, and contextually invert it; apply
* the resulting C to the current segment, using the closest voiceleading
* from the pitches of the previous segment.
- * Contextual inversion is that inversion of C in which the first two
+ * Contextual inversion is that inversion of C in which the first two
* pitch-classes are exchanged.
*/
virtual void KL(double time, bool avoidParallels = true);
/**
- * Find the C of the previous segment, and contextually transpose it;
- * apply the resulting C to the current segment. Contextual transposition
+ * Find the C of the previous segment, and contextually transpose it;
+ * apply the resulting C to the current segment. Contextual transposition
* transposes C up by Q if C is an I-form, and down by Q if C is a T-form.
*/
virtual void Q(double time, double Q_);
/**
- * Find the C of the previous segment, and contextually transpose it;
- * apply the resulting C to the current segment with voicing V.
- * Contextual transposition transposes C up by Q if C is an I-form,
+ * Find the C of the previous segment, and contextually transpose it;
+ * apply the resulting C to the current segment with voicing V.
+ * Contextual transposition transposes C up by Q if C is an I-form,
* and down by Q if C is a T-form.
*/
virtual void QV(double time, double Q_, double V_);
/**
- * Find the C of the previous segment, and contextually transpose it;
- * apply the resulting C to the current segment, using the closest
+ * Find the C of the previous segment, and contextually transpose it;
+ * apply the resulting C to the current segment, using the closest
* voiceleading from the pitches of the previous segment.
- * Contextual transposition transposes C up by Q if C is an I-form,
+ * Contextual transposition transposes C up by Q if C is an I-form,
* and down by Q if C is a T-form.
*/
virtual void QL(double time, double Q_, bool avoidParallels = true);
@@ -320,7 +320,7 @@ namespace csound
* to the beginning of the next operation
* or the end of the score, whichever comes first,
* conform notes produced by this node or its children
- * to the smoothest voice-leading from the pitches
+ * to the smoothest voice-leading from the pitches
* of the previous segment.
* Optionally, parallel fifths can be avoided.
* Note that L specifies what musicians normally call
@@ -338,4 +338,3 @@ namespace csound
};
}
#endif
-
diff --git a/frontends/CsoundAC/algrd_internal.h b/frontends/CsoundAC/algrd_internal.h
new file mode 100644
index 0000000..8b58872
--- /dev/null
+++ b/frontends/CsoundAC/algrd_internal.h
@@ -0,0 +1,5 @@
+/* algread_internal.h -- interface between allegro.cpp and allegrord.cpp */
+
+Alg_error alg_read(std::istream &file, Alg_seq_ptr new_seq,
+ double *offset_ptr = NULL);
+
diff --git a/frontends/CsoundAC/algsmfrd_internal.h b/frontends/CsoundAC/algsmfrd_internal.h
new file mode 100644
index 0000000..75cc009
--- /dev/null
+++ b/frontends/CsoundAC/algsmfrd_internal.h
@@ -0,0 +1,3 @@
+/* algsmfrd_internal.h -- interface from allegrosmfrd.cpp to allegro.cpp */
+
+Alg_error alg_smf_read(std::istream &file, Alg_seq_ptr new_seq);
diff --git a/frontends/CsoundAC/allegro.cpp b/frontends/CsoundAC/allegro.cpp
new file mode 100644
index 0000000..3c5a2a5
--- /dev/null
+++ b/frontends/CsoundAC/allegro.cpp
@@ -0,0 +1,3518 @@
+// Allegro: music representation system, with
+// extensible in-memory sequence structure
+// upward compatible with MIDI
+// implementations in C++ and Serpent
+// external, text-based representation
+// compatible with Aura
+//
+/* CHANGE LOG:
+04 apr 03 -- fixed bug in add_track that caused infinite loop
+*/
+
+#include "assert.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "memory.h"
+#include <iostream>
+#include <fstream>
+using namespace std;
+#include "allegro.h"
+#include "algrd_internal.h"
+#include "algsmfrd_internal.h"
+// #include "trace.h" -- only needed for debugging
+#include "math.h"
+
+#define STREQL(x, y) (strcmp(x, y) == 0)
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define ROUND(x) ((int) ((x) + 0.5))
+
+// 4311 is type cast ponter to long warning
+// 4996 is warning against strcpy
+// 4267 is size_t to long warning
+#pragma warning(disable: 4311 4996 4267)
+Alg_atoms symbol_table;
+Serial_read_buffer Alg_track::ser_read_buf; // declare the static variables
+Serial_write_buffer Alg_track::ser_write_buf;
+
+bool within(double d1, double d2, double epsilon)
+{
+ d1 -= d2;
+ return d1 < epsilon && d1 > -epsilon;
+}
+
+
+char *heapify(const char *s)
+{
+ char *h = new char[strlen(s) + 1];
+ strcpy(h, s);
+ return h;
+}
+
+
+void Alg_atoms::expand()
+{
+ maxlen = (maxlen + 5); // extra growth for small sizes
+ maxlen += (maxlen >> 2); // add 25%
+ Alg_attribute *new_atoms = new Alg_attribute[maxlen];
+ // now do copy
+ memcpy(new_atoms, atoms, len * sizeof(Alg_attribute));
+ if (atoms) delete[] atoms;
+ atoms = new_atoms;
+}
+
+
+// insert_new -- insert an attribute name and type
+//
+// attributes are stored as a string consisting of the type
+// (a char) followed by the attribute name. This makes it
+// easy to retrieve the type or the name or both.
+//
+Alg_attribute Alg_atoms::insert_new(const char *name, char attr_type)
+{
+ if (len == maxlen) expand();
+ char *h = new char[strlen(name) + 2];
+ strcpy(h + 1, name);
+ *h = attr_type;
+ atoms[len++] = h;
+ return h;
+}
+
+
+Alg_attribute Alg_atoms::insert_attribute(Alg_attribute attr)
+{
+ // should use hash algorithm
+ for (int i = 0; i < len; i++) {
+ if (STREQL(attr, atoms[i])) {
+ return atoms[i];
+ }
+ }
+ return insert_new(attr + 1, attr[0]);
+}
+
+
+Alg_attribute Alg_atoms::insert_string(const char *name)
+{
+ char attr_type = name[strlen(name) - 1];
+ for (int i = 0; i < len; i++) {
+ if (attr_type == atoms[i][0] &&
+ STREQL(name, atoms[i] + 1)) {
+ return atoms[i];
+ }
+ }
+ return insert_new(name, attr_type);
+}
+
+
+void Alg_parameter::copy(Alg_parameter_ptr parm)
+{
+ *this = *parm; // copy all fields
+ // if the value is a string, copy the string
+ if (attr_type() == 's') {
+ s = heapify(s);
+ }
+}
+
+
+void Alg_parameter::show()
+{
+ switch (attr[0]) {
+ case 'r':
+ printf("%s:%g", attr_name(), r);
+ break;
+ case 's':
+ printf("%s:%s", attr_name(), s);
+ break;
+ case 'i':
+ printf("%s:%ld", attr_name(), i);
+ break;
+ case 'l':
+ printf("%s:%s", attr_name(), (l ? "t" : "f"));
+ break;
+ case 'a':
+ printf("%s:%s", attr_name(), a);
+ break;
+ }
+}
+
+
+Alg_parameter::~Alg_parameter()
+{
+ if (attr_type() == 's' && s) {
+ delete[] s;
+ }
+}
+
+
+void Alg_parameters::insert_real(Alg_parameters **list, const char *name,
+ double r)
+{
+ Alg_parameters_ptr a = new Alg_parameters(*list);
+ *list = a;
+ a->parm.set_attr(symbol_table.insert_string(name));
+ a->parm.r = r;
+ assert(a->parm.attr_type() == 'r');
+}
+
+
+void Alg_parameters::insert_string(Alg_parameters **list, const char *name,
+ const char *s)
+{
+ Alg_parameters_ptr a = new Alg_parameters(*list);
+ *list = a;
+ a->parm.set_attr(symbol_table.insert_string(name));
+ // string is deleted when parameter is deleted
+ a->parm.s = heapify(s);
+ assert(a->parm.attr_type() == 's');
+}
+
+
+void Alg_parameters::insert_integer(Alg_parameters **list, const char *name,
+ long i)
+{
+ Alg_parameters_ptr a = new Alg_parameters(*list);
+ *list = a;
+ a->parm.set_attr(symbol_table.insert_string(name));
+ a->parm.i = i;
+ assert(a->parm.attr_type() == 'i');
+}
+
+
+void Alg_parameters::insert_logical(Alg_parameters **list, const char *name,
+ bool l)
+{
+ Alg_parameters_ptr a = new Alg_parameters(*list);
+ *list = a;
+ a->parm.set_attr(symbol_table.insert_string(name));
+ a->parm.l = l;
+ assert(a->parm.attr_type() == 'l');
+}
+
+
+void Alg_parameters::insert_atom(Alg_parameters **list, const char *name,
+ const char *s)
+{
+ Alg_parameters_ptr a = new Alg_parameters(*list);
+ *list = a;
+ a->parm.set_attr(symbol_table.insert_string(name));
+ a->parm.a = symbol_table.insert_string(s);
+ assert(a->parm.attr_type() == 'a');
+}
+
+
+Alg_parameters *Alg_parameters::remove_key(Alg_parameters **list,
+ const char *name)
+{
+ while (*list) {
+ if (STREQL((*list)->parm.attr_name(), name)) {
+ Alg_parameters_ptr p = *list;
+ *list = p->next;
+ p->next = NULL;
+ return p; // caller should free this pointer
+ }
+ list = &((*list)->next);
+ }
+ return NULL;
+}
+
+
+Alg_parameter_ptr Alg_parameters::find(Alg_attribute attr)
+{
+ assert(attr);
+ Alg_parameters_ptr temp = this;
+ while (temp) {
+ if (temp->parm.attr == attr) {
+ return &(temp->parm);
+ }
+ }
+ return NULL;
+}
+
+
+int Alg_event::get_type_code()
+{
+ if (!is_note()) {
+ const char* attr = get_attribute();
+ if (STREQL(attr, "gater")) // volume change
+ return ALG_GATE;
+ if (STREQL(attr, "bendr")) // pitch bend
+ return ALG_BEND;
+ if (strncmp(attr, "control", 7) == 0) // control change
+ // note that midi control changes have attributes of the form
+ // "control<n>" where n is the decimal number (as a character string)
+ // of the midi controller, e.g. control2 is the breath controller.
+ // We don't check for decimal numbers in the range 0-127, so any
+ // attribute that begins with "control" is an ALG_CONTROL:
+ return ALG_CONTROL;
+ if (STREQL(attr, "programi")) // program change
+ return ALG_PROGRAM;
+ if (STREQL(attr, "pressurer")) // pressure change
+ return ALG_PRESSURE;
+ if (STREQL(attr, "keysigi")) // key signature
+ return ALG_KEYSIG;
+ if (STREQL(attr, "timesig_numi")) // time signature numerator
+ return ALG_TIMESIG_NUM;
+ if (STREQL(attr, "timesig_deni")) // time signature denominator
+ return ALG_TIMESIG_DEN;
+ return ALG_OTHER;
+ }
+ return ALG_NOTE; // it is a note
+}
+
+
+void Alg_event::set_parameter(Alg_parameter_ptr new_parameter)
+{
+ Alg_parameter_ptr parm;
+ if (is_note()) {
+ Alg_note_ptr note = (Alg_note_ptr) this;
+ parm = note->parameters->find(new_parameter->attr);
+ if (!parm) {
+ note->parameters = new Alg_parameters(note->parameters);
+ parm = &(note->parameters->parm);
+ }
+ } else { // update
+ Alg_update_ptr update = (Alg_update_ptr) this;
+ parm = &(update->parameter);
+ }
+ parm->copy(new_parameter); // copy entire parameter
+}
+
+
+void Alg_event::set_string_value(const char *a, const char *value)
+{
+ assert(a); // must be non-null
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(attr[0] == 's');
+ Alg_parameter parm;
+ parm.set_attr(attr);
+ parm.s = value;
+ set_parameter(&parm);
+ parm.s = NULL; // do this to prevent string from being freed
+}
+
+
+void Alg_event::set_real_value(const char *a, double value)
+{
+ assert(a); // must be non-null
+ // attr is like a, but it has the type code prefixed for
+ // fast lookup, and it is a unique string in symbol_table
+ // e.g. a="attackr" -> attr="rattackr"
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(attr[0] == 'r');
+ Alg_parameter parm;
+ parm.set_attr(attr);
+ parm.r = value;
+ set_parameter(&parm);
+ // since type is 'r' we don't have to NULL the string
+}
+
+
+void Alg_event::set_logical_value(const char *a, bool value)
+{
+ assert(a); // must be non-null
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(attr[0] == 'l');
+ Alg_parameter parm;
+ parm.set_attr(attr);
+ parm.l = value;
+ set_parameter(&parm);
+ // since type is 'l' we don't have to NULL the string
+}
+
+
+void Alg_event::set_integer_value(const char *a, long value)
+{
+ assert(a); // must be non-null
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(attr[0] == 'i');
+ Alg_parameter parm;
+ parm.set_attr(attr);
+ parm.i = value;
+ set_parameter(&parm);
+ // since tpye is 'i' we don't have to NULL the string
+}
+
+
+void Alg_event::set_atom_value(const char *a, const char *value)
+{
+ assert(a); // must be non-null
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(attr[0] == 'a');
+ Alg_parameter parm;
+ parm.set_attr(attr);
+ parm.a = value;
+ set_parameter(&parm);
+ /* since type is 'a' we don't have to null the string */
+}
+
+
+float Alg_event::get_pitch()
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ return note->pitch;
+}
+
+
+float Alg_event::get_loud()
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ return note->loud;
+}
+
+
+double Alg_event::get_start_time()
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ return note->time;
+}
+
+
+double Alg_event::get_end_time()
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ return note->time + note->dur;
+}
+
+
+double Alg_event::get_duration()
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ return note->dur;
+}
+
+
+void Alg_event::set_pitch(float p)
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ note->pitch = p;
+}
+
+void Alg_event::set_loud(float l)
+{
+ assert(is_note());
+ Alg_note *note = (Alg_note *) this;
+ note->loud = l;
+}
+
+
+void Alg_event::set_duration(double d)
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ note->dur = d;
+}
+
+
+bool Alg_event::has_attribute(const char *a)
+{
+ assert(is_note());
+ assert(a); // must be non-null
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ return parm != NULL;
+}
+
+
+char Alg_event::get_attribute_type(const char *a)
+{
+ assert(is_note());
+ assert(a);
+ return a[strlen(a) - 1];
+}
+
+
+const char *Alg_event::get_string_value(const char *a, const char *value)
+{
+ assert(is_note());
+ assert(a); // must be non-null
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(a[0] == 's'); // must be of type string
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ if (parm) return parm->s;
+ return value;
+}
+
+
+double Alg_event::get_real_value(const char *a, double value)
+{
+ assert(is_note());
+ assert(a);
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(a[0] == 'r'); // must be of type real
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ if (parm) return parm->r;
+ return value;
+}
+
+
+bool Alg_event::get_logical_value(const char *a, bool value)
+{
+ assert(is_note());
+ assert(a);
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(a[0] == 'l'); // must be of type logical
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ if (parm) return parm->l;
+ return value;
+}
+
+
+long Alg_event::get_integer_value(const char *a, long value)
+{
+ assert(is_note());
+ assert(a);
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(a[0] == 'i'); // must be of type integer
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ if (parm) return parm->i;
+ return value;
+}
+
+
+const char *Alg_event::get_atom_value(const char *a, const char *value)
+{
+ assert(is_note());
+ assert(a);
+ Alg_note* note = (Alg_note *) this;
+ Alg_attribute attr = symbol_table.insert_string(a);
+ assert(a[0] == 'a'); // must be of type atom
+ Alg_parameter_ptr parm = note->parameters->find(attr);
+ if (parm) return parm->a;
+ // if default is a string, convert to an atom (unique
+ // string in symbol table) and return it
+ return (value == NULL ? NULL :
+ symbol_table.insert_string(value));
+}
+
+
+void Alg_event::delete_attribute(const char *a)
+{
+ assert(is_note());
+ Alg_note* note = (Alg_note *) this;
+ Alg_parameters::remove_key(&(note->parameters), a);
+}
+
+
+const char *Alg_event::get_attribute()
+// Note: this returns a string, not an Alg_attribute
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ return update->parameter.attr_name();
+}
+
+
+char Alg_event::get_update_type()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ return update->parameter.attr_type();
+}
+
+
+const char *Alg_event::get_string_value()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ assert(get_update_type() == 's');
+ return update->parameter.s;
+}
+
+
+double Alg_event::get_real_value()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ assert(get_update_type() == 'r');
+ return update->parameter.r;
+}
+
+
+bool Alg_event::get_logical_value()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ assert(get_update_type() == 'l');
+ return update->parameter.l;
+}
+
+
+long Alg_event::get_integer_value()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ assert(get_update_type() == 'i');
+ return update->parameter.i;
+}
+
+
+const char *Alg_event::get_atom_value()
+{
+ assert(is_update());
+ Alg_update* update = (Alg_update *) this;
+ assert(get_update_type() == 'a');
+ return update->parameter.a;
+}
+
+
+bool Alg_event::overlap(double t, double len, bool all)
+{
+ // event starts within region
+ if (time >= t && time <= t + len - ALG_EPS)
+ return true;
+ if (all && is_note()) {
+ double dur = ((Alg_note_ptr) this)->dur;
+ // note overlaps with region
+ if (time < t && time + dur - ALG_EPS > t)
+ return true;
+ }
+ // does not overlap
+ return false;
+}
+
+
+Alg_note::Alg_note(Alg_note_ptr note)
+{
+ *this = *note; // copy all fields
+ // parameters is now a shared pointer. We need to copy the
+ // parameters
+ Alg_parameters_ptr next_param_ptr = parameters;
+ while (next_param_ptr) {
+ Alg_parameters_ptr new_params = new Alg_parameters(next_param_ptr->next);
+ new_params->parm.copy(&(next_param_ptr->parm)); // copy the attribute and value
+ next_param_ptr = new_params->next;
+ }
+}
+
+
+Alg_note::~Alg_note()
+{
+ while (parameters) {
+ Alg_parameters_ptr to_delete = parameters;
+ parameters = parameters->next;
+ delete to_delete;
+ }
+}
+
+
+void Alg_note::show()
+{
+ printf("Alg_note: time %g, chan %ld, dur %g, key %ld, "
+ "pitch %g, loud %g, attributes ",
+ time, chan, dur, key, pitch, loud);
+ Alg_parameters_ptr parms = parameters;
+ while (parms) {
+ parms->parm.show();
+ printf(" ");
+ parms = parms->next;
+ }
+ printf("\n");
+}
+
+
+Alg_update::Alg_update(Alg_update_ptr update)
+{
+ *this = *update; // copy all fields
+ // parameter requires careful copy to possibly duplicate string value:
+ this->parameter.copy(&(update->parameter));
+}
+
+
+void Alg_update::show()
+{
+ printf("Alg_update: ");
+ parameter.show();
+ printf("\n");
+}
+
+
+void Alg_events::expand()
+{
+ maxlen = (maxlen + 5); // extra growth for small sizes
+ maxlen += (maxlen >> 2); // add 25%
+ Alg_event_ptr *new_events = new Alg_event_ptr[maxlen];
+ // now do copy
+ memcpy(new_events, events, len * sizeof(Alg_event_ptr));
+ if (events) delete[] events;
+ events = new_events;
+}
+
+
+void Alg_events::insert(Alg_event_ptr event)
+{
+ if (maxlen <= len) {
+ expand();
+ }
+ // Note: if the new event is the last one, the assignment
+ // events[i] = event; (below) will never execute, so just
+ // in case, we do the assignment here. events[len] will
+ // be replaced during the memmove() operation below if
+ // this is not the last event.
+ events[len] = event;
+ len++;
+ // find insertion point: (this could be a binary search)
+ for (int i = 0; i < len; i++) {
+ if (events[i]->time > event->time) {
+ // insert event at i
+ memmove(&events[i + 1], &events[i],
+ sizeof(Alg_event_ptr) * (len - i - 1));
+ events[i] = event;
+ return;
+ }
+ }
+}
+
+Alg_event_ptr Alg_events::uninsert(long index)
+{
+ assert(0 <= index && index < len);
+ Alg_event_ptr event = events[index];
+ //printf("memmove: %x from %x (%d)\n", events + index, events + index + 1,
+ // sizeof(Alg_event_ptr) * (len - index - 1));
+ memmove(events + index, events + index + 1,
+ sizeof(Alg_event_ptr) * (len - index - 1));
+ len--;
+ return event;
+}
+
+
+void Alg_events::append(Alg_event_ptr event)
+{
+ if (maxlen <= len) {
+ expand();
+ }
+ events[len++] = event;
+ // keep track of last note_off time
+ if (event->is_note()) {
+ Alg_note_ptr note = (Alg_note_ptr) event;
+ double note_off = note->time + note->dur;
+ if (note_off > last_note_off)
+ last_note_off = note_off;
+ }
+}
+
+
+Alg_events::~Alg_events()
+{
+ assert(!in_use);
+ // individual events are not deleted, only the array
+ if (events) {
+ delete[] events;
+ }
+}
+
+
+Alg_event_list::Alg_event_list(Alg_track *owner)
+{
+ events_owner = owner;
+ sequence_number = owner->sequence_number;
+ beat_dur = 0.0; real_dur = 0.0; type = 'e';
+}
+
+
+Alg_event_ptr &Alg_event_list::operator [](int i)
+{
+ assert(i >= 0 && i < len);
+ return events[i];
+}
+
+
+Alg_event_list::~Alg_event_list()
+{
+ // note that the events contained in the list are not destroyed
+}
+
+
+void Alg_event_list::set_start_time(Alg_event *event, double t)
+{
+ // For Alg_event_list, find the owner and do the update there
+ // For Alg_track, change the time and move the event to the right place
+ // For Alg_seq, find the track and do the update there
+
+ long index, i;
+ Alg_track_ptr track_ptr;
+ if (type == 'e') { // this is an Alg_event_list
+ // make sure the owner has not changed its event set
+ assert(events_owner &&
+ sequence_number == events_owner->sequence_number);
+ // do the update on the owner
+ events_owner->set_start_time(event, t);
+ return;
+ } else if (type == 't') { // this is an Alg_track
+ // find the event in the track
+ track_ptr = (Alg_track_ptr) this;
+ // this should be a binary search since events are in time order
+ // probably there should be member function to do the search
+ for (index = 0; index < length(); index++) {
+ if ((*track_ptr)[index] == event) goto found_event;
+ }
+ } else { // type == 's', an Alg_seq
+ Alg_seq_ptr seq = (Alg_seq_ptr) this;
+ for (i = 0; i < seq->tracks(); i++) {
+ track_ptr = seq->track(i);
+ // if you implemented binary search, you could call it
+ // instead of this loop too.
+ for (index = 0; index < track_ptr->length(); index++) {
+ if ((*track_ptr)[index] == event) goto found_event;
+ }
+ }
+ }
+ assert(false); // event not found seq or track!
+ found_event:
+ // at this point, track[index] == event
+ // we could be clever and figure out exactly what notes to move
+ // but it is simpler to just remove the event and reinsert it:
+ track_ptr->uninsert(index);
+ event->time = t;
+ track_ptr->insert(event);
+}
+
+
+void Alg_beats::expand()
+{
+ maxlen = (maxlen + 5); // extra growth for small sizes
+ maxlen += (maxlen >> 2); // add 25%
+ Alg_beat_ptr new_beats = new Alg_beat[maxlen];
+ // now do copy
+ memcpy(new_beats, beats, len * sizeof(Alg_beat));
+ if (beats) delete[] beats;
+ beats = new_beats;
+}
+
+
+void Alg_beats::insert(long i, Alg_beat_ptr beat)
+{
+ assert(i >= 0 && i <= len);
+ if (maxlen <= len) {
+ expand();
+ }
+ memmove(&beats[i + 1], &beats[i], sizeof(Alg_beat) * (len - i));
+ memcpy(&beats[i], beat, sizeof(Alg_beat));
+ len++;
+}
+
+
+Alg_time_map::Alg_time_map(Alg_time_map *map)
+{
+ refcount = 0;
+ assert(map->beats[0].beat == 0 && map->beats[0].time == 0);
+ assert(map->beats.len > 0);
+ // new_beats[0] = map->beats[0];
+ // this is commented because
+ // both new_beats[0] and map->beats[0] should be (0, 0)
+ for (int i = 1; i < map->beats.len; i++) {
+ beats.insert(i, &map->beats[i]);
+ }
+ last_tempo = map->last_tempo;
+ last_tempo_flag = map->last_tempo_flag;
+}
+
+
+void Alg_time_map::show()
+{
+ printf("Alg_time_map: ");
+ for (int i = 0; i < beats.len; i++) {
+ Alg_beat &b = beats[i];
+ printf("(%g, %g) ", b.time, b.beat);
+ }
+ printf("last tempo: %g\n", last_tempo);
+}
+
+
+long Alg_time_map::locate_time(double time)
+{
+ int i = 0;
+ while ((i < beats.len) && (time > beats[i].time)) {
+ i++;
+ }
+ return i;
+}
+
+
+long Alg_time_map::locate_beat(double beat)
+{
+ int i = 0;
+ while ((i < beats.len) && (beat > beats[i].beat)) {
+ i++;
+ }
+ return i;
+}
+
+
+double Alg_time_map::beat_to_time(double beat)
+{
+ Alg_beat_ptr mbi;
+ Alg_beat_ptr mbi1;
+ if (beat <= 0) {
+ return beat;
+ }
+ int i = locate_beat(beat);
+ // case 1: beat is between two time/beat pairs
+ if (0 < i && i < beats.len) {
+ mbi = &beats[i - 1];
+ mbi1 = &beats[i];
+ // case 2: beat is beyond last time/beat pair
+ } else if (i == beats.len) {
+ if (last_tempo_flag) {
+ return beats[i - 1].time +
+ (beat - beats[i - 1].beat) / last_tempo;
+ } else if (i == 1) {
+ return beat * 60.0 / ALG_DEFAULT_BPM;
+ // so we use that as default allegro tempo too
+ } else {
+ mbi = &beats[i - 2];
+ mbi1 = &beats[i - 1];
+ }
+ // case 3: beat is at time 0
+ } else /* if (i == 0) */ {
+ return beats[0].time;
+ }
+ // whether we extrapolate or interpolate, the math is the same
+ double time_dif = mbi1->time - mbi->time;
+ double beat_dif = mbi1->beat - mbi->beat;
+ return mbi->time + (beat - mbi->beat) * time_dif / beat_dif;
+}
+
+
+double Alg_time_map::time_to_beat(double time)
+{
+ Alg_beat_ptr mbi;
+ Alg_beat_ptr mbi1;
+ if (time <= 0.0) return time;
+ int i = locate_time(time);
+ if (i == beats.len) {
+ if (last_tempo_flag) {
+ return beats[i - 1].beat +
+ (time - beats[i - 1].time) * last_tempo;
+ } else if (i == 1) {
+ return time * (ALG_DEFAULT_BPM / 60.0);
+ } else {
+ mbi = &beats[i - 2];
+ mbi1 = &beats[i - 1];
+ }
+ } else {
+ mbi = &beats[i - 1];
+ mbi1 = & beats[i];
+ }
+ double time_dif = mbi1->time - mbi->time;
+ double beat_dif = mbi1->beat - mbi->beat;
+ return mbi->beat + (time - mbi->time) * beat_dif / time_dif;
+}
+
+
+void Alg_time_map::insert_beat(double time, double beat)
+{
+ int i = locate_time(time); // i is insertion point
+ if (i < beats.len && within(beats[i].time, time, 0.000001)) {
+ // replace beat if time is already in the map
+ beats[i].beat = beat;
+ } else {
+ Alg_beat point;
+ point.beat = beat;
+ point.time = time;
+ beats.insert(i, &point);
+ }
+ // beats[i] contains new beat
+ // make sure we didn't generate a zero tempo.
+ // if so, space beats by one microbeat as necessary
+ long j = i;
+ if (j == 0) j = 1; // do not adjust beats[0]
+ while (j < beats.len &&
+ beats[j - 1].beat + 0.000001 >= beats[j].beat) {
+ beats[j].beat = beats[j - 1].beat + 0.000001;
+ j++;
+ }
+}
+
+
+bool Alg_time_map::insert_tempo(double tempo, double beat)
+{
+ tempo = tempo / 60.0; // convert to beats per second
+ // change the tempo at the given beat until the next beat event
+ if (beat < 0) return false;
+ double time = beat_to_time(beat);
+ long i = locate_time(time);
+ if (i >= beats.len || !within(beats[i].time, time, 0.000001)) {
+ insert_beat(time, beat);
+ }
+ // now i is index of beat where tempo will change
+ if (i == beats.len - 1) {
+ last_tempo = tempo;
+ // printf("last_tempo to %g\n", last_tempo);
+ last_tempo_flag = true;
+ } else { // adjust all future beats
+ // compute the difference in beats
+ double diff = beats[i + 1].beat - beats[i].beat;
+ // convert beat difference to seconds at new tempo
+ diff = diff / tempo;
+ // figure out old time difference:
+ double old_diff = beats[i + 1].time - time;
+ // compute difference too
+ diff = diff - old_diff;
+ // apply new_diff to score and beats
+ i++;
+ while (i < beats.len) {
+ beats[i].time = beats[i].time + diff;
+ i++;
+ }
+ }
+ return true;
+}
+
+
+double Alg_time_map::get_tempo(double beat)
+{
+ Alg_beat_ptr mbi;
+ Alg_beat_ptr mbi1;
+ // if beat < 0, there is probably an error; return something nice anyway
+ if (beat < 0) return ALG_DEFAULT_BPM / 60.0;
+ long i = locate_beat(beat);
+ // this code is similar to beat_to_time() so far, but we want to get
+ // beyond beat if possible because we want the tempo FOLLOWING beat
+ // (Consider the case beat == 0.0)
+ if (i < beats.len && beat >= beats[i].beat) i++;
+ // case 1: beat is between two time/beat pairs
+ if (i < beats.len) {
+ mbi = &beats[i - 1];
+ mbi1 = &beats[i];
+ // case 2: beat is beyond last time/beat pair
+ } else /* if (i == beats.len) */ {
+ if (last_tempo_flag) {
+ return last_tempo;
+ } else if (i == 1) {
+ return ALG_DEFAULT_BPM / 60.0;
+ } else {
+ mbi = &beats[i - 2];
+ mbi1 = &beats[i - 1];
+ }
+ }
+ double time_dif = mbi1->time - mbi->time;
+ double beat_dif = mbi1->beat - mbi->beat;
+ return beat_dif / time_dif;
+}
+
+
+bool Alg_time_map::set_tempo(double tempo, double start_beat, double end_beat)
+{
+ if (start_beat >= end_beat) return false;
+ // algorithm: insert a beat event if necessary at start_beat
+ // and at end_beat
+ // delete intervening map elements
+ // change the tempo
+ insert_beat(beat_to_time(start_beat), start_beat);
+ insert_beat(beat_to_time(end_beat), end_beat);
+ long start_x = locate_beat(start_beat) + 1;
+ long stop_x = locate_beat(end_beat);
+ while (stop_x < beats.len) {
+ beats[start_x] = beats[stop_x];
+ start_x++;
+ stop_x++;
+ }
+ beats.len = start_x; // truncate the map to new length
+ return insert_tempo(tempo, start_beat);
+}
+
+
+bool Alg_time_map::stretch_region(double b0, double b1, double dur)
+{
+ // find current duration
+ double t0 = beat_to_time(b0);
+ double t1 = beat_to_time(b1);
+ double old_dur = t1 - t0;
+ if (old_dur <= 0 || dur <= 0) return false;
+ double scale = dur / old_dur; // larger scale => slower
+ // insert a beat if necessary at b0 and b1
+ insert_beat(t0, b0);
+ insert_beat(t1, b1);
+ long start_x = locate_beat(b0);
+ long stop_x = locate_beat(b1);
+ double orig_time = beats[start_x].time;
+ double prev_time = orig_time;
+ for (int i = start_x + 1; i < beats.len; i++) {
+ double delta = beats[i].time - orig_time;
+ if (i <= stop_x) { // change tempo to next Alg_beat
+ delta *= scale;
+ }
+ orig_time = beats[i].time;
+ prev_time += delta;
+ beats[i].time = prev_time;
+ }
+ return true;
+}
+
+
+void Alg_time_map::trim(double start, double end, bool units_are_seconds)
+{
+ // extract the time map from start to end and shift to time zero
+ // start and end are time in seconds if units_are_seconds is true
+ int i = 0; // index into beats
+ int start_index; // index of first breakpoint after start
+ int count = 1;
+ double initial_beat = start;
+ double final_beat = end;
+ if (units_are_seconds) {
+ initial_beat = time_to_beat(start);
+ final_beat = time_to_beat(end);
+ } else {
+ start = beat_to_time(initial_beat);
+ end = beat_to_time(final_beat);
+ }
+ while (i < length() && beats[i].time < start) i++;
+ // now i is index into beats of the first breakpoint after start
+ // beats[0] is (0,0) and remains that way
+ // copy beats[start_index] to beats[1], etc.
+ // skip any beats at or near (start,initial_beat), using count
+ // to keep track of how many entries there are
+ start_index = i;
+ while (i < length() && beats[i].time < end) {
+ if (beats[i].time - start > ALG_EPS &&
+ beats[i].beat - initial_beat > ALG_EPS) {
+ beats[i].time = beats[i].time - start;
+ beats[i].beat = beats[i].beat - initial_beat;
+ beats[i - start_index + 1] = beats[i];
+ count = count + 1;
+ } else {
+ start_index = start_index + 1;
+ }
+ i = i + 1;
+ }
+ // set last tempo data
+ // we last examined beats[i-1] and copied it to
+ // beats[i - start_index]. Next tempo should come
+ // from beats[i] and store in beats[i - start_index + 1]
+ // case 1: there is at least one breakpoint beyond end
+ // => interpolate to put a breakpoint at end
+ // case 2: no more breakpoints => set last tempo data
+ if (i < length()) {
+ // we know beats[i].time >= end, so case 1 applies
+ beats[i - start_index + 1].time = end - start;
+ beats[i - start_index + 1].beat = final_beat - initial_beat;
+ count = count + 1;
+ }
+ // else we'll just use stored last tempo (if any)
+ beats.len = count;
+}
+
+
+void Alg_time_map::cut(double start, double len, bool units_are_seconds)
+{
+ // remove portion of time map from start to start + len,
+ // shifting the tail left by len. start and len are in whatever
+ // units the score is in. If you cut the time_map as well as cut
+ // the tracks of the sequence, then sequences will preserve the
+ // association between tempo changes and events
+ double end = start + len;
+ double initial_beat = start;
+ double final_beat = end;
+ int i = 0;
+
+ if (units_are_seconds) {
+ initial_beat = time_to_beat(start);
+ final_beat = time_to_beat(end);
+ } else {
+ start = beat_to_time(initial_beat);
+ end = beat_to_time(final_beat);
+ len = end - start;
+ }
+ double beat_len = final_beat - initial_beat;
+
+ while (i < length() && beats[i].time < start - ALG_EPS) {
+ i = i + 1;
+ }
+
+ // if no beats exist at or after start, just return; nothing to cut
+ if (i == length()) return;
+
+ // now i is index into beats of the first breakpoint on or
+ // after start, insert (start, initial_beat) in map
+ if (i < length() && within(beats[i].time, start, ALG_EPS)) {
+ // perterb time map slightly (within alg_eps) to place
+ // break point exactly at the start time
+ beats[i].time = start;
+ beats[i].beat = initial_beat;
+ } else {
+ Alg_beat point(start, initial_beat);
+ beats.insert(i, &point);
+ }
+ // now, we're correct up to beats[i] and beats[i] happens at start.
+ // find first beat after end so we can start shifting from there
+ i = i + 1;
+ int start_index = i;
+ while (i < length() && beats[i].time < end + ALG_EPS) i++;
+ // now beats[i] is the next point to be included in beats
+ // but from i onward, we must shift by (-len, -beat_len)
+ while (i < length()) {
+ Alg_beat &b = beats[i];
+ b.time = b.time - len;
+ b.beat = b.beat - beat_len;
+ beats[start_index] = b;
+ i = i + 1;
+ start_index = start_index + 1;
+ }
+ beats.len = start_index;
+}
+
+
+void Alg_time_map::paste(double beat, Alg_track *tr)
+{
+ // insert a given time map at a given time and dur (in beats)
+ Alg_time_map_ptr from_map = tr->get_time_map();
+ // printf("time map paste\nfrom map\n");
+ // from_map->show();
+ // printf("to map\n");
+ // show();
+ Alg_beats &from = from_map->beats;
+ double time = beat_to_time(beat);
+ // Locate the point at which dur occurs
+ double dur = tr->get_beat_dur();
+ double tr_end_time = from_map->beat_to_time(dur);
+ // add offset to make room for insert
+ int i = locate_beat(beat);
+ while (i < length()) {
+ beats[i].beat += dur;
+ beats[i].time += tr_end_time;
+ i++;
+ }
+ // printf("after opening up\n");
+ // show();
+ // insert point at beginning and end of paste
+ insert_beat(time, beat);
+ // printf("after beginning point insert\n");
+ // show();
+ // insert_beat(time + tr_end_time, beat + dur);
+ // printf("after ending point insert\n");
+ // show();
+ int j = from_map->locate_beat(dur);
+ for (i = 0; i < j; i++) {
+ insert_beat(from[i].time + time, // shift by time
+ from[i].beat + beat); // and beat
+ }
+ // printf("after inserts\n");
+ show();
+}
+
+
+void Alg_time_map::insert_time(double start, double len)
+{
+ // find time,beat pair that determines tempo at start
+ // compute beat offset = (delta beat / delta time) * len
+ // add len,beat offset to each following Alg_beat
+ // show();
+ int i = locate_time(start); // start <= beats[i].time
+ if (beats[i].time == start) i++; // start < beats[i].time
+ // case 1: between beats
+ if (i > 0 && i < length()) {
+ double beat_offset = len * (beats[i].beat - beats[i-1].beat) /
+ (beats[i].time - beats[i-1].time);
+ while (i < length()) {
+ beats[i].beat += beat_offset;
+ beats[i].time += len;
+ i++;
+ }
+ } // otherwise, last tempo is in effect; nothing to do
+ // printf("time_map AFTER INSERT\n");
+ // show();
+}
+
+
+void Alg_time_map::insert_beats(double start, double len)
+{
+ int i = locate_beat(start); // start <= beats[i].beat
+ if (beats[i].beat == start) i++;
+ if (i > 0 && i < length()) {
+ double time_offset = len * (beats[i].time - beats[i-1].time) /
+ (beats[i].beat - beats[i-1].beat);
+ while (i < length()) {
+ beats[i].time += time_offset;
+ beats[i].beat += len;
+ i++;
+ }
+ } // otherwise, last tempo is in effect; nothing to do
+ // printf("time_map AFTER INSERT\n");
+ // show();
+}
+
+
+Alg_track::Alg_track(Alg_time_map *map, bool seconds)
+{
+ type = 't';
+ time_map = NULL;
+ units_are_seconds = seconds;
+ set_time_map(map);
+}
+
+
+Alg_event_ptr Alg_track::copy_event(Alg_event_ptr event)
+{
+ Alg_event *new_event;
+ if (event->is_note()) {
+ new_event = new Alg_note((Alg_note_ptr) event);
+ } else { // update
+ new_event = new Alg_update((Alg_update_ptr) event);
+ }
+ return new_event;
+}
+
+
+Alg_track::Alg_track(Alg_track &track)
+{
+ type = 't';
+ time_map = NULL;
+ for (int i = 0; i < track.length(); i++) {
+ append(copy_event(track.events[i]));
+ }
+ set_time_map(track.time_map);
+ units_are_seconds = track.units_are_seconds;
+}
+
+
+Alg_track::Alg_track(Alg_event_list_ref event_list, Alg_time_map_ptr map,
+ bool units_are_seconds)
+{
+ type = 't';
+ time_map = NULL;
+ for (int i = 0; i < event_list.length(); i++) {
+ append(copy_event(event_list[i]));
+ }
+ set_time_map(map);
+ this->units_are_seconds = units_are_seconds;
+}
+
+
+void Alg_track::serialize(void **buffer, long *bytes)
+{
+ // first determine whether this is a seq or a track.
+ // if it is a seq, then we will write the time map and a set of tracks
+ // if it is a track, we just write the track data and not the time map
+ //
+ // The code will align doubles on ALIGN boundaries, and longs and
+ // floats are aligned to multiples of 4 bytes.
+ //
+ // The format for a seq is:
+ // 'ALGS' -- indicates that this is a sequence
+ // long length of all seq data in bytes starting with 'ALGS'
+ // long channel_offset_per_track
+ // long units_are_seconds
+ // time_map:
+ // double last_tempo
+ // long last_tempo_flag
+ // long len -- number of tempo changes
+ // for each tempo change (Alg_beat):
+ // double time
+ // double beat
+ // time_sigs:
+ // long len -- number of time_sigs
+ // long pad
+ // for each time signature:
+ // double beat
+ // double num
+ // double den
+ // tracks:
+ // long len -- number of tracks
+ // long pad
+ // for each track:
+ // 'ALGT' -- indicates this is a track
+ // long length of all track data in bytes starting with 'ALGT'
+ // long units_are_seconds
+ // double beat_dur
+ // double real_dur
+ // long len -- number of events
+ // for each event:
+ // long selected
+ // long type
+ // long key
+ // long channel
+ // double time
+ // if this is a note:
+ // double pitch
+ // double dur
+ // double loud
+ // long len -- number of parameters
+ // for each parameter:
+ // char attribute[] with zero pad to ALIGN
+ // one of the following, depending on type:
+ // double r
+ // char s[] terminated by zero
+ // long i
+ // long l
+ // char a[] terminated by zero
+ // zero pad to ALIGN
+ // else if this is an update
+ // (same representation as parameter above)
+ // zero pad to ALIGN
+ //
+ // The format for a track is given within the Seq format above
+ assert(get_type() == 't');
+ ser_write_buf.init_for_write();
+ serialize_track();
+ *buffer = ser_write_buf.to_heap(bytes);
+}
+
+
+void Alg_seq::serialize(void **buffer, long *bytes)
+{
+ assert(get_type() == 's');
+ ser_write_buf.init_for_write();
+ serialize_seq();
+ *buffer = ser_write_buf.to_heap(bytes);
+}
+
+
+void Serial_write_buffer::check_buffer(long needed)
+{
+ if (len < (ptr - buffer) + needed) { // do we need more space?
+ long new_len = len * 2; // exponential growth is important
+ // initially, length is zero, so bump new_len to a starting value
+ if (new_len == 0) new_len = 1024;
+ // make sure new_len is as big as needed
+ if (needed > new_len) new_len = needed;
+ char *new_buffer = new char[new_len]; // allocate space
+ ptr = new_buffer + (ptr - buffer); // relocate ptr to new buffer
+ if (len > 0) { // we had a buffer already
+ memcpy(new_buffer, buffer, len); // copy from old buffer
+ delete buffer; // free old buffer
+ }
+ buffer = new_buffer; // update buffer information
+ len = new_len;
+ }
+}
+
+
+void Alg_seq::serialize_seq()
+{
+ int i; // loop counters
+ // we can easily compute how much buffer space we need until we
+ // get to tracks, so expand at least that much
+ long needed = 64 + 16 * time_map->beats.len + 24 * time_sig.length();
+ ser_write_buf.check_buffer(needed);
+ ser_write_buf.set_char('A');
+ ser_write_buf.set_char('L');
+ ser_write_buf.set_char('G');
+ ser_write_buf.set_char('S');
+ long length_offset = ser_write_buf.get_posn();
+ ser_write_buf.set_int32(0); // leave room to come back and write length
+ ser_write_buf.set_int32(channel_offset_per_track);
+ ser_write_buf.set_int32(units_are_seconds);
+ ser_write_buf.set_double(beat_dur);
+ ser_write_buf.set_double(real_dur);
+ ser_write_buf.set_double(time_map->last_tempo);
+ ser_write_buf.set_int32(time_map->last_tempo_flag);
+ ser_write_buf.set_int32(time_map->beats.len);
+ for (i = 0; i < time_map->beats.len; i++) {
+ ser_write_buf.set_double(time_map->beats[i].time);
+ ser_write_buf.set_double(time_map->beats[i].beat);
+ }
+ ser_write_buf.set_int32(time_sig.length());
+ ser_write_buf.pad();
+ for (i = 0; i < time_sig.length(); i++) {
+ ser_write_buf.set_double(time_sig[i].beat);
+ ser_write_buf.set_double(time_sig[i].num);
+ ser_write_buf.set_double(time_sig[i].den);
+ }
+ ser_write_buf.set_int32(tracks());
+ ser_write_buf.pad();
+ for (i = 0; i < tracks(); i++) {
+ track(i)->serialize_track();
+ }
+ // do not include ALGS, include padding at end
+ ser_write_buf.store_long(length_offset, ser_write_buf.get_posn() - length_offset);
+}
+
+
+void Alg_track::serialize_track()
+{
+ // to simplify the code, copy from parameter addresses to locals
+ int j;
+ ser_write_buf.check_buffer(32);
+ ser_write_buf.set_char('A');
+ ser_write_buf.set_char('L');
+ ser_write_buf.set_char('G');
+ ser_write_buf.set_char('T');
+ long length_offset = ser_write_buf.get_posn(); // save location for track length
+ ser_write_buf.set_int32(0); // room to write track length
+ ser_write_buf.set_int32(units_are_seconds);
+ ser_write_buf.set_double(beat_dur);
+ ser_write_buf.set_double(real_dur);
+ ser_write_buf.set_int32(len);
+ for (j = 0; j < len; j++) {
+ ser_write_buf.check_buffer(24);
+ Alg_event *event = (*this)[j];
+ ser_write_buf.set_int32(event->get_selected());
+ ser_write_buf.set_int32(event->get_type());
+ ser_write_buf.set_int32(event->get_identifier());
+ ser_write_buf.set_int32(event->chan);
+ ser_write_buf.set_double(event->time);
+ if (event->is_note()) {
+ ser_write_buf.check_buffer(20);
+ Alg_note *note = (Alg_note *) event;
+ ser_write_buf.set_float(note->pitch);
+ ser_write_buf.set_float(note->loud);
+ ser_write_buf.set_double(note->dur);
+ long parm_num_offset = ser_write_buf.get_posn();
+ long parm_num = 0;
+ ser_write_buf.set_int32(0); // placeholder for no. parameters
+ Alg_parameters_ptr parms = note->parameters;
+ while (parms) {
+ serialize_parameter(&(parms->parm));
+ parms = parms->next;
+ parm_num++;
+ }
+ ser_write_buf.store_long(parm_num_offset, parm_num);
+ } else {
+ assert(event->is_update());
+ Alg_update *update = (Alg_update *) event;
+ serialize_parameter(&(update->parameter));
+ }
+ ser_write_buf.check_buffer(7); // maximum padding possible
+ ser_write_buf.pad();
+ }
+ // write length, not including ALGT, including padding at end
+ ser_write_buf.store_long(length_offset, ser_write_buf.get_posn() - length_offset);
+}
+
+
+void Alg_track::serialize_parameter(Alg_parameter *parm)
+{
+ // add eight to account for name + zero end-of-string and the
+ // possibility of adding 7 padding bytes
+ long len = strlen(parm->attr_name()) + 8;
+ ser_write_buf.check_buffer(len);
+ ser_write_buf.set_string(parm->attr_name());
+ ser_write_buf.pad();
+ switch (parm->attr_type()) {
+ case 'r':
+ ser_write_buf.check_buffer(8);
+ ser_write_buf.set_double(parm->r);
+ break;
+ case 's':
+ ser_write_buf.check_buffer(strlen(parm->s) + 1);
+ ser_write_buf.set_string(parm->s);
+ break;
+ case 'i':
+ ser_write_buf.check_buffer(4);
+ ser_write_buf.set_int32(parm->i);
+ break;
+ case 'l':
+ ser_write_buf.check_buffer(4);
+ ser_write_buf.set_int32(parm->l);
+ break;
+ case 'a':
+ ser_write_buf.check_buffer(strlen(parm->a) + 1);
+ ser_write_buf.set_string(parm->a);
+ break;
+ }
+}
+
+
+
+Alg_track *Alg_track::unserialize(void *buffer, long len)
+{
+ assert(len > 8);
+ ser_read_buf.init_for_read(buffer, len);
+ bool alg = ser_read_buf.get_char() == 'A' &&
+ ser_read_buf.get_char() == 'L' &&
+ ser_read_buf.get_char() == 'G';
+ assert(alg);
+ char c = ser_read_buf.get_char();
+ if (c == 'S') {
+ Alg_seq *seq = new Alg_seq;
+ ser_read_buf.unget_chars(4); // undo get_char() of A,L,G,S
+ seq->unserialize_seq();
+ return seq;
+ } else {
+ assert(c == 'T');
+ Alg_track *track = new Alg_track;
+ ser_read_buf.unget_chars(4); // undo get_char() of A,L,G,T
+ track->unserialize_track();
+ return track;
+ }
+}
+
+
+#pragma warning(disable: 4800) // long to bool performance warning
+
+/* Note: this Alg_seq must have a default initialized Alg_time_map.
+ * It will be filled in with data from the ser_read_buf buffer.
+ */
+void Alg_seq::unserialize_seq()
+{
+ ser_read_buf.check_input_buffer(48);
+ bool algs = (ser_read_buf.get_char() == 'A') &&
+ (ser_read_buf.get_char() == 'L') &&
+ (ser_read_buf.get_char() == 'G') &&
+ (ser_read_buf.get_char() == 'S');
+ assert(algs);
+ long len = ser_read_buf.get_int32();
+ assert(ser_read_buf.get_len() >= len);
+ channel_offset_per_track = ser_read_buf.get_int32();
+ units_are_seconds = ser_read_buf.get_int32() != 0;
+ beat_dur = ser_read_buf.get_double();
+ real_dur = ser_read_buf.get_double();
+ // no need to allocate an Alg_time_map since it's done during initialization
+ time_map->last_tempo = ser_read_buf.get_double();
+ time_map->last_tempo_flag = ser_read_buf.get_int32() != 0;
+ long beats = ser_read_buf.get_int32();
+ ser_read_buf.check_input_buffer(beats * 16 + 4);
+ int i;
+ for (i = 0; i < beats; i++) {
+ double time = ser_read_buf.get_double();
+ double beat = ser_read_buf.get_double();
+ time_map->insert_beat(time, beat);
+ // printf("time_map: %g, %g\n", time, beat);
+ }
+ long time_sig_len = ser_read_buf.get_int32();
+ ser_read_buf.get_pad();
+ ser_read_buf.check_input_buffer(time_sig_len * 24 + 8);
+ for (i = 0; i < time_sig_len; i++) {
+ double beat = ser_read_buf.get_double();
+ double num = ser_read_buf.get_double();
+ double den = ser_read_buf.get_double();
+ time_sig.insert(beat, num, den);
+ }
+ long tracks_num = ser_read_buf.get_int32();
+ ser_read_buf.get_pad();
+ add_track(tracks_num - 1); // create tracks_num tracks
+ for (i = 0; i < tracks_num; i++) {
+ track(i)->unserialize_track();
+ }
+ // assume seq started at beginning of buffer. len measures
+ // bytes after 'ALGS' header, so add 4 bytes and compare to
+ // current buffer position -- they should agree
+ assert(ser_read_buf.get_posn() == len + 4);
+}
+
+
+void Alg_track::unserialize_track()
+{
+ ser_read_buf.check_input_buffer(32);
+ bool algt = (ser_read_buf.get_char() == 'A') &&
+ (ser_read_buf.get_char() == 'L') &&
+ (ser_read_buf.get_char() == 'G') &&
+ (ser_read_buf.get_char() == 'T');
+ assert(algt);
+ long offset = ser_read_buf.get_posn(); // stored length does not include 'ALGT'
+ long bytes = ser_read_buf.get_int32();
+ assert(bytes <= ser_read_buf.get_len() - offset);
+ units_are_seconds = (bool) ser_read_buf.get_int32();
+ beat_dur = ser_read_buf.get_double();
+ real_dur = ser_read_buf.get_double();
+ int event_count = ser_read_buf.get_int32();
+ for (int i = 0; i < event_count; i++) {
+ ser_read_buf.check_input_buffer(24);
+ long selected = ser_read_buf.get_int32();
+ char type = (char) ser_read_buf.get_int32();
+ long key = ser_read_buf.get_int32();
+ long channel = ser_read_buf.get_int32();
+ double time = ser_read_buf.get_double();
+ if (type == 'n') {
+ ser_read_buf.check_input_buffer(20);
+ float pitch = ser_read_buf.get_float();
+ float loud = ser_read_buf.get_float();
+ double dur = ser_read_buf.get_double();
+ Alg_note *note =
+ create_note(time, channel, key, pitch, loud, dur);
+ note->set_selected(selected != 0);
+ long param_num = ser_read_buf.get_int32();
+ int j;
+ // this builds a list of parameters in the correct order
+ // (although order shouldn't matter)
+ Alg_parameters_ptr *list = ¬e->parameters;
+ for (j = 0; j < param_num; j++) {
+ *list = new Alg_parameters(NULL);
+ unserialize_parameter(&((*list)->parm));
+ list = &((*list)->next);
+ }
+ append(note);
+ } else {
+ assert(type == 'u');
+ Alg_update *update = create_update(time, channel, key);
+ update->set_selected(selected != 0);
+ unserialize_parameter(&(update->parameter));
+ append(update);
+ }
+ ser_read_buf.get_pad();
+ }
+ assert(offset + bytes == ser_read_buf.get_posn());
+}
+
+
+void Alg_track::unserialize_parameter(Alg_parameter_ptr parm_ptr)
+{
+ Alg_attribute attr = ser_read_buf.get_string();
+ parm_ptr->attr = symbol_table.insert_string(attr);
+ switch (parm_ptr->attr_type()) {
+ case 'r':
+ ser_read_buf.check_input_buffer(8);
+ parm_ptr->r = ser_read_buf.get_double();
+ break;
+ case 's':
+ parm_ptr->s = heapify(ser_read_buf.get_string());
+ break;
+ case 'i':
+ ser_read_buf.check_input_buffer(4);
+ parm_ptr->i = ser_read_buf.get_int32();
+ break;
+ case 'l':
+ ser_read_buf.check_input_buffer(4);
+ parm_ptr->l = ser_read_buf.get_int32() != 0;
+ break;
+ case 'a':
+ parm_ptr->a = symbol_table.insert_attribute(ser_read_buf.get_string());
+ break;
+ }
+}
+
+#pragma warning(default: 4800)
+
+void Alg_track::set_time_map(Alg_time_map *map)
+{
+ if (time_map) time_map->dereference();
+ if (map == NULL) {
+ time_map = new Alg_time_map(); // new default map
+ time_map->reference();
+ } else {
+ time_map = map;
+ time_map->reference();
+ }
+}
+
+
+void Alg_track::convert_to_beats()
+// modify all times and durations in notes to beats
+{
+ if (units_are_seconds) {
+ units_are_seconds = false;
+ long i;
+
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr e = events[i];
+ double beat = time_map->time_to_beat(e->time);
+ if (e->is_note()) {
+ Alg_note_ptr n = (Alg_note_ptr) e;
+ n->dur = time_map->time_to_beat(n->time + n->dur) - beat;
+ }
+ e->time = beat;
+ }
+ }
+}
+
+
+void Alg_track::convert_to_seconds()
+// modify all times and durations in notes to seconds
+{
+ if (!units_are_seconds) {
+ last_note_off = time_map->beat_to_time(last_note_off);
+ units_are_seconds = true;
+ long i;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr e = events[i];
+ double time = time_map->beat_to_time(e->time);
+ if (e->is_note()) {
+ Alg_note_ptr n = (Alg_note_ptr) e;
+ n->dur = time_map->beat_to_time(n->time + n->dur) - time;
+ }
+ e->time = time;
+ }
+ }
+}
+
+
+void Alg_track::set_dur(double duration)
+{
+ // set beat_dur and real_dur
+ if (units_are_seconds) {
+ set_real_dur(duration);
+ set_beat_dur(time_map->time_to_beat(duration));
+ } else {
+ set_beat_dur(duration);
+ set_real_dur(time_map->beat_to_time(duration));
+ }
+}
+
+
+Alg_note *Alg_track::create_note(double time, int channel, int identifier,
+ float pitch, float loudness, double duration)
+{
+ Alg_note *note = new Alg_note();
+ note->time = time;
+ note->chan = channel;
+ note->set_identifier(identifier);
+ note->pitch = pitch;
+ note->loud = loudness;
+ note->dur = duration;
+ return note;
+}
+
+
+Alg_update *Alg_track::create_update(double time, int channel, int identifier)
+{
+ Alg_update *update = new Alg_update();
+ update->time = time;
+ update->chan = channel;
+ update->set_identifier(identifier);
+ return update;
+}
+
+
+Alg_track_ptr Alg_track::cut(double t, double len, bool all)
+{
+ // since we are translating notes in time, do not copy or use old timemap
+ Alg_track_ptr track = new Alg_track();
+ track->units_are_seconds = units_are_seconds;
+ if (units_are_seconds) {
+ track->set_real_dur(len);
+ track->set_beat_dur(time_map->time_to_beat(t + len) -
+ time_map->time_to_beat(t));
+ } else {
+ track->set_beat_dur(len);
+ track->set_real_dur(time_map->beat_to_time(t + len) -
+ time_map->beat_to_time(t));
+ }
+ int i;
+ int new_len = 0;
+ int change = 0;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->overlap(t, len, all)) {
+ event->time -= t;
+ track->append(event);
+ change = 1;
+ } else { // if we're not cutting this event, move it to
+ // eliminate the gaps in events left by cut events
+ events[new_len] = event;
+ // adjust times of events after t + len
+ if (event->time > t + len - ALG_EPS) {
+ event->time -= len;
+ change = 1;
+ }
+ new_len++;
+ }
+ }
+ // Alg_event_lists based on this track become invalid
+ sequence_number += change;
+ this->len = new_len; // adjust length since we removed events
+ return track;
+}
+
+
+Alg_track_ptr Alg_track::copy(double t, double len, bool all)
+{
+ // since we are translating notes in time, do not copy or use old timemap
+ Alg_track_ptr track = new Alg_track();
+ track->units_are_seconds = units_are_seconds;
+ if (units_are_seconds) {
+ track->set_real_dur(len);
+ track->set_beat_dur(time_map->time_to_beat(t + len) -
+ time_map->time_to_beat(t));
+ } else {
+ track->set_beat_dur(len);
+ track->set_real_dur(time_map->beat_to_time(t + len) -
+ time_map->beat_to_time(t));
+ }
+ int i;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->overlap(t, len, all)) {
+ Alg_event_ptr new_event = copy_event(event);
+ new_event->time -= t;
+ track->append(new_event);
+ }
+ }
+ return track;
+}
+
+
+void Alg_track::paste(double t, Alg_event_list *seq)
+{
+ assert(get_type() == 't');
+ // seq can be an Alg_event_list, an Alg_track, or an Alg_seq
+ // if it is an Alg_event_list, units_are_seconds must match
+ bool prev_units_are_seconds;
+ if (seq->get_type() == 'e') {
+ assert(seq->get_owner()->get_units_are_seconds() == units_are_seconds);
+ } else { // make it match
+ Alg_track_ptr tr = (Alg_track_ptr) seq;
+ prev_units_are_seconds = tr->get_units_are_seconds();
+ if (units_are_seconds) tr->convert_to_seconds();
+ else tr->convert_to_beats();
+ }
+ double dur = (units_are_seconds ? seq->get_real_dur() :
+ seq->get_beat_dur());
+
+ // Note: in the worst case, seq may contain notes
+ // that start almost anytime up to it's duration,
+ // so the simplest algorithm is simply a sequence
+ // of inserts. If this turns out to be too slow,
+ // we can do a merge sort in the case that seq
+ // is an Alg_track (if it's an Alg_event_list, we
+ // are not guaranteed that the events are in time
+ // order, but currently, only a true seq is allowed)
+
+ int i;
+ for (i = 0; i < length(); i++) {
+ if (events[i]->time > t - ALG_EPS) {
+ events[i]->time += dur;
+ }
+ }
+ for (i = 0; i < seq->length(); i++) {
+ Alg_event *new_event = copy_event((*seq)[i]);
+ new_event->time += t;
+ insert(new_event);
+ }
+ // restore track units to what they were before
+ if (seq->get_type() != 'e') {
+ Alg_track_ptr tr = (Alg_track_ptr) seq;
+ if (prev_units_are_seconds) tr->convert_to_seconds();
+ else tr->convert_to_beats();
+ }
+
+}
+
+
+void Alg_track::merge(double t, Alg_event_list_ptr seq)
+{
+ Alg_event_list_ref s = *seq;
+ for (int i = 0; i < s.length(); i++) {
+ Alg_event *new_event;
+ if (s[i]->is_note()) {
+ new_event = new Alg_note((Alg_note_ptr) s[i]);
+ } else {
+ new_event = new Alg_update((Alg_update_ptr) s[i]);
+ }
+ new_event->time += t;
+ insert(new_event);
+ }
+}
+
+
+void Alg_track::clear(double t, double len, bool all)
+{
+ int i;
+ int move_to = 0;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->overlap(t, len, all)) {
+ delete events[i];
+ } else { // if we're not clearing this event, move it to
+ // eliminate the gaps in events left by cleared events
+ events[move_to] = event;
+ // adjust times of events after t + len. This test is based
+ // on the one in Alg_event::overlap() for consistency.
+ if (event->time > t + len - ALG_EPS && event->time > t)
+ event->time -= len;
+ move_to++;
+ }
+ }
+ if (move_to != this->len) { // we cleared at least one note
+ sequence_number++; // Alg_event_lists based on this track become invalid
+ }
+ this->len = move_to; // adjust length since we removed events
+}
+
+
+void Alg_track::silence(double t, double len, bool all)
+{
+ int i;
+ int move_to = 0;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->overlap(t, len, all)) {
+ delete events[i];
+ } else { // if we're not clearing this event, move it to
+ // eliminate the gaps in events left by cleared events
+ events[move_to] = event;
+ move_to++;
+ }
+ }
+ if (move_to != this->len) { // we cleared at least one note
+ sequence_number++; // Alg_event_lists based on this track become invalid
+ }
+ this->len = move_to; // adjust length since we removed events
+}
+
+
+void Alg_track::insert_silence(double t, double len)
+{
+ int i;
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->time > t - ALG_EPS) event->time += len;
+ }
+}
+
+
+Alg_event_list *Alg_track::find(double t, double len, bool all,
+ long channel_mask, long event_type_mask)
+{
+ int i;
+ Alg_event_list *list = new Alg_event_list(this);
+ if (units_are_seconds) { // t and len are seconds
+ list->set_real_dur(len);
+ list->set_beat_dur(get_time_map()->time_to_beat(t + len) -
+ get_time_map()->time_to_beat(t));
+ } else { // t and len are beats
+ list->set_real_dur(get_time_map()->beat_to_time(t + len) -
+ get_time_map()->beat_to_time(t));
+ list->set_beat_dur(len);
+ }
+ for (i = 0; i < length(); i++) {
+ Alg_event_ptr event = events[i];
+ if (event->overlap(t, len, all)) {
+ if ((channel_mask == 0 ||
+ (event->chan < 32 &&
+ (channel_mask & (1 << event->chan)))) &&
+ ((event_type_mask == 0 ||
+ (event_type_mask & (1 << event->get_type_code()))))) {
+ list->append(event);
+ }
+ }
+ }
+ return list;
+}
+
+
+void Alg_time_sigs::expand()
+{
+ assert(maxlen >= len);
+ maxlen = (maxlen + 5); // extra growth for small sizes
+ maxlen += (maxlen >> 2); // add 25%
+ Alg_time_sig_ptr new_time_sigs = new Alg_time_sig[maxlen];
+ // now do copy
+ memcpy(new_time_sigs, time_sigs, len * sizeof(Alg_time_sig));
+ if (time_sigs)
+ delete[] time_sigs;
+ time_sigs = new_time_sigs;
+}
+
+
+void Alg_time_sigs::insert(double beat, double num, double den, bool force)
+{
+ // find insertion point:
+ for (int i = 0; i < len; i++) {
+ if (within(time_sigs[i].beat, beat, ALG_EPS)) {
+ // overwrite location i with new info
+ time_sigs[i].beat = beat;
+ time_sigs[i].num = num;
+ time_sigs[i].den = den;
+ return;
+ } else if (time_sigs[i].beat > beat) {
+ if ((i > 0 && // check if redundant with prev. time sig
+ time_sigs[i - 1].num == num &&
+ time_sigs[i - 1].den == den &&
+ within(fmod(beat - time_sigs[i - 1].beat,
+ 4 * time_sigs[i-1].num / time_sigs[i-1].den),
+ 0, ALG_EPS)) ||
+ // check if redundant with implied initial 4/4 time sig:
+ (i == 0 && num == 4 && den == 4 &&
+ within(fmod(beat, 4), 0, ALG_EPS))) {
+ if (!force) return; // redundant inserts can be ignored here
+ }
+ // make room for new event
+ if (maxlen <= len) expand();
+ // insert new event at i
+ memmove(&time_sigs[i + 1], &time_sigs[i],
+ sizeof(Alg_time_sig) * (len - i));
+ time_sigs[i].beat = beat;
+ time_sigs[i].num = num;
+ time_sigs[i].den = den;
+ len++;
+ return;
+ }
+ }
+ // if we fall out of loop, then this goes at end
+ if (maxlen <= len) expand();
+ time_sigs[len].beat = beat;
+ time_sigs[len].num = num;
+ time_sigs[len].den = den;
+ len++;
+}
+
+
+void Alg_time_sigs::show()
+{
+ printf("Alg_time_sig: ");
+ for (int i = 0; i < len; i++) {
+