Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Trying to set up a C++ project using CSound API

Date2015-08-04 21:32
FromPeter Burgess
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

Aha! I've just realised that char* doesn't have to just be 1 character like char does (unless I totally misunderstood char in the first place). So char* should work fine.

I'm confused yet again about the functions like ReadScore and ScoreEvent. Do they add strings to your actual csd file to show the new score, or do they tell the active instance of Csound to play the score?

On 4 Aug 2015 17:22, "Rory Walsh" <rorywalsh@ear.ie> wrote:
should get you through. What I usually do is search the API docs for a function, then search for it in the C++ header file. Otherwise just ask here. 

On 4 August 2015 at 17:44, Michael Gogins <michael.gogins@gmail.com> wrote:
If you are using std::string you can do this:

csound->ReadScore(mystring.c_str());

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
<pete.soundtechnician@gmail.com> wrote:
> Aha, I'm assuming I was using C functions instead of the C++ ones.
>
> So can I actually use a string with readScore, as the manual says char?
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-04 21:48
FromMichael Gogins
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
When Csound is running it maintains a sorted linked list of score
events that have been massaged to be in real time starting from the
beginning of the performance. ReadScore, ScoreEvent, and InputMessage
all appropriately massage the text and insert a new score event into
the list. So these functions do not write any external files at all.
When performKsmps is called (internally, kperf), Csound examines this
list.  All events whose times are equal to or less than the current
performance time are dequeued from the list and, in most cases, an
instrument instance is created or found to perform that event.

In C and C++ "char" is a number representing one character of text.
ASCII and UTF8 characters are one byte in size (8 bits). In C and C++,
a "string" is an array of char that terminates in a null character
'\0'. A pointer to the first character in the array is also a pointer
to the entire array, the entire string. So a string is typically
represented by a pointer to char, "char *".

So the string "my string' would appear in memory as:

|m|y| |s|t|r|i|n|g|'\0'|

The length of the string, as e.g. returned by strlen, is 9, but you
have to allocate 10 bytes of memory to contain this string plus its
terminating null character.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 4:32 PM, Peter Burgess
 wrote:
> Aha! I've just realised that char* doesn't have to just be 1 character like
> char does (unless I totally misunderstood char in the first place). So char*
> should work fine.
>
> I'm confused yet again about the functions like ReadScore and ScoreEvent. Do
> they add strings to your actual csd file to show the new score, or do they
> tell the active instance of Csound to play the score?
>
> On 4 Aug 2015 17:22, "Rory Walsh"  wrote:
>
> The API docs at:
> http://csound.github.io/docs/api/index.html
> and
> https://github.com/csound/csound/blob/develop/include/csound.hpp
>
> should get you through. What I usually do is search the API docs for a
> function, then search for it in the C++ header file. Otherwise just ask
> here.
>
> On 4 August 2015 at 17:44, Michael Gogins  wrote:
>>
>> If you are using std::string you can do this:
>>
>> csound->ReadScore(mystring.c_str());
>>
>> Regards,
>> Mike
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
>>  wrote:
>> > Aha, I'm assuming I was using C functions instead of the C++ ones.
>> >
>> > So can I actually use a string with readScore, as the manual says char?
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-08-05 01:56
Frompete.goodeve@computer.org
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  

Date2015-08-05 09:33
FromPeter Burgess
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

Mike: Thanks again for an excellent explanation! I understand much clearer now what's going on. I was trying to put the ReadScore before and after compiling the .csd, as I was imagining that it might actually at text to a file or something before starting the performance, but after reading your explanation it was obvious that I had to start the performance first.

I am now fully able to send my scores from C++ to csound! Thank you all for helping me get there. Having spent so long wrestling with Csound, I have had time to get about half way to the first simple prototype on the C++ score gen side of things :D

Thanks Pete as well for chipping in on the char* subject. I'm gaining quite a detailed knowledge of c++ now. Before tackling the Csound API I thought I was fairly up to speed with C++, but I was quite wrong. I'd never come across -> or ? or char* before (when I first saw this I assumed it was just a pointer to a normal char).

If any of you are interested, I'll post up a link to show what I'm working on when I get the prototype up and running, though I dare say I'll be back with some more questions when my project starts to get more complex!

Pete

On 4 Aug 2015 21:49, "Michael Gogins" <michael.gogins@gmail.com> wrote:
When Csound is running it maintains a sorted linked list of score
events that have been massaged to be in real time starting from the
beginning of the performance. ReadScore, ScoreEvent, and InputMessage
all appropriately massage the text and insert a new score event into
the list. So these functions do not write any external files at all.
When performKsmps is called (internally, kperf), Csound examines this
list.  All events whose times are equal to or less than the current
performance time are dequeued from the list and, in most cases, an
instrument instance is created or found to perform that event.

In C and C++ "char" is a number representing one character of text.
ASCII and UTF8 characters are one byte in size (8 bits). In C and C++,
a "string" is an array of char that terminates in a null character
'\0'. A pointer to the first character in the array is also a pointer
to the entire array, the entire string. So a string is typically
represented by a pointer to char, "char *".

So the string "my string' would appear in memory as:

|m|y| |s|t|r|i|n|g|'\0'|

The length of the string, as e.g. returned by strlen, is 9, but you
have to allocate 10 bytes of memory to contain this string plus its
terminating null character.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 4:32 PM, Peter Burgess
<pete.soundtechnician@gmail.com> wrote:
> Aha! I've just realised that char* doesn't have to just be 1 character like
> char does (unless I totally misunderstood char in the first place). So char*
> should work fine.
>
> I'm confused yet again about the functions like ReadScore and ScoreEvent. Do
> they add strings to your actual csd file to show the new score, or do they
> tell the active instance of Csound to play the score?
>
> On 4 Aug 2015 17:22, "Rory Walsh" <rorywalsh@ear.ie> wrote:
>
> The API docs at:
> http://csound.github.io/docs/api/index.html
> and
> https://github.com/csound/csound/blob/develop/include/csound.hpp
>
> should get you through. What I usually do is search the API docs for a
> function, then search for it in the C++ header file. Otherwise just ask
> here.
>
> On 4 August 2015 at 17:44, Michael Gogins <michael.gogins@gmail.com> wrote:
>>
>> If you are using std::string you can do this:
>>
>> csound->ReadScore(mystring.c_str());
>>
>> Regards,
>> Mike
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
>> <pete.soundtechnician@gmail.com> wrote:
>> > Aha, I'm assuming I was using C functions instead of the C++ ones.
>> >
>> > So can I actually use a string with readScore, as the manual says char?
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-08-05 20:46
FromPeter Burgess
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

I'm having trouble using ReadScore to insert a tempo statement. I currently just want a single constant tempo throughout my performance, but if I send a char* = "t 0 180" using ReadScore, Csound reads the t as a w for some reason and tells me its an invalid score statement. I've also tried setting it in the .csd file, but it has no effect, presumably because there's no score statements to apply the tempo to when I compile the .csd. How do you guys deal with tempo?

Cheers in advance!

pete

On 5 Aug 2015 09:33, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

Mike: Thanks again for an excellent explanation! I understand much clearer now what's going on. I was trying to put the ReadScore before and after compiling the .csd, as I was imagining that it might actually at text to a file or something before starting the performance, but after reading your explanation it was obvious that I had to start the performance first.

I am now fully able to send my scores from C++ to csound! Thank you all for helping me get there. Having spent so long wrestling with Csound, I have had time to get about half way to the first simple prototype on the C++ score gen side of things :D

Thanks Pete as well for chipping in on the char* subject. I'm gaining quite a detailed knowledge of c++ now. Before tackling the Csound API I thought I was fairly up to speed with C++, but I was quite wrong. I'd never come across -> or ? or char* before (when I first saw this I assumed it was just a pointer to a normal char).

If any of you are interested, I'll post up a link to show what I'm working on when I get the prototype up and running, though I dare say I'll be back with some more questions when my project starts to get more complex!

Pete

On 4 Aug 2015 21:49, "Michael Gogins" <michael.gogins@gmail.com> wrote:
When Csound is running it maintains a sorted linked list of score
events that have been massaged to be in real time starting from the
beginning of the performance. ReadScore, ScoreEvent, and InputMessage
all appropriately massage the text and insert a new score event into
the list. So these functions do not write any external files at all.
When performKsmps is called (internally, kperf), Csound examines this
list.  All events whose times are equal to or less than the current
performance time are dequeued from the list and, in most cases, an
instrument instance is created or found to perform that event.

In C and C++ "char" is a number representing one character of text.
ASCII and UTF8 characters are one byte in size (8 bits). In C and C++,
a "string" is an array of char that terminates in a null character
'\0'. A pointer to the first character in the array is also a pointer
to the entire array, the entire string. So a string is typically
represented by a pointer to char, "char *".

So the string "my string' would appear in memory as:

|m|y| |s|t|r|i|n|g|'\0'|

The length of the string, as e.g. returned by strlen, is 9, but you
have to allocate 10 bytes of memory to contain this string plus its
terminating null character.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 4:32 PM, Peter Burgess
<pete.soundtechnician@gmail.com> wrote:
> Aha! I've just realised that char* doesn't have to just be 1 character like
> char does (unless I totally misunderstood char in the first place). So char*
> should work fine.
>
> I'm confused yet again about the functions like ReadScore and ScoreEvent. Do
> they add strings to your actual csd file to show the new score, or do they
> tell the active instance of Csound to play the score?
>
> On 4 Aug 2015 17:22, "Rory Walsh" <rorywalsh@ear.ie> wrote:
>
> The API docs at:
> http://csound.github.io/docs/api/index.html
> and
> https://github.com/csound/csound/blob/develop/include/csound.hpp
>
> should get you through. What I usually do is search the API docs for a
> function, then search for it in the C++ header file. Otherwise just ask
> here.
>
> On 4 August 2015 at 17:44, Michael Gogins <michael.gogins@gmail.com> wrote:
>>
>> If you are using std::string you can do this:
>>
>> csound->ReadScore(mystring.c_str());
>>
>> Regards,
>> Mike
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
>> <pete.soundtechnician@gmail.com> wrote:
>> > Aha, I'm assuming I was using C functions instead of the C++ ones.
>> >
>> > So can I actually use a string with readScore, as the manual says char?
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-08-05 21:11
FromMichael Gogins
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

You can't do it.

When Csound reads a sco or csd file it uses the tempo statements to "warp" the times in beats to absolute seconds and writes the warped events into a temporary file that actually drives the performance.

csoundReadScore assumes that all event times are absolute seconds.

Regards,
Mike

On Aug 5, 2015 3:47 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

I'm having trouble using ReadScore to insert a tempo statement. I currently just want a single constant tempo throughout my performance, but if I send a char* = "t 0 180" using ReadScore, Csound reads the t as a w for some reason and tells me its an invalid score statement. I've also tried setting it in the .csd file, but it has no effect, presumably because there's no score statements to apply the tempo to when I compile the .csd. How do you guys deal with tempo?

Cheers in advance!

pete

On 5 Aug 2015 09:33, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

Mike: Thanks again for an excellent explanation! I understand much clearer now what's going on. I was trying to put the ReadScore before and after compiling the .csd, as I was imagining that it might actually at text to a file or something before starting the performance, but after reading your explanation it was obvious that I had to start the performance first.

I am now fully able to send my scores from C++ to csound! Thank you all for helping me get there. Having spent so long wrestling with Csound, I have had time to get about half way to the first simple prototype on the C++ score gen side of things :D

Thanks Pete as well for chipping in on the char* subject. I'm gaining quite a detailed knowledge of c++ now. Before tackling the Csound API I thought I was fairly up to speed with C++, but I was quite wrong. I'd never come across -> or ? or char* before (when I first saw this I assumed it was just a pointer to a normal char).

If any of you are interested, I'll post up a link to show what I'm working on when I get the prototype up and running, though I dare say I'll be back with some more questions when my project starts to get more complex!

Pete

On 4 Aug 2015 21:49, "Michael Gogins" <michael.gogins@gmail.com> wrote:
When Csound is running it maintains a sorted linked list of score
events that have been massaged to be in real time starting from the
beginning of the performance. ReadScore, ScoreEvent, and InputMessage
all appropriately massage the text and insert a new score event into
the list. So these functions do not write any external files at all.
When performKsmps is called (internally, kperf), Csound examines this
list.  All events whose times are equal to or less than the current
performance time are dequeued from the list and, in most cases, an
instrument instance is created or found to perform that event.

In C and C++ "char" is a number representing one character of text.
ASCII and UTF8 characters are one byte in size (8 bits). In C and C++,
a "string" is an array of char that terminates in a null character
'\0'. A pointer to the first character in the array is also a pointer
to the entire array, the entire string. So a string is typically
represented by a pointer to char, "char *".

So the string "my string' would appear in memory as:

|m|y| |s|t|r|i|n|g|'\0'|

The length of the string, as e.g. returned by strlen, is 9, but you
have to allocate 10 bytes of memory to contain this string plus its
terminating null character.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 4:32 PM, Peter Burgess
<pete.soundtechnician@gmail.com> wrote:
> Aha! I've just realised that char* doesn't have to just be 1 character like
> char does (unless I totally misunderstood char in the first place). So char*
> should work fine.
>
> I'm confused yet again about the functions like ReadScore and ScoreEvent. Do
> they add strings to your actual csd file to show the new score, or do they
> tell the active instance of Csound to play the score?
>
> On 4 Aug 2015 17:22, "Rory Walsh" <rorywalsh@ear.ie> wrote:
>
> The API docs at:
> http://csound.github.io/docs/api/index.html
> and
> https://github.com/csound/csound/blob/develop/include/csound.hpp
>
> should get you through. What I usually do is search the API docs for a
> function, then search for it in the C++ header file. Otherwise just ask
> here.
>
> On 4 August 2015 at 17:44, Michael Gogins <michael.gogins@gmail.com> wrote:
>>
>> If you are using std::string you can do this:
>>
>> csound->ReadScore(mystring.c_str());
>>
>> Regards,
>> Mike
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
>> <pete.soundtechnician@gmail.com> wrote:
>> > Aha, I'm assuming I was using C functions instead of the C++ ones.
>> >
>> > So can I actually use a string with readScore, as the manual says char?
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-05 21:13
FromMichael Gogins
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

I should add, I don't use tempos at all, I generate scores with times in absolute seconds.

Doing the warping in your own code would not be hard, however.

Regards,
Mike

On Aug 5, 2015 3:47 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

I'm having trouble using ReadScore to insert a tempo statement. I currently just want a single constant tempo throughout my performance, but if I send a char* = "t 0 180" using ReadScore, Csound reads the t as a w for some reason and tells me its an invalid score statement. I've also tried setting it in the .csd file, but it has no effect, presumably because there's no score statements to apply the tempo to when I compile the .csd. How do you guys deal with tempo?

Cheers in advance!

pete

On 5 Aug 2015 09:33, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

Mike: Thanks again for an excellent explanation! I understand much clearer now what's going on. I was trying to put the ReadScore before and after compiling the .csd, as I was imagining that it might actually at text to a file or something before starting the performance, but after reading your explanation it was obvious that I had to start the performance first.

I am now fully able to send my scores from C++ to csound! Thank you all for helping me get there. Having spent so long wrestling with Csound, I have had time to get about half way to the first simple prototype on the C++ score gen side of things :D

Thanks Pete as well for chipping in on the char* subject. I'm gaining quite a detailed knowledge of c++ now. Before tackling the Csound API I thought I was fairly up to speed with C++, but I was quite wrong. I'd never come across -> or ? or char* before (when I first saw this I assumed it was just a pointer to a normal char).

If any of you are interested, I'll post up a link to show what I'm working on when I get the prototype up and running, though I dare say I'll be back with some more questions when my project starts to get more complex!

Pete

On 4 Aug 2015 21:49, "Michael Gogins" <michael.gogins@gmail.com> wrote:
When Csound is running it maintains a sorted linked list of score
events that have been massaged to be in real time starting from the
beginning of the performance. ReadScore, ScoreEvent, and InputMessage
all appropriately massage the text and insert a new score event into
the list. So these functions do not write any external files at all.
When performKsmps is called (internally, kperf), Csound examines this
list.  All events whose times are equal to or less than the current
performance time are dequeued from the list and, in most cases, an
instrument instance is created or found to perform that event.

In C and C++ "char" is a number representing one character of text.
ASCII and UTF8 characters are one byte in size (8 bits). In C and C++,
a "string" is an array of char that terminates in a null character
'\0'. A pointer to the first character in the array is also a pointer
to the entire array, the entire string. So a string is typically
represented by a pointer to char, "char *".

So the string "my string' would appear in memory as:

|m|y| |s|t|r|i|n|g|'\0'|

The length of the string, as e.g. returned by strlen, is 9, but you
have to allocate 10 bytes of memory to contain this string plus its
terminating null character.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Aug 4, 2015 at 4:32 PM, Peter Burgess
<pete.soundtechnician@gmail.com> wrote:
> Aha! I've just realised that char* doesn't have to just be 1 character like
> char does (unless I totally misunderstood char in the first place). So char*
> should work fine.
>
> I'm confused yet again about the functions like ReadScore and ScoreEvent. Do
> they add strings to your actual csd file to show the new score, or do they
> tell the active instance of Csound to play the score?
>
> On 4 Aug 2015 17:22, "Rory Walsh" <rorywalsh@ear.ie> wrote:
>
> The API docs at:
> http://csound.github.io/docs/api/index.html
> and
> https://github.com/csound/csound/blob/develop/include/csound.hpp
>
> should get you through. What I usually do is search the API docs for a
> function, then search for it in the C++ header file. Otherwise just ask
> here.
>
> On 4 August 2015 at 17:44, Michael Gogins <michael.gogins@gmail.com> wrote:
>>
>> If you are using std::string you can do this:
>>
>> csound->ReadScore(mystring.c_str());
>>
>> Regards,
>> Mike
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Tue, Aug 4, 2015 at 11:40 AM, Peter Burgess
>> <pete.soundtechnician@gmail.com> wrote:
>> > Aha, I'm assuming I was using C functions instead of the C++ ones.
>> >
>> > So can I actually use a string with readScore, as the manual says char?
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-05 23:18
FromPeter Burgess
SubjectRe: [Cs-dev] Trying to set up a C++ project using CSound API
AttachmentsNone  None  

Bugger! And I was hoping to get away with using ints for all the score generation and just multiplying the input tempo by 4 or the like to make it the right speed. You're right though, it will be trivial to generate the timing in full in my scoregen code. I'll just use ints to input the score data and convert it to floats to divide it up dependant on tempo