Csound Csound-dev Csound-tekno Search About

[Csnd] Dynamically/Actively Panning Midi Notes

Date2013-06-28 18:25
Fromjkeary
Subject[Csnd] Dynamically/Actively Panning Midi Notes
Hi there,

I am using csound for my job and have come across something that has stumped
me greatly.  In a nutshell I need to pan an output midi file dynamically,
i.e. drag the notes across the stereo field from left to right over the
duration of the file.  My .csd file outputs a midi file, not an audio file,
not real time, just a .mid file: which I then load into a daw or notation
software such as sibelius, logic, or finale.  This seems to not be the
intended use for csound, regardless its what I am attempting to do for my
job.  The midi notes in the file can be long, and are in actuality tied note
statements such as this: 

inst st dur pch 
i1   0  -2   440
i1   1   1   440

This would be very easy to pan over the course of file if I just added pan p
statements throughout, like so:

inst st dur pch  pan
i1   0  -2   440  0
i1   1   1   440  1

which would pan the note (440 Hz) from left (0) to right (1) over the course
of 2 beats.  HOWEVER, it seems that the negative convention of tying notes
in csound (as laid out in the csound book and this article:
http://www.csounds.com/journal/2005fall/tiedNotes.html) does not translate
into the midi protocol, and thus these notation programs / daws don't know
what to do with a negative note.  So, I then created a matlab script to tie
notes together into a single note statement, in which something like this

inst st dur pch  pan 
i1   0  -2   440  0
i1   1   1   440  1

would become this 

inst st dur pch  pan
i1   0  2   440   ???

So how do I pan that, dynamically from left to right?  I thought of mono-ing
the whole file and creating a mixer instrument that would pan across the
entire file, something like as described here:
http://www.csounds.com/journal/issue13/emulatingMidiBasedStudios.html. 
However DYNAMIC panning doesn't seem possible with this.  Does anyone have
any thoughts on this?  Is it possible?  What about panning note statements
using ftables as you would do with regular cosund instruments?  How would
you do that with midi instruments?  

Heres some code:



--midioutfile=midipantest.mid



sr		=	44100
ksmps	=	100
nchnls	=	2
0dbfs	= 	1

#include "MIDI.txt"

$MIDI(1)



f6 0 -12 2 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0			; pan table (p7)
;p1	p2	p3	p4	p5	p6	p7
;inst	st	dur	note	vel	ch	pt	
i1	0	10	440	90	1	6
e


-----------
Midi.txt macro file:
#define MIDI(inno)	#
instr $inno.

idur = abs(p3)
ipch = p4
outic p6, 10, p7, 0, 127	  <---------- can I use the outic opcode with a pan
table instead of static pan value?
noteondur p6, ipch, ivel, idur

endin
#

Sorry for the long post, hope its clear.  Any help is greatly appreciated.

James




-----
jaemskeray
--
View this message in context: http://csound.1045644.n5.nabble.com/Dynamically-Actively-Panning-Midi-Notes-tp5724944.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2013-06-28 19:35
FromAndres Cabrera
SubjectRe: [Csnd] Dynamically/Actively Panning Midi Notes
Hi,

Panning in MIDI is a control message, generally control #10, so you could send a control output on the MIDI channel you need from 0 to 127 in the duration that you need. You could use int and changed to avoid sending more messages than you need.

Cheers,
Andrés


On Fri, Jun 28, 2013 at 10:25 AM, jkeary <jkeary@gmail.com> wrote:
Hi there,

I am using csound for my job and have come across something that has stumped
me greatly.  In a nutshell I need to pan an output midi file dynamically,
i.e. drag the notes across the stereo field from left to right over the
duration of the file.  My .csd file outputs a midi file, not an audio file,
not real time, just a .mid file: which I then load into a daw or notation
software such as sibelius, logic, or finale.  This seems to not be the
intended use for csound, regardless its what I am attempting to do for my
job.  The midi notes in the file can be long, and are in actuality tied note
statements such as this:

inst st dur pch
i1   0  -2   440
i1   1   1   440

This would be very easy to pan over the course of file if I just added pan p
statements throughout, like so:

inst st dur pch  pan
i1   0  -2   440  0
i1   1   1   440  1

which would pan the note (440 Hz) from left (0) to right (1) over the course
of 2 beats.  HOWEVER, it seems that the negative convention of tying notes
in csound (as laid out in the csound book and this article:
http://www.csounds.com/journal/2005fall/tiedNotes.html) does not translate
into the midi protocol, and thus these notation programs / daws don't know
what to do with a negative note.  So, I then created a matlab script to tie
notes together into a single note statement, in which something like this

inst st dur pch  pan
i1   0  -2   440  0
i1   1   1   440  1

would become this

inst st dur pch  pan
i1   0  2   440   ???

So how do I pan that, dynamically from left to right?  I thought of mono-ing
the whole file and creating a mixer instrument that would pan across the
entire file, something like as described here:
http://www.csounds.com/journal/issue13/emulatingMidiBasedStudios.html.
However DYNAMIC panning doesn't seem possible with this.  Does anyone have
any thoughts on this?  Is it possible?  What about panning note statements
using ftables as you would do with regular cosund instruments?  How would
you do that with midi instruments?

Heres some code:

<CsoundSynthesizer>
<CsOptions>
--midioutfile=midipantest.mid
</CsOptions>
<CsInstruments>

sr              =       44100
ksmps   =       100
nchnls  =       2
0dbfs   =       1

#include "MIDI.txt"

$MIDI(1)

</CsInstruments>
<CsScore>
f6 0 -12 2 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0                      ; pan table (p7)
;p1     p2      p3      p4      p5      p6      p7
;inst   st      dur     note    vel     ch      pt
i1      0       10      440     90      1       6
e
</CsScore>
</CsoundSynthesizer>
-----------
Midi.txt macro file:
#define MIDI(inno)      #
instr $inno.

idur = abs(p3)
ipch = p4
outic p6, 10, p7, 0, 127          <---------- can I use the outic opcode with a pan
table instead of static pan value?
noteondur p6, ipch, ivel, idur

endin
#

Sorry for the long post, hope its clear.  Any help is greatly appreciated.

James




-----
jaemskeray
--
View this message in context: http://csound.1045644.n5.nabble.com/Dynamically-Actively-Panning-Midi-Notes-tp5724944.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2013-07-01 06:32
Fromjkeary
Subject[Csnd] Re: Dynamically/Actively Panning Midi Notes
Hi Andreas,

Thanks for the quick reply, but I still not sure I understand.  Would I use
the ctrl7 opcode to pan it dynamically?  Perhaps an example would help. 
Thanks again.

James



-----
jaemskeray
--
View this message in context: http://csound.1045644.n5.nabble.com/Dynamically-Actively-Panning-Midi-Notes-tp5724944p5725029.html
Sent from the Csound - General mailing list archive at Nabble.com.