Csound Csound-dev Csound-tekno Search About

[Csnd] samples playback PWGL/Csound

Date2014-02-03 23:08
FromLuis Antunes Pena
Subject[Csnd] samples playback PWGL/Csound
Hello,

I'm building a patch in PWGL/Lisp that generates score events to trigger samples within a csound orchestra. This works fine until now. My problem is that the PWGL Patch is becoming more complex and it takes quite a long time to generate the csound score. One solution would be to move some tasks from PWGL to Csound which should be more much faster. This is where I would like to ask your opinion. How would you do the following: Csound receives a midi note number and has to decide according to the available samples which one to choose and which transposition should be applied. Something like this:

Samples available (60 63 66 69)
Input Midi note: 61
Output: sample 60 transposition 2^1/12

I thought about using tables but also about arrays - I'm not yet familiar with arrays.

Thanks.

Luís

--
signatur http://luisantunespena.eu


Date2014-02-04 12:42
Fromjoachim heintz
SubjectRe: [Csnd] samples playback PWGL/Csound
hi luis -

this should be very easy to do. the midi note triggers an instrument 
instance, and this instance selects the sample, and applies any other 
transformations. something like:

strset 60, "sample1.wav"
strset 61, "sample2.wav"
...

massign 0, "Play"

instr Play
iSample notnum
iTransp = 100 ;cent
aPlay diskin iSample, cent(iTransp)
out aPlay
endin

this is not tested, but you will know what i mean. not sure, though, in 
your example, how you get the sample and the transposition.

hoe this helps, best -

	joachim


Am 04.02.2014 00:08, schrieb Luis Antunes Pena:
> Hello,
>
> I'm building a patch in PWGL/Lisp that generates score events to trigger 61
> samples within a csound orchestra. This works fine until now. My problem
> is that the PWGL Patch is becoming more complex and it takes quite a
> long time to generate the csound score. One solution would be to move
> some tasks from PWGL to Csound which should be more much faster. This is
> where I would like to ask your opinion. How would you do the following:
> Csound receives a midi note number and has to decide according to the
> available samples which one to choose and which transposition should be
> applied. Something like this:
>
> Samples available (60 63 66 69)
> Input Midi note: 61
> Output: sample 60 transposition 2^1/12
>
> I thought about using tables but also about arrays - I'm not yet
> familiar with arrays.
>
> Thanks.
>
> Luís
>
> --
> signatur http://luisantunespena.eu
>

Date2014-02-05 10:21
FromTarmo Johannes
SubjectRe: [Csnd] samples playback PWGL/Csound
signatur

Hi Luis,

 

Thinking while writing, hope it leas somewhere...

 

So you have a sample according to say midi pitch 55, you want to play it on the pitch 56 and you want to find the fequancy ratio for diskin2 opcode (kpitch parameter) to get the right pitch modification from the sample 55

 

then I guess

itrans =

 

 

 

 

On Tuesday 04 February 2014 00:08:12 Luis Antunes Pena wrote:

Hello,

I'm building a patch in PWGL/Lisp that generates score events to trigger samples within a csound orchestra. This works fine until now. My problem is that the PWGL Patch is becoming more complex and it takes quite a long time to generate the csound score. One solution would be to move some tasks from PWGL to Csound which should be more much faster. This is where I would like to ask your opinion. How would you do the following: Csound receives a midi note number and has to decide according to the available samples which one to choose and which transposition should be applied. Something like this:

Samples available (60 63 66 69)
Input Midi note: 61
Output: sample 60 transposition 2^1/12

I thought about using tables but also about arrays - I'm not yet familiar with arrays.

Thanks.

Luís

--
http://luisantunespena.eu




Date2014-02-05 10:42
FromTarmo Johannes
SubjectRe: [Csnd] samples playback PWGL/Csound
signatur

sorry, pressed Enter incidentally

---------

Hi Luis,

 

Thinking while writing, hope it leas somewhere...

 

So you have a sample according to say midi pitch 55, you want to play it on the pitch 56 and you want to find the fequancy ratio for diskin2 opcode (kpitch parameter) to get the right pitch modification from the sample 55

 

then I guess

-----------

ifile = p4

iclosest_sample = 55

itrans = cpspch(ifile)/cpspch(iclosest_sample)

diskin2 ifile, itrans

 

the question is, how to find, which is the closest existing sample.

 

Perhaps easiest would be to define an array as you already suggested youself

 

giSampleIndex[] init 100 ; or how many notes you will have

 

giSampleIndex[55] = 55

giSampleIndex[56] = 55

giSampleIndex[57] = 55

;etc

giSampleIndex[58] = 58

giSampleIndex[59] = 58

 

Probalby it is more convenient to use genarray for defining the values

iarray genarray istart, iens[, inc]

 

and then

itrans = cpspch(ifile)/cpspch(giSampleIndex[ifile])

 

OR

you can define a table, for example with GEN07 (straight lines):

 

f 1 0 128 -7 0 55 0 0 55 3 55 0 58 4 58 ; etc I hope it is correct, did not check

and then

iclosest_sample tab_i ifile, 1

 

I myself would brefer the array version - somehow closer to my thinking

 

Best!

tarmo

 

 

 

 

 

There are better ways to fill array:

 

 

 

 

On Wednesday 05 February 2014 12:21:02 Tarmo Johannes wrote:

Hi Luis,

 

Thinking while writing, hope it leas somewhere...

 

So you have a sample according to say midi pitch 55, you want to play it on the pitch 56 and you want to find the fequancy ratio for diskin2 opcode (kpitch parameter) to get the right pitch modification from the sample 55

 

then I guess

itrans =

 

 

 

 

On Tuesday 04 February 2014 00:08:12 Luis Antunes Pena wrote:

Hello,

I'm building a patch in PWGL/Lisp that generates score events to trigger samples within a csound orchestra. This works fine until now. My problem is that the PWGL Patch is becoming more complex and it takes quite a long time to generate the csound score. One solution would be to move some tasks from PWGL to Csound which should be more much faster. This is where I would like to ask your opinion. How would you do the following: Csound receives a midi note number and has to decide according to the available samples which one to choose and which transposition should be applied. Something like this:

Samples available (60 63 66 69)
Input Midi note: 61
Output: sample 60 transposition 2^1/12

I thought about using tables but also about arrays - I'm not yet familiar with arrays.

Thanks.

Luís

--
http://luisantunespena.eu






Date2014-02-05 19:57
FromLuis Antunes Pena
SubjectRe: [Csnd] samples playback PWGL/Csound
Thanks Tarmo. I'll take  closer look at this an post later the development.

Am 05.02.14 11:42, schrieb Tarmo Johannes:
signatur

sorry, pressed Enter incidentally

---------

Hi Luis,

 

Thinking while writing, hope it leas somewhere...

 

So you have a sample according to say midi pitch 55, you want to play it on the pitch 56 and you want to find the fequancy ratio for diskin2 opcode (kpitch parameter) to get the right pitch modification from the sample 55

 

then I guess

-----------

ifile = p4

iclosest_sample = 55

itrans = cpspch(ifile)/cpspch(iclosest_sample)

diskin2 ifile, itrans

 

the question is, how to find, which is the closest existing sample.

 

Perhaps easiest would be to define an array as you already suggested youself

 

giSampleIndex[] init 100 ; or how many notes you will have

 

giSampleIndex[55] = 55

giSampleIndex[56] = 55

giSampleIndex[57] = 55

;etc

giSampleIndex[58] = 58

giSampleIndex[59] = 58

 

Probalby it is more convenient to use genarray for defining the values

iarray genarray istart, iens[, inc]

 

and then

itrans = cpspch(ifile)/cpspch(giSampleIndex[ifile])

 

OR

you can define a table, for example with GEN07 (straight lines):

 

f 1 0 128 -7 0 55 0 0 55 3 55 0 58 4 58 ; etc I hope it is correct, did not check

and then

iclosest_sample tab_i ifile, 1

 

I myself would brefer the array version - somehow closer to my thinking

 

Best!

tarmo

 

 

 

 

 

There are better ways to fill array:

 

 

 

 

On Wednesday 05 February 2014 12:21:02 Tarmo Johannes wrote:

Hi Luis,

 

Thinking while writing, hope it leas somewhere...

 

So you have a sample according to say midi pitch 55, you want to play it on the pitch 56 and you want to find the fequancy ratio for diskin2 opcode (kpitch parameter) to get the right pitch modification from the sample 55

 

then I guess

itrans =

 

 

 

 

On Tuesday 04 February 2014 00:08:12 Luis Antunes Pena wrote:

Hello,

I'm building a patch in PWGL/Lisp that generates score events to trigger samples within a csound orchestra. This works fine until now. My problem is that the PWGL Patch is becoming more complex and it takes quite a long time to generate the csound score. One solution would be to move some tasks from PWGL to Csound which should be more much faster. This is where I would like to ask your opinion. How would you do the following: Csound receives a midi note number and has to decide according to the available samples which one to choose and which transposition should be applied. Something like this:

Samples available (60 63 66 69)
Input Midi note: 61
Output: sample 60 transposition 2^1/12

I thought about using tables but also about arrays - I'm not yet familiar with arrays.

Thanks.

Luís

--
http://luisantunespena.eu







--
signatur http://luisantunespena.eu