Csound Csound-dev Csound-tekno Search About

[Csnd] Array mathematics

Date2014-07-05 18:35
Fromhlolli
Subject[Csnd] Array mathematics
I have one short mathematical question. I'm trying to generate score trough
python programming(the same logic would apply for any programming language).
And I'm trying to find a way to write beat patterns.

So how would I go about having this array [1, 1, 1, 0.5, 0.5] of length
between note events (p2 field for example(assiming p3 is fixed at <0.5)).
Changed into 0, 1, 2, 3, 3.5. Well preferable would to extend this further.
To multiply the array so I would end up with 4 * [1, 1, 1, 0.5, 0.5] = 0, 1,
2, 3, 3.5, 4, 5, 6, 7, 7.5, 8, 9, 10, 11, 11.5, 12, 13, 14, 15, 15.5.

Well these operations are very useful when writing rhythmic music and would
save alot of space to make some simple mathematical operation rather than to
write it out by hands. Any ideas?



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-07-05 19:02
Fromumptious
SubjectRe: [Csnd] Array mathematics
I think you are going to have to describe what you want much more clearly before anyone can help you; I can't understand from your examples what the operation you are performing is. You need to explain the algorithm.


On 5 July 2014 18:35, hlolli <hlolli@gmail.com> wrote:
I have one short mathematical question. I'm trying to generate score trough
python programming(the same logic would apply for any programming language).
And I'm trying to find a way to write beat patterns.

So how would I go about having this array [1, 1, 1, 0.5, 0.5] of length
between note events (p2 field for example(assiming p3 is fixed at <0.5)).
Changed into 0, 1, 2, 3, 3.5. Well preferable would to extend this further.
To multiply the array so I would end up with 4 * [1, 1, 1, 0.5, 0.5] = 0, 1,
2, 3, 3.5, 4, 5, 6, 7, 7.5, 8, 9, 10, 11, 11.5, 12, 13, 14, 15, 15.5.

Well these operations are very useful when writing rhythmic music and would
save alot of space to make some simple mathematical operation rather than to
write it out by hands. Any ideas?



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-07-05 19:11
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Array mathematics
Yes, maybe bit unclear. Maybe I'm bit wishful. I want to find the algoritm to do this. I'm asking if someone knows a magic formula to make 

 [1, 1, 1, 0.5, 0.5]  become 0, 1, 2, 3, 3.5
or make
[0.5, 0.5, 1, 1, 1] become 0, 0.5, 1, 2, 3
etc...

My solution would be to

pattern = [0, 1, 2, 3, 3.5]

while index < len(pattern) * 4:
    pattern[index % len(pattern)]
    #Find a way to find when index reads the array to the end
    #count the times that it has reached the end and multiply that count by the total sum of the pattern array.

That's obviously inefficient, In supercollider they have this kind of rythm notation, just trying to find out how they calculate it.

So I can write 4/4 beat
[1, 1, 1, 1]
and repeat it x times without thinking about anything.


2014-07-05 18:02 GMT+00:00 umptious <umptious@gmail.com>:
I think you are going to have to describe what you want much more clearly before anyone can help you; I can't understand from your examples what the operation you are performing is. You need to explain the algorithm.


On 5 July 2014 18:35, hlolli <hlolli@gmail.com> wrote:
I have one short mathematical question. I'm trying to generate score trough
python programming(the same logic would apply for any programming language).
And I'm trying to find a way to write beat patterns.

So how would I go about having this array [1, 1, 1, 0.5, 0.5] of length
between note events (p2 field for example(assiming p3 is fixed at <0.5)).
Changed into 0, 1, 2, 3, 3.5. Well preferable would to extend this further.
To multiply the array so I would end up with 4 * [1, 1, 1, 0.5, 0.5] = 0, 1,
2, 3, 3.5, 4, 5, 6, 7, 7.5, 8, 9, 10, 11, 11.5, 12, 13, 14, 15, 15.5.

Well these operations are very useful when writing rhythmic music and would
save alot of space to make some simple mathematical operation rather than to
write it out by hands. Any ideas?



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






Date2014-07-05 19:53
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Array mathematics
Maybe it's just as simple as

pattern = [1, 1, 1, 0.5, 0.5]
index = 0
totaltime = 0 #p2 field

while index < len(pattern) *4:
    totaltime = totaltime + pattern[index % len(pattern)]

That would give me the first value of 1 instead of 0. That's not very much of a dilemma. So I think I'll do that.


2014-07-05 18:11 GMT+00:00 Hlöðver Sigurðsson <hlolli@gmail.com>:
Yes, maybe bit unclear. Maybe I'm bit wishful. I want to find the algoritm to do this. I'm asking if someone knows a magic formula to make 

 [1, 1, 1, 0.5, 0.5]  become 0, 1, 2, 3, 3.5
or make
[0.5, 0.5, 1, 1, 1] become 0, 0.5, 1, 2, 3
etc...

My solution would be to

pattern = [0, 1, 2, 3, 3.5]

while index < len(pattern) * 4:
    pattern[index % len(pattern)]
    #Find a way to find when index reads the array to the end
    #count the times that it has reached the end and multiply that count by the total sum of the pattern array.

That's obviously inefficient, In supercollider they have this kind of rythm notation, just trying to find out how they calculate it.

So I can write 4/4 beat
[1, 1, 1, 1]
and repeat it x times without thinking about anything.


2014-07-05 18:02 GMT+00:00 umptious <umptious@gmail.com>:

I think you are going to have to describe what you want much more clearly before anyone can help you; I can't understand from your examples what the operation you are performing is. You need to explain the algorithm.


On 5 July 2014 18:35, hlolli <hlolli@gmail.com> wrote:
I have one short mathematical question. I'm trying to generate score trough
python programming(the same logic would apply for any programming language).
And I'm trying to find a way to write beat patterns.

So how would I go about having this array [1, 1, 1, 0.5, 0.5] of length
between note events (p2 field for example(assiming p3 is fixed at <0.5)).
Changed into 0, 1, 2, 3, 3.5. Well preferable would to extend this further.
To multiply the array so I would end up with 4 * [1, 1, 1, 0.5, 0.5] = 0, 1,
2, 3, 3.5, 4, 5, 6, 7, 7.5, 8, 9, 10, 11, 11.5, 12, 13, 14, 15, 15.5.

Well these operations are very useful when writing rhythmic music and would
save alot of space to make some simple mathematical operation rather than to
write it out by hands. Any ideas?



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"







Date2014-07-05 20:08
Fromzappfinger
Subject[Csnd] Re: Array mathematics
So you want to convert the relative start times to absolute start times. 
The following will work, although it is not pretty (maybe someone else has a
better solution)

# define a global variable sum:
sum = 0

# function to add an element with 'memory'
def add(element):
  global sum
  sum+=element
  return sum

# a little list comprehension
abspattern = [add(el) for el in relpattern]

 

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-07-05 20:55
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Re: Array mathematics
Holy shit she solution was so simple after all that I slapped myself for being slow to think. Just wanted to share the obvious solution:

index = 0
pattern = [1, 1, 1, 0.5, 0.5]
totaltime = -1

while index < len(pattern)*4:
    pitch = 36
    totaltime = totaltime + pattern[index % len(pattern)]
    MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
    index += 1

The "magic" was to initialize totaltime to -1.

I'm hoping to use python to help me to write score in csound, I'm on the right track I think :)



2014-07-05 19:08 GMT+00:00 zappfinger <zappfinger@gmail.com>:
So you want to convert the relative start times to absolute start times.
The following will work, although it is not pretty (maybe someone else has a
better solution)

# define a global variable sum:
sum = 0

# function to add an element with 'memory'
def add(element):
  global sum
  sum+=element
  return sum

# a little list comprehension
abspattern = [add(el) for el in relpattern]



Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-07-06 03:30
FromJustin Smith
SubjectRe: [Csnd] Re: Array mathematics
in clojure:

(reductions + 0 [1 1 1 0.5 0.5])


On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Holy shit she solution was so simple after all that I slapped myself for being slow to think. Just wanted to share the obvious solution:

index = 0
pattern = [1, 1, 1, 0.5, 0.5]
totaltime = -1

while index < len(pattern)*4:
    pitch = 36
    totaltime = totaltime + pattern[index % len(pattern)]
    MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
    index += 1

The "magic" was to initialize totaltime to -1.

I'm hoping to use python to help me to write score in csound, I'm on the right track I think :)



2014-07-05 19:08 GMT+00:00 zappfinger <zappfinger@gmail.com>:

So you want to convert the relative start times to absolute start times.
The following will work, although it is not pretty (maybe someone else has a
better solution)

# define a global variable sum:
sum = 0

# function to add an element with 'memory'
def add(element):
  global sum
  sum+=element
  return sum

# a little list comprehension
abspattern = [add(el) for el in relpattern]



Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






Date2014-07-06 23:14
FromSteven Yi
SubjectRe: [Csnd] Re: Array mathematics
Thanks Justin for mentioning reductions! I hadn't realized there was
that function and it simplified some code in my Score library.

For Python, I came up with:

pattern = [1, 1, 1, 0.5, 0.5]
vals = [0]
for i in pattern:
    vals.append(vals[-1] + i)

where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
best to do that in a function, something like:

def repeat(start, pattern, numTimes=1):
  vals = [start]
  for k in range(numTimes):
    for i in pattern:
      vals.append(vals[-1] + i)
  return vals

vals = repeat(0, pattern, 4)

 and vals then equals:

[0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
12.0, 13.0, 14.0, 15.0, 15.5, 16.0]


On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith  wrote:
> in clojure:
>
> (reductions + 0 [1 1 1 0.5 0.5])
>
>
> On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson 
> wrote:
>>
>> Holy shit she solution was so simple after all that I slapped myself for
>> being slow to think. Just wanted to share the obvious solution:
>>
>> index = 0
>> pattern = [1, 1, 1, 0.5, 0.5]
>> totaltime = -1
>>
>> while index < len(pattern)*4:
>>     pitch = 36
>>     totaltime = totaltime + pattern[index % len(pattern)]
>>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>>     index += 1
>>
>> The "magic" was to initialize totaltime to -1.
>>
>> I'm hoping to use python to help me to write score in csound, I'm on the
>> right track I think :)
>>
>>
>>
>> 2014-07-05 19:08 GMT+00:00 zappfinger :
>>
>>> So you want to convert the relative start times to absolute start times.
>>> The following will work, although it is not pretty (maybe someone else
>>> has a
>>> better solution)
>>>
>>> # define a global variable sum:
>>> sum = 0
>>>
>>> # function to add an element with 'memory'
>>> def add(element):
>>>   global sum
>>>   sum+=element
>>>   return sum
>>>
>>> # a little list comprehension
>>> abspattern = [add(el) for el in relpattern]
>>>
>>>
>>>
>>> Richard
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>>> Sent from the Csound - General mailing list archive at Nabble.com.
>>>
>>>
>>> Send bugs reports to
>>>         https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>>
>>
>


Date2014-07-07 19:19
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Re: Array mathematics
Offtopic:

I'm experimenting alot with programming so I was interested to try the Clojure demos you have made Steven,

I installed all that was required but now I have library error:

CompilerException java.lang.ClassNotFoundException: csnd6.csnd6, compiling:
(score/demo/csound_demo.clj:1:1) 

How can I tell clojure/leningen/java? to find the Csound libraries?


2014-07-06 22:14 GMT+00:00 Steven Yi <stevenyi@gmail.com>:
Thanks Justin for mentioning reductions! I hadn't realized there was
that function and it simplified some code in my Score library.

For Python, I came up with:

pattern = [1, 1, 1, 0.5, 0.5]
vals = [0]
for i in pattern:
    vals.append(vals[-1] + i)

where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
best to do that in a function, something like:

def repeat(start, pattern, numTimes=1):
  vals = [start]
  for k in range(numTimes):
    for i in pattern:
      vals.append(vals[-1] + i)
  return vals

vals = repeat(0, pattern, 4)

 and vals then equals:

[0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
12.0, 13.0, 14.0, 15.0, 15.5, 16.0]


On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith <noisesmith@gmail.com> wrote:
> in clojure:
>
> (reductions + 0 [1 1 1 0.5 0.5])
>
>
> On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson <hlolli@gmail.com>
> wrote:
>>
>> Holy shit she solution was so simple after all that I slapped myself for
>> being slow to think. Just wanted to share the obvious solution:
>>
>> index = 0
>> pattern = [1, 1, 1, 0.5, 0.5]
>> totaltime = -1
>>
>> while index < len(pattern)*4:
>>     pitch = 36
>>     totaltime = totaltime + pattern[index % len(pattern)]
>>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>>     index += 1
>>
>> The "magic" was to initialize totaltime to -1.
>>
>> I'm hoping to use python to help me to write score in csound, I'm on the
>> right track I think :)
>>
>>
>>
>> 2014-07-05 19:08 GMT+00:00 zappfinger <zappfinger@gmail.com>:
>>
>>> So you want to convert the relative start times to absolute start times.
>>> The following will work, although it is not pretty (maybe someone else
>>> has a
>>> better solution)
>>>
>>> # define a global variable sum:
>>> sum = 0
>>>
>>> # function to add an element with 'memory'
>>> def add(element):
>>>   global sum
>>>   sum+=element
>>>   return sum
>>>
>>> # a little list comprehension
>>> abspattern = [add(el) for el in relpattern]
>>>
>>>
>>>
>>> Richard
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>>> Sent from the Csound - General mailing list archive at Nabble.com.
>>>
>>>
>>> Send bugs reports to
>>>         https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>>
>>
>


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-07-07 19:42
FromSteven Yi
SubjectRe: [Csnd] Re: Array mathematics
Which OS are you using? For Windows and OSX the csnd6.jar should get
installed into a location that's automatically found if you using the
Csound installer and install to the default path.

On Mon, Jul 7, 2014 at 2:19 PM, Hlöðver Sigurðsson  wrote:
> Offtopic:
>
> I'm experimenting alot with programming so I was interested to try the
> Clojure demos you have made Steven,
>
> I installed all that was required but now I have library error:
>
> CompilerException java.lang.ClassNotFoundException: csnd6.csnd6, compiling:
> (score/demo/csound_demo.clj:1:1)
>
> How can I tell clojure/leningen/java? to find the Csound libraries?
>
>
> 2014-07-06 22:14 GMT+00:00 Steven Yi :
>
>> Thanks Justin for mentioning reductions! I hadn't realized there was
>> that function and it simplified some code in my Score library.
>>
>> For Python, I came up with:
>>
>> pattern = [1, 1, 1, 0.5, 0.5]
>> vals = [0]
>> for i in pattern:
>>     vals.append(vals[-1] + i)
>>
>> where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
>> best to do that in a function, something like:
>>
>> def repeat(start, pattern, numTimes=1):
>>   vals = [start]
>>   for k in range(numTimes):
>>     for i in pattern:
>>       vals.append(vals[-1] + i)
>>   return vals
>>
>> vals = repeat(0, pattern, 4)
>>
>>  and vals then equals:
>>
>> [0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
>> 12.0, 13.0, 14.0, 15.0, 15.5, 16.0]
>>
>>
>> On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith 
>> wrote:
>> > in clojure:
>> >
>> > (reductions + 0 [1 1 1 0.5 0.5])
>> >
>> >
>> > On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson 
>> > wrote:
>> >>
>> >> Holy shit she solution was so simple after all that I slapped myself
>> >> for
>> >> being slow to think. Just wanted to share the obvious solution:
>> >>
>> >> index = 0
>> >> pattern = [1, 1, 1, 0.5, 0.5]
>> >> totaltime = -1
>> >>
>> >> while index < len(pattern)*4:
>> >>     pitch = 36
>> >>     totaltime = totaltime + pattern[index % len(pattern)]
>> >>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>> >>     index += 1
>> >>
>> >> The "magic" was to initialize totaltime to -1.
>> >>
>> >> I'm hoping to use python to help me to write score in csound, I'm on
>> >> the
>> >> right track I think :)
>> >>
>> >>
>> >>
>> >> 2014-07-05 19:08 GMT+00:00 zappfinger :
>> >>
>> >>> So you want to convert the relative start times to absolute start
>> >>> times.
>> >>> The following will work, although it is not pretty (maybe someone else
>> >>> has a
>> >>> better solution)
>> >>>
>> >>> # define a global variable sum:
>> >>> sum = 0
>> >>>
>> >>> # function to add an element with 'memory'
>> >>> def add(element):
>> >>>   global sum
>> >>>   sum+=element
>> >>>   return sum
>> >>>
>> >>> # a little list comprehension
>> >>> abspattern = [add(el) for el in relpattern]
>> >>>
>> >>>
>> >>>
>> >>> Richard
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> >>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>> >>> Sent from the Csound - General mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> Send bugs reports to
>> >>>         https://github.com/csound/csound/issues
>> >>> Discussions of bugs and features can be posted here
>> >>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >>> "unsubscribe
>> >>> csound"
>> >>>
>> >>>
>> >>>
>> >>
>> >
>>
>>
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>>
>


Date2014-07-07 19:44
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Re: Array mathematics
Linux fedora,

csnd6.jar is in /usr/local/lib/csnd6.jar

But /usr/local/lib/ is not listed in my $PATH, you think adding it there will solve this?


2014-07-07 18:42 GMT+00:00 Steven Yi <stevenyi@gmail.com>:
Which OS are you using? For Windows and OSX the csnd6.jar should get
installed into a location that's automatically found if you using the
Csound installer and install to the default path.

On Mon, Jul 7, 2014 at 2:19 PM, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
> Offtopic:
>
> I'm experimenting alot with programming so I was interested to try the
> Clojure demos you have made Steven,
>
> I installed all that was required but now I have library error:
>
> CompilerException java.lang.ClassNotFoundException: csnd6.csnd6, compiling:
> (score/demo/csound_demo.clj:1:1)
>
> How can I tell clojure/leningen/java? to find the Csound libraries?
>
>
> 2014-07-06 22:14 GMT+00:00 Steven Yi <stevenyi@gmail.com>:
>
>> Thanks Justin for mentioning reductions! I hadn't realized there was
>> that function and it simplified some code in my Score library.
>>
>> For Python, I came up with:
>>
>> pattern = [1, 1, 1, 0.5, 0.5]
>> vals = [0]
>> for i in pattern:
>>     vals.append(vals[-1] + i)
>>
>> where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
>> best to do that in a function, something like:
>>
>> def repeat(start, pattern, numTimes=1):
>>   vals = [start]
>>   for k in range(numTimes):
>>     for i in pattern:
>>       vals.append(vals[-1] + i)
>>   return vals
>>
>> vals = repeat(0, pattern, 4)
>>
>>  and vals then equals:
>>
>> [0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
>> 12.0, 13.0, 14.0, 15.0, 15.5, 16.0]
>>
>>
>> On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith <noisesmith@gmail.com>
>> wrote:
>> > in clojure:
>> >
>> > (reductions + 0 [1 1 1 0.5 0.5])
>> >
>> >
>> > On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson <hlolli@gmail.com>
>> > wrote:
>> >>
>> >> Holy shit she solution was so simple after all that I slapped myself
>> >> for
>> >> being slow to think. Just wanted to share the obvious solution:
>> >>
>> >> index = 0
>> >> pattern = [1, 1, 1, 0.5, 0.5]
>> >> totaltime = -1
>> >>
>> >> while index < len(pattern)*4:
>> >>     pitch = 36
>> >>     totaltime = totaltime + pattern[index % len(pattern)]
>> >>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>> >>     index += 1
>> >>
>> >> The "magic" was to initialize totaltime to -1.
>> >>
>> >> I'm hoping to use python to help me to write score in csound, I'm on
>> >> the
>> >> right track I think :)
>> >>
>> >>
>> >>
>> >> 2014-07-05 19:08 GMT+00:00 zappfinger <zappfinger@gmail.com>:
>> >>
>> >>> So you want to convert the relative start times to absolute start
>> >>> times.
>> >>> The following will work, although it is not pretty (maybe someone else
>> >>> has a
>> >>> better solution)
>> >>>
>> >>> # define a global variable sum:
>> >>> sum = 0
>> >>>
>> >>> # function to add an element with 'memory'
>> >>> def add(element):
>> >>>   global sum
>> >>>   sum+=element
>> >>>   return sum
>> >>>
>> >>> # a little list comprehension
>> >>> abspattern = [add(el) for el in relpattern]
>> >>>
>> >>>
>> >>>
>> >>> Richard
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> >>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>> >>> Sent from the Csound - General mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> Send bugs reports to
>> >>>         https://github.com/csound/csound/issues
>> >>> Discussions of bugs and features can be posted here
>> >>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >>> "unsubscribe
>> >>> csound"
>> >>>
>> >>>
>> >>>
>> >>
>> >
>>
>>
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>>
>


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-07-08 18:34
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Re: Array mathematics
I have made damn sure that both LD_LIBRARY_PATH and PATH are including /usr/local/lib where csnd6.jar is included.

According to the FLOSS manual, to use Java API
javac -cp /usr/local/lib/csound/java/csnd.jar CsoundCommand.java
java -cp /usr/local/lib/csound/java/csnd.jar:. CsoundCommand
But to update for csnd6 I would just chande the location to

javac -cp /usr/local/lib/csnd6.jar CsoundCommand.java

That will give me 

javac: file not found: CsoundCommand.java

also 

java -cp /usr/local/lib/csnd6.jar:. CsoundCommand

will give me

Error: Could not find or load main class CsoundCommand

Any ideas to get Java API working?(so I can try your score library)





2014-07-07 18:44 GMT+00:00 Hlöðver Sigurðsson <hlolli@gmail.com>:
Linux fedora,

csnd6.jar is in /usr/local/lib/csnd6.jar

But /usr/local/lib/ is not listed in my $PATH, you think adding it there will solve this?


2014-07-07 18:42 GMT+00:00 Steven Yi <stevenyi@gmail.com>:

Which OS are you using? For Windows and OSX the csnd6.jar should get
installed into a location that's automatically found if you using the
Csound installer and install to the default path.

On Mon, Jul 7, 2014 at 2:19 PM, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
> Offtopic:
>
> I'm experimenting alot with programming so I was interested to try the
> Clojure demos you have made Steven,
>
> I installed all that was required but now I have library error:
>
> CompilerException java.lang.ClassNotFoundException: csnd6.csnd6, compiling:
> (score/demo/csound_demo.clj:1:1)
>
> How can I tell clojure/leningen/java? to find the Csound libraries?
>
>
> 2014-07-06 22:14 GMT+00:00 Steven Yi <stevenyi@gmail.com>:
>
>> Thanks Justin for mentioning reductions! I hadn't realized there was
>> that function and it simplified some code in my Score library.
>>
>> For Python, I came up with:
>>
>> pattern = [1, 1, 1, 0.5, 0.5]
>> vals = [0]
>> for i in pattern:
>>     vals.append(vals[-1] + i)
>>
>> where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
>> best to do that in a function, something like:
>>
>> def repeat(start, pattern, numTimes=1):
>>   vals = [start]
>>   for k in range(numTimes):
>>     for i in pattern:
>>       vals.append(vals[-1] + i)
>>   return vals
>>
>> vals = repeat(0, pattern, 4)
>>
>>  and vals then equals:
>>
>> [0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
>> 12.0, 13.0, 14.0, 15.0, 15.5, 16.0]
>>
>>
>> On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith <noisesmith@gmail.com>
>> wrote:
>> > in clojure:
>> >
>> > (reductions + 0 [1 1 1 0.5 0.5])
>> >
>> >
>> > On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson <hlolli@gmail.com>
>> > wrote:
>> >>
>> >> Holy shit she solution was so simple after all that I slapped myself
>> >> for
>> >> being slow to think. Just wanted to share the obvious solution:
>> >>
>> >> index = 0
>> >> pattern = [1, 1, 1, 0.5, 0.5]
>> >> totaltime = -1
>> >>
>> >> while index < len(pattern)*4:
>> >>     pitch = 36
>> >>     totaltime = totaltime + pattern[index % len(pattern)]
>> >>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>> >>     index += 1
>> >>
>> >> The "magic" was to initialize totaltime to -1.
>> >>
>> >> I'm hoping to use python to help me to write score in csound, I'm on
>> >> the
>> >> right track I think :)
>> >>
>> >>
>> >>
>> >> 2014-07-05 19:08 GMT+00:00 zappfinger <zappfinger@gmail.com>:
>> >>
>> >>> So you want to convert the relative start times to absolute start
>> >>> times.
>> >>> The following will work, although it is not pretty (maybe someone else
>> >>> has a
>> >>> better solution)
>> >>>
>> >>> # define a global variable sum:
>> >>> sum = 0
>> >>>
>> >>> # function to add an element with 'memory'
>> >>> def add(element):
>> >>>   global sum
>> >>>   sum+=element
>> >>>   return sum
>> >>>
>> >>> # a little list comprehension
>> >>> abspattern = [add(el) for el in relpattern]
>> >>>
>> >>>
>> >>>
>> >>> Richard
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> >>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>> >>> Sent from the Csound - General mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> Send bugs reports to
>> >>>         https://github.com/csound/csound/issues
>> >>> Discussions of bugs and features can be posted here
>> >>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >>> "unsubscribe
>> >>> csound"
>> >>>
>> >>>
>> >>>
>> >>
>> >
>>
>>
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>>
>>
>


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






Date2014-07-08 18:53
FromSteven Yi
SubjectRe: [Csnd] Re: Array mathematics
For:

javac -cp /usr/local/lib/csnd6.jar CsoundCommand.java
javac: file not found: CsoundCommand.java

It sounds like you have the right command but CsoundCommand.java is
not in the directory you're running the command in. If that doesn't
compile, then you won't have a CsoundCommand.class file, so the next
part would fail:

java -cp /usr/local/lib/csound/java/csnd.jar:. CsoundCommand
Error: Could not find or load main class CsoundCommand

In general for Java, you need to have any external jar files you are
going to use as part of the classpath (give with the -cp flag). Also,
if they have native library components, then the directory where the
native lib is located needs to be given with
-Djava.lib.path=/where/lib_jcsound6.so/is/located.

You might want to try to simplify things a little bit by copying the
csnd6.jar and lib_jcsound6.so into the directory where you are
compiling the java files. You could do something like:

cd /Users/stevenyi/work/csound/csoundAPI_examples/java/src

 (using wherever you have the csoundAPI_examples folder)

cp /usr/local/lib/csound/java/csnd6.jar .
cp /usr/local/lib/csound/java/lib_jcsound6.so .

(double check the locaiton of lib_jcsound6.so)

javac -cp csnd6.jar csoundAPI_examples/*
java -cp csnd6.jar:. -Djava.lib.path=. examples/Example1



On Tue, Jul 8, 2014 at 1:34 PM, Hlöðver Sigurðsson  wrote:
> I have made damn sure that both LD_LIBRARY_PATH and PATH are including
> /usr/local/lib where csnd6.jar is included.
>
> According to the FLOSS manual, to use Java API
>
> javac -cp /usr/local/lib/csound/java/csnd.jar CsoundCommand.java
> java -cp /usr/local/lib/csound/java/csnd.jar:. CsoundCommand
>
> But to update for csnd6 I would just chande the location to
>
> javac -cp /usr/local/lib/csnd6.jar CsoundCommand.java
>
> That will give me
>
> javac: file not found: CsoundCommand.java
>
> also
>
> java -cp /usr/local/lib/csnd6.jar:. CsoundCommand
>
> will give me
>
> Error: Could not find or load main class CsoundCommand
>
> Any ideas to get Java API working?(so I can try your score library)
>
>
>
>
>
> 2014-07-07 18:44 GMT+00:00 Hlöðver Sigurðsson :
>
>> Linux fedora,
>>
>> csnd6.jar is in /usr/local/lib/csnd6.jar
>>
>> But /usr/local/lib/ is not listed in my $PATH, you think adding it there
>> will solve this?
>>
>>
>> 2014-07-07 18:42 GMT+00:00 Steven Yi :
>>
>>> Which OS are you using? For Windows and OSX the csnd6.jar should get
>>> installed into a location that's automatically found if you using the
>>> Csound installer and install to the default path.
>>>
>>> On Mon, Jul 7, 2014 at 2:19 PM, Hlöðver Sigurðsson 
>>> wrote:
>>> > Offtopic:
>>> >
>>> > I'm experimenting alot with programming so I was interested to try the
>>> > Clojure demos you have made Steven,
>>> >
>>> > I installed all that was required but now I have library error:
>>> >
>>> > CompilerException java.lang.ClassNotFoundException: csnd6.csnd6,
>>> > compiling:
>>> > (score/demo/csound_demo.clj:1:1)
>>> >
>>> > How can I tell clojure/leningen/java? to find the Csound libraries?
>>> >
>>> >
>>> > 2014-07-06 22:14 GMT+00:00 Steven Yi :
>>> >
>>> >> Thanks Justin for mentioning reductions! I hadn't realized there was
>>> >> that function and it simplified some code in my Score library.
>>> >>
>>> >> For Python, I came up with:
>>> >>
>>> >> pattern = [1, 1, 1, 0.5, 0.5]
>>> >> vals = [0]
>>> >> for i in pattern:
>>> >>     vals.append(vals[-1] + i)
>>> >>
>>> >> where vals then equals [0, 1, 2, 3, 3.5, 4.0].  It'd probably be be
>>> >> best to do that in a function, something like:
>>> >>
>>> >> def repeat(start, pattern, numTimes=1):
>>> >>   vals = [start]
>>> >>   for k in range(numTimes):
>>> >>     for i in pattern:
>>> >>       vals.append(vals[-1] + i)
>>> >>   return vals
>>> >>
>>> >> vals = repeat(0, pattern, 4)
>>> >>
>>> >>  and vals then equals:
>>> >>
>>> >> [0, 1, 2, 3, 3.5, 4.0, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 11.5,
>>> >> 12.0, 13.0, 14.0, 15.0, 15.5, 16.0]
>>> >>
>>> >>
>>> >> On Sat, Jul 5, 2014 at 10:30 PM, Justin Smith 
>>> >> wrote:
>>> >> > in clojure:
>>> >> >
>>> >> > (reductions + 0 [1 1 1 0.5 0.5])
>>> >> >
>>> >> >
>>> >> > On Sat, Jul 5, 2014 at 12:55 PM, Hlöðver Sigurðsson
>>> >> > 
>>> >> > wrote:
>>> >> >>
>>> >> >> Holy shit she solution was so simple after all that I slapped
>>> >> >> myself
>>> >> >> for
>>> >> >> being slow to think. Just wanted to share the obvious solution:
>>> >> >>
>>> >> >> index = 0
>>> >> >> pattern = [1, 1, 1, 0.5, 0.5]
>>> >> >> totaltime = -1
>>> >> >>
>>> >> >> while index < len(pattern)*4:
>>> >> >>     pitch = 36
>>> >> >>     totaltime = totaltime + pattern[index % len(pattern)]
>>> >> >>     MyMIDI.addNote(0, 0, pitch, totaltime, 0.25, 85)
>>> >> >>     index += 1
>>> >> >>
>>> >> >> The "magic" was to initialize totaltime to -1.
>>> >> >>
>>> >> >> I'm hoping to use python to help me to write score in csound, I'm
>>> >> >> on
>>> >> >> the
>>> >> >> right track I think :)
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> 2014-07-05 19:08 GMT+00:00 zappfinger :
>>> >> >>
>>> >> >>> So you want to convert the relative start times to absolute start
>>> >> >>> times.
>>> >> >>> The following will work, although it is not pretty (maybe someone
>>> >> >>> else
>>> >> >>> has a
>>> >> >>> better solution)
>>> >> >>>
>>> >> >>> # define a global variable sum:
>>> >> >>> sum = 0
>>> >> >>>
>>> >> >>> # function to add an element with 'memory'
>>> >> >>> def add(element):
>>> >> >>>   global sum
>>> >> >>>   sum+=element
>>> >> >>>   return sum
>>> >> >>>
>>> >> >>> # a little list comprehension
>>> >> >>> abspattern = [add(el) for el in relpattern]
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> Richard
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> View this message in context:
>>> >> >>>
>>> >> >>>
>>> >> >>> http://csound.1045644.n5.nabble.com/Array-mathematics-tp5736202p5736206.html
>>> >> >>> Sent from the Csound - General mailing list archive at Nabble.com.
>>> >> >>>
>>> >> >>>
>>> >> >>> Send bugs reports to
>>> >> >>>         https://github.com/csound/csound/issues
>>> >> >>> Discussions of bugs and features can be posted here
>>> >> >>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>> >> >>> "unsubscribe
>>> >> >>> csound"
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>
>>> >> >
>>> >>
>>> >>
>>> >> Send bugs reports to
>>> >>         https://github.com/csound/csound/issues
>>> >> Discussions of bugs and features can be posted here
>>> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>> >> "unsubscribe
>>> >> csound"
>>> >>
>>> >>
>>> >>
>>> >
>>>
>>>
>>> Send bugs reports to
>>>         https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>>
>>
>