Difference between revisions of "Managed Machines"

From Jeskola Buzz Wiki
Jump to: navigation, search
(Equivalence in unmanaged machines)
m (Managed machines were supported from build 1416 and up)
Line 1: Line 1:
== Programming tips and tricks for the Managed Machines in Buzz Build XXXX+ ==
== Programming tips and tricks for the Managed Machines in Buzz Build 1416+ ==
=== Coding ===
=== Coding ===

Revision as of 19:14, 24 February 2012

Programming tips and tricks for the Managed Machines in Buzz Build 1416+


You should read the documentation given in the BuzzGUI svn here in IBuzzMachine.cs.

Machine/MachineGUI relationship

In coding Managed Machines for Buzz, there are two elements which can be used for different parts of the same buzz machine. The IBuzzMachine and the IMachineGUI interfaces, the first is the audio handling, and the second is an optional graphical user interface. Buzz will display any parameters and attributes, menu items, and about boxs you set up with the IBuzzMachine, but the IMachineGUI will allow for a custom interface such as the ones in the Jeskola Loop Recorder and NoteMatrix machines.

Equivalence to the old unmanaged machines

If you have already programmed unmanaged machines, using c++ and machineinterface.h, you will find a lot of the set up of the code is done for you and lots of things have been simplified. The main parts of a buzz machine that remain are Parameter Declaration, Tick, and Work, but they are accessed in different ways.

The MachineInfo data block has been replaced by the MachineDecl attribute of the IBuzzMachine class, the majority of the old parameter declaration is now in the ParameterDecl attribute, which can be applied to int, bool, and float classes for Global parameters, and to a public method which take one of those classes and a track identifier for Track parameters. The type of class which the parameter uses replicated the switch, byte, word, and note parameter types you are used too; if you want a byte parameter, simply set MaxValue=254 or lower in ParameterDecl.

In addition to this, the Interpolator class has been added which can handle the inertia and scale of parameters for you, as can be seen in IBuzzMachine.cs and the example below.

The code which you would have put in Tick(), handling the new input your machine has been given, should now occur in the YourParameter.set() method for global params and YourParameter(int,int) method for track params.

Work used to have a few different implementations based on the type of machine that you were writing, with mono, stereo, and multio versions. In the managed machines, Work can occur either by sample or by block, and effects and generators define different methods.

Saving and retrieving data from files and templates is considerably simplified, as you will see below. Midi input handling, menu access, and a Stop command are also provided for in the managed machine interface.

Order called of constructors and methods



TODO: show basic machine, ie gain in example. where IBuzzMachine ends and IMachineGUI starts..


Recommended settings in VC express / VC2010.

Output path for both builds (debug and release) should be in the correct buzz directory, "C:\Program Files\Jeskola\buzz\gear\effects" for effects and "C:\Program Files\Jeskola\buzz\gear\generators" for everything else.

Use "Any CPU" build platform.

Set assembly name to "YourMachine.NET".


Attach to process

In VC 2010 and C#, you can attach your debugger to buzz and then see where bugs are in your code. Start buzz as normal after compiling your managed machine, choose "attach to process" from the debug menu, and select buzz.exe from the window you are shown. Then add your machine to buzz, and you will be able to debug normally.

Launch Buzz from the compiler. (from Ixix's tip)

Attaching to process is useful for finding where the bug is, but it won't allow the "edit and continue" feature in VC2010, which allows you to fix the bug during execution! So you can use this trick to allow launching Buzz for debugging. (If there's an easier way to do it we'd love to know.)

Edit the solution's startup project file (YourMachine.csproj here) and add this to the first PropertyGroup: Code:

   <StartProgram>C:\Program Files\Jeskola Buzz\Buzz.exe</StartProgram>

I've also added this to the post-build event for each project... Code:

   copy "$(TargetPath)" "C:\Program Files\Jeskola Buzz\"

This can also be done in Project -> Properties -> Debug -> start external program = "C:\Program Files\Jeskola Buzz\Buzz.exe" Project -> Properties -> Debug -> Command line arguements = "/nocr" Project -> Properties -> Debug -> Working directory = "C:\Program Files\Jeskola Buzz\"

Now just hit F5 and it builds, copies the files and launches Buzz all in one step. You can add break points as normal (F9), and you should be able to edit the code when exceptions are thrown, saving you lots of time.