buzz forums

forums of the buzz
It is currently Tue Mar 26, 2019 9:29 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Jan 21, 2012 11:01 am 
User avatar

Joined: Mon Nov 21, 2011 7:23 pm
Posts: 294
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)


Top
 Profile  
 
PostPosted: Sat Jan 21, 2012 11:12 am 

Joined: Tue Nov 22, 2011 1:42 pm
Posts: 7
Which thread are you calling from? You may need to create a task with the appropriate synchronisation context to use to call it from.


Top
 Profile  
 
PostPosted: Sat Jan 21, 2012 11:19 am 
User avatar

Joined: Mon Nov 21, 2011 7:23 pm
Posts: 294
Code:
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...


Top
 Profile  
 
PostPosted: Sat Jan 21, 2012 1:15 pm 
User avatar

Joined: Wed Nov 23, 2011 2:59 pm
Posts: 297
Location: berlin
i am just a rookie but this should actually work.


Top
 Profile  
 
PostPosted: Sat Jan 21, 2012 4:37 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 275
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/cc190259(v=vs.95).aspx


Top
 Profile  
 
PostPosted: Sat Jan 21, 2012 5:49 pm 
User avatar

Joined: Mon Nov 21, 2011 7:23 pm
Posts: 294
Cheers, I'll try that.


Top
 Profile  
 
PostPosted: Mon Jan 23, 2012 6:21 pm 
User avatar

Joined: Mon Nov 21, 2011 7:23 pm
Posts: 294
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/cc190259(v=vs.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:
            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?


Top
 Profile  
 
PostPosted: Mon Jan 23, 2012 6:51 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 275
You can't use DispatcherAction for this. It's used to delay-execute an action in the current (UI) thread.

This should work:

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


Top
 Profile  
 
PostPosted: Mon Jan 23, 2012 7:00 pm 
User avatar

Joined: Mon Nov 21, 2011 7:23 pm
Posts: 294
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:
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
}));


Ahhhh.. works great now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group