Ascore

A Csound Scoring Front End
1. Introduction 2. Time Symbols 3. Note Patterns 4. Start Time
5. Multi-Note Patterns 6. Simultaneous Notes 7. The Track Section 8. Example 1
9. Building the Score Download

1. Introduction

Ascore allows you to create your Csound score visually. You specify pattern names in columns down the page, and each column represents a "track" in the score. For example,

7* Lovely_Melody % %
* | % Trumpet_Notes
3q % Strings |
q Lovely_Melody | %
5* | % %

The above portion of an Ascore "score" section contains 3 "tracks", being the 3 columns starting with Lovely_Melody. The leftmost column is the score's timing track which must consist only of note duration symbols. This structure gives a crude pictorial view of the music as it occurs in time. For instance, Lovely_Melody is a note pattern (previous defined--see below) that starts first. After 7 eighth notes have elapsed, Trumpet_Notes begins. After another eighth note has elapsed, Strings begins. A "|" symbol means that the note pattern above it is still playing. A "%" symbol is a rest symbol. At any row in the score, the current time is given by the sum of all duration symbols in the rows above it. Thus, when Lovely_Melody starts for the second time above 8 eighth notes (7* = 7 eighth notes, * = 1 eighth note) and 3 quarter notes (3q = 3 quarter notes) have already elapsed.

Observe that this accomplishes the most important goal of any Csound front end: you don't need to calculate the note start times by hand. The above block of tracks may be cut-and-pasted into another section of the score as-is without having to worry about score times.

This representation in terms of "tracks" accomplishes, what I consider to be, the second most important goal of a Csound front end: keeping track of the synchronization of different instruments and score sections. Note that the track columns have significance only with respect to the time symbol on the left-hand side of the page. Every pattern found on the same line will start at the same time. The time symbol on the left tells how much time will elapse before the next line is started. If the pattern duration lasts for 4 eighth notes, and the time symbol on the left is one eighth note, then the next line will start while the current line is still playing.



2. Time Symbols

One of the most difficult aspects of working with raw Csound scores is keeping track of the time. In Ascore you keep track of time with relative time symbols. These symbols are musical notes durations such as quarter notes, half notes, etc. You don't have to calculate the time for any of these symbols. They are calculated for you based on the value of the global TEMPO statement that must be at the top of your file. In the timing track of the score section the current time in the score is the sum of all the time duration symbols that precede the current row. In the above example there are five rows. If you append a sixth row at the bottom of the score its note pattern will begin at time (7*) + (*) + (3q) + (q) + (5*), which is 7 eighth notes plus 1 eighth note plus 3 quarter notes plus 1 quarter note plus 5 eighth notes. Thus, the sixth row begins after a time equal to 21 eighth notes.

The TEMPO is in units of beats per minute, where one beat is a quarter note. The duration symbols are

! sixteenth
* eighth
q quarter
h half
o whole



3. Note Patterns

A note pattern is the basic unit given on a score line. Patterns are sequences of notes, and notes are specified by a list of variables or literal numbers that form a Csound score line. Consider the following Csound score line:

i8 0 0.6 0.9 7.02

where p1 is the instrument number, p2 is the start time, p3 is the duration, p4 is the amplitude, and p5 is the pitch. You would define this line as a one-note pattern in Ascore with the following code:

set MyNote & 8 & q 0.9 7.02

The "set" keyword is used to define a variable or list of variables. In a note pattern definition the first element in the list is a local tempo specifier. In the above example, the tempo is given as "&" which means use the global TEMPO. The remaining elements in the list after the tempo specifier have the same order and meaning as the Csound score line. The second elemnt is the instrument number. The third element is the start time. Notice that in the example an "&" symbol is used for the start time. This means that the note starts at the current score time (the sum of the duration symbols in all rows preceding it), so you don't have to keep recalculating the time in seconds. The fourth element is the duration, and here we see the relative duration symbol for a quarter note, again so that you don't have to calculate time in seconds. The fifth element in the list is the amplitude, and the sixth element is the pitch. These values are given as literal numbers, but you can also specify them as variables. Consider the following variable definitions:

set AmpNormal 0.9
set FirstPitch 7.02

Now the note pattern definition can be rewritten with these new variables:

set MyNote & 8 & q AmpNormal FirstPitch

Any other note pattern definition can now use these variables.

Now "MyNote" can be listed in the track section as a pattern to be played.



4. Start Time

In the above examples we saw that the starting time of a note can be specified as the current score time by using the "&" symbol. This "relation symbol", as I call it, is actually a simple linear function that can have a gain and an offset. Specifying "&" is equivalent to writing the following psuedo code

(1 * &) + 0

or, 1 times the current score time plus 0 seconds (the "*" above means multiplication, which is why I say psuedo code). This way you can make subtle modifications to the note starting time such as


0.95&

&+1.01

2.5&+0.001

The syntax of the relation symbols requires that the gain (multiplier) be written with no multiplication symbol so that "2 times &" must be written as "2&" not as "2*&" (the "*" symbol is already used as a duration symbol). Also, there may not be any whitespace between the gain, "&", and offset specifiers.

The offset to a relation symbol can be either a literal number in units of seconds or a duration symbol.


&+[5*]

means the current score time plus 5 eighth notes. The duration symbols must be enclosed in square brackets in a start-time definition.



5. Multi-Note_Patterns

In the above section on Note Patterns we saw how a single-note pattern is defined. It resembles a score line in Csound but with some symbolic replacements. Try to imagine that a Csound score (for the same instrument) is a matrix: each p-field on a line is a separate column of the matrix, and each following line in the score (for the same instrument) is a separate row of the matrix.

i3 0 1 0.7
i3 1 1 0.6
i3 2 1 0.5
i3 3 1 0.4
i3 4 1 0.3

In Ascore, to define a pattern with more than one note, the pattern definition contains column names in place of p-fields. This means that each column must have its own definition, with an entry corresponding to each note in the pattern. For the above sequence of Csound notes the column containing the instrument numbers could be defined as follows:

set ins_a1 3 3 3 3 3

and the column containing the duration times could be defined as follows:

set dur_a1 1 1 1 1 1

But let's say that the note duration of 1 second corresponds to a tempo in which a quarter note is 1 second. Then the duration column would be defined as

set dur_a1 q q q q q

The column containing the amplitudes could be defined as follows:

set amp_a1 0.7 0.6 0.5 0.4 0.3

We could define the columns containing the start time with the following definition:

set str_a1 0 1 2 3 4

however, simply putting numbers for the note start times would defeat the primary purpose of a Csound front end. Instead, for the start time column we define the following definition:

set str_a1 & & & & &

which means that each note starts when the previous note ends. But we can simplify this further by setting the first relation symbol (the "&"), and Ascore will back-fill the column with the last symbol found until all notes are represented.

set str_a1 &

So now we can define the above Csound sequence of notes as a single pattern:

set ins_a1 3
set str_a1 &
set dur_a1 q
set amp_a1 0.7 0.6 0.5 0.4 0.3
set Pattern_a1 & ^ins_a1 ^str_a1 ^dur_a1 ^amp_a1

and now "Pattern_a1" can be listed in the track section as a pattern to be played.

The "^" symbol that is prepended to the column name means that the array is transposed (like in matrix algebra!). If the transpose symbol were not used, then each array would be substituted into "Pattern_a1" across instead of down. That would result in the pattern having many columns but only one row.

At last, notice the single "&" symbol preceding the "ins_a1" entry. This entry represents the local tempo. It means that, withing this pattern only, use this for the tempo. The "&" symbol means simply to use the global song tempo. We did not create an array definition for the local tempo since it doesn't change in the pattern. In fact, we could have simply put a "&" for the start time entry in the "Pattern_a1" line. The "&" symbol will be back-filled into all the notes at compile time.



6. Simultaneous Notes

There are two start time symbols: "&" and "@". The "&" in the above examples is the current score time but also relative to the current note pattern. If the note pattern contained, say, two notes, then the "&" in the second note's start time means "the current score time PLUS the duration of all preceding notes in this pattern". You can think of "&" as a sequential start time for notes in a pattern. If each note in a pattern is defined with "&" as the start time, then the notes follow one after the other in time.

The second start time is the "@" symbol. It means the absolute score time. If all notes in a pattern are defined with "@" as the start time then they all start simultaneously. You can thing of "@" as a parallel start time for notes in a pattern. It would be used for defining a piano chord, for example. Also, if you want notes to overlap, then you would use the "@" start time symbol with offsets:

@ @+[q]

which says that the first note starts at the absolute current score time and the second note starts at the same time, but after a quarter note duration. If the first note was defined with a half note duration, then the second note would start while the first note was still playing.



7. The Track Section

Any line in the Ascore (.asc) file that begins with a time duration symbol

! * q h o

is regarded as a track line. The TEMPO and TRACKS must be defined before any track lines are read.

TEMPO 100
TRACKS 3

The "#" symbol is a comment character.

When you don't want to compile the whole score but work only on some short passage, you can easily "comment out" the other parts of the score by using the SKIPSCORE and STARTSCORE keywords. Every score line after SKIPSCORE is found will be ignored until a STARTSCORE line is found.



8. Example 1

The following simple example illustrates the use of Ascore.


#	-----------------------------------------------------------
#	ex1_ascore.asc, A. Steffens Jr.,  5/23/2006
#
#	ascore example 1
#	-----------------------------------------------------------
#
#   
#   timing symbols:
#   ---------------
#   ! = 16th note
#   * = 8th note 
#   q = quarter note
#   h = half note
#   o = whole note
#   & = current score time, or current tempo
#   @ = parallel score time
#
#
#	pitch
#	---------------
#	8.00 = middle C in Csound
#



#   ----------------------
#   global volume slider
#   ----------------------
set Amp 1.0


#   -------------------------------
#   volume slider for instrument 1
#   -------------------------------
eval PAmp $Amp * 0.7


#
#   volume macros for instrument 1
#
eval pamp025        $PAmp * 0.25
eval pamp050        $PAmp * 0.5
eval pamp075        $PAmp * 0.75


#	------------------------------------------------------------
#	Pattern 1, instrument 1
#
set ins_pn1_1	1
set str_pn1_1	&
set dur_pn1_1	* q * q q
set amp_pn1_1	$pamp075 $pamp075 $pamp050 $pamp050 $pamp075
set pch_pn1_1	8.00  8.02  9.00  8.10  8.00
#
#
set pn1_rf_1	&  ^ins_pn1_1  ^str_pn1_1  ^dur_pn1_1  ^amp_pn1_1  ^pch_pn1_1
#	------------------------------------------------------------


#	------------------------------------------------------------
#	Pattern 2, instrument 1
#	(same as pattern 1, but up an octave---add 12 to the pitch
#	column)
#
child pn1_rf_2 pn1_rf_1   6  k+  12
#	------------------------------------------------------------


#	------------------------------------------------------------
#	Pattern 3, instrument 1
#	(same as pattern 1, but up with instrument 2 (multiply column
#	2 by 2)
#
child pn1_rf_3 pn1_rf_1   2  *  2
#	------------------------------------------------------------



#   ------------------------------------------------------------
#   a header file that is in Csound .sco format
#   must be done before any score lines
#	THIS IS WHERE FTABLES AND EVERYTHING ELSE THAT IS NOT A NOTE
#	DEFINITION IS INSERTED.
#
HEADER header.sco
#   ------------------------------------------------------------



#	------------------------------------------------------------
#	Score Tracks
#	------------------------------------------------------------
#
#	Tempo is 100 beats per minute
#
TEMPO 100
#
#	Start out with 1 "track", patterns 1 and 2 follow each other
#	then rest for 1 eighth note
#	Then let pattern 1 and 3 play at the same time in two tracks
#	Then rest for a quarter note
#	Then start pattern 1 playing in one track, and let pattern
#	2 start after 3 eighth notes have elapsed.
#	
#
TRACKS 1
#
o      pn1_rf_1
o      pn1_rf_2
#
*          %
#
TRACKS 2
#
o      pn1_rf_3      pn1_rf_1
#
q          %             %
#
3*     pn1_rf_1          %
5*         |         pn1_rf_3
3*         %             |
#
#
#	------------------------------------------------------------
#	end  Score section
#	------------------------------------------------------------


#	------------------------------------------------------------
#	append the Csound "e" to the score
#
END
#	------------------------------------------------------------



9. Building the Score

Ascore is an AWK script. It doesn't get any harder than this brothers and sisters:

    cat  ex1_ascore.asc   |   awk  -f  ascore.awk

    mv  hold.sco  ex1_ascore.sco
    

Ascore writes its output to a temporary file called hold.sco. Now compile ex1_ascore.sco with Csound.



Download Ascore

Lastest version is 3.5

The installation package just contains the ascore.awk file. It is very simple.




Linux Music Synthesis
[JPG image artwork that is a companion to the text]
© Alfred Steffens Jr., 2007