Csound Csound-dev Csound-tekno Search About

Re: [Old-Csnd] [Csnd] simple MIDI arpeggiator... (fwd)

Date2016-03-08 21:31
Fromjpff
SubjectRe: [Old-Csnd] [Csnd] simple MIDI arpeggiator... (fwd)

---------- Forwarded message ----------
Date: Tue, 8 Mar 2016 13:54:04 -0500
From: Dr. Richard Boulanger 
Subject: Re: [Old-Csnd] [Csnd] simple MIDI arpeggiator...

nice!  thanks for making and thanks for sharing.  -dB

On Thu, Jul 16, 2015 at 6:25 AM, Rory Walsh  wrote:
       
       
       -+rtaudio=jack -odac -+rtmidi=virtual -M0 -b2048
       
       
       sr = 44100
       ksmps = 64
       nchnls = 2
       0dbfs=1


       gkNumNotes init 0
       gkNotes[] init 10

       massign 1, 1

       ;instrument is always on and listens for incoming MIDI notes
       instr 1000
       ;reset gkNumNotes to 0 when no notes are playing
       if active:k(2)==0 then
       gkNumNotes=0
       endif

       kstatus, kchan, kNoteNum, kVel  midiin            ;read in midi
       ktrigger  changed  kstatus, kchan, kNoteNum, kVel ;trigger if midi
       data changes
       if ktrigger=1 && kstatus!=0 then          ;if status byte is
       non-zero...
       ;    printks
       "status:%d%tchannel:%d%tdata1:%d%tdata2:%d%n",0,kstatus,kchan,kNoteNum,kVel
           if kVel!=0 then
                gkNotes[gkNumNotes] = kNoteNum
               gkNumNotes = gkNumNotes+1
           else
                gkNumNotes = gkNumNotes-1
           endif
       endif
       endin

       ;instrument is triggered by MIDI notes, and in turn
       ;triggers the sound synth, cycling through the held
       ;notes array. We only ever want one instance of this so
       ;we use turnoff to make sure.
       instr 1
       iInstances active 1
       if iInstances>1 then
           turnoff
       endif

       kIndex init 0
       if metro(4)==1 then
           event "i", 2, 0, 1, gkNotes[kIndex]
           ;printks "Note:%d Index:%d, NumNotes:%d\n", 0,
       gkNotes[kIndex],
       kIndex, gkNumNotes
           kIndex = kIndex
       
       f1 0 1024 10 1
       i1000 0 36000
       
       




--
_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design
Professional Writing and Music Technology Division
Berklee College of Music
______________________________________________
President of Boulanger Labs - http://boulangerlabs.com
Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book
Author & Editor of The Audio Programming Book -
http://mitpress.mit.edu/books/audio-programming-book
______________________________________________
about: http://www.boulangerlabs.com/about/richardboulanger/
about: http://www.csounds.com/community/developers/dr-richard-boulanger/
music:http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-b
oulanger-music/
______________________________________________
email: rboulanger@berklee.edu
facebook: https://www.facebook.com/richard.boulanger.58

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here