-
-
-
-
More Advanced Examples
-
-
-
-
- The following program demonstrates reading from two different input files. The idea is to switch between two 2-section scores, and write out the interleaved sections to a single output file.
-
-
-
-
-
-
-
- Finally, we show how to take a literal, uninterpreted score file and imbue it with some expressive timing changes. The theory of composer-related metric pulses has been investigated at length by Manfred Clynes, and the following is in the spirit of his work. The strategy here is to first create an array of new onset times for every possible sixteenth-note onset, then to index into it so as to adjust the start and duration of each note of the input score to the interpreted time-points. This also shows how a Csound orchestra can be invoked repeatedly from a run-time score generator.
-
-
-
-
-
-#include "cscore.h" /* CSCORE_PULSE.C */
-
-/* program to apply interpretive durational pulse to */
-/* an existing score in 3/4 time, first beats on 0, 3, 6 ... */
-
-
-static float four[4] = { 1.05, 0.97, 1.03, 0.95 }; /* pulse width for 4's */
-static float three[3] = { 1.03, 1.05, .92 }; /* pulse width for 3's */
-
-
-cscore(CSOUND* cs) /* This example should be called from Csound */
-{
- EVLIST *a, *b;
- EVENT *e, **ep;
- float pulse16[4*4*4*4*3*4]; /* 16th-note array, 3/4 time, 256 measures */
- float acc16, acc1,inc1, acc3,inc3, acc12,inc12, acc48,inc48, acc192,inc192;
- float *p = pulse16;
- int n16, n1, n3, n12, n48, n192;
-
- /* fill the array with interpreted ontimes */
- for (acc192=0.,n192=0; n192<4; acc192+=192.*inc192,n192++)
- for (acc48=acc192,inc192=four[n192],n48=0; n48<4; acc48+=48.*inc48,n48++)
- for (acc12=acc48,inc48=inc192*four[n48],n12=0;n12<4; acc12+=12.*inc12,n12++)
- for (acc3=acc12,inc12=inc48*four[n12],n3=0; n3<4; acc3+=3.*inc3,n3++)
- for (acc1=acc3,inc3=inc12*four[n3],n1=0; n1<3; acc1+=inc1,n1++)
- for (acc16=acc1,inc1=inc3*three[n1],n16=0; n16<4; acc16+=.25*inc1*four[n16],n16++)
- *p++ = acc16;
-
-
- /* for (p = pulse16, n1 = 48; n1--; p += 4) /* show vals & diffs */
- /* printf("%g %g %g %g %g %g %g %g\n", *p, *(p+1), *(p+2), *(p+3),
- /* *(p+1)-*p, *(p+2)-*(p+1), *(p+3)-*(p+2), *(p+4)-*(p+3)); */
-
- a = cscoreListGetSection(cs); /* read sect from tempo-warped score */
- b = cscoreListSeparateTWF(cs, a); /* separate warp & fn statements */
- cscoreListPlay(cs, b); /* and send these to performance */
- a = cscoreListAppendStringEvent(cs, a, "s"); /* append a sect statement to note list */
- cscoreListPlay(cs, a); /* play the note-list without interpretation */
- for (ep = &a->e[1], n1 = a->nevents; n1--; ) { /* now pulse-modifiy it */
- e = *ep++;
- if (e->op == 'i') {
- e->p[2] = pulse16[(int)(4. * e->p2orig)];
- e->p[3] = pulse16[(int)(4. * (e->p2orig + e->p3orig))] - e->p[2];
- }
- }
-
- cscoreListPlay(cs, a); /* now play modified list */
-}
-
-
-
-
-
-
-
diff --git a/CscoreCompile.html b/CscoreCompile.html
deleted file mode 100644
index 4526d119592..00000000000
--- a/CscoreCompile.html
+++ /dev/null
@@ -1,164 +0,0 @@
-
-
-
-
-
-
-
-
-
Compiling a Cscore Program
-
-
-
-
- A Cscore program can be invoked either as a standalone program or as part of Csound in between sorting the score and performing the score with the orchestra:
-
-
-
-
-
cscore
[scorefilein
] [> scorefileout
]
-
-
-
-
- or
-
-
-
-
-
csound
[-C] [otherflags
] [orchname
] [scorename
]
-
-
-
-
- Before trying to compile your own Cscore program, you will most likely want to obtain a copy of the Csound source code. Either download the latest source distribution for your platform or check out a copy of the csound5 module from Sourceforge CVS. There are several files in the sources that will help you. Within the examples/cscore/
directory are a number of examples of Cscore control programs, including all of the examples contained in this manual. And in the frontends/cscore/
directory are the two files cscoremain.c and cscore.c. cscoremain.c contains a simple main function that performs all of the initialization that a standalone Cscore program needs to do before it calls your control function. This main “stub” initializes Csound, reads the commandline arguments, opens the input and output score files, and then calls a function cscore(). As described above, it is expected that you will write the cscore() function and provide it in another file. The file frontends/cscore/cscore.c shows the simplest example of a cscore() function that reads in a score of any length and writes it to the output unchanged.
-
-
-So, to create a standalone program, write a control program as shown in the previous section. Let's assume that you saved this program in a file named “mycscore.c”. Next, you need to compile and link this program with the Csound library and cscoremain.c in order to create an exectuable by following the set of directions below that apply to your operating system. It will be helpful to already have some familiarity with the C compiler on your computer since the information below cannot be complete for all possible systems.
-
-
Linux and Unix
-
-The following commands assume that you have copied your file mycscore.c into the same directory as cscoremain.c, that you have opened a terminal to that same directory, and that you have previously installed a binary distribution of Csound that placed a library libcsound.a or libcsound.so into /usr/local/lib and the header files for the Csound API into /usr/local/include/csound.
-
-
-To compile and link:
-
-
-
-To run (sending the results to standard output):
-
-
-
-It is possible that on some Unix systems, the C compiler will be named cc or something else other than gcc.
-
-
Windows
-
-Csound is usually compiled on Windows using the MinGW environment that makes GCC -- the same compiler used on Linux -- available using a Unix-like command shell (MSYS). Since pre-compiled libraries for Csound on Windows are built in this way, you may need to use MinGW as well to link to them. If you have built Csound using another compiler, then you should be able to build Cscore with that compiler as well.
-
-
-Compiling standalone Cscore programs using MinGW should be similar to the procedure for Linux above with library and header paths changed appropriately for where Csound is installed on the Windows system. (Please feel free to contribute more detailed instructions here as the editor has been unable to test Cscore on a Windows machine).
-
-
OS X
-
-The following commands assume that you have copied your file mycscore.c into the same directory as cscoremain.c and that you have opened a terminal to that same directory. In addition, the Apple-supplied developer tools (including the GCC compiler) should be installed on your system and you should have previously installed a binary distribution of Csound that placed the CsoundLib framework into /Library/Frameworks.
-
-
-Use this command compile and link. (You may get a warning about "multiple definitions of symbol _cscore").
-
-
-
-To run (sending the results to standard output):
-
-
-
MacOS 9
-
- You will need CodeWarrior or some other development environment installed on your computer (MPW may work). Download the source code distribution for OS 9 (it will have a name like Csound5.05_OS9_src.smi.bin).
-
-
- If using CodeWarrior, find and open the project file "Cscore5.cw8.mcp" in the folder "Csound5.04-OS9-source:macintosh:Csound5Library:". This project file is configured to use the source files cscore.c and cscoremain_MacOS9.c from the csound5 source tree and the Csound5Lib shared library produced by compiling Csound with the "Csound5.cw8.mcp" project file. You should substitute your own Cscore program file for cscore.c and either compile Csound5Lib first or substitute a copy of the library in the project from the binary distribution of Csound for OS 9. The file cscoremain_MacOS9.c contains specialized code for configuring CodeWarrior's SIOUX console library and allows commandline arguments to be entered before the program is run.
-
-
-Once you have the proper files included in the project window, click the "Make" button and CodeWarrior should produce an application named “Cscore”. When you run this application, it first displays a window allowing you to type in the arguments to the main function. You only need to type in the filename or pathname to the input score -- do not type in "cscore". The input file should be in the same folder as the application or else you will need to type a full or relative pathname to the file. Output will be displayed in the console window. You can use the Save command from the File menu before quitting if you wish. Alternatively, in the commandline dialog, you can choose to redirect the output to a file by clicking on the File button on the right side of the dialog. (Note that the console window can only display about 32,000 characters, so writing to a file is necessary for long scores).
-
-
Making Cscore usable from within Csound
-
- To operate from Csound, first follow the instructions for compiling Csound (see Building Csound) according to the operating system that you are using. Once you have successfully built an unmodified Csound system, then substitute your own cscore() function for the one in the file Top/cscore_internal.c, and rebuild Csound.
-
-
- The resulting executable is your own special Csound, usable as above. The -C flag will invoke your Cscore program after the input score is sorted into “score.srt”. The details of what happens when you run Csound with the -C flag are given in the next section.
-
-
- Csound 5 also provides an additional way to run your own Cscore program from within Csound. Using the API, a host application can set a Cscore callback function, which is a function that Csound will call instead of using the built-in cscore() function. One advantage of this approach is that it is not necessary to recompile the entirety of Csound. Another benefit is that the host application can select at runtime from more than one Cscore function to designate as the callback. The disadvantage is that you need to write a host application.
-
-
- A simple approach to using a Cscore callback via the API would be to modify the standard Csound main program -- which is a simple Csound host -- contained in the file frontends/csound/csound_main.c. Adding a call to csoundSetCscoreCallback() after the call to csoundCreate() but before the call to csoundCompile() should do the job. Recompiling this file and linking to an existing Csound library will make a commandline version of Csound that works similarly to the one described above. Don't forget to use the -C flag.
-
-
Notes about score formats and run-time behavior
-
- As stated previously, the input files to Cscore may be in original or time-warped and pre-sorted form; this modality will be preserved (section by section) in reading, processing, and writing scores. Standalone processing will most often use unwarped sources and create unwarped new files. When running from within Csound, the input score will arrive already warped and sorted, and can thus be sent directly (normally section by section) to the orchestra. One advantage of this method of using Cscore is that all of the syntactical conveniences of the full Csound score language may be used -- macros, arithmetic expressions, carry, ramp, etc. -- since the score will go through the "Carry, Tempo, Sort" phases of score processing before being passed to the user-supplied Cscore program.
-
-
- When running within Csound, a list of events can be conveyed to a Csound orchestra using cscoreListPlay(). There may be any number of cscoreListPlay() calls in a Cscore program. Each list so conveyed can be either time-warped or not, but each list must be in strict p2-chronological order (either from presorting or using cscoreListSort()). If there is no cscoreListPlay() in a Cscore module run from within Csound, all events written out (via cscorePutEvent(), cscorePutString(), or cscoreListPut()) are written to a new score in the current directory with the name “cscore.out”. Csound then invokes the score sorter again before sending this new score to the orchestra for performance. The final, sorted, output score is written to a file named “cscore.srt”.
-
-
- A standalone Cscore program will normally use the “put” commands to write into its output file. If a standalone Cscore program calls cscoreListPlay(), the events thus intended for performance will be sent to the output in the same way as if cscoreListPut() had been called instead.
-
-
- A note list sent by cscoreListPlay() for performance should be temporally distinct from subsequent note lists. No note-end should extend past the next list's start time, since cscoreListPlay() will complete each list before starting the next (i.e. like a Section marker that doesn't reset local time to zero). This is important when using cscoreListGetNext() or cscoreListGetUntil() to fetch and process score segments prior to performance, because these functions may only read part of an unsorted section.
-
-
-
-
-
diff --git a/CscoreMain.html b/CscoreMain.html
deleted file mode 100644
index 0e1f6d63ea6..00000000000
--- a/CscoreMain.html
+++ /dev/null
@@ -1,390 +0,0 @@
-
-
-
-
-
-
-
-
-
Writing a Cscore Control Program
-
-
-
-
- The general format for a Cscore control program is:
-
-
-
-
-
-
- The include statement will define the event and list structures and all of the Cscore API functions for the program. The name of the user function needs to be cscore if it will be linked with the standard main program in cscormai.c
or linked as the internal Cscore routine for a personal Csound executable. This cscore() function receives one argument from cscormai.c
or Csound -- CSOUND *cs -- which is a pointer to a Csound object. The pointer cs must be passed as the first parameter to every Cscore API function that the program calls.
-
-
- The following C program will read from a standard numeric score, up to (but not including) the first s or e statement, then write that data (unaltered) as output.
-
-
-
-
-
-
-
- After execution of cscoreListGetSection(), the variable a points to a list of event addresses, each of which points to a stored event. We have used that same pointer to enable another list function -- cscoreListPut() -- to access and write out all of the events that were read. If we now define another symbol e to be an event pointer, then the statement
-
-
-
-
-
- will set it to the contents of the 4th slot in the EVLIST structure, a. The contents is a pointer to an event, which is itself comprised of an array of parameter field values. Thus the term e->p[5] will mean the value of parameter field 5 of the 4th event in the EVLIST denoted by a. The program below will multiply the value of that pfield by 2 before writing it out.
-
-
-
-
-
-
-
- Now consider the following score, in which p[5] contains frequency in Hz.
-
-
-
-
-
-
- If this score were given to the preceding main program, the resulting output would look like this:
-
-
-
-
-
-
- Note that the 4th event is in fact the second note of the score. So far we have not distinguished between notes and function table setup in a numeric score. Both can be classed as events. Also note that our 4th event has been stored in e[4] of the structure. For compatibility with Csound pfield notation, we will ignore p[0] and e[0] of the event and list structures, storing p1 in p[1], event 1 in e[1], etc. The Cscore functions all adopt this convention.
-
-
- As an extension to the above, we could decide to use the same pointers a and e to examine each of the events in the list. Note that e was not set to the numeral 4, but to the location of the 4th slot in the list. To inspect p5 of the previous event in the list, we need only redefine e with the assignment
-
-
-
-
-
-and reference the 5th slot of the pfield array using the expression
-
-
-
-
-
-
- More generally, we can use an integer variable as an index to the array e[], and access each event in sequence by using a loop and incrementing the index. The number of events stored in an EVLIST is contained in the nevents member of the struct.
-
-
-
-
-
-
-
- The above example starts with e[1] and increases the index each time through the loop (index++) until it is greater than a->nevents, the index of the last event in the list. The statements inside the for loop do execute a final time when index equals a->nevents.
-
-
- In the following program we will use the same input score. This time we will separate the ftable statements from the note statements. We will next write the three note-events stored in the list a to the output, then create a second score section consisting of the original pitch set and a transposed version of itself. This will bring about an octave doubling.
-
-
- Here, our index to the array is n and we increment n as part of a for block which iterates nevents times, allowing one statement to act upon the same pfield of each successive event.
-
-
-
-
-
-
-
- The output of this program is:
-
-
-
-
-
-
-
- If the output is only being written to a file, then the unsorted order of the events is not a problem. The output is written to a file (or standard output) whenever the function cscoreListPut() is used. However, if this program were to be called during a Csound performance and the function cscoreListPlay() replaced cscoreListPut(), then the events would be sent to the orchestra instead of to a file and they should then be sorted beforehand by calling the function cscoreListSort(). The details of score output and playing when using Cscore from within Csound are described in the next section.
-
-
- Next we extend the above program by using the for loop to look at p[5] and p[6]. In the original score p[6] denotes amplitude. To create a diminuendo in the added lower octave, which is independent from the original set of notes, a variable called dim will be used.
-
-
-
-
-
-
-
- Using the same input score again, the output from this program is:
-
-
-
-
-
-
- In the following program the same three-note sequence will be repeated at various time intervals. The starting time of each group is determined by the values of the array cue. This time the dim will occur for each group of notes rather than each note. Note the position of the statement which increments the variable dim outside the inner for loop.
-
-
-
-
-
-
-
- Here the inner for loop looks at the events of list a (the notes) and the outer for loop looks at each repetition of the events of list a (the pitch group "cues"). This program also demonstrates a useful trouble-shooting device with the printf function. The semi-colon is first in the character string to produce a comment statement in the resulting score file. In this case the value of cue is being printed in the output to insure that the program is taking the proper array member at the proper time. When output data is wrong or error messages are encountered, the printf function can help to pinpoint the problem.
-
-
- Using the same input file, the C program above will generate the following score. Can you determine why the last set of notes starts at the wrong time and how to correct the problem?
-
-
-
-
-
-
-
-
-
-
diff --git a/CscoreTop.html b/CscoreTop.html
deleted file mode 100644
index fcc1000e393..00000000000
--- a/CscoreTop.html
+++ /dev/null
@@ -1,255 +0,0 @@
-
-
-
-
-
-
-
-
- Cscore is an API (application programming interface) for generating and manipulating numeric score files. It is a part of the larger Csound API and includes a number of functions that can be called by a user-designed program written in the C language. Cscore can be invoked either as a standalone score preprocessor, or as part of a Csound performance by including the -C flag in its arguments:
-
-
-
-
-
cscore
[scorefilein
] [> scorefileout
]
-
-
-
-
(where cscore is the name of your user-written program), or
-
-
-
-
csound
[-C] [otherflags
] [orchname
] [scorename
]
-
-
-
-
- The available API functions augment the C language library functions; they can read either standard numeric scores or pre-sorted score files, can massage and expand the data in various ways, then make it available for performance by a Csound orchestra.
-
-
- The user-written control program is written in C, and is compiled and linked to the Csound library (or the csound commandline program) by the user. It is not essential to know the C language well to write this program, since the function calls have a simple syntax, and are powerful enough to do most of the complicated work. Additional power can come from C later as the need arises.
-
-
- The following sections explain all of the steps needed to make use of Cscore:
-
-
-
-
-
-
-
Events, Lists, and Operations
-
-
-
-
- An event in Cscore is equivalent to one statement of a standard numeric score or a time-warped score (the format in which Csound writes a sorted score -- see any score.srt), and is stored internally in time-warped format. It is important to note that when Cscore is used in standalone-mode, it cannot understand any of the non-numeric "conveniences" that Csound allows in the input score format. Therefore, scores making use of features such as carry, ramp, expressions, and others will have to either be sorted first with the scsort utility or used with a modified Csound executable that contains the user's Cscore program. Score opcodes with macro arguments (r, m, n, and {}) are not understood.
-
-
-Score events are each read in from an existing score file and stored in a C structure. The structures main components are an opcode and an array of pfield values. Cscore handles reading the events and storing them in memory for you. The format of the structure starts as follows:
-
-
-
-
-
-
-
-MYFLT is either the C type float or double depending on how your copy of the Csound library was compiled. You should just declare any floating-point variables as MYFLT in your user program for compatibility.
-
-
- Any Cscore function that creates, reads, or copies an event will return a pointer to the storage structure holding the event data. The event pointer can be used to access any component of the structure, in the form of e->op or e->p[n]. Each newly stored event will give rise to a new pointer, and a sequence of new events will generate a sequence of distinct pointers that must themselves be stored. Groups of event pointers are stored in an event list, which has its own structure:
-
-
-
-
-
-
-
- Any Cscore function that creates or modifies a list will return a pointer to the new list. The list pointer can be used to access any of its component event pointers, in the form of a->e[n]. Event pointers and list pointers are thus primary tools for manipulating the data of a score file. Pointers and lists of pointers can be copied and reordered without modifying the data values they refer to. This means that notes and phrases can be copied and manipulated from a high level of control. Alternatively, the data within an event or group of events can be modified without changing the event or list pointers. The Cscore API functions enable scores to be created and manipulated in this way.
-
-
-With Csound 5, the names of all of the Cscore API functions have changed to be more explicit. In addition, each function now requires a pointer to a CSOUND object as its first argument. The structure of the CSOUND object is unimportant (and indeed cannot be modified in a user program). How to obtain this CSOUND pointer will be shown in the next section. The Cscore functions and data structures are available in the cscore.h
header file, which you must include in your program code before you can you use them.
-
-
-The names of the Cscore functions specify whether they operate on single events or event lists. In the following summary of available function calls, some simple naming conventions are used:
-
-
-
-
-
-The symbol cs is a pointer to a CSOUND object (CSOUND *);
-The symbols e, f are pointers to events (notes);
-The symbols a, b are pointers to lists (arrays) of such events;
-The symbol n is an integer parameter of type int;
-"..." indicates a string parameter (either a constant or variable of type char *);
-The symbol fp is a score input stream file pointer (FILE *);
-
-calling syntax description
--------------- -----------
-/* Functions for working with single events */
-e = cscoreCreateEvent(cs, n); create a blank event with n pfields
-e = cscoreDefineEvent(cs, "..."); defines an event as per the character string ...
-e = cscoreCopyEvent(cs, f); make a new copy of event f
-e = cscoreGetEvent(cs); read the next event in the score input file
- cscorePutEvent(cs, e); write event e to the score output file
- cscorePutString(cs, "..."); write the string-defined event to score output
-
-/* Functions for working with event lists */
-a = cscoreListCreate(cs, n); create an empty event list with n slots
-a = cscoreListAppendEvent(cs, a, e); append event e to list a
-a = cscoreListAppendStringEvent(cs, a, "..."); append a string-defined event to list a;
-a = cscoreListCopy(cs, b); copy the list b (but not the events)
-a = cscoreListCopyEvents(cs, b); copy the events of b, making a new list
-a = cscoreListGetSection(cs); read all events from score input, up to next s or e
-a = cscoreListGetNext(cs, nbeats); read next nbeats beats from score input (nbeats is MYFLT)
-a = cscoreListGetUntil(cs, beatno); read all events from score input up to beat beatno (MYFLT)
-a = cscoreListSeparateF(cs, b); separate the f statements from list b into list a
-a = cscoreListSeparateTWF(cs, b); separate the t,w & f statements from list b into list a
-a = cscoreListAppendList(cs, a, b); append the list b onto the list a
-a = cscoreListConcatenate(cs, a, b); concatenate (append) the list b onto the list a (same as previous)
- cscoreListSort(cs, a); sort the list a into chronological order by p[2]
-n = cscoreListCount(cs, a); returns the number of events in list a
-a = cscoreListExtractInstruments(cs, b, "..."); extract notes of instruments ... (no new events)
-a = cscoreListExtractTime(cs, b, from, to); extract notes of time-span, creating new events (from and to are MYFLT)
- cscoreListPut(cs, a); write the events of list a to the score output file
- cscoreListPlay(cs, a); send events of list a to the Csound orchestra for
- immediate performance (or print events if no orchestra)
-/* Functions for reclaiming memory */
- cscoreFreeEvent(cs, e); release the space of event e
- cscoreListFree(cs, a); release the space of list a (but not the events)
- cscoreListFreeEvents(cs, a); release the events of list a, and the list space
-
-/* Functions for working with multiple input score files */
-fp = cscoreFileGetCurrent(cs); get the currently active input scorefile pointer
- (initially finds the command-line input scorefile pointer)
-fp = cscoreFileOpen(cs, "filename"); open another input scorefile (maximum of 5)
- cscoreFileSetCurrent(cs, fp); make fp the currently active scorefile pointer
- cscoreFileClose(cs, fp); close the scorefile relating to FILE *fp
-
-
-
-
-Under Csound 4, the function names and parameters were as follows:
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MiscAmp.html b/MiscAmp.html
index e5369e1dc77..f8a4f386761 100644
--- a/MiscAmp.html
+++ b/MiscAmp.html
@@ -35,7 +35,7 @@
John Bower, a student of Scott Lindroth, compiled this list of modal frequencies for various objects and materials. Some modes work better than others, and most need to be in a particular frequency range to sound plausible. Caveat emptor.
@@ -45,7 +45,7 @@