Page 1 of 1

Solo, bypass (and fader) on Machines?

Posted: Wed Jan 18, 2017 11:23 pm
by AndersBrontosaurus
I wonder, since the machines have a on/offbutton in the left top corner and a closebutton in the top right, would it be possible to add more buttons. I think it would be nice to also have a solo and a Bypassbutton.

I also remember being able to pan in old Buzz. Would it be possible to use this function as a fader? It would be very nice with the KrossIn Krossout.

Joachip, I hope you're ok with me using your nice avatar.

Re: Solo, bypass (and fader) on Machines?

Posted: Thu Jan 19, 2017 1:12 pm
by IXix
I think it should be possible to do anything you like if you have the XAML skills. Sadly I don't have the skills. :(

Re: Solo, bypass (and fader) on Machines?

Posted: Thu Jan 19, 2017 11:32 pm
by AndersBrontosaurus
IXix wrote:I think it should be possible to do anything you like if you have the XAML skills. Sadly I don't have the skills. :(
Ah. That xaml... Unfortunately I don't have that skills either.

Re: Solo, bypass (and fader) on Machines?

Posted: Fri Jan 20, 2017 9:34 am
by IXix
AndersBrontosaurus wrote:Ah. That xaml... Unfortunately I don't have that skills either.
It's a valid idea though.

New buttons should be fairly easy to work out. Panning might be a little bit more difficult but I don't really know. It's basically just a matter of defining an element and binding it to the appropriate command. This is the led/mute button definition from MachineControl.xaml...

Code: Select all

<Button Name="ledButton" Command="{Binding MuteCommand}" Canvas.Left="2" Canvas.Top="2" Style="{StaticResource SmallButtonStyle}" BorderBrush="Black" BorderThickness="1" ToolTip="Mute">
  <Button.Background>
    <SolidColorBrush Color="{Binding Path=MachineLEDOffColor}"/>
  </Button.Background>
  <Image Name="ledButtonSkinImage" Visibility="Collapsed"/>
</Button>
As you can see, it's not actually that complicated, even though there's a lot of it. The bit that makes it work is the command binding, so if you find out what commands are available then you can make any button you like.

edit: okay, I admit I probably do have the skills.

Re: Solo, bypass (and fader) on Machines?

Posted: Fri Jan 20, 2017 11:16 pm
by AndersBrontosaurus
Yes. Being a zero on coding this is what I was thinking or hoping, that they were bound together in some way. I assume "solo" would be easier then since there is a solofunction already while bypassing demands more coding since there isno command to bind it to yet?
IXix wrote:edit: okay, I admit I probably do have the skills.
Ummm...yes, it certainly looks so. :-)

Re: Solo, bypass (and fader) on Machines?

Posted: Sat Jan 21, 2017 10:37 am
by IXix
AndersBrontosaurus wrote:I assume "solo" would be easier then since there is a solofunction already while bypassing demands more coding since there isno command to bind it to yet?
No, there will be a bypass command to bind to. Same with the panning, you just have to bind a control to the correct machine parameter but I don't know how to access that without some digging. Here are most of the commands (the ones that should work as buttons) defined by the MachineControl, if you feel like getting your toes wet...

Code: Select all

DeleteCommand
MuteCommand
SoloCommand
BypassCommand
OversampleCommand
WirelessCommand
LatencyCommand
CloneCommand
:twisted:

Re: Solo, bypass (and fader) on Machines?

Posted: Sat Jan 21, 2017 2:13 pm
by AndersBrontosaurus
Ooh! I'll definitely try. Seems like I can't really mess something up and it would be awesome to contribute with actual coding. (even if it'll most be copy-edit-paste). Right now it seems like the biggest task will be where to get and put the code. :-)

Re: Solo, bypass (and fader) on Machines?

Posted: Sat Jan 21, 2017 3:59 pm
by IXix
AndersBrontosaurus wrote:Ooh! I'll definitely try. Seems like I can't really mess something up and it would be awesome to contribute with actual coding. (even if it'll most be copy-edit-paste). Right now it seems like the biggest task will be where to get and put the code. :-)
That's the spirit! Make a backup before you start tinkering. :)

Program Files\Jeskola Buzz\Themes\<your_theme>\MachineView\MachineControl.xaml

Re: Solo, bypass (and fader) on Machines?

Posted: Sat Jan 21, 2017 8:56 pm
by AndersBrontosaurus
Ok. It wasn't as simple as I had hoped. I thought I'd get away with just renaming and rebinding to other commands but I got several windows full of complaints about object references. Any obvious mistakes?

wireless2.jpg
wireless2.jpg (229.96 KiB) Viewed 6746 times

[spoiler]

Code: Select all

<!-- led/mute button -->
                <Canvas>
                  <Button Name="ledButton" Command="{Binding MuteCommand}" Canvas.Left="2" Canvas.Top="2" Style="{StaticResource SmallButtonStyle}" BorderBrush="Black" BorderThickness="1" ToolTip="Mute">
                    <Button.Background>
                      <SolidColorBrush Color="{Binding Path=MachineLEDOffColor}"/>
                    </Button.Background>
                    <Image Name="ledButtonSkinImage" Visibility="Collapsed"/>
                  </Button>
                </Canvas>
				
				<!-- Solo button -->
                <Canvas>
                  <Button Name="SoloButton" Command="{Binding SoloCommand}" Canvas.Left="10" Canvas.Top="2" Style="{StaticResource SmallButtonStyle}" BorderBrush="Black" BorderThickness="1" ToolTip="Solo">
                    <Button.Background>
                      <SolidColorBrush Color="{Binding Path=MachineLEDOffColor}"/>
                    </Button.Background>
                    <Image Name="ledButtonSkinImage" Visibility="Collapsed"/>
                  </Button>
                </Canvas>
				
				<!-- Bypass button -->
                <Canvas>
                  <Button Name="BypassButton" Command="{Binding BypassCommand}" Canvas.Left="20" Canvas.Top="2" Style="{StaticResource SmallButtonStyle}" BorderBrush="Black" BorderThickness="1" ToolTip="Bypass">
                    <Button.Background>
                      <SolidColorBrush Color="{Binding Path=MachineLEDOffColor}"/>
                    </Button.Background>
                    <Image Name="ledButtonSkinImage" Visibility="Collapsed"/>
                  </Button>
                </Canvas>
[/spoiler]

Re: Solo, bypass (and fader) on Machines?

Posted: Sun Jan 22, 2017 11:04 am
by IXix
AndersBrontosaurus wrote:Ok. It wasn't as simple as I had hoped. I thought I'd get away with just renaming and rebinding to other commands but I got several windows full of complaints about object references. Any obvious mistakes?
Try putting all the buttons inside a single canvas element. Just a guess.

Re: Solo, bypass (and fader) on Machines?

Posted: Sun Jan 22, 2017 11:34 am
by IXix
Just had a quick look and I think the led button is in a canvas because it has to update rapidly in response to th machine audio. The delete button is on its own outside the canvas so I tried duplicating the delete button and making it function as solo. It worked but then there are alignment issues so I wrapped both buttons in a horizontal StackPanel and that looks like the best way to go. Here's the code...

Code: Select all

<StackPanel Orientation="Horizontal" Margin="0,3,3,0" HorizontalAlignment="Right" VerticalAlignment="Top">
	<Button Name="deleteButton" Command="{Binding DeleteCommand}" Style="{StaticResource DeleteButtonStyle}" BorderThickness="0" BorderBrush="#000000" Background="Transparent" ToolTip="Delete"/>
	<Button Name="soloButton" Command="{Binding SoloCommand}" Style="{StaticResource DeleteButtonStyle}" BorderBrush="Black" BorderThickness="0" ToolTip="Solo" />
</StackPanel>
Obviously that's a pretty crappy implementation but it works. You'd just need to sort out a button style and some images to make it look nice. The button styles are defined at the top of the file. You should probably copy the DeleteButtonStyle and tweak it for the behaviour you want.

Code: Select all

  <Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource SmallButtonStyle}">
		<Setter Property="Width" Value="9"/>
		<Setter Property="Height" Value="9"/>
		<Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Button}">
          <Border Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
						<Path Name="path" Data="M0,0 L1,1 M0,1 L1,0" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stretch="Fill"/>
					</Border>
					<ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter TargetName="path" Property="Stroke" Value="White"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
Now I'd better go and do something that I'm supposed to be doing...

Re: Solo, bypass (and fader) on Machines?

Posted: Sun Jan 22, 2017 11:38 am
by IXix
Oh btw, in case you weren't aware, you can edit the files and just reload your theme from the Themes menu to see the changes. No need to restart Buzz.

Re: Solo, bypass (and fader) on Machines?

Posted: Sun Jan 22, 2017 4:20 pm
by IXix
IXix wrote:Same with the panning, you just have to bind a control to the correct machine parameter but I don't know how to access that without some digging.
I was wrong about that. I forgot that panning is a property of the machine connections, not the machines, so a pan control on the machine wouldn't make sense.

Re: Solo, bypass (and fader) on Machines?

Posted: Sun Jan 22, 2017 9:28 pm
by AndersBrontosaurus
Eeehh...hhrrmm... A canvas is what you use for painting so I think I made the assumption that canvas was the name used for this particular machinebox. :-). I know better now. A canvas Defines an area within which you can explicitly position child elements by using coordinates that are relative to the Canvas area.
I'll have a little try and see what comes out.
IXix wrote:Oh btw, in case you weren't aware, you can edit the files and just reload your theme from the Themes menu to see the changes. No need to restart Buzz.
Good thinking. No, I was definitely not aware. :-)
IXix wrote:
IXix wrote:Same with the panning, you just have to bind a control to the correct machine parameter but I don't know how to access that without some digging.
I was wrong about that. I forgot that panning is a property of the machine connections, not the machines, so a pan control on the machine wouldn't make sense.
Ok. Then, a follow-up question? Since my initial idea was to use a slider as a fader or rather a crossfader on KrossIn/Out, would it be possible to code so that there is a slider on KrossIn/Out and (and not on other machines) which is bound to the "position"parameter

Re: Solo, bypass (and fader) on Machines?

Posted: Mon Jan 23, 2017 9:32 pm
by IXix
AndersBrontosaurus wrote:would it be possible to code so that there is a slider on KrossIn/Out and (and not on other machines) which is bound to the "position"parameter
I think it's possible but it will take more XAML skills than just rigging up a new button.

You'd have to define your slider as part of the standard machine control then use a data trigger inside the slider style to detect the dll name and set the slider visibility as appropriate. You'd also need to bind the slider value to the appropriate parameter.

Here's a snippet from MachineView.xaml that detects if a machine is a generator and applies the appropriate colour, so you can get an idea of how triggers work...

Code: Select all

<DataTrigger Binding="{Binding Path=Machine.DLL.Info.Type}" Value="Generator">
   <Setter TargetName="Border" Property="Background">
      <Setter.Value>
         <SolidColorBrush Color="{Binding Path=Machine.Graph.Buzz.ThemeColors[MV Generator]}"/>
      </Setter.Value>
   </Setter>
</DataTrigger>
It looks complicated but all it does is read the property "Machine.DLL.Info.Type" and if it's "Generator" it sets the brush colour for the machine rectangle. A similar strategy using "Machine.DLL.Name" or possibly "Machine.DLL.Path" could handle the slider visibility. Other possibilities are "Machine.DLL.Info.Name", "Machine.DLL.Info.ShortName" and "Machine.DLL.Info.Author".

I don't know how you'd go about binding to a machine parameter from XAML but I'd be suprised if you couldn't do it. I could probably figure it out but I can't spare the time right now. I am curious to know whether it would work though so if you can't figure it out yourself, remind me in a couple of weeks and I'll give it a try.

There are a several WPF/XAML tutorials on the web that should get you up to speed with styles and triggers. Good luck and kudos for daring to dive into the code yourself! :ugeek:

Re: Solo, bypass (and fader) on Machines?

Posted: Sat Jan 28, 2017 11:16 pm
by AndersBrontosaurus
Thank you for educating me!
I will definitely stick my toes back in the water once I've seen this stubborn flu out but I'm not sure I'm going to as deep as to the calves. :-)