When running Csound, I get a lot of printouts like this in the console- again and again, and again - another block is dropped, I presume...
- I think that you would advise that I increase the block size in the settings.

Prior to this in the console I read:

orch now loaded
audio buffered in 256 sample-frame blocks
SECTION 1:
Initialising spinlock...
Starting realtime mode queue: 0xb50a6010 thread: 0x1c37738

Should I be setting the setting to a blocksize of 256, so that it corresponds to the Csound Audio Buffer?
- or 128, or 512 - for stereo?

Also, my typical sample rate is 44100 - should this be the sample rate that is set in the settings?

Or do the Csound Sample Rate and Krate overRide the Bela Settings - in which chase I should do all the adjusting
in the header of my .csd

Thanks for any suggestions or advice you can offer me (and my students),

Dr.B.

    csounder Also, my typical sample rate is 44100 - should this be the sample rate that is set in the settings?

    that's the only sample rate possible on Bela.

    csounder - I think that you would advise that I increase the block size in the settings.

    I normally would, but the IDE settings are actually ignored for Csound projects.

    csounder Or do the Csound Sample Rate and Krate overRide the Bela Settings - in which chase I should do all the adjusting
    in the header of my .csd

    I don't actually know. Looking at the code, it would seem that the Bela's own periodSize is ignored, and there is just a fifo going on there where csound->GetKsmps(); samples at a time are processed, which would give more frequent underruns than it should. It needs more digging and fixing.

      giuliomoro Thanks for the info.

      - my ears were telling me that the IDE settings were probably being ignored by Csound.
      - good to know that the max sample rate is 44100 (the Csound default)

      I am wondering if all those printouts to the console might not be putting a little load on the processor?
      - if there a flag that might prevent them from printing?

      11 days later

      Awesome, I am testing now. It eliminates a lot of warning messages. (wonderful)
      1. You might need to add a ksmps = 16 or ksmps = 8 to your 0-hello.world example.
      2. You suggest that one needs to install the latest portMIDI (libportmidi0_217-6_armhf.deb) too.
      (this might also be a requirement, to get your 4-MIDI-in example to run too.)
      - I know how to install into individual projects, but I am wondering how to install/update for all projects
      (searching the forum now for advice on this)

        csounder 1. You might need to add a ksmps = 16 or ksmps = 8 to your 0-hello.world example.

        Will do yes. Haven't touched the examples yet, actually I meant to ask you if you wanted to provide some that would work out of the box, to improve and enrich our currently scarce portfolio.

        csounder - I know how to install into individual projects, but I am wondering how to install/update for all projects
        (searching the forum now for advice on this)

        The method I previously explained (drag on the IDE, and run in the console dpkg -i PROJECTNAME/*.deb actually installs the package globally.

          There might be an issue with audio in.
          - an instrument that previously worked with real-time audio input (coming from a mic in a mixer, for example),
          does not seem to be working now with Csound 6.15 V2

          • I have tried setting it with the -iadc commandline input flag (previously not necessary), and it still does not work.
            I will attach several .csd files for you to use in your tests.

            csounder - an instrument that previously worked with real-time audio input (coming from a mic in a mixer, for example),
            does not seem to be working now with Csound 6.15 V2

            wow! who knows what I did there

            csounder I will attach several .csd files for you to use in your tests.

            thanks, looking forward to this

            giuliomoro Thanks! I have been doing this, and in the console, it does report that things are being unzipped, but then the previously working MIDI instruments are not working now. WAIT! I think I have it...

            In the past, (probably because it was using other MIDI drivers?), in the command-line, it was recommended that one set the following defaults:

            -Mhw:1,0,0 -+rtmidi=NULL --daemon -dm0

            it turns out that you do NOT want to set -+rtmidi=NULL any longer

            Once that is removed, all my previously running MIDI instruments are working AND...

            I am very happy to report that you are now supporting the connecting of multiple MIDI devices
            - I have a USB hub plugged into the Bela MINI
            - I have a Novation LaunchPad mini Mk3 PLUS a Korg NanoKontrol plugged into the hub
            - I am running my MIDI .csd with the following command-line arguments

            -Mhw:1,0,0 -Ma --daemon -dm0

            And both controllers are playing and controlling the instrument! (WONDERFUL)

            • You might need to make changes to the Csound examples, as I suggested to you previously
              using this as a default header for the .csd files

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

            and for MIDI instruments:

            -Mhw:1,0,0 -Ma --daemon -dm0

            Now to get to the bottom of why the audio input is not working on previous .csd files.
            - any suggestions about what might have changed, or what might now be required.

              csounder You might need to make changes to the Csound examples, as I suggested to you previously
              using this as a default header for the .csd files

              will do once the release is ready.

              csounder - any suggestions about what might have changed, or what might now be required.

              nothing as far as I know 🙁 send me an example passthrough patch and I can have a look

              When I comment out the RtMIDI=NULL from the 4-MIDI example, it runs, but...

              there are a lot of little clicks now (possibly data-lates as Barry Vercoe used to call them?)

              and the console does report a lot of dropouts and mode switches (which might explain the clicks)

              Underrun detected: 1 blocks dropped
              Underrun detected: 1 blocks dropped

              Underrun detected: 1 blocks dropped
              Underrun detected: 1 blocks dropped
              rtevent: T 12.251 TT 12.251 M: 0.06069 0.08127
              rtevent: T 12.263 TT 12.263 M: 0.04022 0.04759
              Underrun detected: 1 blocks dropped
              Underrun detected: 1 blocks dropped

              Underrun detected: 1 blocks dropped

              Underrun detected: 1 blocks dropped
              35608 mode switches detected on the audio thread.
              Underrun detected: 1 blocks dropped
              38370 mode switches detected on the audio thread.
              41137 mode switches detected on the audio thread.
              backtrace() returned 0 addresses
              Csound tidy up: Terminated
              Makefile:595: recipe for target 'runide' failed
              make: *** [runide] Terminated
              inactive allocs returned to freespace
              end of score. overall amps: 0.15828 0.15978
              overall samples out of range: 0 0
              0 errors in performance
              Elapsed time at end of performance: real: 16.050s, CPU: 7.453s
              Bela stopped
              root@bela ~/Bela#

              I am using the following sample rate and krate settings

              sr = 44100
              ksmps = 8. or ksmps = 16
              nchnls = 2
              0dbfs = 1

              I see. Mode switches are happening.

              Was this not happening in the script you previously mentioned was working fine? If that's the case, could you send me the well behaving script?

                giuliomoro There were almost always "some" mode switches and dropped blocks, but never this many and never these little cricket clicks. I will send you a few files to test. Working on them now.

                sounds like this is not a viable solution then, and I may have to revert to the previous one. Can you send me some example code that uses multiple MIDI devices? Then I can figure out how to make it work with the "Bela" MIDI API.

                  giuliomoroRunning multiple MIDI devices is not a top priority, but it would be nice to connect a hub to the bela and just use any of the controllers that one has connected.

                  The strange thing now, is that realtime audio in does not work with the latest bela2 (it could be connected perhaps?)
                  - and so, this might not be portMIDI related.

                  in the examples, the audio loopback still works, but none of my 50+ audio examples work any longer
                  - and the console does not report any issues.

                  As a test example, you could just use the previous example with the 'ins' opcode
                  - this works on the laptop and this worked previously

                  I tried forcing the comandline with a -iadc and -odac and --realtime and --daemon, but this made no difference.

                  <CsoundSynthesizer>
                  <CsOptions>
                  </CsOptions>
                  <CsInstruments>
                  
                  sr       = 44100
                  ksmps    = 16
                  nchnls   = 2
                  0dbfs    = 1
                  
                  instr    1 ; Stereo delay with normal and cross-feedback
                  
                  ilevl    = p4      ; Output level
                  idelay1  = p5/1000 ; L delay in ms
                  idelay2  = p6/1000 ; R delay in ms
                  ifdbk1   = p7      ; L feedback
                  ifdbk2   = p8      ; R feedback
                  ifdbkx   = p9      ; X Feedback
                  ifreq1   = p10     ; L cutoff
                  ifreq2   = p11     ; R cutoff
                  imix     = p12     ; Mix: 0=Dry 1=Delay
                  afdbk1   init 0
                  afdbk2   init 0
                  
                  ainL, ainR ins
                  ain = ainL+ainR
                  
                  ;ain      soundin  "sp_hellorcb.aif"   ; Does NOT work on Bela
                  ;ain     diskin "sp_hellorcb.aif", 1    ; WORKS on Bela
                  
                  ain1     = ain + afdbk1*ifdbk1 + afdbk2*ifdbkx
                  ain2     = ain + afdbk2*ifdbk2 + afdbk1*ifdbkx
                  adelay1  delay  ain1, idelay1
                  adelay2  delay  ain2, idelay2
                  adelay1  butterlp  adelay1, ifreq1
                  adelay2  butterlp  adelay2, ifreq2
                  afdbk1   = adelay1
                  afdbk2   = adelay2
                  aout1    = adelay1*imix + ain*(1 - imix)
                  aout2    = adelay2*imix + ain*(1 - imix)
                  outs1    aout1*ilevl
                  outs2    aout2*ilevl
                  
                  endin
                  
                  </CsInstruments>
                  <CsScore>
                  ;Delay in ms, Filt in Hz. Total feedback should be <1?
                  
                  ;   Strt  Leng   Levl  DelyL DelyR FeedL FeedR XFeed FiltL FiltR Mix
                  i1  0.00  10.00  1.00  500   400   0.40  0.40  0.40  2500  2500  0.50
                  e
                  </CsScore>
                  </CsoundSynthesizer>

                    csounder As a test example, you could just use the previous example with the 'ins' opcode

                    which one please? I am not sure I understand which one you are referring to.

                    In the meantime, you can try 6.15-bela3 release:

                    • restores MIDI functionality (or at least it should, let me know)
                    • adds support for Trill Craft. You have to specify 30 "touches", and the touch size for each will be the reading from each individual pad ( I think -- completely untested)

                      giuliomoro I will try the latest version, and solder up my Trill Crafts for those tests too!

                      Here is a working MIDI .csd, in the CsOptions section, you will see command lines for:
                      previous Bela 6.15 (with no multiple MIDI support, but excellent MIDI)
                      Bela 6.15 v2 (with multiple MIDI support, working!... but many Mode switches and Dropped blocks)
                      the command line settings I use on the Mac, to run Csound with multiple MIDI devices in the terminal

                      As you will see from the .csd below, it is reading MIDI CCs 1-9 (typically from my nanoControl)

                      <CsoundSynthesizer>
                      <CsOptions>
                      ;-Mhw:1,0,0 -+rtmidi=NULL --daemon -dm0 ; Bela 6.15 v1
                      ;-Mhw:1,0,0 --daemon -dm0 ; Bela 6.15 v2
                      -Mhw:1,0,0 -Ma --daemon -dm0 ; Bela 6.15 v2 (multiple MIDI devices)
                      ;csound -+rtaudio=pa_cb -iadc1 -odac1 -+rtmidi=portmidi -Ma --env:CSNOSTOP=yes ; Mac commandline
                      </CsOptions>
                      <CsInstruments>
                      
                      sr		= 44100
                      ksmps	= 16
                      nchnls	= 2
                      0dbfs	= 1
                      
                      gaRvb	init 0
                      
                      ctrlinit	1,   1,100, 2,0, 3,0, 4,64, 5,1, 6,10, 7,100, 8,10, 9,76
                      
                      		instr	1
                      icps	cpsmidi
                      iamp	ampmidi .5
                      
                      kamp	midic7 1, 0,1
                      kamp	port 	kamp,.1	
                      kcar	midic7 2, 1,4
                      kcar	port 	kcar,.01
                      kmod	midic7 3, 1,10
                      kmod	port 	kmod,.01
                      kindx	midic7 4, 1,13
                      kindx	port	kindx,.01
                      iatk	midic7 5, .001,1
                      idec	midic7 6, .01,1
                      isus	midic7 7, 0,1
                      irel	midic7 8, .01,2
                      kWet	midic7 9, 0,1
                      
                      asig	foscil	kamp*iamp, icps, kcar, 1+(kmod), kindx, 1
                      kmgate	mxadsr	iatk, idec, isus, irel
                      
                      aDry	=	asig * kmgate
                      
                      		vincr 	gaRvb, aDry * kWet
                      
                      		outs		aDry, aDry
                      		endin
                      
                      		instr 99
                      		denorm	gaRvb
                      awetL,awetR freeverb gaRvb, gaRvb, .9, .5
                      		outs awetL, awetR
                      		clear gaRvb
                      		endin
                      
                      </CsInstruments>
                      
                      <CsScore>
                      f1	0	16384	10	1
                      i 1  0 z
                      i 99 0 z
                      </CsScore>
                      
                      </CsoundSynthesizer>

                      giuliomoro to test and see/hear if realtime audio in is working again, you would use the version of the stereo-delay instrument that includes the two uncommented lines (and plug in your iPhone or a Microphone):

                      ainL, ainR ins
                      ain = ainL+ainR

                      to test if the soundin opcode is working, you need to add your own mono sample to the project and uncomment
                      the ain line with the soundin opcode.

                      ;ain soundin "sp_hellorcb.aif" ; Does NOT work on Bela.

                      • you should replace "sp_hellorcb.aif" with the name of your uploaded mono sample.
                        It can be either a wave or aiff - for instance

                      ain soundin "sp_hellogiulio.wav"

                      and if instead, you were to uncomment the line using diskin opcode, you will hear/see that it does work

                      ain diskin "sp_hellorcb.aif", 1 ; WORKS on Bela

                      I will try your latest build now.

                      Best,

                      -dB

                        giuliomoro I would love to provide several additional example instruments that would show additional ways of working with the Bela and Csound - and that sound great too! I will pull them together and you can see which you might like to include.