Also - one other question and request.

Your examples are awesome (and I hope that you will soon add a few examples in the Csound section that show how to use the Trill sensors with Csound Code too.

As you and Astrid know, from my demos and tutorials to your group, my Csound Project Files for my classes and students contain dozens of working .csd files that serve as Bela models of MIDI Synths, DSP FX, and Algorithmic and Generative Music Boxes.

The IDE is great with Csound (it would be even better if it linked to The Csound Manual), but It is great to be able to select a .csd and edit it in your IDE. However, to push it to the Bela, one needs to either - rename it "main.csd" or select all, copy, scroll up to main.csd, select all, paste, and then render/run. As the project gets larger and contains more files and samples, this takes more and more time - and a lot of steps which can lead to error.

As you know, your examples, under the lightBulb icon, display the csound code in the IDE. where it can be edited and the edited version can be pushed to the board instantly - without renaming or copying it to _main - you do this internally or in the background.

Could you please consider updating the IDE so that, whatever is displayed and currently edited in the IDE can be pushed directly to the Bela without needing to copy to main or rename as main and then once completed rename again to save it in ones "collection" or working models?

It would be a big time saver and really improve the workFlow.

Dr.B.

    csounder Could you please consider updating the IDE so that, whatever is displayed and currently edited in the IDE can be pushed directly to the Bela without needing to copy to main or rename as main and then once completed rename again to save it in ones "collection" or working models?

    you can achieve this functionality on your board by creating a file in /root/Bela/CustomMakefileTop.in and placing the following into it:

    ===this code is broken (see amendment below)
    ifdef PROJECT
    ifndef CSOUND_FILE
    PROJECT_SETTINGS_JSON = $(PROJECT_DIR)/settings.json
    CURRENT_FILENAME = $(shell cat $(PROJECT_SETTINGS_JSON) 2> /dev/null | tr "," "\n" | grep fileName | sed 's/.*"fileName"\s*:\s*"\(.*\)"/\1/' )
    override CSOUND_FILE = $(PROJECT_DIR)/$(CURRENT_FILENAME)
    endif
    endif
    ===this code is broken (see amendment below)

    This will apply to all the Csound projects you will run. If you want to apply this only to specific projects, we can figure out a slightly different solution.

    NOTE: this requires the Bela core code to be updated after May 20 2020 (specifically, contain this commit, image v0.3.8a is the first that ships with this).

      giuliomoro. Giulio... THANKS SO MUCH!!! This works perfectly and is a HUGE boost to the workflow with the Bela and Csound. Now... I just select my .csd from a collection of hundreds in a project, they load into the editor and they push to the Bela. FANTASTIC. My future classes and workshops will now be so much smoother (and less prone to copy/paste errors and slip-ups). I hope that you will consider adding it as a standard "script" with future releases of the IDE. - So helpful, smooth, and transparent. Loving the Bela even more. Dr.B.

        csounder PS: after following your instructions and creating the file called 'CustomMakefileTop.in', I used a previous bit of advice from you to copy the newly created file into the correct directory from the Terminal on my Mac.

        scp /Users/rboulanger/Desktop/Bela-Script2PushCSD/CustomMakefileTop.in root@192.168.7.2:/root/Bela

        Perhaps 'CustomMakefileTop.in' should be located in the current project directory and not in the root directory?

        I see what's happening, this is also the source of trouble you are having elsewhere. Use this instead:

        ifdef PROJECT
        ifndef CSOUND_FILE
        PROJECT_SETTINGS_JSON = $(PROJECT_DIR)/settings.json
        CURRENT_FILENAME = $(shell cat $(PROJECT_SETTINGS_JSON) 2> /dev/null | tr "," "\n" | grep "fileName.*\.csd\>" | sed 's/.*"fileName"\s*:\s*"\(.*\.csd\>\)"/\1/' )
        override CSOUND_FILE = $(PROJECT_DIR)/$(CURRENT_FILENAME)
        endif
        endif

        Swapping to this version of the CustomMakefileTop.in script did repair the trills, but sadly, it does not work as the other one did. When you select a .csd file from the project and hit the "Build & Run" button, the previous script would push the file to the Bela (as if it were in _main.csd) - and was a huge timesaver and workflow improver.

        This version does say loading file in the console, but then it reports the following error message:

        Building project ...
        Build finished
        Makefile:153: *** Invalid/empty project. A project needs to have at least one .cpp or .c or .cc or _main.pd or _main.scd or  or run.sh file.  Stop.

        Hopefully it is an easy fix.

        Dr.B.

        Hmm, that's strange, as it works for me.

        Can you show me the file list for this project and also the content of the settings.json file in the project folder? This file is hidden normally, but you can show it by going to the IDE settings and enabling "View hidden files", then it should show up among your project files.

          giuliomoro It is very curious. Some of the .csd files do work.
          - you select them
          - they appear in the IDE
          - you edit them there
          - you push the 'Build & Run' icon/button
          - They build and run ! Success.

          Others, like the Generative Haiku.csd or some of the MIDI instruments do not
          - the console reports
          Building project ...
          Build finished
          Makefile:153: *** Invalid/empty project. A project needs to have at least one .cpp or .c or .cc or main.pd or main.scd or or run.sh file. Stop.

          AND it is noteworthy, that with 6.15 the following libraries are missing and warnings appear

          Building project ...
          Build finished
          Running project ...
          0"060.998| WARNING: [main] duplicate call from main program to xenomai_init() ignored
          0"061.299| WARNING: [main] (xeno-config --no-auto-init disables implicit call)
          0dBFS level = 32768.0
          --Csound version 6.15 (float samples) Oct 15 2020
          [commit: c329d91b2527e96f05ecb47837e2bfd3b68f5be7]
          libsndfile-1.0.27
          realtime mode enabled
          WARNING: [mcould not open library '/usr/lib/csound/plugins-6.0/libfluidOpcodes.so' (libfluidsynth.so.1: cannot open shared object file: No such file or directory)
          WARNING: could not open library '/usr/lib/csound/plugins-6.0/libosc.so' (liblo.so.7: cannot open shared object file: No such file or directory)[m
          [mUnifiedCSD: /root/Bela/projects/Aug2/DSP-Cook-AnalogEcho.csd
          STARTING FILE
          Creating options
          Creating orchestra
          closing tag
          Creating score
          realtime mode enabled
          rtmidi: ALSA Raw MIDI module enabled
          Elapsed time at end of orchestra compile: real: 0.044s, CPU: 0.031s
          sorting score ...
          ... done
          Elapsed time at end of score sort: real: 0.047s, CPU: 0.031s
          setting dummy interface
          graphics suppressed, ascii substituted
          0dBFS level = 32768.0
          orch now loaded
          audio buffered in 256 sample-frame blocks
          SECTION 1:
          Initialising spinlock...
          Starting realtime mode queue: 0xb50b9010 thread: 0x12371b0

          I am not sure how you would like me to show you the file list for the project
          - The Project is called Aug2
          - The list of files in the project are:

          main.csd
          ALGO-Aikin-Groovish
          ALGO-McCurdy-Haiku4
          Bela-Trill1.csd
          DSP-Alex-mTog-SubInstruments
          DSP-Cook-AnalogEcho.csd
          DSP-Cook-Harmoniser.csd
          DSP-Cook-LorenzChorus.csd
          DSP-Cook-mStressonCC.csd
          DSP-Cook-Mutator.csd
          DSP-dB+Hans-mTog-CCmultFX
          DSP-FLOSS-Audio2Control
          DSP-McCurdy-mGrain
          DSP-Pedro-mTog-NLresBank
          DSP-Pedro-mTog-NLstresBank
          DSP-Pedro-mTog-NLStresIncr
          DSP-Siena-mTog-chanGetSetFX.csd
          DSP-Siena-MultiFX_0803
          .csd
          DSP-Victor-mTog-LiveLoop
          MIDI-615toggle.csd
          MIDI-Adam-HansPluck
          MIDI-cntCreate.csd
          MIDI-ctrlPresetV6-ffitch.csd
          MIDI-FM-cc1-8
          MIDI-Gabe-mTog-ccSwitch4.csd
          MIDI-micro-cpstunSwitch.csd
          MIDI-micro-FOF-Bohlen-Pierce.csd
          MIDI-micro-NoisePitch-B-Pierce.csd
          MIDI-MoogVCF
          MIDI-Pedro-mTog-2EventInsts
          MIDI-RCB-sndwarp.csd
          MIDI-Turnon-Event.csd
          MIDI-Turnon-Scoreline.csd
          my_ctrlinits.txt
          my_ctrlpresets.txt
          NL-bob.csd
          NL-lag.csd
          NL-sterrain.csd
          NL-Toot1-RCB.csd
          NL-trighold.csd
          NL-vps.csd
          settings.json
          z-AdrienS.aif
          z-no_fluteC3.wav
          z-OboeScaleS.aif
          z-sp_hamlet.aif
          z-sp_hellorcb.aif
          zCosmoBlur.udo
          zCosmoChorus.udo
          zCosmoFakeGrainer.udo
          zCosmoLowPass.udo
          zCosmoRandDelay.udo
          zCosmoReverb.udo
          zFox.wav

          The contents of the settings.json folder is:

          {"fileName":"settings.json","CLArgs":{"-p":"16","-C":"4","-B":"16","-H":"-6","-N":"1","-G":"1","-M":"0","-D":"0","-A":"0","--pga-gain-left":"10","--pga-gain-right":"10","user":"","make":"","-X":"0","audioExpander":"0","-Y":"","-Z":"","--disable-led":"0"}}

          This file 'MIDI-615toggle.csd' (which requires Version 6.15 to run successfully) - does work with your script.
          - It loads into the IDE and then you hit build and run (without copying to _main and it builds and runs :

          <CsoundSynthesizer>
          
          <CsOptions>
          -Mhw:1,0,0 -+rtmidi=NULL --daemon -dm0
          </CsOptions>
          
          <CsInstruments>
          nchnls = 2
          0dbfs = 1
          
           gicntA cntCreate 1     ; a toggle
           gicntNoteA cntCreate 1 ; ignore note-off message - turn MIDI notes into toggles
           gicntB cntCreate 1
           gicntNoteB cntCreate 1 
           gicntC cntCreate 1
           gicntNoteC cntCreate 1 
          
          instr 1
          
          kkey sensekey
          printk2 kkey
          
          if (kkey == 97) then  ; ASCII 'a' = 97
           k1 count gicntA
           if k1==0 then
            event "i", 2, 0, -1
           else
            event "d", 2, 0, -1
           endif
          endif
          
          if (kkey == 115) then  ; ASCII 's' = 115
           k1 count gicntB
           if k1==0 then
            event "i", 3, 0, -1
           else
            event "d", 3, 0, -1
           endif
          endif
          
          if (kkey == 100) then  ; ASCII 'd' = 100
           k1 count gicntC
           if k1==0 then
            event "i", 4, 0, -1
           else
            event "d", 4, 0, -1
           endif
          endif
          
          inote notnum
          print  inote
          
          if (inote == 60) then
           i2 count_i gicntNoteA
           print i2
           if i2==0 then
            event_i "i", 2, 0, -1
           else
            event_i "d", 2, 0, -1
           endif
          endif
          
          if (inote == 62) then
           i2 count_i gicntNoteB
           print i2
           if i2==0 then
            event_i "i", 3, 0, -1
           else
            event_i "d", 3, 0, -1
           endif
          endif
          
          if (inote == 64) then
           i2 count_i gicntNoteC
           print i2
           if i2==0 then
            event_i "i", 4, 0, -1
           else
            event_i "d", 4, 0, -1
           endif
          endif
          
          endin
          
          
          instr 2
          kenv linenr .25,.1,.1,.01
          asig oscil kenv, 261.63
          outs asig,asig
          endin
          
          instr 3
          kenv linenr .25,.05,.1,.01
          asig oscil kenv, 293.665
          outs asig,asig
          endin
          
          instr 4
          kenv linenr .25,.02,.1,.01
          asig oscil kenv, 329.628
          	outs asig,asig
          endin
          
          </CsInstruments>
          
          <CsScore>
          i1 0 z
          </CsScore>
          
          </CsoundSynthesizer>

          This one (ALGO-Aikin-Groovish) - is the Bela 'Theme Song' in my classes - by Jim Aikin from Keyboard Magazine fame, required you to copy it to _main before it will build and run

          <CsoundSynthesizer>
          <CsOptions>
          -dm0
          </CsOptions>
          <CsInstruments>
          
          sr = 44100
          ksmps = 16
          nchnls = 2
          0dbfs = 1
          
          		seed	127
          
          giSine	ftgen	0, 0, 8192, 10, 1
          gaRevL	init 0
          gaRevR	init 0
          
          gkMetro init 0
          gkCtr	init 0
          gkLineA	init 0
          gkLineB	init 0
          gkLineC	init 0
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr gControl
          
          gkMetro		metro		7
          if (gkMetro == 1) then
          	gkCtr = gkCtr + 1
          endif
          
          ih = p3 * 0.5
          iq = p3 * 0.25
          ie = p3 * 0.125
          
          gkLineA		linseg		1, ie, 0, iq, 1, ie, 0, ih, 1
          gkLineB		linseg		1, iq, 0, iq, 1, iq, 0, iq, 1
          gkLineC		linseg		0, ie, 1, ie, 0, ie, 1, ie, 0, ie, 1, ie, 0, ie, 1, ie, 0
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr SourceA
          
          kdiv		oscil		2, 0.2, giSine, 0.2
          kdiv		=			int(kdiv + 5) - int(gkLineC * 3)
          ktrig		init		0
          
          if ((gkCtr % kdiv == 0) && (gkMetro == 1)) then
          	ktrig = 1
          else
          	ktrig = 0
          endif
          
          schedkwhen	ktrig, 0, 12, 11, 0, 0.2 + (0.2 * gkLineB), 100, 0.5, 0.7
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr SourceB
          
          kdiv		oscil		2, 0.17, giSine, 0.7
          kdiv		=			int(kdiv + 4) + int(gkLineC * 3)
          ktrig		init		0
          
          if ((gkCtr % kdiv == 0) && (gkMetro == 1)) then
          	ktrig = 1
          else
          	ktrig = 0
          endif
          
          schedkwhen	ktrig, 0, 12, 12, 0, 0.2, 200, 0.3, 0.4, 1, 1, 1.2
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr SourceC
          
          kdiv		oscil		1.5, 0.143, giSine
          kdiv		=			int(kdiv + 3) + int(gkLineC * 3)
          ktrig		init		0
          
          if ((gkCtr % kdiv == 0) && (gkMetro == 1)) then
          	ktrig = 1
          else
          	ktrig = 0
          endif
          
          schedkwhen	ktrig, 0, 12, 12, 0, 0.2, 300, 0.05, 0.1, 1, 3, 0.7
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr SourceD
          
          kdiv		oscil		2.5, 0.23, giSine
          kdiv		=			int(kdiv + 4) + int(gkLineC * 3)
          ktrig		init		0
          
          if ((gkCtr % kdiv == 0) && (gkMetro == 1)) then
          	ktrig = 1
          else
          	ktrig = 0
          endif
          
          schedkwhen	ktrig, 0, 12, 12, 0, 0.2, 400, 0.7, 0.4, 2, 1, 0.4
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr SourceE
          
          kdiv		oscil		2, 0.09, giSine
          kdiv		=			int(kdiv + 5) - int(gkLineC * 3)
          ktrig		init		0
          
          if ((gkCtr % kdiv == 0) && (gkMetro == 1)) then
          	ktrig = 1
          else
          	ktrig = 0
          endif
          
          schedkwhen	ktrig, 0, 12, 11, 0, 0.2, 500, 0.95, 0.1
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr 11		; a sine tone generator
          
          iLineB = i(gkLineB)
          ibp1 = 0.3 + (iLineB * 0.4)
          ibp2 = 0.2 + (iLineB * 0.1)
          ibp3 = 0.1 + (iLineB * 0.04)
          
          irand		random	0, 1
          if (irand > ibp1) then
          	ifreq_offset = 0
          elseif (irand > ibp2) then
          	ifreq_offset = 150
          elseif (irand > ibp3) then
          	ifreq_offset = 225
          else
          	ifreq_offset = 300
          endif
          
          iamprand	random	0.11, 0.23
          
          iLineA = i(gkLineA)
          iatk = 0.002 + (0.1 - (0.1 * iLineA))
          
          kline		linsegr	0, iatk, iamprand, p3, iamprand * 0.25, p6, 0
          asig		oscil		kline, p4 + ifreq_offset, giSine
          aL, aR	pan2		asig, p5
          
          gaRevL = gaRevL + aL
          gaRevR = gaRevR + aR
          		outs		aL, aR
          
          endin
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
          instr 12		; a more crisp tone generator
          
          irand		random	0, 1
          if (irand > 0.5) then
          	ifreq_offset = 0
          elseif (irand > 0.3) then
          	ifreq_offset = 150
          elseif (irand > 0.1) then
          	ifreq_offset = 225
          else
          	ifreq_offset = 300
          endif
          
          iamprand	random	0.07, 0.17
          iamp = iamprand * p9 * 1.1
          indexrand	random	0.2, 0.3
          
          iLineA = i(gkLineA)
          iatk = 0.002 + (0.02 - (0.02 * iLineA))
          
          indexstart	=		indexrand + (iLineA * 0.5)
          indexend	=		indexstart * 0.3
          kindex		line	indexrand, p3, indexend
          
          kline		linsegr	0, iatk, iamp, p3, iamp * 0.25, p6, 0
          asig		foscil		kline, p4 + ifreq_offset, p7, p8, kindex, giSine
          aL, aR	pan2		asig, p5
          
          gaRevL = gaRevL + (aL * (gkLineB + 1))
          gaRevR = gaRevR + (aR * (gkLineB + 1))
          		outs		aL, aR
          
          endin
          
          instr Reverb
          
          iamp = 0.6
          inlevel = 0.4
          isize = 0.75
          icutoff = 2000
          aoutL, aoutR	reverbsc	gaRevL * inlevel, gaRevR * inlevel, isize, icutoff
          
          gaRevL = 0
          gaRevR = 0
          
          			outs	aoutL * iamp, aoutR * iamp
          
          endin
          
          </CsInstruments>
          <CsScore>
          
          i "gControl"	0 121
          i "SourceA"		0 120
          i "SourceB"		0 120
          i "SourceC"		0 120
          i "SourceD"		0 120
          i "SourceE"		0 120
          i "Reverb"		0 123
          
          </CsScore>
          </CsoundSynthesizer>

          I FOUND IT - I FOUND OUT WHY !!!!

          it turns out that the filenames can only be a certain length, and even though I was adding a .csd to the end of each filename, sometimes the .csd was getting cut off.

          if the filename ends with .csd, your script works perfectly! THANKS

          maybe you should allow for longer filenames (but for sure, I should be more attentive and more clear in my file naming.

          It didn't matter before, because - I was alway copying the file to _main.csd and so... it always ended with .csd!

            yes it definitely was an issue with missing .csd: the current file has to end in .csd in order to be run.

            csounder t turns out that the filenames can only be a certain length, and even though I was adding a .csd to the end of each filename, sometimes the .csd was getting cut off.

            I cannot reproduce this. Could you try to give me step-by-step instructions to reproduce this?

              giuliomoro you may be right about the length of filename not being the issue, I might have just been forgetting to type the .csd when I renamed the files originally.