Archive for the C# Category

TuneMachine

Posted in .NET, C#, Melody Mine, Music, Programming, Windows, WPF on 04/07/2020 by imekon8

I’ve started writing a new tool to help generate MIDI output. The song part consists of chunks of patterns that get output to MIDI when play is activated.

song

Patterns describe the notes to output:

pattern

These are notes – but not as you’d know them. The scale and mode (see the top) describe which notes get used (in this case C Major). That way any notes you play are always “musical” as the scale isn’t chromatic (i.e. all the twelve notes) but on a scale.

Working in Guildford

Posted in .NET, C#, Sound on 01/12/2013 by imekon8

As I did tests for our sound tech, I ran a standard one that had flies buzzing about my head. I had this on my 7.1 surround system. A voice called out, “you got a dead body there?” to a few laughs around the office.

My first day at Codies

Posted in C#, Programming, Sound with tags , on 01/12/2013 by imekon8

My desk sat facing three offices in the sound engineers corridor. I could hear machine guns firing, as one guy worked on Flashpoint.

Behind me was a voice booth. Another engineer was recording sound effects for a horror game called Jericho.

So, machine guns in front, screaming behind me. Sound engineers play things LOUDLY. I had a headache at the end of my first week!

Tools for Games

Posted in C#, Programming, Work on 24/10/2010 by imekon8

Been working on general tools in C# for the last few months. Not doing audio stuff. Makes a change.

Adventures in WPF

Posted in .NET, C#, Programming, WPF on 25/04/2010 by imekon8

First steps in hooking up code to UI in WPF. Here’s the XAML for the main window:

<Window x:Class="test3.MainWindow"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:custom="clr-namespace:test3"
 Title="MainWindow" Height="190" Width="177">
 <Window.Resources>
 <CollectionViewSource
    Source="{Binding Source={x:Static Application.Current}, Path=MainWindow.Platforms}"
    x:Key="platforms"/>
 <DataTemplate x:Key="platformTemplate" DataType="{x:Type custom:Platform}">
    <StackPanel Orientation="Horizontal">
       <CheckBox Margin="1" IsChecked="{Binding Path=Selected}"/>
       <TextBlock Margin="1" Text="{Binding Path=Name}"/>
    </StackPanel>
 </DataTemplate>
 </Window.Resources>
    <Grid>
       <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition Height="23" />
          <RowDefinition Height="23" />
       </Grid.RowDefinitions>
    <ListBox Grid.Row="0"
       ItemsSource="{Binding Source={StaticResource platforms}}"
       ItemTemplate="{StaticResource platformTemplate}"/>
    <Button Click="OnBuild" Grid.Row="1">Build...</Button>
    <Button Click="OnTogglePC" Grid.Row="2">Toggle PC</Button>
 </Grid>
</Window>

Here’s the code behind the above:

public partial class MainWindow : Window
 {
    ObservableCollection<Platform> m_platforms;

    public MainWindow()
    {
       m_platforms = new ObservableCollection<Platform>();

       m_platforms.Add(new Platform("PC"));
       m_platforms.Add(new Platform("PS3"));
       m_platforms.Add(new Platform("Xbox 360"));

       InitializeComponent();
    } 

    public ObservableCollection<Platform> Platforms
    {
       get { return m_platforms; }
       set { m_platforms = value; }
    }

    private void OnBuild(object sender, RoutedEventArgs e)
    {
       string text = "";

       foreach (Platform platform in m_platforms)
       {
          if (platform.Selected)
          {
             text += platform.Name + " ";
          }
       }

       if (text == "")
       {
          text = "none";
       }

       MessageBox.Show(text, "WPF TEST");
    }

    private void OnTogglePC(object sender, RoutedEventArgs e)
    {
       m_platforms[0].Selected = !m_platforms[0].Selected;
    }
 }

Here’s the Platform class:

public class Platform : INotifyPropertyChanged
{
    private string m_name;
    private bool m_selected;

    public Platform(string name)
    {
       m_name = name;
       m_selected = false;
    }

    public string Name
    {
       get { return m_name; }
       set
       {
          m_name = value;

          OnPropertyChanged("Name");
       }
    }

    public bool Selected
    {
       get { return m_selected; }
       set
       {
          m_selected = value;

          OnPropertyChanged("Selected");
       }
    }

    private void OnPropertyChanged(string name)
    {
       if (PropertyChanged != null)
       {
          PropertyChanged(this, new PropertyChangedEventArgs(name));
       }
    }

    public event PropertyChangedEventHandler PropertyChanged;
 }

…and here’s what it looks like:

If you change the check boxes by each platform, then click on “Build”, you get a message box indicating which boxes you ticked; if you click on the “Toggle PC”, you’ll see the check box by PC changing.

WPF

Posted in .NET, C#, Programming, Windows on 24/04/2010 by imekon8

“…and so it begins”.

Once you’ve accepted C#, I guess there’s no turning back. Now onto WPF…