public async Task <IActionResult> Edit(int id, [Bind("Id,ProviderName")] SampleProvider sampleProvider) { if (id != sampleProvider.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sampleProvider); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SampleProviderExists(sampleProvider.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sampleProvider)); }
public Startup() { IMonitor monitor = new DefaultMonitor(); IProvider provider = new SampleProvider(); this.starter = new WebApplicationStarter(provider, monitor); }
public void Execute(ref ExecuteContext <NoParameters, Providers> context) { var providers = context.Providers; Assert.That(providers.Count, Is.EqualTo(Enum.GetNames(typeof(Providers)).Length)); // First is single value, so check its 0th element can be accessed. SampleProvider singleProv = providers.GetSampleProvider(Providers.Single); Assert.That(singleProv.Valid, Is.False); Assert.That(providers.GetCount(Providers.Single), Is.EqualTo(1)); Assert.Throws <ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.Single, 1)); // Second item is a var array. These are born empty. Assert.Throws <ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.VariableSizeArray)); Assert.That(providers.GetCount(Providers.VariableSizeArray), Is.EqualTo(0)); // Third item is a fixed array. These are born with their final size. Assert.That(providers.GetCount(Providers.FixedArray), Is.EqualTo(3)); for (int i = 0; i < 3; ++i) { SampleProvider p = providers.GetSampleProvider(Providers.FixedArray, 0); Assert.That(p.Valid, Is.False); } Assert.Throws <ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.FixedArray, 3)); Assert.Throws <ArgumentOutOfRangeException>(() => providers.GetSampleProvider(3)); }
public void Start() { Init(); SampleCount = AudioReader.GetSampleCount(); float[] samples = new float[SampleCount]; SampleProvider.Read(new float[SampleCount], 0, SampleCount); SampleProvider.Sample -= OnSample; }
public async Task <IActionResult> Create([Bind("Id,ProviderName")] SampleProvider sampleProvider) { if (ModelState.IsValid) { _context.Add(sampleProvider); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sampleProvider)); }
/* * Yet im not able to calculate FFT with non power of 2 fftsize. !!! check it out? !!! it is important? !!! * -------> WIP <--------------- * public ShortTimeFourierTransform(string filePath, double frequencyGap, double timeResolution = 0.010) * { * FilePath = filePath; * TimeResolution = timeResolution; * Reset(); * FFTLength = (int)(AudioReader.WaveFormat.SampleRate / frequencyGap); * m = (int)Math.Log(FFTLength, 2.0); * } */ public void Start() { Reset(); float[] samples = new float[SampleCount]; Stopwatch stopwatch = Stopwatch.StartNew(); SampleProvider.Read(new float[SampleCount], 0, SampleCount); SampleProvider.Sample -= OnSample; stopwatch.Stop(); AudioReader.Dispose(); Ended?.Invoke(stopwatch.Elapsed.TotalSeconds); }
public void SampleProvider_Execute_Succeeds( ISampleService sampleService) { A.CallTo(() => sampleService.CanExecute) .Returns(true); var sampleProvider = new SampleProvider(sampleService); sampleProvider.ExecuteSample(); A.CallTo(() => sampleService.Execute()) .MustHaveHappened(Repeated.Exactly.Once); }
public void Execute(ref ExecuteContext <NoParameters, NoProviders> context) { var localArray = new SampleProviderContainer <NoProviders>(); Assert.That(localArray.Count, Is.EqualTo(0)); var localProvider = new SampleProvider(); Assert.That(localProvider.Valid, Is.False); var outputs = context.Outputs; Assert.Throws <InvalidOperationException>(() => localProvider.Read(outputs.GetSampleBuffer(0).Buffer.Slice())); }
public void SampleProvider_Execute_Succeeds( ISampleService sampleService) { // Arrange A.CallTo(() => sampleService.CanExecute) .Returns(true); var sampleProvider = new SampleProvider(sampleService); // Act sampleProvider.ExecuteSample(); // Assert A.CallTo(() => sampleService.Execute()) .MustHaveHappenedOnceExactly(); }
// read either mono or stereo, always convert to stereo interleaved static unsafe bool ReadSamples(SampleProvider provider, NativeSlice <float> destination) { if (!provider.Valid) { return(true); } var finished = false; // Read from SampleProvider and convert to stereo if needed var destinationFrames = destination.Length / 2; if (provider.ChannelCount == 2) { var read = provider.Read(destination.Slice(0, destination.Length)); if (read < destinationFrames) { for (var i = read; i < destinationFrames; i++) { destination[i] = 0; destination[i + destinationFrames] = 0; } return(true); } } else { var buffer = destination.Slice(0, destinationFrames); var read = provider.Read(buffer); if (read < destinationFrames) { for (var i = read; i < destinationFrames; i++) { destination[i] = 0; } finished = true; } var left = (float *)destination.GetUnsafePtr(); var right = left + read; UnsafeUtility.MemCpy(right, left, read * UnsafeUtility.SizeOf <float>()); } return(finished); }
public void GetProviderShouldReturnTheProviderWithTheHighestPriorityValue([Frozen] IGetsMessageProviderInfoFactory providerFactoryFactory, FailureMessageProviderSelector sut, IGetsMessageProviderInfo providerFactory, SampleProvider provider1, SampleProvider provider2, SampleProvider provider3, [RuleResult] ValidationRuleResult ruleResult) { var info1 = new TestingMessageProviderInfo(provider1, 4); var info2 = new TestingMessageProviderInfo(provider2, 10); var info3 = new TestingMessageProviderInfo(provider3, 3); Mock.Get(providerFactoryFactory).Setup(x => x.GetProviderInfoFactory()).Returns(providerFactory); Mock.Get(providerFactory).Setup(x => x.GetMessageProviderInfo(ruleResult)).Returns(new[] { info1, info2, info3 }); Assert.That(() => sut.GetProvider(ruleResult), Is.SameAs(provider2)); }
public void SampleProvider_ExecuteWithDto_Succeeds( ISampleService sampleService, SampleDto dto, string returnValue) { A.CallTo(() => sampleService.CanExecute) .Returns(true); A.CallTo(() => sampleService.ExecuteWithDto(dto)) .Returns(returnValue); var sampleProvider = new SampleProvider(sampleService); var actual = sampleProvider.ExecuteSampleWithDto(dto); A.CallTo(() => sampleService.ExecuteWithDto(A <SampleDto> .Ignored)) .MustHaveHappened(Repeated.Exactly.Once); Assert.Equal(returnValue, actual); }
public bool ResampleLerpRead <T>( SampleProvider provider, NativeArray <float> input, SampleBuffer outputBuffer, ParameterData <T> parameterData, T rateParam) where T : unmanaged, Enum { var finishedSampleProvider = false; var outputL = outputBuffer.GetBuffer(0); var outputR = outputBuffer.GetBuffer(1); for (var i = 0; i < outputL.Length; i++) { Position += parameterData.GetFloat(rateParam, i); var length = input.Length / 2; while (Position >= length - 1) { m_LastLeft = input[length - 1]; m_LastRight = input[input.Length - 1]; finishedSampleProvider |= ReadSamples(provider, new NativeSlice <float>(input, 0)); Position -= length; } var positionFloor = Math.Floor(Position); var positionFraction = Position - positionFloor; var previousSampleIndex = (int)positionFloor; var nextSampleIndex = previousSampleIndex + 1; var prevSampleL = (previousSampleIndex < 0) ? m_LastLeft : input[previousSampleIndex]; var prevSampleR = (previousSampleIndex < 0) ? m_LastRight : input[previousSampleIndex + length]; var sampleL = input[nextSampleIndex]; var sampleR = input[nextSampleIndex + length]; outputL[i] = (float)(prevSampleL + (sampleL - prevSampleL) * positionFraction); outputR[i] = (float)(prevSampleR + (sampleR - prevSampleR) * positionFraction); } return(finishedSampleProvider); }
protected override async Task OnHandlerAsync(ParameterHandlerInfo info) { var serializer = new NBinarySerializer(); var service = new SampleProvider(); Core.Log.InfoBasic("Setting RPC Server"); var rpcServer = new RPCServer(new DefaultTransportServer(20050, serializer)); rpcServer.AddService(typeof(ISampleProvider), service); await rpcServer.StartAsync().ConfigureAwait(false); Core.Log.InfoBasic("Setting RPC Client"); var rpcClient = new RPCClient(new DefaultTransportClient("127.0.0.1", 20050, 1, serializer)); var hClient = await rpcClient.CreateDynamicProxyAsync <ISampleProvider>().ConfigureAwait(false); var client = hClient.ActAs <ISampleProvider>(); Core.Log.InfoBasic("GetSampleAsync"); var sampleTsk = await client.GetSampleAsync().ConfigureAwait(false); Core.Log.InfoBasic("DelayTestAsync"); await client.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample = client.GetSample(); Core.Log.InfoBasic("GetSample as Async"); var sampleSimAsync = ((dynamic)hClient).GetSample2Async().Result; var pClient = await rpcClient.CreateProxyAsync <SampleProxy>().ConfigureAwait(false); Core.Log.InfoBasic("GetSampleAsync"); var sampleTsk2 = await pClient.GetSampleAsync().ConfigureAwait(false); Core.Log.InfoBasic("DelayTestAsync"); await pClient.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample2 = pClient.GetSample(); rpcClient.Dispose(); await rpcServer.StopAsync().ConfigureAwait(false); }
public void SampleProvider_ExecuteWithParam_Succeeds( ISampleService sampleService, string value, string returnValue) { // Arrange A.CallTo(() => sampleService.CanExecute) .Returns(true); A.CallTo(() => sampleService.ExecuteWithParam(value)) .Returns(returnValue); var sampleProvider = new SampleProvider(sampleService); // Act var actual = sampleProvider.ExecuteSampleWithParam(value); // Assert A.CallTo(() => sampleService.ExecuteWithParam(A <string> .Ignored)) .MustHaveHappened(Repeated.Exactly.Once); Assert.Equal(returnValue, actual); }
public void SampleProvider_ExecuteWithParams_CanExecute_Succeeds( bool canExecute, string returnValue, ISampleService sampleService, string value) { // Arrange A.CallTo(() => sampleService.CanExecute) .Returns(canExecute); A.CallTo(() => sampleService.ExecuteWithParam(value)) .Returns(returnValue); var sampleProvider = new SampleProvider(sampleService); // Act var actual = sampleProvider.ExecuteSampleWithParam(value); // Assert A.CallTo(() => sampleService.ExecuteWithParam(A <string> .Ignored)) .MustHaveHappenedANumberOfTimesMatching(n => n == (canExecute ? 1 : 0)); Assert.Equal(returnValue, actual); }
public void SampleProvider_ExecuteWithParams_CanExecute_Succeeds( bool canExecute, string returnValue, ISampleService sampleService, string value) { A.CallTo(() => sampleService.CanExecute) .Returns(canExecute); A.CallTo(() => sampleService.ExecuteWithParam(value)) .Returns(returnValue); var sampleProvider = new SampleProvider(sampleService); var actual = sampleProvider.ExecuteSampleWithParam(value); A.CallTo(() => sampleService.ExecuteWithParam(A <string> .Ignored)) .MustHaveHappened( canExecute ? Repeated.Exactly.Once : Repeated.Never); Assert.Equal(returnValue, actual); }
public void SampleProvider_ExecuteWithDto_CanExecute_Succeeds( bool canExecute, string returnValue, ISampleService sampleService, SampleDto dto) { // Arrange A.CallTo(() => sampleService.CanExecute) .Returns(canExecute); A.CallTo(() => sampleService.ExecuteWithDto(dto)) .Returns(returnValue); var sampleProvider = new SampleProvider(sampleService); // Act var actual = sampleProvider.ExecuteSampleWithDto(dto); // Assert A.CallTo(() => sampleService.ExecuteWithDto(A <SampleDto> .Ignored)) .MustHaveHappened( canExecute ? Repeated.Exactly.Once : Repeated.Never); Assert.Equal(returnValue, actual); }
protected override async Task OnHandlerAsync(ParameterHandlerInfo info) { var serializer = new NBinarySerializer(); var service = new SampleProvider(); Core.Log.InfoBasic("Setting RPC Server"); var rpcServer = new RPCServer(new DefaultTransportServer(20050, serializer)); rpcServer.AddService(typeof(ISampleProvider), service); await rpcServer.StartAsync().ConfigureAwait(false); Core.Log.InfoBasic("Setting RPC Client"); var rpcClient = new RPCClient(new DefaultTransportClient("127.0.0.1", 20050, 1, serializer)); var hClient = await rpcClient.CreateDynamicProxyAsync <ISampleProvider>().ConfigureAwait(false); var client = hClient.ActAs <ISampleProvider>(); double perItemMs; try { var intEnumerable = await client.GetInt().ConfigureAwait(false); } catch (Exception ex) { Core.Log.Write(ex); } using (var watch = Watch.Create("GetSampleAsync")) { Sample res; for (var i = 0; i < 100000; i++) { res = await client.GetSampleAsync().ConfigureAwait(false); } perItemMs = watch.GlobalElapsedMilliseconds / 100000; } Core.Log.InfoBasic($"GetSampleAsync per item: {perItemMs}ms"); Console.ReadLine(); Core.Log.InfoBasic("DelayTestAsync"); await client.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample = client.GetSample(); Core.Log.InfoBasic("GetSample as Async"); var sampleSimAsync = ((dynamic)hClient).GetSample2Async().Result; Console.ReadLine(); var pClient = await rpcClient.CreateProxyAsync <SampleProxy>().ConfigureAwait(false); using (var watch = Watch.Create("GetSampleAsync")) { Sample res; for (var i = 0; i < 100000; i++) { res = await pClient.GetSampleAsync().ConfigureAwait(false); } perItemMs = watch.GlobalElapsedMilliseconds / 100000; } Core.Log.InfoBasic($"GetSampleAsync per item: {perItemMs}ms"); Console.ReadLine(); Core.Log.InfoBasic("DelayTestAsync"); await pClient.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample2 = pClient.GetSample(); rpcClient.Dispose(); await rpcServer.StopAsync().ConfigureAwait(false); }
public Startup() { IMonitor monitor = new DefaultMonitor(); IProvider provider = new SampleProvider(); this.starter = new WebApplicationStarter(provider, monitor); }