Setting machine properties from a managed machine
- mantratronic
- Posts: 296
- Joined: Mon Nov 21, 2011 7:23 pm
Setting machine properties from a managed machine
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)
(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
Which thread are you calling from? You may need to create a task with the appropriate synchronisation context to use to call it from.
- mantratronic
- Posts: 296
- Joined: Mon Nov 21, 2011 7:23 pm
Re: Setting machine properties from a managed machine
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;
}
- strobotone
- Posts: 297
- Joined: Wed Nov 23, 2011 2:59 pm
- Location: berlin
- Contact:
Re: Setting machine properties from a managed machine
i am just a rookie but this should actually work.
Re: Setting machine properties from a managed machine
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
http://msdn.microsoft.com/en-us/library ... s.95).aspx
- mantratronic
- Posts: 296
- Joined: Mon Nov 21, 2011 7:23 pm
Re: Setting machine properties from a managed machine
Cheers, I'll try that.
- mantratronic
- Posts: 296
- Joined: Mon Nov 21, 2011 7:23 pm
Re: Setting machine properties from a managed machine
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.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
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);
Re: Setting machine properties from a managed machine
You can't use DispatcherAction for this. It's used to delay-execute an action in the current (UI) thread.
This should work:
This should work:
Code: Select all
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
}));
- mantratronic
- Posts: 296
- Joined: Mon Nov 21, 2011 7:23 pm
Re: Setting machine properties from a managed machine
Ahhhh.. works great now!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(() => { }));