Cantabile dot NET library

Hi @brad and all :smile:

It’s a long time I’m coding myself utilities in VB.Net interacting with Cantabile via Midi.
I recently, tried a few simple Network API interactions like asking Cantabile for States list or Song List.

So the idea came to have a .NET library somewhat mimicking the JavaScript API behaviour.

As you can guess from VB.net, I’m not a skilled programmer. My business is music.

In fact this is already a pretty advanced project and Claude helped a lot (Sorry @brad :downcast_face_with_sweat:) . Library is built with all documented functions available in Cantabile API, events etc…
Tests with a local Cantabile instance basically works

At the moment it’s an internal VB.net Nuget ready.library.

The idea after deep testing is to share a C# source version and a Nuget Package.

@brad tell me your thoughts about idea, sharing and naming.
.

1 Like

Here is a vb.net usage example:


Imports Cantabile

’ Create and connect a session
Dim session = New CantabileSession(“localhost”, 35007)
Await session.ConnectAsync()

’ Read current state
Console.WriteLine($“Song : {session.Song.Name}”)
Console.WriteLine($“Transport : {session.Transport.State} @ {session.Transport.Tempo} BPM”)

’ Event subscription
AddHandler session.Transport.StateChanged, Sub(s, e)
Console.WriteLine($“New State : {session.Transport.State}”)
End Sub

’ Control
Await session.Transport.PlayAsync()

’ Disconnection
Await session.DisconnectAsync()
Await session.DisposeAsync()


Available Endpoints

session.Transport
session.Song
session.SetList
session.SongStates
session.Application
session.Variables
session.Commands
session.Bindings
session.ShowNotes
session.KeyRanges
session.OnscreenKeyboard
session.Engine

1 Like

Very nice. Some thoughts:

  • While I had no plans for a .net library I’m not opposed to it.
  • It’s been a long time since I’ve done any VB so I’m not too familiar with its current state. That said while a C# port would be nice it’s probably not necessary as shouldn’t the lib work in c# as is anyway?
  • probably the biggest argument for port to c# is if you want to get help from others maintaining the library itself. C# seems to be the better known more standard .Net language.
  • do you know if the library works on other .net platforms (Linux, mobile etc)? If not that might be something worth addressing. Or, perhaps not, not sure

I’m curious… what are you building with this?

These days I tend to lean pretty heavily towards JavaScript because it runs pretty much everywhere with little dependencies and you can build pretty sophisticated UI in a browser - again same language, runs everywhere.

One more thing to be aware of. I can foresee some significant updates to the netapi coming soon. In fact I’ve just made some changes last night. Nothing that should break what’s already there but if you want to keep it complete there’s going to be ongoing work.

Anyway, thanks for this and look forward to seeing where it goes and who might use it for what.

Brad

I finally have time to be back on this. :grinning_face:

Thanks @brad for your welcome. :folded_hands:

Here is the last VB version: GitHub - igbro/Cantabile.Net: .Net Library for Cantabile Network API · GitHub

API-Reference.md in Docs folder, shows the .Net implementation compared to JS.

  • Yes the lib should work in C# (VB is now, apart from its verbose syntax, very close to C#, same compiler and IL).
  • Yes, I plan a C# version to be more in sync with the coding community and I will publish a Nuget package.
  • Don’t know about other .Net platforms, but I doubt…
  • My go to gig tablet is a MS surface and I try to build my own interfaces to suit my needs. A previous one, for example, had a search function for states which wasn’t available in Cantabile at this time.(my songs where in fact states back in the days)
  • You’re right about the universality of JS but I don’t have time to dig into it.
  • I will try to follow the API changes :sweat_smile:

Glad to share if it can be useful to the Cantabile community. Who knows…

Igor

1 Like

Good stuff!

Can you please explain a practical use of this work?

Sure, :smiley:

My gig box is a DIY compact box containing a Mini PC, a sound card, a wifi router and fans.

I don’t want to bring two screens on stage and don’t use Cantabile’s screen while playing (except for launch via Virtual Desktop) for the reasons below.

I play mostly covers where I don’t know in advance which song I’m gonna play.
I made a generic song containing all the generic sounds I use the most for both keyboards.
I want to be able to display any chord chart / Score on my tablet within the same song so Show Notes doesn’t work for me in this case.
This leads me to play, since many years, “Cantabile blind” changing the sounds via programmed buttons on my keyboard..It can be a little scary!

Another common case (unfortunately) are budget gigs where I launch drums patterns (thanks Mulab VST), playing left hand bass and right hand harmonies.

Complex setup where there are several drums pattern, breaks and sound setups per song with the ability to switch all those live.

Cantabile feedback becomes crucial here… to much to remember in blind mode.

Since my tablet is a MS Surface running windows came the idea to build my own interfaces asking Canabile for feedback via Brad’s Cantabile Network Api and thus, have the best of both worlds. My charts and the Cantabile feedback I want where I want on the same screen.

Brad made a Java script library to programmatically call network API but I’m not a skilled coder and I’ve chosen to stick with VB and .net I know the best.

Here you are. :downcast_face_with_sweat:

2 Likes

Well, a bit of a struggle when invoking an indexed object (Rack, plugin etc) trying to pass the index or name parameter…Fixed and repo updated.

Now code like this works:

Await cantabile.Bindings.InvokeAsync(BindingPoint.Plugin(0, “gain”), 0.8)
Await cantabile.Bindings.InvokeAsync(BindingPoint.Plugin(1, “bypass”), False)
Await cantabile.Bindings.InvokeAsync(BindingPoint.Plugin(“MODO BASS 2 1”, “gain”), 0.1)
Await cantabile.Bindings.InvokeAsync(BindingPoint.Rack(0, “outputGain”), 0.9)
Await cantabile.Bindings.InvokeAsync(BindingPoint.Rack(“Strings”, “outputGain”), 0.2)

2 Likes

Thank you… though I have to admit I’m no wiser!

And as you have guessed, my first language is not English, which might not help… :joy:

Let me try to translate:

Essentially, this library allows you to write software in Visual Basic that can remote-control Cantabile over the network. Convenient when you have your Cantabile PC sitting somewhere on stage without a monitor and you want to remote-control some aspects from a small tablet on your keyboard rig. Maybe just a few buttons and a few lines of display may be enough to get through a gig.

Knocking together a quick program in Visual Basic is often easier than using a full-blown development stack and framework, so this library may come in handy for some of us nerds.

Cheers,

Torsten

Thanks @Torsten.

C# users should be able to use it too when Nuget package is ready.

Thanks both of you.

Ah, if only it were Commodore 64 BASIC…

1 Like

This is really interesting to me, as a long-time C# developer :slight_smile:

1 Like