public async Task Recieve(CancellationToken cancellation) { int durration; string[] encoding; HttpClient client = MuseNetworkRequest.GetClient(); lock (threadLock) { encoding = (string[])encodedMidi.Clone(); durration = currentDurration; } while (durration < totalDurration) { if (cancellation.IsCancellationRequested) { return; } encoding = await MuseNetworkRequest.MakeMuseRequest(encoding, genre, instruments, temperature, trunication, cancellation); if (encoding == null) { break; } else if (encoding.Length == 1 && Equals(encoding[0], "noresponse")) { IsNoResponse = true; break; } durration = MuseDecoder.GetDurration(encoding); lock (threadLock) { encodedMidi = encoding; currentDurration = durration; } } client.Dispose(); }
public MuseReciever(MidiFile startMelodie, string genre, Instruments instruments, int temperature, int turnication, float length, string startMelodieName = "") { if (startMelodie != null) { encodedMidi = MuseEncoder.Encode(startMelodie); } else { encodedMidi = new string[0]; } currentDurration = MuseDecoder.GetDurration(encodedMidi); this.genre = genre; this.instruments = instruments; this.temperature = temperature; this.trunication = turnication; this.totalDurration = (int)(length * 60 * 1000); this.startMelodieName = startMelodieName.Replace("F-" + genre, ""); }