Page 1 of 1
Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 11:01 am
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)
Re: Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 11:12 am
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.
Re: Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 11:19 am
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...
Re: Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 1:15 pm
by strobotone
i am just a rookie but this should actually work.
Re: Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 4:37 pm
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
Re: Setting machine properties from a managed machine
Posted: Sat Jan 21, 2012 5:49 pm
by mantratronic
Cheers, I'll try that.
Re: Setting machine properties from a managed machine
Posted: Mon Jan 23, 2012 6:21 pm
by mantratronic
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?
Re: Setting machine properties from a managed machine
Posted: Mon Jan 23, 2012 6:51 pm
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(() =>
{
}));
Re: Setting machine properties from a managed machine
Posted: Mon Jan 23, 2012 7:00 pm
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!