mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-10 01:43:46 +00:00
Reinstate Audio Level updating and sliders
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@@ -9,24 +10,25 @@ namespace qController
|
||||
void AudioLevelsUpdated(object source, AudioLevelArgs args)
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() => {
|
||||
activeCue = args.cue_id;
|
||||
levels = args.levels;
|
||||
if (mainSlider != null)
|
||||
{
|
||||
mainSlider.Value = (double)levels[0];
|
||||
mainSlider.Value = levels[0];
|
||||
}
|
||||
if (leftSlider != null)
|
||||
{
|
||||
leftSlider.Value = (double)levels[1];
|
||||
leftSlider.Value = levels[1];
|
||||
}
|
||||
if (rightSlider != null)
|
||||
{
|
||||
rightSlider.Value = (double)levels[2];
|
||||
rightSlider.Value = levels[2];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Label type;
|
||||
JToken levels;
|
||||
List<double> levels;
|
||||
string activeCue;
|
||||
Slider mainSlider;
|
||||
Slider leftSlider;
|
||||
Slider rightSlider;
|
||||
@@ -52,7 +54,6 @@ namespace qController
|
||||
new ColumnDefinition{Width = new GridLength(1,GridUnitType.Star)}
|
||||
}
|
||||
};
|
||||
type = new Label { Text = "" };
|
||||
|
||||
mainSlider = new Slider
|
||||
{
|
||||
@@ -61,7 +62,7 @@ namespace qController
|
||||
};
|
||||
mainSlider.ValueChanged += (sender, args) =>
|
||||
{
|
||||
qController.qClient.sendArgs("/cue/selected/sliderLevel/0", (float)args.NewValue);
|
||||
qController.qClient.sendArgs("/cue_id/" + activeCue + "/sliderLevel/0", (float)args.NewValue);
|
||||
};
|
||||
|
||||
leftSlider = new Slider
|
||||
@@ -71,7 +72,7 @@ namespace qController
|
||||
};
|
||||
leftSlider.ValueChanged += (sender, args) =>
|
||||
{
|
||||
qController.qClient.sendArgs("/cue/selected/sliderLevel/1", (float)args.NewValue);
|
||||
qController.qClient.sendArgs("/cue_id/" + activeCue + "/sliderLevel/1", (float)args.NewValue);
|
||||
};
|
||||
|
||||
rightSlider = new Slider
|
||||
@@ -81,7 +82,7 @@ namespace qController
|
||||
};
|
||||
rightSlider.ValueChanged += (sender, args) =>
|
||||
{
|
||||
qController.qClient.sendArgs("/cue/selected/sliderLevel/2", (float)args.NewValue);
|
||||
qController.qClient.sendArgs("/cue_id/" + activeCue + "/sliderLevel/2", (float)args.NewValue);
|
||||
};
|
||||
mainG.Children.Add(mainSlider, 1, 0);
|
||||
mainG.Children.Add(leftSlider, 1, 1);
|
||||
@@ -116,11 +117,7 @@ namespace qController
|
||||
mainG.Children.Add(rightLabel, 0, 2);
|
||||
|
||||
Content = mainG;
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue(QCue cue)
|
||||
{
|
||||
type.Text = cue.type;
|
||||
Margin = new Thickness(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,22 +99,22 @@ namespace qController
|
||||
|
||||
public void UpdateSpecificCue(string cue_id)
|
||||
{
|
||||
Console.WriteLine("Cue needs to be updated: " + cue_id);
|
||||
Console.WriteLine("Updating specific cue: " + cue_id);
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\",\"notes\"]";
|
||||
string address = "/cue_id/" + cue_id + "/valuesForKeys";
|
||||
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue()
|
||||
{
|
||||
Console.WriteLine("Updating selected cue");
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\",\"notes\"]";
|
||||
sendAndReceiveStringArgs("/cue/selected/valuesForKeys", valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateWorkspace(string ws_id)
|
||||
{
|
||||
Console.WriteLine("Workspace needs to be updaeted: " + ws_id);
|
||||
Console.WriteLine("Workspace needs to be updated: " + ws_id);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
||||
@@ -16,17 +16,38 @@ namespace qController
|
||||
public QController(string address, int port)
|
||||
{
|
||||
qClient = new QClient(address, port);
|
||||
|
||||
qUpdater = new QUpdater(this);
|
||||
qUpdater.Start();
|
||||
|
||||
qClient.qParser.SelectedCueUpdated += this.OnSelectedCueUpdated;
|
||||
qClient.qParser.WorkspaceUpdated += this.OnWorkspaceUpdated;
|
||||
qClient.qParser.PlaybackPositionUpdated += this.OnPlaybackPositionUpdated;
|
||||
qClient.qParser.CueInfoUpdated += this.OnCueUpdateReceived;
|
||||
qClient.qParser.AudioLevelsUpdated += this.OnAudioLevelsUpdated;
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
qClient.sendAndReceiveString("/cueLists");
|
||||
|
||||
}
|
||||
|
||||
private void OnAudioLevelsUpdated(object source, AudioLevelArgs args)
|
||||
{
|
||||
if(qWorkspace != null)
|
||||
qWorkspace.UpdateLevels(args.cue_id, args.levels);
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
qClient.sendStringUDP("/connect");
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
qClient.sendStringUDP("/disconnect");
|
||||
}
|
||||
|
||||
public void ConnectWithPass(string pass)
|
||||
{
|
||||
qClient.sendArgsUDP("/connect", pass);
|
||||
}
|
||||
|
||||
public void sendCommand(string cmd){
|
||||
@@ -34,7 +55,7 @@ namespace qController
|
||||
}
|
||||
|
||||
public void updateCueValue(QCue cue, string property, object newValue){
|
||||
// qSender.sendArgs("/cue_id/"+cue.uniqueID+"/"+property, newValue);
|
||||
//qClient.sendArgs("/cue_id/"+cue.uniqueID+"/"+property, newValue);
|
||||
}
|
||||
|
||||
public void OnSelectedCueUpdated(object source, CueEventArgs args)
|
||||
@@ -66,7 +87,13 @@ namespace qController
|
||||
{
|
||||
playbackPosition = args.Cue.uniqueID;
|
||||
}
|
||||
if(args.Cue.type == "Audio" || args.Cue.type == "Mic" || args.Cue.type == "Video")
|
||||
{
|
||||
Console.WriteLine("Cue has audio levels...sending request");
|
||||
qClient.sendStringUDP("/cue_id/" + args.Cue.uniqueID + "/levels");
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill(){
|
||||
qUpdater.Kill();
|
||||
qClient.Close();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using SharpOSC;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace qController
|
||||
{
|
||||
@@ -16,7 +17,12 @@ namespace qController
|
||||
|
||||
public class AudioLevelArgs : EventArgs
|
||||
{
|
||||
public JToken levels
|
||||
public string cue_id
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public List<double> levels
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -38,6 +44,14 @@ namespace qController
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class ConnectEventArgs : EventArgs
|
||||
{
|
||||
public string Status
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class QParser
|
||||
{
|
||||
public QParser()
|
||||
@@ -50,7 +64,8 @@ namespace qController
|
||||
public delegate void WorkspaceUpdatedHandler(object source, WorkspaceEventArgs args);
|
||||
public delegate void CueInfoUpdatedHandler(object source, CueEventArgs args);
|
||||
public delegate void PlaybackPositionUpdatedHandler(object source, PlaybackPositionArgs args);
|
||||
|
||||
public delegate void ConnectionStatusHandler(object source, ConnectEventArgs args);
|
||||
public event ConnectionStatusHandler ConnectionStatusChanged;
|
||||
public event SelectedCueUpdatedHandler SelectedCueUpdated;
|
||||
public event AudioLevelsUpdatedHandler AudioLevelsUpdated;
|
||||
public event WorkspaceUpdatedHandler WorkspaceUpdated;
|
||||
@@ -62,7 +77,10 @@ namespace qController
|
||||
{
|
||||
if (msg.Address.Contains("valuesForKeys"))
|
||||
{
|
||||
ParseCueUpdateInfo(msg);
|
||||
if (msg.Address.Contains("WithArguments"))
|
||||
ParseLevelInfo(msg);
|
||||
else
|
||||
ParseCueUpdateInfo(msg);
|
||||
}
|
||||
else if (msg.Address.Contains("notes"))
|
||||
ParseNoteInfo(msg);
|
||||
@@ -74,6 +92,8 @@ namespace qController
|
||||
ParsePositionUpdateInfo(msg);
|
||||
else if (msg.Address.Contains("thump"))
|
||||
Console.WriteLine("Heartbeat Received");
|
||||
else if (msg.Address.Contains("connect"))
|
||||
ParseConnectInfo(msg);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Unknown message type");
|
||||
@@ -87,6 +107,12 @@ namespace qController
|
||||
}
|
||||
}
|
||||
|
||||
public void ParseConnectInfo(OscMessage msg)
|
||||
{
|
||||
JToken connectStatus = OSC2JSON(msg);
|
||||
OnConnectionStatusChanged(connectStatus.ToString());
|
||||
}
|
||||
|
||||
public void ParsePositionUpdateInfo(OscMessage msg)
|
||||
{
|
||||
if(msg.Arguments.Count > 0)
|
||||
@@ -114,8 +140,9 @@ namespace qController
|
||||
}
|
||||
|
||||
public void ParseLevelInfo(OscMessage msg){
|
||||
var cue_id = msg.Address.Split('/')[3];
|
||||
JToken levels = OSC2JSON(msg)[0];
|
||||
OnAudioLevelsUpdated(levels);
|
||||
OnAudioLevelsUpdated(cue_id, levels.ToObject<List<double>>());
|
||||
}
|
||||
|
||||
public void ParseWorkspaceInfo(OscMessage msg)
|
||||
@@ -143,9 +170,9 @@ namespace qController
|
||||
SelectedCueUpdated(this, new CueEventArgs() { Cue = cue });
|
||||
}
|
||||
|
||||
protected virtual void OnAudioLevelsUpdated(JToken audioLevels){
|
||||
protected virtual void OnAudioLevelsUpdated(string id, List<double> audioLevels){
|
||||
if (AudioLevelsUpdated != null)
|
||||
AudioLevelsUpdated(this, new AudioLevelArgs { levels = audioLevels });
|
||||
AudioLevelsUpdated(this, new AudioLevelArgs { cue_id = id, levels = audioLevels });
|
||||
}
|
||||
|
||||
protected virtual void OnCueInfoUpdated(QCue cue)
|
||||
@@ -159,5 +186,10 @@ namespace qController
|
||||
if (PlaybackPositionUpdated != null)
|
||||
PlaybackPositionUpdated(this, new PlaybackPositionArgs() { PlaybackPosition = id });
|
||||
}
|
||||
protected virtual void OnConnectionStatusChanged(string status)
|
||||
{
|
||||
if (ConnectionStatusChanged != null)
|
||||
ConnectionStatusChanged(this, new ConnectEventArgs() { Status = status });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace qController
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace qController
|
||||
public string displayName { get; set; }
|
||||
public bool isLoaded { get; set; }
|
||||
public string notes { get; set; }
|
||||
|
||||
public List<double> levels { get; set; }
|
||||
public string getIconString()
|
||||
{
|
||||
switch (type)
|
||||
|
||||
@@ -39,6 +39,22 @@ namespace qController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLevels(string cue_id, List<double> levels)
|
||||
{
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < data[i].cues.Count; j++)
|
||||
{
|
||||
if (data[i].cues[j].uniqueID == cue_id)
|
||||
{
|
||||
Console.WriteLine("Cue found and levels updated");
|
||||
data[i].cues[j].levels = levels;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PrintStats()
|
||||
{
|
||||
foreach (var cueList in data)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace qController
|
||||
QSelectedCueCell qCell;
|
||||
QSelectedCueOptionsCell qSelectedCueOptions;
|
||||
Grid mainG;
|
||||
ListView listView;
|
||||
|
||||
public ControlPage(string name, string address)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -22,12 +22,28 @@ namespace qController
|
||||
qController.qClient.qParser.WorkspaceUpdated += WorkspaceUpdated;
|
||||
qController.qClient.qParser.PlaybackPositionUpdated += PlaybackPositionUpdated;
|
||||
qController.qClient.qParser.CueInfoUpdated += OnCueUpdateReceived;
|
||||
|
||||
qController.qClient.qParser.ConnectionStatusChanged += OnConnectionStatusChanged;
|
||||
instanceName.Text = name;
|
||||
App.rootPage.MenuItemSelected += OnMenuItemSelected;
|
||||
|
||||
qController.Connect();
|
||||
InitGUI();
|
||||
|
||||
}
|
||||
|
||||
private void OnConnectionStatusChanged(object source, ConnectEventArgs args)
|
||||
{
|
||||
if (args.Status == "ok")
|
||||
{
|
||||
Console.WriteLine("Workspace has successfully connected");
|
||||
}
|
||||
else if (args.Status == "badpass")
|
||||
{
|
||||
Console.WriteLine("Password incorrect or no password supplied");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Workspace not found");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMenuItemSelected(object source, MenuEventArgs args)
|
||||
@@ -149,9 +165,11 @@ namespace qController
|
||||
|
||||
void Back()
|
||||
{
|
||||
qController.Disconnect();
|
||||
App.rootPage.MenuPage.ChangeToHome();
|
||||
App.NavigationPage.Navigation.PopAsync();
|
||||
}
|
||||
|
||||
public void SelectedCueUpdated(object sender, CueEventArgs e){
|
||||
Device.BeginInvokeOnMainThread(()=>{
|
||||
if (e.Cue.type.Equals("Audio"))
|
||||
@@ -190,12 +208,12 @@ namespace qController
|
||||
if (cue.type.Equals("Audio"))
|
||||
{
|
||||
//Console.WriteLine("CUE IS AN AUDIO CUE");
|
||||
//sLayout.Children.Add(qSelectedCueOptions);
|
||||
sLayout.Children.Add(qSelectedCueOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("CUE IS NOT AN AUDIO CUE");
|
||||
//sLayout.Children.Remove(qSelectedCueOptions);
|
||||
sLayout.Children.Remove(qSelectedCueOptions);
|
||||
}
|
||||
qCell.UpdateSelectedCue(cue);
|
||||
});
|
||||
@@ -211,6 +229,16 @@ namespace qController
|
||||
Console.WriteLine("Cue that was updated is equal to the playback position.");
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
if (args.Cue.type.Equals("Audio"))
|
||||
{
|
||||
//Console.WriteLine("CUE IS AN AUDIO CUE");
|
||||
sLayout.Children.Add(qSelectedCueOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("CUE IS NOT AN AUDIO CUE");
|
||||
sLayout.Children.Remove(qSelectedCueOptions);
|
||||
}
|
||||
qCell.UpdateSelectedCue(args.Cue);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace qController
|
||||
icon.FontSize = 20;
|
||||
var label = new Label { VerticalOptions = LayoutOptions.FillAndExpand };
|
||||
label.SetBinding(Label.TextProperty, "Title");
|
||||
Console.WriteLine(label.Text);
|
||||
if (label.Text == "Disconnect")
|
||||
{
|
||||
label.TextColor = Color.DarkRed;
|
||||
|
||||
Reference in New Issue
Block a user