public async void getNotes(string noteBookId) { //if (DataBaseHelper.tableExists<Notes>()) //{ // using (SQLiteConnection con = new SQLiteConnection(DataBaseHelper.dbfile)) // { // var notes = con.Table<Notes>(). // Where(n => n.NoteBookId.Equals(notebookid)). // ToList(); // NotesCollection.Clear(); // foreach (var note in notes) // { // NotesCollection.Add(note); // } // } //} try { var notes = await App.MobileServiceClient.GetTable <Notes>(). Where(n => n.NoteBookId == noteBookId).ToListAsync(); NotesCollection.Clear(); foreach (var note in notes) { NotesCollection.Add(note); } } catch (Exception e) { Console.WriteLine("Exceptionin getting notes" + e.Message); } }
public static void Test() { var midiFile = new MidiFile(); TempoMap tempoMap = midiFile.GetTempoMap(); var trackChunk = new TrackChunk(); using (var notesManager = trackChunk.ManageNotes()) { NotesCollection notes = notesManager.Notes; var g = Enum.GetValues(typeof(NoteName)); NoteName n = (NoteName)g.GetValue(MainWindow._rnd.Next(g.Length)); notes.Add(new InterNote(n, 4, LC.ConvertFrom( new MetricTimeSpan(hours: 0, minutes: 0, seconds: 2), 0, tempoMap))); n = (NoteName)g.GetValue(MainWindow._rnd.Next(g.Length)); notes.Add(new InterNote(n, 3, LC.ConvertFrom( new MetricTimeSpan(hours: 0, minutes: 0, seconds: 1, milliseconds: 500), 0, tempoMap))); n = (NoteName)g.GetValue(MainWindow._rnd.Next(g.Length)); notes.Add(new InterNote(n, 5, LC.ConvertFrom( new MetricTimeSpan(hours: 0, minutes: 0, seconds: 3), 0, tempoMap))); } midiFile.Chunks.Add(trackChunk); using (var outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth")) using (var playback = midiFile.GetPlayback(outputDevice)) { // playback.Speed = 2.0; playback.Play(); } }
/// <summary>Create <see cref="Repository"/>.</summary> /// <param name="gitAccessor">Git repository access provider.</param> /// <param name="workingDirectory">Repository working directory.</param> /// <param name="load"><c>true</c> to load repository; <c>false</c> otherwise.</param> private Repository(IGitAccessor gitAccessor, string workingDirectory, bool load) { Verify.Argument.IsNotNull(gitAccessor, "gitAccessor"); Verify.Argument.IsNotNull(workingDirectory, "workingDirectory"); _workingDirectory = GetWorkingDirectory(workingDirectory); _gitDirectory = GetGitDirectory(_workingDirectory); _configurationManager = GetConfigurationManager(_gitDirectory); _accessor = gitAccessor.CreateRepositoryAccessor(this); _revisionCache = new RevisionCache(this); _configuration = new ConfigParametersCollection(this); _status = new Status(this); _stash = new StashedStatesCollection(this); _refs = new RefsCollection(this); _notes = new NotesCollection(this); _remotes = new RemotesCollection(this); _submodules = new SubmodulesCollection(this); _users = new UsersCollection(this); _hooks = new HooksCollection(this); if(load) { try { LoadCore(this, null, CancellationToken.None); } catch { Dispose(); throw; } } }
private void LoadNotesCollection() { if (Notes != null) { foreach (Note Note in Notes) { NotesCollection.Add(Note); } } }
public async Task RemoveNoteAsync() { if (SelectedNote == null || NotesCollection.Count <= 0) { return; } await Task.FromResult(NotesCollection.Remove(SelectedNote)); SelectedNote = NotesCollection.LastOrDefault(); }
private static List <Note> _listBias(NotesCollection notes, int octBias = 0) { if (octBias == 0) { return(notes.ToList()); } var list = notes.ToList(); foreach (var item in list) { item.SetNoteNameAndOctave(item.NoteName, item.Octave + octBias); } return(list); }
void InitializeFirestoreReferences() { // If we are going to create a new note, generate a new note node if (IsNewNote) { noteDocument = NotesCollection.CreateDocument(); Note = new Note { Id = noteDocument.Id }; Folder.NotesCount++; } else { noteDocument = NotesCollection.GetDocument(Note.Id); } }
public void InitPlay() { _midiFile = new MidiFile(); TempoMap tempoMap = _midiFile.GetTempoMap(); var trackChunk = new TrackChunk(); using (var notesManager = trackChunk.ManageNotes()) { NotesCollection notes = notesManager.Notes; var len = LC.ConvertFrom(new MetricTimeSpan(hours: 0, minutes: 0, seconds: 1), 0, tempoMap); notes.Add(new InterNote(Note, Octave, len)); } _midiFile.Chunks.Add(trackChunk); }
private async void DeleteButton_Click(object sender, RoutedEventArgs e) { ContentDialog deleteFileDialog = new ContentDialog { Title = "Delete note permanently?", Content = "If you delete this note, you won't be able to recover it. Do you want to delete it?", PrimaryButtonText = "Delete", CloseButtonText = "Cancel" }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { NotesCollection.Remove((sender as FrameworkElement).Tag as Note); ((sender as FrameworkElement).Tag as Note).Delete(App.Context, App.ShowToastNotification); } }
public MainViewModel() { AddCommand = new RelayCommand(async() => await AddNoteAsync()); SaveCommand = new RelayCommand(async() => await SaveNotesAsync()); RemoveCommand = new RelayCommand(async() => await RemoveNoteAsync(), CanRemoveNote); FileManager = new FileManager("notes.csv"); if (DesignMode.DesignModeEnabled == true) { NotesCollection = new ObservableCollection <NoteModel>() { new NoteModel("A"), new NoteModel("B"), new NoteModel("C") }; } else { NotesCollection = GetNotesAsync().GetAwaiter().GetResult(); } SelectedNote = NotesCollection.FirstOrDefault(); }
public static MidiFile ToMidiFile(this Bitmap bitmap, TimeSpan songLength) { bool newPixelSet = true; var metricTimeSpan = new MetricTimeSpan(songLength); var midiFile = new MidiFile(); TempoMap tempoMap = midiFile.GetTempoMap(); long maxLength = TimeConverter.ConvertFrom(metricTimeSpan, tempoMap); List <MidiPixelSet> pixelSet = new List <MidiPixelSet>(); MidiPixelSet midiPixelSet = new(); for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { var pixel = bitmap.GetPixel(i, j); if (pixel.A == 0) { break; } if (newPixelSet) { midiPixelSet = new(); midiPixelSet.Tone = new(pixel.R, pixel.G, pixel.B); } else { midiPixelSet.Timing = new(pixel.R, pixel.G, pixel.B, maxLength); pixelSet.Add(midiPixelSet); } newPixelSet = !newPixelSet; } } for (int i = 0; i < 10; i++) { Console.WriteLine(pixelSet[i].Tone.NoteNumber); } var trackChunk = new TrackChunk(); int count = 0; using (var notesManager = trackChunk.ManageNotes()) { NotesCollection notes = notesManager.Notes; pixelSet.ForEach(x => { count++; notes.Add(new Note(x.Tone.NoteNumber, x.Tone.Length, x.Timing.Time)); }); } midiFile.Chunks.Add(trackChunk); return(midiFile); }
public void TestMethod() { Console.WriteLine("Testing..."); var midiFile = MidiFile.Read("C:\\Users\\trent.jones\\Documents\\midi\\test my C scales.mid"); using (NotesManager notesManager = midiFile.GetTrackChunks() // shortcut method for // Chunks.OfType<TrackChunk>() .First() .ManageNotes()) { // Get notes ordered by time NotesCollection notes = notesManager.Notes; // Get all C# notes //IEnumerable<Melanchall.DryWetMidi.Interaction.Note> cSharpNotes = notes.Where(n => n.NoteName == NoteName.C); //long prevTime = 0; //The first note is the start octave foreach (var note in notes) { notesPlayed++; if (notesPlayed == 1) { rootNote = note; startOctave = note.Octave; scaleInterval = 1; startTime = note.Time; } else if (note.NoteNumber > prevNote.NoteNumber) { playDirection = "asc"; } else if (note.NoteNumber < prevNote.NoteNumber) { playDirection = "desc"; } //Set the interval //Maybe let's wait until we have all the scales plugged in Console.WriteLine(notesPlayed + " " + note.Octave + " " + note.NoteName + "(" + note.NoteNumber + ")" + " " + (note.Time - prevTime)); prevTime = note.Time; prevNote = note; //If we're back to the root note... if (note.NoteNumber == rootNote.NoteNumber && notesPlayed > 1) { Console.WriteLine("The total time was " + (note.Time - startTime)); ResetScale(); } } // Add new note: C# of octave with number of 2 // Note: DryWetMIDI uses scientific pitch notation which means middle C is C4 //notes.Add(new Melanchall.DryWetMidi.Interaction.Note(NoteName.C, 2) //{ // Channel = (FourBitNumber)2, // Velocity = (SevenBitNumber)95 //}); } }
public async Task AddNoteAsync() { NotesCollection.Add(new NoteModel()); await Task.FromResult(SelectedNote = NotesCollection.LastOrDefault()); }
void LoadBeatmapFromMidi(string midipath) { MidiFile mf = MidiFile.Read(midipath); var tempoMap = mf.GetTempoMap(); foreach (TrackChunk tc in mf.GetTrackChunks()) { using (var notesManager = new NotesManager(tc.Events)) { NotesCollection notes = notesManager.Notes; IOrderedEnumerable <Note> sortedNotes = notes.OrderBy(n => n.Time); SequenceTrackNameEvent trackNameEvent; //this may fail if the first event isnt a trackname try //this will take us to the next track chunk in the case that this one doesnt have a name event { trackNameEvent = (SequenceTrackNameEvent)tc.Events[0]; } catch (InvalidCastException e) { Debug.Log(e.ToString()); continue; } string trackName = trackNameEvent.Text; if (trackName == "" || trackName == null) { Debug.Log("Trackname is null"); } foreach (Note n in sortedNotes) { MetricTimeSpan metricTime = TimeConverter.ConvertTo <MetricTimeSpan>(n.Time, tempoMap); var bpm = tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute; switch (trackName) { case "TestNote": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "TestNote2": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Tap": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Hold": MetricTimeSpan duration = TimeConverter.ConvertTo <MetricTimeSpan>(n.Length, tempoMap); object[] args = { duration.TotalMicroseconds / 1000000f }; GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4, args); break; case "Slide": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Miss": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Tap Hold": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Tap Slide": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; case "Tap Release": GetComponent <NoteOrigin>().EnqueueNote(trackName, n.NoteNumber, metricTime.TotalMicroseconds / 1000000f + Time.time, tempoMap.Tempo.AtTime(n.Time).BeatsPerMinute, lifetime: 4); break; default: Debug.Log("ChunkId not found: " + trackName); break; } } } } float musicDelay = tempoMap.Tempo.First().Value.MicrosecondsPerQuarterNote *7; //this is 7 because the beatmap is weird //and the song has a leadup measure StartCoroutine(musicDelayStart(musicDelay)); }
public void DeleteNote(AnnouncementsNote note) { NoteAnnouncementsRepository.Instance.Service.Delete(note.noteID); NotesCollection.Remove(note); }