public async Task <IActionResult> GetNoteAsync([FromRoute] string noteId, CancellationToken cancelltionToken) { cancelltionToken.ThrowIfCancellationRequested(); if (!Guid.TryParse(noteId, out var modelNoteId)) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } Model.Notes.Note modelNote = null; try { modelNote = await this.repository.GetAsync(modelNoteId, cancelltionToken).ConfigureAwait(false); } catch (Model.Notes.NoteNotFoundExcepction) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } var clientNote = NoteConverter.Convert(modelNote); return(this.Ok(clientNote)); }
public async Task <IActionResult> GetNoteAsync( [FromRoute] string noteId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (!this.TryGetSessionState(this.HttpContext.Request.Cookies, out var state)) { return(this.Unauthorized()); } if (!Guid.TryParse(noteId, out var noteIdGuid)) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } Models.Notes.Note modelNote = null; try { modelNote = await this.repository.GetAsync(noteIdGuid, cancellationToken).ConfigureAwait(false); } catch (Models.Notes.NoteNotFoundExcepction) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } if (!state.UserId.Equals(modelNote.UserId)) { return(this.Forbid()); } var clientNote = NoteConverter.Convert(modelNote); return(this.Ok(clientNote)); }
public async Task <IActionResult> PatchNoteAsync([FromRoute] string noteId, [FromBody] Client.Notes.NotePatchInfo patchInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (patchInfo == null) { var error = ServiceErrorResponses.BodyIsMissing("NotePatchInfo"); return(this.BadRequest(error)); } if (!Guid.TryParse(noteId, out var noteIdGuid)) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } var modelPathInfo = NotePathcInfoConverter.Convert(noteIdGuid, patchInfo); Model.Notes.Note modelNote = null; try { modelNote = await this.repository.PatchAsync(modelPathInfo, cancellationToken).ConfigureAwait(false); } catch (Model.Notes.NoteNotFoundExcepction) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } var clientNote = NoteConverter.Convert(modelNote); return(this.Ok(clientNote)); }
public void ConvertNote_AccidGes(string accid, Model.AccidType accidType) { meinote.SetAccidGes(accid); NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(accidType, convertedNote.AccidGes); }
public void ConvertNoteTest_Ratio(int num, int numbase) { meinote.SetNum(num.ToString()); meinote.SetNumbase(numbase.ToString()); NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(new Fraction(num, numbase), convertedNote.Ratio); }
void Update() { foreach (Wave w in waves) { if (!string.IsNullOrEmpty(w.note)) { w.frequency = NoteConverter.getFreq(w.note); } } }
public void ConvertNoteTest_Duration(string meidur, Model.Duration dur) { if (meidur != null) { meinote.SetDur(meidur); } NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(dur, convertedNote.Duration); }
public void ConvertNoteTest_Fermata(string fermata, bool assert) { if (fermata != null) { meinote.SetFermata(fermata); } NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(assert, convertedNote.Fermata); }
public void ConvertNoteTest_Coloration(string colored, bool assert) { if (colored != null) { meinote.SetColored(colored); } NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(assert, convertedNote.Coloration); }
public static PreciseDouble GetRelativeFretPosition(StringTuning tuning, int fret, Temperament temperament) { if (fret == 0) { return(1d); } var pitchAtFret = FretCompensationCalculator.GetPitchAtFret(tuning.FinalPitch, fret, temperament); PreciseDouble fretRatio = NoteConverter.CentsToIntonationRatio(pitchAtFret.Cents - tuning.FinalPitch.Cents); return((PreciseDouble)1d / fretRatio); }
public void ConvertNoteTest_Stem(string pos, string dir, Model.StemDesc stem) { if (dir != null) { meinote.SetStemDir(dir); } if (pos != null) { meinote.SetStemPos(pos); } NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(stem, convertedNote.Stem); }
public void ConvertNoteTest_WrittenPitch(string _pname, string _oct, int _base40) { if (_pname != null) { meinote.SetPname(_pname); } if (_oct != null) { meinote.SetOct(_oct); } NoteConverter.ConvertNote(convertedNote, meinote); Assert.AreEqual(_base40, convertedNote.WrittenPitch); }
public void DoNote() { if (activeMelody == null || currentNote >= activeMelody.Length) { SelectVariation(); } string note = activeMelody[currentNote]; if (string.IsNullOrEmpty(note) || note == "x") { activeWave.gain = 0; } else { float f = NoteConverter.getFreq(note); //if (activeWave.frequency == f) //{ // currentNote++; // return; //keep playing //} //else //{ activeWave.CopyFrom(waveSettings); activeWave.frequency = f; activeWave.note = note; activeArpeggio = null; if (Conductor.NoteInActiveKey(note) && enableArpeggios) { if (Random.value < .5f) { SelectArpeggio(); baseNote = note; noteStart = Time.time; } } //} } if (++currentNote >= activeMelody.Length) { SelectVariation(); } }
public void Randomize() { var layer = rhcFile.layers.layers.First(); var beatNotesList = NoteConverter.ConvertToBeatNotes(layer.notes); var randomizedNotes = RandomizeBeatNotes(beatNotesList); var rhNotes = NoteConverter.ConvertToRhNotes(randomizedNotes); layer.notes = rhNotes; UpdatePanelConfig(layer, rhNotes); var rhDir = Path.GetDirectoryName(settings.rhPath); SaveRandomizedRhc(rhDir); SyncRandomizedRhcToCache(rhDir); }
public async Task <IActionResult> PatchNoteAsync( [FromRoute] string noteId, [FromBody] Client.Notes.NotePatchInfo patchInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (!this.TryGetSessionState(this.HttpContext.Request.Cookies, out var state)) { return(this.Unauthorized()); } if (patchInfo == null) { var error = ServiceErrorResponses.BodyIsMissing("NotePatchInfo"); return(this.BadRequest(error)); } if (!Guid.TryParse(noteId, out var noteIdGuid)) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } if (!this.IsNoteBelongsToUserAsync(state, noteIdGuid, cancellationToken).Result) { return(this.Forbid()); } Models.Notes.Note modelNote = null; var modelPathInfo = NotePathcInfoConverter.Convert(noteIdGuid, patchInfo); try { modelNote = await this.repository.PatchAsync(modelPathInfo, cancellationToken).ConfigureAwait(false); } catch (Models.Notes.NoteNotFoundExcepction) { var error = ServiceErrorResponses.NoteNotFound(noteId); return(this.NotFound(error)); } var clientNote = NoteConverter.Convert(modelNote); return(this.Ok(clientNote)); }
public void DoNote() { if (activeMelody == null || currentNote >= activeMelody.Length) { SelectVariation(); } string note = activeMelody[currentNote]; if (string.IsNullOrEmpty(note) || note == "x") { activeWave.gain = 0; } else { float f = NoteConverter.getFreq(note); //string firstNote = Conductor.GetRelativeNoteInKey(Conductor.activeKey, note, 2 * 7); //string secondNote = Conductor.GetRelativeNoteInKey(Conductor.activeKey, note, 2 * 7 + 2); //Debug.Log(string.Format("Overtones: {0} , {1} from base note {2}", firstNote, secondNote, note)); //if (activeWave.frequency == f) //{ // currentNote++; // activeWave.note = note; // return; //keep playing //} //else //{ activeWave.CopyFrom(waveSettings); activeWave.frequency = f; activeWave.note = note; //} } if (++currentNote >= activeMelody.Length) { SelectVariation(); } }
protected virtual void OnAudioFilterRead(float[] data, int channels) { if (activeWave.gain == 0) { //play silence } else { //play activeWave if (!string.IsNullOrEmpty(activeWave.note)) { activeWave.frequency = NoteConverter.getFreq(activeWave.note); } activeWave.increment = activeWave.frequency * 2 * Mathf.PI / GlobalSoundVariables.SAMPLING_FREQUENCY; for (var i = 0; i < data.Length; i = i + channels) { activeWave.phase = activeWave.phase + activeWave.increment; // this is where we copy audio data to make them “available” to Unity float targetGain = (activeWave.gain + Mathf.Sin(activeWave.gainPhaseSpeed * time) * activeWave.gainPhaseRange); data[i] = (float)(targetGain) * Mathf.Sin(activeWave.phase); if (activeWave.square) { data[i] = (data[i] > 0) ? targetGain : -targetGain; } // if we have stereo, we copy the mono data to each channel if (channels == 2) { data[i + 1] = data[i]; } if (activeWave.phase > 2 * Mathf.PI) { activeWave.phase = 0; } } } }
protected override void OnAudioFilterRead(float[] data, int channels) { if (activeWave.gain == 0) { return; } if (!string.IsNullOrEmpty(activeWave.note)) { activeWave.frequency = NoteConverter.getFreq(activeWave.note); } activeWave.increment = activeWave.frequency * 2 * Mathf.PI / GlobalSoundVariables.SAMPLING_FREQUENCY; for (var i = 0; i < data.Length; i = i + channels) { activeWave.phase = activeWave.phase + activeWave.increment; // this is where we copy audio data to make them “available” to Unity float targetGain = (activeWave.gain + Mathf.Sin(activeWave.gainPhaseSpeed * time) * activeWave.gainPhaseRange); data[i] += (float)(targetGain) * Mathf.Sin(activeWave.phase); if (activeWave.square) { data[i] = (data[i] > 0) ? targetGain : -targetGain; } // if we have stereo, we copy the mono data to each channel if (channels == 2) { data[i + 1] = data[i]; } if (activeWave.phase > 2 * Mathf.PI) { activeWave.phase = 0; } } //add overtones one.CopyFrom(activeWave); //add a double octave one.note = Conductor.GetRelativeNoteInKey(Conductor.activeKey, one.note, 2 * 7); one.square = false; one.gainPhaseSpeed = 10; one.gainPhaseRange = one.gain * .5f; one.frequency = NoteConverter.getFreq(one.note); one.increment = one.frequency * 2 * Mathf.PI / GlobalSoundVariables.SAMPLING_FREQUENCY; for (var i = 0; i < data.Length; i = i + channels) { one.phase = one.phase + one.increment; // this is where we copy audio data to make them “available” to Unity float targetGain = (one.gain + Mathf.Sin(one.gainPhaseSpeed * time) * one.gainPhaseRange); data[i] += (float)(targetGain) * Mathf.Sin(one.phase); if (one.square) { data[i] = (data[i] > 0) ? targetGain : -targetGain; } // if we have stereo, we copy the mono data to each channel if (channels == 2) { data[i + 1] = data[i]; } if (one.phase > 2 * Mathf.PI) { one.phase = 0; } } //add a double octave third? two.CopyFrom(activeWave); two.note = Conductor.GetRelativeNoteInKey(Conductor.activeKey, two.note, 2 * 7 + 2); if (int.Parse(two.note[two.note.Length - 1].ToString()) > 4) { two.note = two.note.Substring(0, two.note.Length - 1) + "4"; } two.square = false; two.gain *= 2; two.gainPhaseSpeed = 1; two.gainPhaseRange = two.gain * .5f; two.frequency = NoteConverter.getFreq(two.note); two.increment = two.frequency * 2 * Mathf.PI / GlobalSoundVariables.SAMPLING_FREQUENCY; for (var i = 0; i < data.Length; i = i + channels) { two.phase = two.phase + two.increment; // this is where we copy audio data to make them “available” to Unity float targetGain = (two.gain + Mathf.Sin(two.gainPhaseSpeed * time) * two.gainPhaseRange); data[i] += (float)(targetGain) * Mathf.Sin(two.phase); if (two.square) { data[i] = (data[i] > 0) ? targetGain : -targetGain; } // if we have stereo, we copy the mono data to each channel if (channels == 2) { data[i + 1] = data[i]; } if (two.phase > 2 * Mathf.PI) { two.phase = 0; } } }