Example project for a simple C#/XAML machine (non-DSP)?

Post Reply
snowglobe
Posts: 356
Joined: Wed Nov 23, 2011 12:36 pm

Example project for a simple C#/XAML machine (non-DSP)?

Post by snowglobe »

Would one of you code maestros be willing to put together a Visual Studio project for a machine that just sends MIDI to selected targets based on MIDI in events and pattern data? I'm studying BuzzGUI sources, but it has been really slow-going :cry:

GUI basically just a ListBox with SelectionMode = Multiple that updates when machines are added or deleted.

Image
oskari
Site Admin
Posts: 296
Joined: Mon Nov 21, 2011 2:04 pm

Re: Example project for a simple C#/XAML machine (non-DSP)?

Post by oskari »

There are GUI demos already (qsamo, relativion) but sending midi works like this:

Code: Select all

	[MachineDecl(Name = "Jeskola MidiTest", ShortName = "MidiTest", Author = "Oskari Tammelin")]
	public class MidiTestMachine : IBuzzMachine
	{
		IBuzzMachineHost host;

		List<IMachine> targets = new List<IMachine>();

		public MidiTestMachine(IBuzzMachineHost host)
		{
			this.host = host;

			lock (targets) targets.Add(Global.Buzz.Song.Machines.FirstOrDefault(m => m.Name == "Qsamo"));
		}

		[ParameterDecl(DefValue = false)]
		public bool Enabled { get; set; }

		public void Work()
		{
			if (!Enabled) return;

			if (host.MasterInfo.PosInTick == 0)
			{
				IMachine[] threadsafeTargets;
				lock (targets) threadsafeTargets = targets.ToArray();

				foreach (var t in threadsafeTargets)
				{
					if (t != null) t.SendMIDINote(0, 60, 100);
				}
			}

		}

	}
snowglobe
Posts: 356
Joined: Wed Nov 23, 2011 12:36 pm

Re: Example project for a simple C#/XAML machine (non-DSP)?

Post by snowglobe »

oskari wrote:There are GUI demos already (qsamo, relativion)
Yes, but you forgot to add Comments for the Retarded (TM).
but sending midi works like this:
Thanks for the snippet. I'll keep plodding.
snowglobe
Posts: 356
Joined: Wed Nov 23, 2011 12:36 pm

Re: Example project for a simple C#/XAML machine (non-DSP)?

Post by snowglobe »

I'm feeling so out of my depth here, y'all ...

Going to try some baby-steps questions about Relativion.

First one: Where/how do the pattern params - Root Note, Lowest Note, Highest Note, etc. - get defined? (I see that Note Matrix gets its dummy param from NoteMatrixMachine.cs, but Relativion's params seem to show up magically)
oskari
Site Admin
Posts: 296
Joined: Mon Nov 21, 2011 2:04 pm

Re: Example project for a simple C#/XAML machine (non-DSP)?

Post by oskari »

Relativion is a native machine, it was before "managed machines". See NTracker for an example of parameters.
User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Re: Example project for a simple C#/XAML machine (non-DSP)?

Post by mantratronic »

hey,

i've done something similar to the list of machines idea. https://dl.dropboxusercontent.com/u/123 ... getgui.rar is the .cs and xaml for a picker window that gets the machine and parameter list from buzz and let you choose a machine/parameter pair. im told the way i do gui coding is an offense to humanity (not really, just very wrong) so i would ignore that bit and look at the fillTreeList function which fills up a gui class with the data.

Code: Select all

			foreach (IMachine m in BuzzGUI.Common.Global.Buzz.Song.Machines)
runs a loop for each machine in the song. maybe check they are a gen and have the midi params you want then add them to the class you are using to display them.

I havent used an auto update for this (ie you would need to open the window again if a machine got added), but you can listen to

Code: Select all

		event Action<IMachine> MachineAdded;
		event Action<IMachine> MachineRemoved;
from BuzzGUI.Common.Global.Buzz.Song and rebuild the list when they trigger

in IBuzz you can also find

Code: Select all

event Action<int> MIDIInput;
which i guess will help the midi side?

will be about the irc channel if you have questions
Post Reply