Csound Csound-dev Csound-tekno Search About

[Csnd] FluidProgramSelect bank/preset from midi file?

Date2011-12-26 11:07
Fromzappfinger
Subject[Csnd] FluidProgramSelect bank/preset from midi file?
Is it possible that FluidProgramSelect's bank and preset number are assigned
from a midi file that is played?

Richard

--
View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5101360.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"

Date2011-12-26 11:47
FromVictor Lazzarini
SubjectRe: [Csnd] FluidProgramSelect bank/preset from midi file?
yes, see this example:

http://www.csounds.com/manual/html/examples/fluidcomplex.csd

On 26 Dec 2011, at 11:07, zappfinger wrote:

> Is it possible that FluidProgramSelect's bank and preset number are assigned
> from a midi file that is played?
> 
> Richard
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5101360.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





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"


Date2011-12-26 11:48
Fromzappfinger
Subject[Csnd] Re: FluidProgramSelect bank/preset from midi file?
So that is what this example is about ;-)
It uses midi status 192 (program change on channel 1) only, so I could
extend it for all incoming midi channels...

--
View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5101425.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"

Date2011-12-26 13:50
Fromzappfinger
Subject[Csnd] Re: FluidProgramSelect bank/preset from midi file?
I changed Istvan's example so that is reacts on program change/bank select
messages on channels 1..10
Now I can play a GM file and get the correct sounds ...



; Select audio/midi flags here according to platform
;Load external midi file from manual/examples
-odac -T -F  ./midis/AmD7bossa.mid   ;;;realtime audio I/O and midifile in
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o fluidcomplex.wav -W ;;; for file output any platform



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

; Example by Istvan Varga
; changed by zappfinger for more general use

; disable triggering of instruments by MIDI events

ichn = 1
lp1:
        massign   ichn, 0
        loop_le   ichn, 1, 16, lp1
        pgmassign 0, 0

; initialize FluidSynth

gifld   fluidEngine
gisf2   fluidLoad "./samples/003.3mg GS Roland Sound Set 16 bit Bank.sf2",
gifld, 1

; k-rate version of fluidProgramSelect

opcode fluidProgramSelect_k, 0, kkkkk
  keng, kchn, ksf2, kbnk, kpre xin
        igoto     skipInit
  doInit:
        fluidProgramSelect i(keng), i(kchn), i(ksf2), i(kbnk), i(kpre)
        reinit    doInit
        rireturn
  skipInit:
endop

instr 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  ; initialize channels
  kchn  init 1
  if (kchn == 1) then
lp2:
        fluidControl gifld, 192, kchn - 1, 0, 0
        fluidControl gifld, 176, kchn - 1, 7, 100
        fluidControl gifld, 176, kchn - 1, 10, 64
        loop_le   kchn, 1, 16, lp2
  endif

  ; send any MIDI events received to FluidSynth
nxt:
  kst, kch, kd1, kd2 midiin
  if (kst != 0) then
    if (kst != (192 + kch -1)) then  ; respond to changes on all channels...
        fluidControl gifld, kst, kch - 1, kd1, kd2
    else
        fluidProgramSelect_k gifld, kch - 1, gisf2, 0, kd1
    endif
      kgoto nxt
  endif

; get audio output from FluidSynth
  ivol   init 3 ;a bit louder
  aL, aR fluidOut gifld
         outs     aL*ivol, aR*ivol
endin




i 1 0 3600
e


 

--
View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5101547.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"

Date2011-12-26 18:49
FromVictor Lazzarini
SubjectRe: [Csnd] Re: FluidProgramSelect bank/preset from midi file?
Not sure what you mean, but here his original example work with a GM midifile without the need for any changes. PG changes were recognised in all channels.
On 26 Dec 2011, at 13:50, zappfinger wrote:

> I changed Istvan's example so that is reacts on program change/bank select
> messages on channels 1..10
> Now I can play a GM file and get the correct sounds ...
> 
> 
> 
> ; Select audio/midi flags here according to platform
> ;Load external midi file from manual/examples
> -odac -T -F  ./midis/AmD7bossa.mid   ;;;realtime audio I/O and midifile in
> ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
> ; For Non-realtime ouput leave only the line below:
> ; -o fluidcomplex.wav -W ;;; for file output any platform
> 
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs  = 1
> 
> ; Example by Istvan Varga
> ; changed by zappfinger for more general use
> 
> ; disable triggering of instruments by MIDI events
> 
> ichn = 1
> lp1:
>        massign   ichn, 0
>        loop_le   ichn, 1, 16, lp1
>        pgmassign 0, 0
> 
> ; initialize FluidSynth
> 
> gifld   fluidEngine
> gisf2   fluidLoad "./samples/003.3mg GS Roland Sound Set 16 bit Bank.sf2",
> gifld, 1
> 
> ; k-rate version of fluidProgramSelect
> 
> opcode fluidProgramSelect_k, 0, kkkkk
>  keng, kchn, ksf2, kbnk, kpre xin
>        igoto     skipInit
>  doInit:
>        fluidProgramSelect i(keng), i(kchn), i(ksf2), i(kbnk), i(kpre)
>        reinit    doInit
>        rireturn
>  skipInit:
> endop
> 
> instr 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
>  ; initialize channels
>  kchn  init 1
>  if (kchn == 1) then
> lp2:
>        fluidControl gifld, 192, kchn - 1, 0, 0
>        fluidControl gifld, 176, kchn - 1, 7, 100
>        fluidControl gifld, 176, kchn - 1, 10, 64
>        loop_le   kchn, 1, 16, lp2
>  endif
> 
>  ; send any MIDI events received to FluidSynth
> nxt:
>  kst, kch, kd1, kd2 midiin
>  if (kst != 0) then
>    if (kst != (192 + kch -1)) then  ; respond to changes on all channels...
>        fluidControl gifld, kst, kch - 1, kd1, kd2
>    else
>        fluidProgramSelect_k gifld, kch - 1, gisf2, 0, kd1
>    endif
>      kgoto nxt
>  endif
> 
> ; get audio output from FluidSynth
>  ivol   init 3 ;a bit louder
>  aL, aR fluidOut gifld
>         outs     aL*ivol, aR*ivol
> endin
> 
> 
> 
> 
> i 1 0 3600
> e
> 
> 
>  
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5101547.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





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"


Date2011-12-26 21:09
Fromzappfinger
Subject[Csnd] Re: FluidProgramSelect bank/preset from midi file?
It did not work at all for me, until I made these changes. 
Wrong instruments. I am talking about a multitimbral (multichannel) GM file,
with drums, piano, bass, organ, etc.
In this case generated by BiaB, because somehow Logic Express does not allow
me to create multi-channel midi files (but that's another story).
Here is an example.
http://csound.1045644.n5.nabble.com/file/n5102064/12brok1.MID 12brok1.MID 




--
View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5102064.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"

Date2011-12-26 21:22
FromVictor Lazzarini
SubjectRe: [Csnd] Re: FluidProgramSelect bank/preset from midi file?
Funny, because it always works here with my MIDI files.
On 26 Dec 2011, at 21:09, zappfinger wrote:

> It did not work at all for me, until I made these changes. 
> Wrong instruments. I am talking about a multitimbral (multichannel) GM file,
> with drums, piano, bass, organ, etc.
> In this case generated by BiaB, because somehow Logic Express does not allow
> me to create multi-channel midi files (but that's another story).
> Here is an example.
> http://csound.1045644.n5.nabble.com/file/n5102064/12brok1.MID 12brok1.MID 
> 
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/FluidProgramSelect-bank-preset-from-midi-file-tp5101360p5102064.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





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"