コード例 #1
0
        /// <summary>
        /// Loop that reads the first entrance of the <see cref="AudioBuffer"/> and makes the API call.
        /// The data that is recieved is pushed into the <see cref="ResultBuffer"/>./>
        /// </summary>
        /// <param name="ct">Token that throws an OperationCancelledException when the token state is set to cancel. Used to stop the task.</param>
        /// <returns>Task, so the method can be run asynchronously.</returns>
        private async Task ProcessingCycle(CancellationToken ct)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.Timeout = new TimeSpan(0, 0, 12);
                while (true)
                {
                    //if (DevFlags.LoggingEnabled) Logger.APILog("Looping");
                    ct.ThrowIfCancellationRequested();
                    if (AudioBuffer?.Peek() != null)
                    {
                        var data = AudioBuffer?.Get();
                        if (data != null)
                        {
                            EssentiaModel essentiaModel = new EssentiaModel(data.Data, data.Time);
                            var           chordData     = await DoAPICall(essentiaModel, httpClient, ct);

                            ResultBuffer.Add(chordData);
                        }
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Constructor
 /// <para>Sets the <see cref="ResultBuffer"/>.</para>
 /// </summary>
 /// <param name="resultBuffer">Buffer to use.</param>
 public DataAnalyzer(ResultBuffer resultBuffer)
 {
     ResultBuffer = resultBuffer;
 }
コード例 #3
0
 /// <summary>
 /// Clean both buffers.
 /// </summary>
 private void EmptyBuffer()
 {
     AudioBuffer.Clean();
     ResultBuffer.Clean();
 }