Csound Csound-dev Csound-tekno Search About

[Cs-dev] API Real-time questions

Date2007-07-08 22:54
Frombenjohns
Subject[Cs-dev] API Real-time questions
Greetings everyone,
I’m an undergrad computer science student trying my best to write a Csound
frontend. I discovered Csound about two years ago and I started this
frontend project when classes let out for the summer. Most of my time so far
has been spent learning the windows API to create the GUI. Thanks to Rory’s
.pdf, my program renders a wave file from orchestra and score files just
fine.

Real-time has been more difficult. My initial goal is to get an oscillator
to play whenever I press a key. My current build uses csoundCreateThread()
and csoundScoreEvent() as described in Rory’s .pdf. I’ve got it to build and
run without crashing, but no noise plays. So after studying csound.h and
scanning the mailing list archives, I’ve decided it’s time to come out of
the shadows and ask my first two of probably several questions:

1. I need very simple Csound files to test real-time performance. I just
want to be sure these will work:

--- .sco ---
f1 0 2048 10 1  ;Sine 
f0 120
e

--- .orc ---
instr 1
	a1	oscil	12000, 400,1
	out	a1
endin

I then send to csoundInitialize() “csound orcFilePath scoFilePath –odac”. I
send to csoundScoreEvent() only p1 = 1, as my instrument takes no parameters
except p1 = 1 tells it to use the instrument named 1, correct?

2. csound.h seems to suggest that csoundSetPlayopenCallback() and
csoundSetRtplayCallback() would be useful to me as they are commented as
“for real-time use”, but I’m lost as to how to use them. My end goal is to
bind keyboard keys to instruments and parameters (e.g. “A” corresponds to
instrument 1 with p2 = 400) and then have those notes play when pressed.
Pseudocode:

BeginPerformance()
Loop: If(keypress) then PlayNote()
EndPerformance()

Should I concern myself with csoundSetRtplayCallback(), etc.? Is
csoundScoreEvent() the way to go? Is there a better way?

Thanks for reading. I feel if I can just get this simple oscillator to play
I will be able to accomplish the rest of my project goals with enough
effort. At that point I look forward to sharing it with you all.

- Ben Johnson

-- 
View this message in context: http://www.nabble.com/API-Real-time-questions-tf4046102.html#a11493207
Sent from the Csound - Dev mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourcefor

Date2007-07-09 09:53
FromVictor Lazzarini
SubjectRe: [Cs-dev] API Real-time questions
I think the simplest way to get RT playback is to use the
realtime modules that come with Csound (unless you
are in platform that does not have them). csoundSetRTPlaybackOpen()
et al are there so that you can implement your own RT, if
Csound does not provide it or you have a very good reason for
re-writing the RT modules.

So all you need to do is to pass the "-o dac" option to Csound,
which can be done either as an argument to csoundCompile()
(or Csound::Compile()) or in the  
field of a CSD file.

Victor


At 22:54 08/07/2007, you wrote:

>Greetings everyone,
>I’m an undergrad computer science student trying my best to write a Csound
>frontend. I discovered Csound about two years ago and I started this
>frontend project when classes let out for the summer. Most of my time so far
>has been spent learning the windows API to create the GUI. Thanks to Rory’s
>.pdf, my program renders a wave file from orchestra and score files just
>fine.
>
>Real-time has been more difficult. My initial goal is to get an oscillator
>to play whenever I press a key. My current build uses csoundCreateThread()
>and csoundScoreEvent() as described in Rory’s .pdf. I’ve got it to 
>build and
>run without crashing, but no noise plays. So after studying csound.h and
>scanning the mailing list archives, I’ve decided it’s time to come out of
>the shadows and ask my first two of probably several questions:
>
>1. I need very simple Csound files to test real-time performance. I just
>want to be sure these will work:
>
>--- .sco ---
>f1 0 2048 10 1  ;Sine
>f0 120
>e
>
>--- .orc ---
>instr 1
>         a1      oscil   12000, 400,1
>         out     a1
>endin
>
>I then send to csoundInitialize() “csound orcFilePath scoFilePath 
>­odac”. I
>send to csoundScoreEvent() only p1 = 1, as my instrument takes no parameters
>except p1 = 1 tells it to use the instrument named 1, correct?
>
>2. csound.h seems to suggest that csoundSetPlayopenCallback() and
>csoundSetRtplayCallback() would be useful to me as they are commented as
>“for real-time use”, but I’m lost as to how to use them. My end goal 
>is to
>bind keyboard keys to instruments and parameters (e.g. “A” corresponds to
>instrument 1 with p2 = 400) and then have those notes play when pressed.
>Pseudocode:
>
>BeginPerformance()
>Loop: If(keypress) then PlayNote()
>EndPerformance()
>
>Should I concern myself with csoundSetRtplayCallback(), etc.? Is
>csoundScoreEvent() the way to go? Is there a better way?
>
>Thanks for reading. I feel if I can just get this simple oscillator to play
>I will be able to accomplish the rest of my project goals with enough
>effort. At that point I look forward to sharing it with you all.
>
>- Ben Johnson
>
>--
>View this message in context: 
>http://www.nabble.com/API-Real-time-questions-tf4046102.html#a11493207
>Sent from the Csound - Dev mailing list archive at Nabble.com.
>
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>_______________________________________________
>Csound-devel mailing list
>Csound-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/csound-devel

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-07-09 10:18
Fromjpff
SubjectRe: [Cs-dev] API Real-time questions
>>>>> "benjohns" == benjohns   writes:

 benjohns> I then send to csoundInitialize() ?csound orcFilePath scoFilePath ?odac?. I
 benjohns> send to csoundScoreEvent() only p1 = 1, as my instrument takes no parameters
 benjohns> except p1 = 1 tells it to use the instrument named 1, correct?


You need p2 to say when to play and p3 to say for how long

==John ffitch

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-07-09 12:37
FromVictor Lazzarini
Subject[Cs-dev] pvsanal.c
John, I suppose this is the sliding PV underway, but could you
wrap it with a different token, instead of BETA?

It doesn't build here unless I use buildRelease=1. Perhaps
you could use a different token, so that I can still build a
debug version of Csound.

Victor
Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-07-10 04:57
Fromjpff
SubjectRe: [Cs-dev] pvsanal.c
What is the problem with use of BETA?  As far as i could tell it
compiled both with and without it.  Yes I am back-porting sliding
discrete Fourier transform so if the overlap is set too low it
switches to single sample overlaps.  Also modifies restriction on
overlap v k-rate.  
==John ffitch

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-07-10 10:29
FromVictor Lazzarini
SubjectRe: [Cs-dev] pvsanal.c
pvsanal.c wasn't compiling here with BETA, that's why I asked;
BETA is taken out if I use buildRelease=1 but then I don't
get the debug options as well.

Victor

At 04:57 10/07/2007, you wrote:
>What is the problem with use of BETA?  As far as i could tell it
>compiled both with and without it.  Yes I am back-porting sliding
>discrete Fourier transform so if the overlap is set too low it
>switches to single sample overlaps.  Also modifies restriction on
>overlap v k-rate.
>==John ffitch
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>_______________________________________________
>Csound-devel mailing list
>Csound-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/csound-devel

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net