| I have now compared my own and JavaSound's methods for simply writing a wave
soundfile. Code snippets:
void renderWithJavaSound() throws java.io.IOException
{
FunctionTable functionTable = new FunctionTable();
functionTable.setHarmonic(1, 16834.0, 0.0);
functionTable.octaveToSamplingIncrement(8.0);
ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
for(int i = 0; i < 441000; i++)
{
int sample = (int) functionTable.tickInterpolated();
byteArrayOutputStream.write((byte) (sample & 0x000000ff));
byteArrayOutputStream.write((byte) ((sample & 0x0000ff00) >>
8));
}
byte[] buffer = byteArrayOutputStream.toByteArray();
System.out.println("Buffer length = " + buffer.length);
InputStream inputStream = new ByteArrayInputStream(buffer);
AudioFormat audioFormat = new
AudioFormat(AudioFormat.Encoding.PCM_SIGNED_BIG_ENDIAN, 44100.0, 16, 1, 16,
44100.0);
AudioStream audioStream = new AudioStream(inputStream, audioFormat,
AudioStream.UNKNOWN_LENGTH);
File file = new File("c:/JavaSound.wav");
AudioSystem.write(audioStream, file,
javax.media.sound.sampled.FileStream.FileType.WAVE, -1);
}
void renderWaveSoundfile() throws java.io.IOException
{
FunctionTable functionTable = new FunctionTable();
functionTable.setHarmonic(1, 16834.0, 0.0);
functionTable.octaveToSamplingIncrement(8.0);
WaveSoundfile waveSoundfile = new WaveSoundfile();
waveSoundfile.create("c:/WaveSoundfile.wav", 2, 1, 44100);
for(int i = 0; i < 441000; i++)
{
double sample = functionTable.tickInterpolated();
waveSoundfile.setSignal(0, sample);
waveSoundfile.tickWrite();
}
waveSoundfile.close();
}
Note that FunctionTable and WaveSoundfile are my own pure Java classes for
sound processing. The test writes a pure sine tone to the soundfile at
middle C using linear interpolation at 44.1 KHz 16 bit mono samples.
Preliminary impressions:
On my Pentium II 450 MHz 128 MB with HotSpot, the above takes, after several
iterations to give HotSpot time to optimize:
WaveSoundfile 0.5 seconds
JavaSound 0.7 seconds
My class is slightly faster. Given that JavaSound is in beta and is not
primarily designed for this kind of work, that's not so bad.
My code is more natural for this type of work. The JavaSound API is clearly
oriented towards real-time sound and is not primarily designed for
manipulating soundfiles. To use it in a more natural way, I would have to
implement my own subclass of InputStream into which I would push synthesized
or processed samples; the AudioSystem would then pull samples out of my
subclass.
However, I regard this as a small price to pay to get the rest of Java
Sound - but only if MIDI input is implemented and latency is adequate! It
would make sense for me to redesign my framework around this stream pull
orientation.
Note to people interested in Java for music: I am rendering in 1/20th of
real time.
Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa21025;
2 May 99 0:07 BST
Received: from [156.3.140.104] (helo=shoko.calarts.edu)
by shaun.maths.bath.ac.uk with esmtp (Exim 2.12 #1)
id 10dir0-0001WE-00
for jpff@maths.bath.ac.uk; Sun, 2 May 1999 00:07:27 +0100
Received: (from majordom@localhost)
by shoko.calarts.edu (8.9.3/8.9.3) id PAA02665
for music-dsp-outgoing; Sat, 1 May 1999 15:50:09 -0700 (PDT)
X-Authentication-Warning: shoko.calarts.edu: majordom set sender to owner-music-dsp@shoko.calarts.edu using -f
Received: from smtp4.mindspring.com (smtp4.mindspring.com [207.69.200.64])
by shoko.calarts.edu (8.9.3/8.9.3) with ESMTP id PAA02661
for ; Sat, 1 May 1999 15:50:07 -0700 (PDT)
Received: from Realizer (user-2ive2fd.dialup.mindspring.com [165.247.9.237])
by smtp4.mindspring.com (8.8.5/8.8.5) with SMTP id SAA21291;
Sat, 1 May 1999 18:50:02 -0400 (EDT)
Message-ID: <000701be9425$1a80c4e0$79d496c0@Realizer.ngt.sungard.com>
From: Michael Gogins
To: JavaSound , csound@maths.ex.ac.uk,
music-dsp
MMDF-Warning: Parse error in original version of preceding line at UK.AC.Bath.maths.omphalos
Subject: Evaluation of JavaSound
Date: Sat, 1 May 1999 18:51:05 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Sender: owner-music-dsp@shoko.calarts.edu
Precedence: bulk
Reply-To: music-dsp@shoko.calarts.edu
I have now compared my own and JavaSound's methods for simply writing a wave
soundfile. Code snippets:
void renderWithJavaSound() throws java.io.IOException
{
FunctionTable functionTable = new FunctionTable();
functionTable.setHarmonic(1, 16834.0, 0.0);
functionTable.octaveToSamplingIncrement(8.0);
ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
for(int i = 0; i < 441000; i++)
{
int sample = (int) functionTable.tickInterpolated();
byteArrayOutputStream.write((byte) (sample & 0x000000ff));
byteArrayOutputStream.write((byte) ((sample & 0x0000ff00) >>
8));
}
byte[] buffer = byteArrayOutputStream.toByteArray();
System.out.println("Buffer length = " + buffer.length);
InputStream inputStream = new ByteArrayInputStream(buffer);
AudioFormat audioFormat = new
AudioFormat(AudioFormat.Encoding.PCM_SIGNED_BIG_ENDIAN, 44100.0, 16, 1, 16,
44100.0);
AudioStream audioStream = new AudioStream(inputStream, audioFormat,
AudioStream.UNKNOWN_LENGTH);
File file = new File("c:/JavaSound.wav");
AudioSystem.write(audioStream, file,
javax.media.sound.sampled.FileStream.FileType.WAVE, -1);
}
void renderWaveSoundfile() throws java.io.IOException
{
FunctionTable functionTable = new FunctionTable();
functionTable.setHarmonic(1, 16834.0, 0.0);
functionTable.octaveToSamplingIncrement(8.0);
WaveSoundfile waveSoundfile = new WaveSoundfile();
waveSoundfile.create("c:/WaveSoundfile.wav", 2, 1, 44100);
for(int i = 0; i < 441000; i++)
{
double sample = functionTable.tickInterpolated();
waveSoundfile.setSignal(0, sample);
waveSoundfile.tickWrite();
}
waveSoundfile.close();
}
Note that FunctionTable and WaveSoundfile are my own pure Java classes for
sound processing. The test writes a pure sine tone to the soundfile at
middle C using linear interpolation at 44.1 KHz 16 bit mono samples.
Preliminary impressions:
On my Pentium II 450 MHz 128 MB with HotSpot, the above takes, after several
iterations to give HotSpot time to optimize:
WaveSoundfile 0.5 seconds
JavaSound 0.7 seconds
My class is slightly faster. Given that JavaSound is in beta and is not
primarily designed for this kind of work, that's not so bad.
My code is more natural for this type of work. The JavaSound API is clearly
oriented towards real-time sound and is not primarily designed for
manipulating soundfiles. To use it in a more natural way, I would have to
implement my own subclass of InputStream into which I would push synthesized
or processed samples; the AudioSystem would then pull samples out of my
subclass.
However, I regard this as a small price to pay to get the rest of Java
Sound - but only if MIDI input is implemented and latency is adequate! It
would make sense for me to redesign my framework around this stream pull
orientation.
Note to people interested in Java for music: I am rendering in 1/20th of
real time.
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa21418;
2 May 99 4:52 BST
Received: from [144.173.6.14] (helo=exeter.ac.uk)
by shaun.maths.bath.ac.uk with esmtp (Exim 2.12 #1)
id 10dnIy-0001a5-00
for jpff@maths.bath.ac.uk; Sun, 2 May 1999 04:52:36 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (EAA03964); Sun, 2 May 1999 04:49:28 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Sun, 2 May 1999 04:49:05 +0100
Received: from root@big.fishnet.net [204.89.144.3] by hermes via ESMTP (EAA10427); Sun, 2 May 1999 04:49:03 +0100 (BST)
Received: from rcsreg.com (x217.core.fishnet.net [204.89.144.217])
by big.fishnet.net (8.9.2/8.8.5) with ESMTP id TAA26741
for ; Sat, 1 May 1999 19:54:17 -0700 (PDT)
Message-ID: <372BCBDE.519D0346@rcsreg.com>
Date: Sun, 02 May 1999 03:51:58 +0000
From: Tobiah
X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.2 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: Csound List
Subject: why not database as score generator?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk
My company has been using Linux, the PHP CGI, and the Mysql SQL
database server as a key propellant for it's business. I love
this environment so much, that it got me to thinking.
When I make a large piece of music with Csound, I end up
littering a large directory tree on my hard drive with
endless lists of 'notes' portrayed in ASCII. This fact
is actually quite soothing to me in itself!
What has happened to me, is that after having been inundated
with various techniques of database creation and management
at my workplace, I have actually begun to see that the methods
that I have been using at work could actually reinforce and expand
those that I have been using at home to manage my music data.
As yet, I am focusing on 'score' data.
I want to be able to structure score data so that different aspects
of my piece (different score generator programs) could have a notion
as to what another part of the piece is doing, or using as pitch or
timing information.
My idea is rather undeveloped as yet, but I have a preliminary notion
as to the structure of the data that would be used. I am going to
list it here as an SQL database structure:
CREATE TABLE note (
note_rsn bigint(20) unsigned DEFAULT '0' NOT NULL auto_increment,
opcode float(4),
start float(4),
end float(4),
PRIMARY KEY (note_rsn)
);
CREATE TABLE pfield (
pfield_rsn bigint(20) unsigned DEFAULT '0' NOT NULL auto_increment,
p_note_rsn int(10) unsigned,
value float(4),
PRIMARY KEY (pfield_rsn)
);
CREATE TABLE notelist (
notelist_rsn bigint(20) unsigned DEFAULT '0' NOT NULL auto_increment,
p_note_rsn int(10) unsigned,
name varchar(20),
PRIMARY KEY (notelist_rsn)
);
So, the 'note' is the center of attraction. If there are pfields beyond
the third, then they are linked to the note by way of the 'p_note_rsn',
or, 'pointer to note record sequence number'. A similar relationship is
held between the 'note' and 'notelist', so that an actual score can be
pulled from 'notelist' through the 'name' field.
I was walking along the coast of southern California today, mingling
my toes with the surf, when a very striking thought blessed me as I
was mulling this data-structure over and over through my mind:
Supposing there were specific data types for things like
'sets of notes'. By this I am referring to a vague concept that
was brought up to me by a teacher that I admired. He showed me
a book (the title of which escapes me now) that had been compiled
by a composer that was enthralled with the idea of analysing and
composing music from the standpoint that there is a very basic unit
of music, called a 'set', which is really just an array of pitches.
The above data structure allows for the functionality of the present
(past?) 'cscore' lib. I know however, that there is a larger canvas
of relationships between score elements to be covered. I like the
idea of the SQL server as the core of score data, because it can span
pieces, users, computers, and continents! I would like to consider
'hosting' score data, for use, and particularly *dynamic* use by the
entire globe of csounders.
I am going to use perl to tie things together. I will try to make the
interface to the database generic, as with the DBI:: package.
I solicit any help in the design of the tables of this database, and
in the surrounding software. I want it to be done correctly.
Thanks,
Toby
- There otta be a law -
Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa21544;
2 May 99 6:31 BST
Received: from [144.173.6.14] (helo=exeter.ac.uk)
by shaun.maths.bath.ac.uk with esmtp (Exim 2.12 #1)
id 10dor6-0001ep-00
for jpff@maths.bath.ac.uk; Sun, 2 May 1999 06:31:56 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (GAA12805); Sun, 2 May 1999 06:28:20 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Sun, 2 May 1999 06:28:08 +0100
Received: from smtp3.mindspring.com [207.69.200.33] by hermes via ESMTP (GAA14439); Sun, 2 May 1999 06:28:07 +0100 (BST)
Received: from Realizer (user-2ive378.dialup.mindspring.com [165.247.12.232])
by smtp3.mindspring.com (8.8.5/8.8.5) with SMTP id BAA23015;
Sun, 2 May 1999 01:28:04 -0400 (EDT)
Message-ID: <000a01be945c$ad416a00$79d496c0@Realizer.ngt.sungard.com>
From: Michael Gogins
To: Tobiah , Csound List
Subject: Re: why not database as score generator?
Date: Sun, 2 May 1999 01:28:56 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk
This could be interesting, but I urge you to test the speed of note access
in your database with a test program using realistic numbers of notes.
You probably will get better results than I did, when years ago I used
Microsoft Access to do something like this on a 486 PC. In a word, it was
too slow for me in the context of generating 10 K notes every few minutes
for interactive algorithmic composition.
Probably speed is much better now, but you should check it out just to be
sure.
-----Original Message-----
From: Tobiah
To: Csound List
Date: Saturday, May 01, 1999 11:50 PM
Subject: why not database as score generator?
>My company has been using Linux, the PHP CGI, and the Mysql SQL
>database server as a key propellant for it's business. I love
>this environment so much, that it got me to thinking.
>
>When I make a large piece of music with Csound, I end up
>littering a large directory tree on my hard drive with
>endless lists of 'notes' portrayed in ASCII. This fact
>is actually quite soothing to me in itself!
>
>What has happened to me, is that after having been inundated
>with various techniques of database creation and management
>at my workplace, I have actually begun to see that the methods
>that I have been using at work could actually reinforce and expand
>those that I have been using at home to manage my music data.
>As yet, I am focusing on 'score' data.
>
>I want to be able to structure score data so that different aspects
>of my piece (different score generator programs) could have a notion
>as to what another part of the piece is doing, or using as pitch or
>timing information.
>
>My idea is rather undeveloped as yet, but I have a preliminary notion
>as to the structure of the data that would be used. I am going to
>list it here as an SQL database structure:
>
>
>CREATE TABLE note (
> note_rsn bigint(20) unsigned DEFAULT '0' NOT NULL auto_increment,
> opcode float(4),
> start float(4),
> end float(4),
> PRIMARY KEY (note_rsn)
>);
>
>CREATE TABLE pfield (
> pfield_rsn bigint(20) unsigned DEFAULT '0' NOT NULL
auto_increment,
> p_note_rsn int(10) unsigned,
> value float(4),
> PRIMARY KEY (pfield_rsn)
>);
>
>CREATE TABLE notelist (
> notelist_rsn bigint(20) unsigned DEFAULT '0' NOT NULL
auto_increment,
> p_note_rsn int(10) unsigned,
> name varchar(20),
> PRIMARY KEY (notelist_rsn)
>);
>
>
>
>So, the 'note' is the center of attraction. If there are pfields beyond
>the third, then they are linked to the note by way of the 'p_note_rsn',
>or, 'pointer to note record sequence number'. A similar relationship is
>held between the 'note' and 'notelist', so that an actual score can be
>pulled from 'notelist' through the 'name' field.
>
>I was walking along the coast of southern California today, mingling
>my toes with the surf, when a very striking thought blessed me as I
>was mulling this data-structure over and over through my mind:
>
>Supposing there were specific data types for things like
>'sets of notes'. By this I am referring to a vague concept that
>was brought up to me by a teacher that I admired. He showed me
>a book (the title of which escapes me now) that had been compiled
>by a composer that was enthralled with the idea of analysing and
>composing music from the standpoint that there is a very basic unit
>of music, called a 'set', which is really just an array of pitches.
>
>The above data structure allows for the functionality of the present
>(past?) 'cscore' lib. I know however, that there is a larger canvas
>of relationships between score elements to be covered. I like the
>idea of the SQL server as the core of score data, because it can span
>pieces, users, computers, and continents! I would like to consider
>'hosting' score data, for use, and particularly *dynamic* use by the
>entire globe of csounders.
>
>I am going to use perl to tie things together. I will try to make the
>interface to the database generic, as with the DBI:: package.
>
>I solicit any help in the design of the tables of this database, and
>in the surrounding software. I want it to be done correctly.
>
>Thanks,
>
>Toby
>
> - There otta be a law -
Received: from shaun.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa21587;
2 May 99 7:13 BST
Received: from [144.173.6.14] (helo=exeter.ac.uk)
by shaun.maths.bath.ac.uk with esmtp (Exim 2.12 #1)
id 10dpVL-0001f7-00
for jpff@maths.bath.ac.uk; Sun, 2 May 1999 07:13:31 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (HAA05116); Sun, 2 May 1999 07:10:08 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Sun, 2 May 1999 07:09:54 +0100
Received: from root@smtp4.fas.harvard.edu [140.247.30.84] by hermes via ESMTP (HAA09531); Sun, 2 May 1999 07:09:52 +0100 (BST)
Received: from default (volpe-3.student.harvard.edu [140.247.181.231]) by smtp4.fas.harvard.edu with SMTP id CAA27827; Sun, 2 May 1999 02:09:51 -0400 (EDT)
Message-ID: <002701be9462$4cea9360$e7b5f78c@default.fas.harvard.edu>
From: Dew Drops
To: The CSound mailinglist
Subject: Re: Repeat command in score (NOT section-wise)
Date: Sun, 2 May 1999 02:09:12 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk
Hi,
I'm a newbie to CSound and was trying to use the loop Gabriel Maldonado
demonstrated, but haven't been able to figure it out (I'm using DirectCsound
Version 2.5). This is my sco file:
{ 10 nn
;ins strt dur amp
i2 $nn .25 1
}
e
and I get this error:
sread: illegal opcode {, sect 1 line 9
What am I doing wrong ?
Do I have to do something different to use DirectCsound as opposed to CSound
? I'm just using the csound.exe that came with the DirectInstall zip (there
are no other exe's with it).
Drew
_____________________________________________________________________
Q: How many IBM 370's does it take to execute a job?
A: Four, three to hold it down, and one to rip its head off.
Drew Volpe volpe@fas.harvard.edu
_____________________________________________________________________
|