Skip to content
Menno Knevel edited this page Jul 12, 2024 · 2 revisions

Author: Menno Knevel

This article is a collection of things that i encounter when working in Blue, and - although maybe being perfectly logical in itself - strikes me as being 'odd' or 'non-intuitive'. I have to mention that programming does not come naturally to me, but somehow i find the energy to struggle on. Some of the subjects below may have been a bit of a puzzle for me, for others the solutions may have been so obvious that they are not even worth mentioning.


1. JMask Object


Working to generate Scores with JMask vs. nGen

...and wanting to scale the generated values afterwards with the Tuning Scale Processor in the Note Processor. Motivation was i could easily change scales this way AND make use of the the Jmask Score Generator to create dozens of events.

My newly created Tuning Scale is one where an octave is divided into 24 slices. This still allows to think of the notes (relative to one another) like when using the PianoRoll. Or any other DAW showing a Midi layout of 12-notes-in-an-octave for that matter. Only this time the resolution is 2 times that of a 'normal' DAW... i can then easily replace this 24 scale to a 48-notes-in-an-octave whenever i want, just to try things out. Or to 96 when i am looking for thick layers of sound, and possibly beating sounds.

The Tuning Scale expects Blue PCH values, "a format similar to Csound PCH but differs in that it does not allow fractional values. Values are generated as "octave.scaleDegree" i.e. "8.22" would be octave 8 and scale degree 22 in a scale that has 23 or more notes" according to the manual. So first the "octave number" and then the slice number within that space, going from pitch X to pitch 2x X.

In my case there are 24 notes. P4 is used for the pitch of the events.

Properties24Scale

The basic axis = 261.625565. This is an important value as you will see later.

The JMask Parameter was one that went in a straight line from 8.00 to 8.24. These values are then converted by the Tuning Scale Processor on P4 into frequencies. The Tuning scale is a "octave.scaleDegree" To Frequency Converter.

JMaskTT

A closeup from the settings
closeup

And, when i check the generated data without this conversion to frequencies, i get to see:

values

The values are going from 8.00 to 8.23...all is well. So now i expected to see, after Frequenciy Conversion, the values to go from 261 to 508 Hertz.

AllValues

No such thing! What is that strange value of 277 at the end of the row doing there? It looks misplaced! 8.1 and 8.2 are coverted incorrectly it seems. 8.1 produces the same value as produced by 8.01, and 8.2 the same as 8.02...What is happening? I did draw a straight line, did i not??

Lets check what happens, this time i try to do the same not with the JMaskObject, but with the nGen Score Generator. This Score Generator can be downloaded from BlueShare. In nGen i move the values over the entire Object from 8.00 to 8.24 with precision 2. Precision 2 means a resolution of 0.01. And in the next pfield i do the same but with the Tuning Scale 24-in-an-octave so you can see what is happening.

nGenMoves

I hit the TEST button and get (of course) a result:

ScorenGen2

This is the result i was looking for. Why does nGen do what i want and what is the difference between JMask en nGen in this regard? Why does JMask think that 8.01 and 8.1 are one and the same?

The difference between JMask/Blue PCH and nGen/Blue PCH is that Jmask is treating values as numbers rather than as a string. It would need to be treated as a string to preserve the formatting of 8.10 vs. 8.1. However, Cmask/Jmask treats it as just numbers.

BUT: This is not the end of the story. Something else interesting is happening...remember 261.625565? This is set as Base Frequency in the Tuning Scale Note Processor. For the Tuning Scale, the entire world is a division of 24 slices. From 8.00 to 8.24 all goes well, but what happens if you go from 7.00 to 8.00?

Cross

Panic in the 24 slices world!

nGenCross

Here you see that all goes well from 7.00 to 7.24. Where it has reached the end of its world. It is the same value as 8.00! And 7.25 is 8.01!! Something to keep in mind.


2. General


K- and I-rate Dropdown Menu and Checkbox BSBs

This is all about the mixing of k- and i-rate variables in if..then statements.

Screenshot from 2023-03-26 20-15-21

Used here, as a switch, is the DropDownMenu BSB, but the CheckBox behaves in the same way. The BSB is set to Automatable.

Screenshot from 2023-03-26 20-02-59

What i want to achieve is, when the DropDown Menu is set to either 'item 1' or 'item 2', it should play the sound that belongs to that choice and also to have printed in the Output of Blue: 'item 1' or 'item 2'.

After making the choice, the appropriate oscil is played correctly. But both items are printed in the Output!

Screenshot from 2023-03-26 20-07-24

I did not understand this at first...i am telling the program to follow my choice and then print only that item print output to screen, did i not? And i do hear the correct choice is made because of the sine wave being played...why then does the program even dare to look at the other choice?

The issue here is that a k-rate statement (the switch is checked every k- time to see if there is a different selection made) is mixed with i rate statements like prints "item 1\n" and prints "item 2\n". Csound first checks the program for all i rate code and carries out all i-rate statements. Like, in this case, printing the i-rate item. And so it prints both item 1 and 2.

To avoid and streamline issues like these, the code should be improved. Check the new code; the k-rate switch now has become i-rate as well! And extra 2 simple envelopes are added to prove that the switch is now done correctly for k-rate and i-rate...

Screenshot from 2023-03-26 20-28-16

This way, the Automation Line can still be used to switch between the 2 options, and set to Automatable assuring the existence of an Automation Line:

Screenshot from 2023-03-26 17-59-49

and, as Frozen Objects:

Screenshot from 2023-03-26 17-59-08

For completeness sake, the Output:

Screenshot from 2023-03-26 20-31-52

Another mystery solved...


3. General


<INSTR_ID>

Useful to determine the instr number when using more than one of the same instr. to be completed


4. Midi


Midi out

Portmidi, alsaseq, jackmidi

So, here are the instructions for using blue to render Csound pieces to Jack using the Jacko opcodes:

  1. Uninstall previous versions of Csound including Linux packages. You should try to get them all out.
  2. Build Csound from current sources: in a build subdirectory, cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo; make clean; make; sudo make install.
  3. Build the Jacko opcodes from current plugin sources: in a build subdirectory, cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo; make clean; sudo make install.
  4. Run blue.
  5. Import jacko_test.csd and save it as blue project jacko_test.blue. _All rendering will be done as though to a soundfile!!! Even though blue will in fact play real-time audio!!! In the Tools menu, Options dialog, Disk Render tab, set Render Method to Commandline Runner. Set the sampling rate to 48000 (or the same as Jack) and ksmps to 128 (or the same as Jack).
  6. In the Project Properties tab of jacko_test.blue, set the sampling rate to 48000 (or the same as Jack) and ksmps to 128 (or the same as Jack), and the output filename to jacko_test.wav.

Now you can use the File menu, Render to Disk command to perform the piece. Everything should work. The only thing missing here is the ability of blue to send values to Csound control channels using the Csound API.


5. Mixing


Side-chaining (sort of)

How to use the amplitude and/or pitch from another instrument to send and use by another instrument in Blue? Side-chaining in Blue is not yetan option, but with creativity there is a way to get things done. The inspiration for this came from one of the SoundObjects, the LineObject.

score

The lines and line points are written to an ftable:

score

Instruments are created and a Global variable is assigned:

score

Why a Global variable? The manual explains this: The name of the signal will be prepended with "gk" when outputing a signal ....and... For the LineObject to work properly, be sure to give all Instruments concerned a higher Instrument ID.

A higher Instrument ID can take in this gkxxx and use the ftable information. Here, in this higher Instrument ID, the values range must be adapted and scaled to fit your needs. A more modern way of sending data from a lower Instr ID to a higher Instr is to make use of the Channel system:

score

score


6. PianoRoll


Samples and PianoRoll

Samples in the Instrument and used with the PianoRoll, are played back at their original speed when the note is on 8.00 in the Note tab. For samples, in the Properties tab the Base Frequency can be set at 1.0; this way, 9.00 will represent the sample playback of 2 x (one octave higher) and 7.00 will be 2 x lower.

score


7. General


Extra Time!

when Freezing Objects, it may be that notes are truncated. It may be that a reverb is cut off or the release of a Midi-like event is cut short; in cases where the Object to be Frozen needs extra time, making the Frozen Object longer than when it is not Frozen, just add an amount of time before you Freeze:

mixer

the result:

Xtended


8. PianoRoll


Extra Note!

Regarding the PianoRoll: when in scale and drawing note events, all notes that are added after another note will move the end of the Object to the end of the newly added note. As a result, the PianoRoll in scale mode is always populated up until the end.

If you add an extra dummy note at the end of the PianoRoll, meaning a dot with zero amplitude, the Object will get his new end, but also some space.

extra Note

This is handy when copying or manually repeating the Object; some breathing space between the gestures of the PianoRoll Objects.


9. General


The D of ADSR

TheDofADSR

The Decay of the ADSR is a bit special imo, and it bites me from time to time. That is why i am writing this down as a reminder: for you, for me, for the whole world to see!


10. PianoRoll


Fractional Instr in PianoRoll

For Jmask in the present state, there is still no way to generate fractional instrument numbers for use with tied notes, but for the PianRoll Object i have found how to do it. Here, in the Properties Tab, you set the integer Instrument but no fractions.

PianoRollFractional

Then, over to the Notes Tab, one can add on a note per note basis, the fractional number

Screenshot from 2024-07-04 14-47-42

As this line is a text replacement, for this particular note i added .1 to the i <INSTR_ID>. Result is 300.1. For this note and other notes that may have added other fractional additions, in:

FractionalNotes

In practice, this works wonderfully well. You know you want to tie what note to what other note(s) by changing to -. Interesting tied notes sequences can be made.


11. PianoRoll


Process your Notes

The PianoRoll is great for entering note events in whatever scale you want, but how about randomization of the values of your notes? The PianoRoll does not have an option to do this. And I am not a lazy person, but if we could automate this?

Then we apply the Note Processor.

Screenshot from 2024-07-12 14-02-56

In this case, randomization of p8 is set to control the azimuth of static 3d binaural sounds. p9 will be set to randomize the Elevation.

Screenshot from 2024-07-12 14-04-51

This all can be easily achieved by setting p8 to 1 and add a RandomMultiply Note Processor to p8. Set the appropriate Min and Max settings and Bob's your uncle.