public AnalyserFileStream(AnalyserConfig config, string name, Stream source) { this.Config = config; this.Name = name; this.Source = source; this._magicHeader = new Lazy <string>(() => GetMagicHeader()); }
/// <summary> /// Construct the storage for an audio channel /// </summary> /// <param name="config"></param> public Channel(AnalyserConfig config) { Slot0 = new double[config.SamplesPerSlot]; Slot1 = new double[config.SamplesPerSlot]; Slot2 = new double[config.SamplesPerSlot]; RmsBuffer = new double[config.FirLength]; Filter = new Hpf(); }
/// <summary> /// Start the analyser /// If we are configure with a dummy recorder device then simulate the analyser (design mode) /// </summary> private void DoStart() { if (running) { return; } DoOff(); running = true; var configuration = locator.Configuration; AnalyserConfig analyserConfig; try { hostAddress = new IPEndPoint(IPAddress.Parse(configuration.Host), Int32.Parse(configuration.Port)); analyserConfig = new AnalyserConfig { Recorder = configuration.Device.Device, FirLength = int.Parse(configuration.FirLength ?? FIR_LENGTH_DEFAULT), SamplesPerSlot = configuration.VideoMode.SamplesPerSlot, SlotsPerFrame = configuration.VideoMode.SlotsPerFrame, TimecodeFormat = configuration.TimecodeMode.Mode, VideoMode = configuration.VideoMode.Mode }; } catch (Exception) { MessageBox.Show("Invalid configuration"); return; } if (analyserConfig.Recorder == null) { MessageBox.Show("Starting in design mode", "Design Mode", MessageBoxButton.OK); dummyTaskCancel = new CancellationTokenSource(); var token = dummyTaskCancel.Token; Task.Run(async() => { var tcg = new TimecodeGenerator(configuration.VideoMode.Fps / 1000).GetEnumerator(); var delay = 1000000 / configuration.VideoMode.Fps; while (!token.IsCancellationRequested) { tcg.MoveNext(); var t = Task.Delay(delay, token); Application.Current.Dispatcher.Invoke(() => Timecode = TimecodeString(tcg.Current), DispatcherPriority.Background); await t; } }, token); } else { client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); analyser = new Analyser(analyserConfig); analyser.FingerprintCreated += FingerprintCreated; analyser.Start(); } }
protected IEnumerable <IAssemblyAction> ResolveActions(AnalyserConfig config) { foreach (var analyser in config.Analysers) { var value = analyser.Resolve <IAssemblyAction>(); if (value != null) { value.Id = analyser.Id; value.DisplayMessage = analyser.DisplayMessage; value.Severity = analyser.Severity; value.Config = config; yield return(value); } } }
public void Test1() { var config = new AnalyserConfig { FirLength = 20, SamplesPerSlot = 48, SlotsPerFrame = 40 }; var samplesPerFrame = config.SamplesPerSlot * config.SlotsPerFrame; var sampleBuffer = new short[samplesPerFrame * Analyser.CHANNELS]; for (var i = 0; i < samplesPerFrame; i++) { var sin4k = (short)(10000 * Math.Sin(2 * Math.PI * i / 12)); var sin1k = (short)(10000 * Math.Sin(2 * Math.PI * i / 48)); var l = ((i / 48) & 1) == 0 ? sin4k : sin1k; var r = ((i / 48) & 1) != 0 ? sin4k : sin1k; sampleBuffer[i * Analyser.CHANNELS] = l; sampleBuffer[(i * Analyser.CHANNELS) + 1] = r; } var cb = new Callback(config); var handle = GCHandle.Alloc(sampleBuffer, GCHandleType.Pinned); var buf = handle.AddrOfPinnedObject(); var fingerprints1 = cb.GetAudioFingerprints(buf, config); var fingerprints2 = cb.GetAudioFingerprints(buf, config); Assert.AreEqual(0x800000FFFFF55555UL, fingerprints1[0]); Assert.AreEqual(0x800000FFFFFAAAAAUL, fingerprints1[1]); Assert.AreEqual(0x8000005555555555UL, fingerprints2[0]); Assert.AreEqual(0x800000AAAAAAAAAAUL, fingerprints2[1]); handle.Free(); }
public Analyser(AnalyserConfig config) { this.Config = config; }
public AssemblyFileAnalyser(AnalyserConfig config, string path) { this.Path = path; this.Source = File.OpenRead(path); }
public AnalyserFile(AnalyserConfig config, string path) : base(config, path, TryGetStream(path)) { }
public AssemblyAnalyser(AnalyserConfig config, Stream source) { this.config = config; this.Source = source; this.Actions = this.ResolveActions(config); }