Csound Csound-dev Csound-tekno Search About

[Cs-dev] conditional loop and event question

Date2015-10-03 10:28
FromPeiman Khosravi
Subject[Cs-dev] conditional loop and event question
AttachmentsNone  None  
Dear all,

I've never done this before and can't figure it out in my head.

I'd like to put event (or event_i) inside a loop block in order to generate N instances of an instrument. I've tried a normal krate loop but I think I'm getting a note on each k-cycle instead of a predefined number of notes, which in the instrument below should correspond to the channel count in the file.  

instr 1
ilength filelen "$FILE"            ; Length of file in seconds
ichanNumb filenchnls "$FILE" 
kchanOffset init 0
generate:
kchanOffset = kchanOffset+1
event "i", 2, 0, ilength*0.02, kchanOffset
if (kchanOffset < ichanNumb) kgoto generate
endin

Any suggestions much appreciated.

All the best,
Peiman

Date2015-10-03 10:33
FromVictor Lazzarini
SubjectRe: [Cs-dev] conditional loop and event question
AttachmentsNone  None  
You need to make your counter 0 after you generate the desired number of events:

kcnt init 0
while kcnt < iend do
event ...
kcnt += 1
od
kcnt = 0

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:28, Peiman Khosravi <peimankhosravi@gmail.com> wrote:

Dear all,

I've never done this before and can't figure it out in my head.

I'd like to put event (or event_i) inside a loop block in order to generate N instances of an instrument. I've tried a normal krate loop but I think I'm getting a note on each k-cycle instead of a predefined number of notes, which in the instrument below should correspond to the channel count in the file.  

instr 1
ilength filelen "$FILE"            ; Length of file in seconds
ichanNumb filenchnls "$FILE" 
kchanOffset init 0
generate:
kchanOffset = kchanOffset+1
event "i", 2, 0, ilength*0.02, kchanOffset
if (kchanOffset < ichanNumb) kgoto generate
endin

Any suggestions much appreciated.

All the best,
Peiman
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-10-03 10:35
FromVictor Lazzarini
SubjectRe: [Cs-dev] conditional loop and event question
AttachmentsNone  None  
actually that was wrong. In my previous code, you should not reset kcnt if you only want one set of events in one kcycle.

Sorry for the confusion

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:28, Peiman Khosravi <peimankhosravi@gmail.com> wrote:

Dear all,

I've never done this before and can't figure it out in my head.

I'd like to put event (or event_i) inside a loop block in order to generate N instances of an instrument. I've tried a normal krate loop but I think I'm getting a note on each k-cycle instead of a predefined number of notes, which in the instrument below should correspond to the channel count in the file.  

instr 1
ilength filelen "$FILE"            ; Length of file in seconds
ichanNumb filenchnls "$FILE" 
kchanOffset init 0
generate:
kchanOffset = kchanOffset+1
event "i", 2, 0, ilength*0.02, kchanOffset
if (kchanOffset < ichanNumb) kgoto generate
endin

Any suggestions much appreciated.

All the best,
Peiman
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-10-03 10:38
FromVictor Lazzarini
SubjectRe: [Cs-dev] conditional loop and event question
AttachmentsNone  None  
Also note that you can do this at i-time:

icnt = 0
while icnt < iend do
event_i ...
icnt += 1
od

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:35, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:

actually that was wrong. In my previous code, you should not reset kcnt if you only want one set of events in one kcycle.

Sorry for the confusion

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:28, Peiman Khosravi <peimankhosravi@gmail.com> wrote:

Dear all,

I've never done this before and can't figure it out in my head.

I'd like to put event (or event_i) inside a loop block in order to generate N instances of an instrument. I've tried a normal krate loop but I think I'm getting a note on each k-cycle instead of a predefined number of notes, which in the instrument below should correspond to the channel count in the file.  

instr 1
ilength filelen "$FILE"            ; Length of file in seconds
ichanNumb filenchnls "$FILE" 
kchanOffset init 0
generate:
kchanOffset = kchanOffset+1
event "i", 2, 0, ilength*0.02, kchanOffset
if (kchanOffset < ichanNumb) kgoto generate
endin

Any suggestions much appreciated.

All the best,
Peiman
------------------------------------------------------------------------------
_______________________________________________
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-10-03 10:51
FromPeiman Khosravi
SubjectRe: [Cs-dev] conditional loop and event question
AttachmentsNone  None  
Thanks Victor,

That works perfectly!

Best,
Peiman

On 03/10/2015 10:38, Victor Lazzarini wrote:
Also note that you can do this at i-time:

icnt = 0
while icnt < iend do
event_i ...
icnt += 1
od

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:35, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:

actually that was wrong. In my previous code, you should not reset kcnt if you only want one set of events in one kcycle.

Sorry for the confusion

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 3 Oct 2015, at 10:28, Peiman Khosravi <peimankhosravi@gmail.com> wrote:

Dear all,

I've never done this before and can't figure it out in my head.

I'd like to put event (or event_i) inside a loop block in order to generate N instances of an instrument. I've tried a normal krate loop but I think I'm getting a note on each k-cycle instead of a predefined number of notes, which in the instrument below should correspond to the channel count in the file.  

instr 1
ilength filelen "$FILE"            ; Length of file in seconds
ichanNumb filenchnls "$FILE" 
kchanOffset init 0
generate:
kchanOffset = kchanOffset+1
event "i", 2, 0, ilength*0.02, kchanOffset
if (kchanOffset < ichanNumb) kgoto generate
endin

Any suggestions much appreciated.

All the best,
Peiman
------------------------------------------------------------------------------
_______________________________________________
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