Ejemplo n.º 1
0
        protected bool SaveTrack(Models.Track track, XOUNDContext ctx)
        {
            Mp3FileReader reader = new Mp3FileReader(track.AudioFile.InputStream);

            track.DurationMinutes = reader.TotalTime.Minutes;
            track.DurationSeconds = reader.TotalTime.Seconds;

            ctx.Tracks.Add(track);
            ctx.SaveChanges();

            byte[] fileData = null;
            using (var binaryReader = new BinaryReader(track.AudioFile.InputStream))
            {
                fileData = binaryReader.ReadBytes(track.AudioFile.ContentLength);
            }

            Models.TrackFile file = new Models.TrackFile()
            {
                TrackID = track.ID,
                Track   = fileData
            };

            ctx.TrackFiles.Add(file);
            ctx.SaveChanges();

            return(true);
        }
Ejemplo n.º 2
0
        public void Convert(MidiEvent midiEvent, ref Models.Track track)
        {
            var metaMessage = midiEvent.MidiMessage as MetaMessage;

            byte[] tempoBytes = metaMessage.GetBytes();
            int    tempo      = (tempoBytes[0] & 0xff) << 16 | (tempoBytes[1] & 0xff) << 8 | (tempoBytes[2] & 0xff);
            int    bpm        = 60000000 / tempo;

            track.SetLastBarBeatsPerMinute(bpm);
        }
Ejemplo n.º 3
0
        public void Convert(MidiEvent midiEvent, ref Models.Track track)
        {
            var metaMessage = midiEvent.MidiMessage as MetaMessage;

            byte[] timeSignatureBytes = metaMessage.GetBytes();
            int    _beatNote          = timeSignatureBytes[0];
            int    _beatsPerBar       = (int)(1 / Math.Pow(timeSignatureBytes[1], -2));

            track.SetLastBarBeatsPerBar(new Tuple <int, int>(_beatNote, _beatsPerBar));
        }
Ejemplo n.º 4
0
        public void Convert(MidiEvent midiEvent, ref Models.Track track)
        {
            MetaMessage metaMessage = midiEvent.MidiMessage as MetaMessage;
            MetaType    metaType    = metaMessage.MetaType;

            if (converters.ContainsKey(metaType))
            {
                var converter = converters[metaType];
                converter.Convert(midiEvent, ref track);
            }
        }
            public void Add()
            {
                var track = new Models.Track
                {
                    Name        = ".Net",
                    Description = "All things .Net",
                    Color       = "Blue"
                };

                Console.WriteLine(EventsXdService.Tracks.Add(5577, track));
            }
            public void Update()
            {
                var track = new Models.Track
                {
                    Name        = ".Net",
                    Description = "All things .Net",
                    Color       = "Green",
                    Id          = "10550"
                };

                Console.WriteLine(EventsXdService.Tracks.Update(5577, track));
            }
Ejemplo n.º 7
0
        public async Task AddTrackByPlaylistIdAsync(Models.Track track, long playlistId)
        {
            await _track.AddTrackAsync(track);

            var currentPlayList = await _playLists.GetPlayLists().FirstOrDefaultAsync(p => p.Id == playlistId);

            var trackPlayList = new TrackPlayList {
                Track = track, PlayList = currentPlayList
            };

            await _trackPlayList.AddAsync(trackPlayList);
        }
Ejemplo n.º 8
0
        public void MapTrack(Models.Track track, Json.TrackState json)
        {
            if (track == null)
            {
                throw new ArgumentNullException("track", "Track should not be null in a mapper method.");
            }

            track.Name        = json.trackName;
            track.Distance    = json.lapDist;
            track.Phase       = json.gamePhase;
            track.SectorFlags = json.sectorFlags != null?json.sectorFlags.ToString() : string.Empty;

            track.Session = MapSession(json);
        }
Ejemplo n.º 9
0
        public Models.Library LoadLibrary(string path)
        {
            var trackFiles = trackConfigurationSearcher.FindSongConfigurationFiles(path);
            var library    = new Models.Library(new DirectoryInfo(path));

            foreach (var file in trackFiles)
            {
                var          text = File.ReadAllText(file.FullName);
                Models.Track item = trackParser.Parse(text);
                item.Location = file;
                library.AddSong(item);
            }
            return(library);
        }
Ejemplo n.º 10
0
        public ActionResult GenerateTrackingNo(int id)
        {
            int orderID    = id;
            var chkOrderID = Orders.CheckOrder(orderID);

            if (chkOrderID)
            {
                var r = new Models.Track().GenerateTrack(orderID);
                if (r)
                {
                    TempData["show"]    = 1;
                    TempData["Message"] = "Track No Generated";
                }
            }

            return(RedirectToAction("Order"));
        }
Ejemplo n.º 11
0
        public ActionResult Create(Models.Track track)
        {
            XOUNDContext ctx = new XOUNDContext();

            SaveTrack(track, ctx);

            if (Session["albums"] != null)
            {
                ViewBag.Albums = Session["albums"];
            }
            else
            {
                var items = ctx.Albums.ToList().Select(x => new SelectListItem()
                {
                    Text  = x.Title,
                    Value = x.ID.ToString()
                });
                ViewBag.Albums    = items;
                Session["albums"] = items;
            }
            return(View());
        }
Ejemplo n.º 12
0
 public async Task DeleteAsync(Models.Track track)
 {
     _context.Tracks.Remove(track);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 13
0
        private Sequence GetSequenceFromWPFStaffs(List <MusicalSymbol> WPFStaffs, Models.Track track)
        {
            List <string> notesOrderWithCrosses = new List <string>()
            {
                "c", "cis", "d", "dis", "e", "f", "fis", "g", "gis", "a", "ais", "b"
            };
            int absoluteTicks = 0;

            Sequence sequence = new Sequence();

            Sanford.Multimedia.Midi.Track metaTrack = new Sanford.Multimedia.Midi.Track();
            sequence.Add(metaTrack);

            // Calculate tempo
            var bar = (Bar)track.GetStaffs().Last().Bars.Last();

            int speed = (60000000 / bar.BarContext.BeatsPerMinute);

            byte[] tempo = new byte[3];
            tempo[0] = (byte)((speed >> 16) & 0xff);
            tempo[1] = (byte)((speed >> 8) & 0xff);
            tempo[2] = (byte)(speed & 0xff);
            metaTrack.Insert(0 /* Insert at 0 ticks*/, new MetaMessage(MetaType.Tempo, tempo));

            Sanford.Multimedia.Midi.Track notesTrack = new Sanford.Multimedia.Midi.Track();
            sequence.Add(notesTrack);

            for (int i = 0; i < WPFStaffs.Count; i++)
            {
                var musicalSymbol = WPFStaffs[i];
                switch (musicalSymbol.Type)
                {
                case MusicalSymbolType.Note:
                    PSAMControlLibrary.Note note = musicalSymbol as PSAMControlLibrary.Note;

                    // Calculate duration
                    double absoluteLength = 1.0 / (double)note.Duration;
                    absoluteLength += (absoluteLength / 2.0) * note.NumberOfDots;

                    double relationToQuartNote  = bar.BarContext.BeatsInBar.Item2 / 4.0;
                    double percentageOfBeatNote = (1.0 / bar.BarContext.BeatsInBar.Item2) / absoluteLength;
                    double deltaTicks           = (sequence.Division / relationToQuartNote) / percentageOfBeatNote;

                    // Calculate height
                    int noteHeight = notesOrderWithCrosses.IndexOf(note.Step.ToLower()) + ((note.Octave + 1) * 12);
                    noteHeight += note.Alter;
                    notesTrack.Insert(absoluteTicks, new ChannelMessage(ChannelCommand.NoteOn, 1, noteHeight, 90));     // Data2 = volume

                    absoluteTicks += (int)deltaTicks;
                    notesTrack.Insert(absoluteTicks, new ChannelMessage(ChannelCommand.NoteOn, 1, noteHeight, 0));     // Data2 = volume

                    break;

                case MusicalSymbolType.TimeSignature:
                    byte[] timeSignature = new byte[4];
                    // timeSignature[0] = (byte)_beatsPerBar;
                    //timeSignature[1] = (byte)(Math.Log(_beatNote) / Math.Log(2));
                    metaTrack.Insert(absoluteTicks, new MetaMessage(MetaType.TimeSignature, timeSignature));
                    break;

                default:
                    break;
                }
            }

            notesTrack.Insert(absoluteTicks, MetaMessage.EndOfTrackMessage);
            metaTrack.Insert(absoluteTicks, MetaMessage.EndOfTrackMessage);
            return(sequence);
        }
Ejemplo n.º 14
0
        public void SaveToMidi(string fileName, List <MusicalSymbol> WPFStaffs, Models.Track track)
        {
            Sequence sequence = GetSequenceFromWPFStaffs(WPFStaffs, track);

            sequence.Save(fileName);
        }
Ejemplo n.º 15
0
 public async Task UpdateTrack(Models.Track track)
 {
     await _track.UpdateAsync(track);
 }
Ejemplo n.º 16
0
 public async Task UpdateAsync(Models.Track track)
 {
     _context.Tracks.Update(track);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 17
0
        public async Task AddTrackAsync(Models.Track track)
        {
            await _context.Tracks.AddAsync(track);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 18
0
 public async Task RemoveTrack(Models.Track track)
 {
     await _track.DeleteAsync(track);
 }
 // Write away as string. After refractor this is obsolete, will be done at printing the file
 public void Convert(MidiEvent midiEvent, ref Models.Track track)
 {
 }
Ejemplo n.º 20
0
 public ViewTrackPage(Models.Track myItem)
 {
     InitializeComponent();
     currentTrack = myItem;
     PopulateView();
 }