Setting machine properties from a managed machine

Post Reply
User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Setting machine properties from a managed machine

Post by mantratronic »

I'm trying to make a muting peer machine like btdsys's mooter in the new managed interface, is it possible for a machine to call IsBypassed.Set (and IsMuted and IsSoloed)? I'm getting exceptions saying a different thread owns them, so is there a way I can send a request to that thread?

(IsMuted.Set works btw, it just throws an exception, IsBypassed.Set throws an exception and the track param set exits)

intoxicat
Posts: 7
Joined: Tue Nov 22, 2011 1:42 pm

Re: Setting machine properties from a managed machine

Post by intoxicat »

Which thread are you calling from? You may need to create a task with the appropriate synchronisation context to use to call it from.

User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Re: Setting machine properties from a managed machine

Post by mantratronic »

Code: Select all

namespace MT.Overpass
{
    [MachineDecl(Name = "Mantratronic Overpass", ShortName = "Overpass", Author = "blah", MaxTracks = 20)]
    public class OverpassMachine : IBuzzMachine, INotifyPropertyChanged
    {
        [ParameterDecl(ValueDescriptions = new[] { "---", "mute", "bypass", "solo" }, IsTrackParameter = true, MaxValue = 3, DefValue = 0)]
        public void Mac(int v, int track)
        {
            if (peers[track].target != null)
            {
                // if input == 0 remove all settings
                if (v == 0)
                {
                    peers[track].target.IsBypassed = false;
                    peers[track].target.IsMuted = false;
                    peers[track].target.IsSoloed = false;
                }
Where target is an IMachine. So I guess it's in the tick() thread? (multithreading is set to false atm) I don't know how buzz handles threading...

User avatar
strobotone
Posts: 297
Joined: Wed Nov 23, 2011 2:59 pm
Location: berlin
Contact:

Re: Setting machine properties from a managed machine

Post by strobotone »

i am just a rookie but this should actually work.

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

Re: Setting machine properties from a managed machine

Post by oskari »

I should probably make them work in the audio thread too but right now you can do this:

http://msdn.microsoft.com/en-us/library ... s.95).aspx

User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Re: Setting machine properties from a managed machine

Post by mantratronic »

Cheers, I'll try that.

User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Re: Setting machine properties from a managed machine

Post by mantratronic »

oskari wrote:I should probably make them work in the audio thread too but right now you can do this:

http://msdn.microsoft.com/en-us/library ... s.95).aspx
I think I must be doing it wrong, currently i get a new BuzzGUI.Common.DispatcherAction and dispatch it, but the code isn't being run.

Code: Select all

            BuzzGUI.Common.DispatcherAction da;

                    Action blah = () =>
                    {
                        peers[track].target.IsBypassed = false;
                        peers[track].target.IsMuted = false;
                        peers[track].target.IsSoloed = false;
                    };

                    da = new BuzzGUI.Common.DispatcherAction(blah);
                    da.Dispatch(DispatcherPriority.Normal);
Any ideas?

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

Re: Setting machine properties from a managed machine

Post by oskari »

You can't use DispatcherAction for this. It's used to delay-execute an action in the current (UI) thread.

This should work:

Code: Select all

Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
}));

User avatar
mantratronic
Posts: 296
Joined: Mon Nov 21, 2011 7:23 pm

Re: Setting machine properties from a managed machine

Post by mantratronic »

oskari wrote:You can't use DispatcherAction for this. It's used to delay-execute an action in the current (UI) thread.

This should work:

Code: Select all

Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
}));
Ahhhh.. works great now!

Post Reply