public SongWindow(SongMeta meta) { _song = SongLoader.Load(meta); InitializeComponent(); Text = $"Score: {meta.Artist} - {meta.Name} [{meta.Instrument}]"; albumArtwork.Image = _song.GetCover(); score1.SetSong(_song); _player = _song.GetSongPlayer(); for (int x = 0; x < _player.Channels; x++) { AddFader(x); } seekBar1.Samples = (long)(_player.Length.TotalSeconds * 44100.0 + 0.5); seekBar1.OnSliderDrop += i => _player.Position = TimeSpan.FromSeconds(i); _timer = new Timer(); _timer.Interval = 30; _timer.Tick += TimerTick; _timer.Start(); waveform1.WaveData = _song.GetWaveform(); waveform1.Sections = _song.Sections; waveform1.Beats = _song.Beats; waveform1.Looper.OnLoop += d => _player.Position = TimeSpan.FromSeconds(d); }
public void Play(ISong Song) { #if DEBUG_VERBOSE if (Debugger.IsAttached) Debug.WriteLine("Play(Song) called from NullAudioService"); #endif }
public string AddSongToSet(string[] args) { try { string songName = args[0]; string setName = args[1]; ISet set = this.stage.GetSet(setName); if (set == null) { throw new InvalidOperationException("ERROR: Invalid set provided"); } ISong song = this.stage.GetSong(songName); if (song == null) { throw new InvalidOperationException("ERROR: Invalid song provided"); } set.AddSong(song); return($"Added {song.ToString()} to {setName}"); } catch (Exception ex) { return(ex.Message); } }
private void DoLyricsProgressReport(ISong song, int stage) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action) delegate { DoLyricsProgressReport(song, stage); }); return; } ITrack track = controller.CurrentTrack; if (track?.GetHashCode() == song.GetHashCode()) { if ((stage >= 0) && (stage <= 5)) { taskPanel.LyricsState = stage.ToString(); } else { taskPanel.LyricsState = string.Empty; } } }
/// <summary> /// Starts creating PDF file and moves it to another folder. /// </summary> /// <param name="song">The song.</param> /// <param name="tempFileName">The file name for temporary files.</param> /// <param name="deleteTempFiles">Whether to delete temporary files or not.</param> /// <returns></returns> public async static Task CreatePdfAsync(ISong song, string tempFileName, bool deleteTempFiles) { string tempDir = String.Format(@"{0}\{1}", PATH_TO_PDF_FILES, TEMP_DIR); string srcDir = String.Format(@"{0}\{1}", PATH_TO_PDF_FILES, SOURCE_DIR); Lilypond lyGenerator = new Lilypond(song, tempDir, tempFileName, deleteTempFiles); string filePath = await lyGenerator.CreateFileAsync(); string songFileName = SongFileName(song); if (!File.Exists(filePath)) // PDF not created so something is wrong... { throw new Exception("Something went wrong!"); } if (deleteTempFiles) { if (File.Exists(String.Format(@"{0}\{1}.ly", tempDir, Hash(songFileName)))) { File.Delete(String.Format(@"{0}\{1}.ly", tempDir, Hash(songFileName))); File.Delete(String.Format(@"{0}\{1}.bat", tempDir, Hash(songFileName))); } } string moveTo = String.Format(@"{0}\{1}\{2}.pdf", srcDir, PDF_ASSETS_DIR, songFileName); if (File.Exists(moveTo)) { File.Delete(moveTo); } File.Move(filePath, moveTo); File.Delete(filePath); }
public JsonSong(ISong song) { this.Title = song?.Track; this.Artist = song?.Artist; this.Album = song?.Album; this.Length = song?.Length ?? -1; }
public void Play(ISong song) { this.Dispatcher.BeginInvoke(new Action(() => { this.Current = song; })); }
/// <summary> /// Initializes new instance of <see cref="Lilypond"/> class. /// </summary> /// <param name="song">The song.</param> /// <param name="path">The path.</param> /// <param name="fileName">The name of file.</param> /// <param name="deleteTempFiles">Whether to delete temporary files or not.</param> public Lilypond(ISong song, string path, string fileName, bool deleteTempFiles) { this.Song = song; this.Path = path; this.FileName = fileName; this.DeleteTempFiles = deleteTempFiles; dynamic code = JsonConvert.DeserializeObject(Song.Code); this.Key = code.Key; this.Time = code.Time; this.Antiphona = code.AntiphonaStanza; if (code.PsalmMeasured != null) { this.PsalmMeasured = code.PsalmMeasured; } else { this.PsalmMeasured = true; } if (code.AntiphonaMeasured != null) { this.AntiphonaMeasured = code.AntiphonaMeasured; } else { this.AntiphonaMeasured = true; } }
public TEditor(ListBox lb, ISong song, GUI owner, ITranslation trans) { // // Erforderlich für die Windows Form-Designerunterstützung // InitializeComponent(); this.AcceptButton = this.button1; this.song = song; this.trans = trans; this.lb = lb; this.owner = owner; this.textBox2.Text = this.song.Number.ToString(); this.textBox2.Enabled = false; tEditor = this; TEditorOpen = true; if (this.trans != null) { this.textBox1.Text = this.trans.Title; this.richTextBox1.Text = this.trans.Text; this.checkBox1.Checked = this.trans.Unformatted; this.panel1.Enabled = !this.trans.Unformatted; } else { this.textBox1.Text = ""; this.richTextBox1.Text = ""; } }
static bool CanExecutePlaySongCommand(object sender) { ISong song = sender as ISong; if (song == null) { return(false); } if (song.Urls == null) { return(false); } if (song.Urls.Count > 0) { return(true); } if (song.Urls.Count == 0) { ManualResetEvent resetEvent = new ManualResetEvent(false); Task.Run(() => { GetSongInfo(song, resetEvent); }); resetEvent.WaitOne(); return(true); } return(false); }
public override void PlaySong(ISong isong) { // MediaPlayer.Stop(); // var song = ((XnaSong)songs[songName]).Song; // MediaPlayer.IsRepeating = true; // MediaPlayer.Play(song); }
//======================================================================================== // Methods //======================================================================================== /// <summary> /// Asynchronously searches for the lyrics of the given song. /// </summary> /// <param name="song">An ISong specifying both the artist and title of the song.</param> public void RetrieveLyrics(ISong song) { // song could be null if we called this method just when switching tracks // yes a very small window but nonetheless.. if (!isConnected || (song == null)) { return; } int hash = song.GetHashCode(); lock (engine) { if (!queue.ContainsKey(hash)) { var worker = new BackgroundWorker(); worker.DoWork += RetrieveLyrics; worker.RunWorkerCompleted += LyricsRetrieved; worker.WorkerSupportsCancellation = true; queue.Add(song.GetHashCode(), worker); worker.RunWorkerAsync(song); } } }
public Song ToSong(ISong song) { Song s = new Song(""); s.Title = song.Title; return(s); }
/// <summary> /// 歌を聴く準備をします。 /// </summary> /// <param name="song">歌</param> public void Standby(ISong song) { Song = song; // 歌が変わったら満足度を戻す IsSatisfied = false; }
public string AddSongToSet(string[] args) { string songName = args[0]; string setName = args[1]; if (!this.stage.Sets.Any(s => s.Name == setName)) { throw new InvalidOperationException(InvalidSetMessage); } if (!this.stage.Songs.Any(s => s.Name == songName)) { throw new InvalidOperationException(InvalidSongMessage); } ISet set = this.stage.Sets.FirstOrDefault(s => s.Name == setName); ISong song = this.stage.Songs.FirstOrDefault(s => s.Name == songName); set.AddSong(song); string result = string.Format(SongAddedSuccessfullyToSet, songName, string.Format(TimeFormat, song.Duration.Minutes, song.Duration.Seconds), setName); return(result); }
/// <summary> /// 歌を設定します。 /// </summary> /// <param name="song">歌オブジェクト</param> public void SetSong(ISong song) { this.Song = song; // 歌が変わったら満足度を戻す this.IsSatisfied = false; }
/// <summary> /// /// </summary> /// <param name="song"></param> /// <param name="stage"></param> private void DoLyricsProgressReport(ISong song, int stage) { if (LyricsProgressReport != null) { LyricsProgressReport(song, stage); } }
public SongDisplayedEventArgs(ISong song, ISong next, ISong previous) { this.song = song; this.next = next; this.previous = previous; this.jumpmarks = new List<JumpMark>(); }
private void InsertSong(ISong song, IPerformer performer) { this.media.Add(song); this.mediaSupplies.Add(song, new SalesInfo()); performer.Songs.Add(song); this.Printer.PrintLine("Song {0} by {1} added successfully", song.Title, performer.Name); }
private void play(ISong song) { this.Reset(); this.player = new SongWavePlayer(new SongWaveContent(this, song)); this.player.Stopped += Player_Stopped; this.player.Play(); }
public bool HasSong(string name) { ISong song = this.songs .Find(s => s.Name == name); return(song != null); }
public uint Play(ISong song, bool loop) { try { this.Stop(); this._currentlyPlayingSound = this._engine.Play2D(song.FileLocation, loop); System.Console.WriteLine("Playing: " + song.FileLocation); if (this._currentlyPlayingSound == null) { throw new ArgumentException("Unable to play song"); } this._playUpdater.Start(); return(this._currentlyPlayingSound.PlayLength); } catch (Exception e) { //TODO: do something with this System.Console.WriteLine(e.ToString()); return(0); } }
private IList <ISet> ParseTracks(JArray tracks) { IList <ISet> sets = new List <ISet>(); ISet set = null; ISong song = null; foreach (var track in tracks) { string setName = track.Value <string>("set_name"); if (!sets.Any(s => s.Name == setName)) { set = new Set(); set.Name = setName; sets.Add(set); } song = new Song(); song.Name = track.Value <string>("title"); song.Position = track.Value <int>("position"); song.Duration = track.Value <int>("duration"); set.Songs.Add(song); } return(sets); }
/// <summary> /// Creates a song player for the given song using the NAudio backend. /// </summary> /// <param name="s">ISong to play.</param> internal JammitNAudioSongPlayer(ISong s) { _waveOut = new WaveOutEvent(); _mixer = new WaveMixerStream32(); _channels = new List <WaveChannel32>(); _chanNames = new List <string>(); foreach (var t in s.Tracks) { if (t.ClassName == "JMFileTrack") { var stream = s.GetSeekableContentStream($"{t.Id}_jcfx"); _channels.Add(new WaveChannel32(new ImaWaveStream(stream))); _chanNames.Add(t.Title); } else if (t.ClassName == "JMClickTrack") { _channels.Add(new WaveChannel32(new ClickTrackStream(s.Beats))); _chanNames.Add(t.Title); } } foreach (var d in _channels) { _mixer.AddInputStream(d); d.Volume = 0.75f; } _waveOut.PlaybackStopped += (sender, args) => { Position = TimeSpan.Zero; }; _waveOut.DesiredLatency = 60; _waveOut.NumberOfBuffers = 2; _waveOut.Init(_mixer); }
///<inheritdoc/> protected override LegacyPlaylistSong CreateFrom(ISong song) { if (song is LegacyPlaylistSong legacySong) { return(legacySong); } return(new LegacyPlaylistSong(song)); }
public async Task <HttpResponseMessage> GetByIdAsync(int songId, [FromUri] string[] options) { ISong s = await Service.GetByIdAsync(songId, options); SongModel result = Mapper.Map <SongModel>(s); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public void AddSong(ISong song) { if (_Repertoire.Songs.Any(x => x.Title == song.Title)) { throw new ArgumentException("Cannot add a duplicate song title", nameof(song)); } _Repertoire.Songs.Add(song); }
public bool TryUpdateDate(ISong song, DateTime newDate) { if (song == null || song.Hash == null || song.Hash.Length == 0) { return(false); } return(TryUpdateDate(song.Hash, newDate)); }
public override void PlaySong(ISong isong) { XnaMediaPlayer.Stop(); var song = ((XnaSong)isong).Song; XnaMediaPlayer.IsRepeating = true; XnaMediaPlayer.Play(song); }
public ISong CreateSong(string name, TimeSpan duration) { Type songType = Assembly.GetCallingAssembly().GetTypes().FirstOrDefault(x => x.Name == "Song"); ISong song = (ISong)Activator.CreateInstance(songType, new object[] { name, duration }); return(song); }
public override void PlaySong(ISong song, double position = 0) { if (this.Player != null) { this.Player.PlayUri(this.listener.operationCallback, song.UniqueId, 0, (int)(position * 1000)); this.playingSong = song; } }
public void AddSong(ISong song) { if (song.Duration + this.ActualDuration > MaxDuration) { throw new InvalidOperationException("Song is over the set limit!"); } this.songs.Add(song); }
private Task<string> Save(ISong currentSong) { var lyricsTask = currentSong.GetLyrics(); lyricsTask.Wait(); return Writer.WriteFile(lyricsTask.Result, currentSong.Name); }
/// <summary> /// If the provided song exists in history, change the flag to the one provided. Returns true if the song was found. /// </summary> /// <param name="song"></param> /// <param name="flag"></param> /// <returns></returns> public bool TryUpdateFlag(ISong song, HistoryFlag flag) { if (song == null) { return(false); } return(TryUpdateFlag(song.Hash, flag)); }
/// <summary> /// Makes a preview of a song. /// </summary> /// <param name="song">The song.</param> /// <returns></returns> public async Task <ISong> PreviewAsync(ISong song) { string songFileName = SongHelper.SongFileName(song); await SongHelper.CreatePdfAsync(song, SongHelper.Hash(songFileName), false); return(song); }
/// <summary> /// Adds an instance of an object with the ISong interface implemented. /// </summary> /// <param name="song">The song to add.</param> /// <param name="play">if set to <c>true</c> then the song will automatically play once added.</param> public void AddSong(ISong song, bool play = false) { song.PlaybackStopped += song_PlaybackStopped; SongList.Add(song); if (play) song.Play(); }
//public GuessWholeShow(ITopic topic) //{ // Topic = topic; // SongList = new WholeShowSongList(); // CreatedDate = DateTime.Now; //} //public GuessWholeShow(ITopic topic, int songTotal) //{ // Topic = topic; // SongList = new WholeShowSongList(songTotal); // CreatedDate = DateTime.Now; //} public bool Contains(ISong song) { if (SongList.ContainsSong(song)) { return true; } return false; }
public void SaveCommit(ISong song, out bool success) { using (IUnitOfWork uow = UnitOfWork.Begin()) { Save(song, out success); if (success) uow.Commit(); } }
public bool SongIsEqual(ISong song) { bool valid = false; if (SongId == song.SongId) valid = true; return valid; }
public bool ContainsSong(ISong song) { foreach (var s in SongList) { if (song.SongIsEqual(s.Key)) { return true; } } return false; }
/// <summary> /// Retrieve the lyrics for the given song /// </summary> /// <param name="song">The song whose lyrics are to be fetched</param> /// <returns>The lyrics or an empty string if the lyrics could not be found</returns> public override string RetrieveLyrics(ISong song) { // clean the title; we don't need quotes string title = Regex.Replace(song.Title, "['\"]", ""); string lyrics = String.Empty; using (WebClient client = new WebClient()) { try { string uri = Uri.EscapeUriString( String.Format(QueryFormat, song.Title, song.Artist)); uri = uri.Replace("%20", "+"); string result = client.DownloadString(uri); if (!String.IsNullOrEmpty(result)) { // @"<div id=""lyrics"">(*?)</div>"; int start = result.IndexOf(StartMarker); if (start > 0) { start += StartMarker.Length; int end = result.IndexOf(EndMarker, start); if (end > start) { lyrics = result .Substring(start, end - start) .Replace(BreakMarker, ""); // clean it up lyrics = Encode(lyrics); } } } failures = 0; } catch (Exception exc) { Logger.WriteLine(base.name, exc); failures++; lyrics = String.Empty; } } return lyrics; }
public ISong ContainsSongReturned(ISong song) { ISong retSong = null; foreach (ISong s in SongList.Keys) { if (s.SongId == song.SongId) { retSong = s; } } return retSong; }
private void InsertSongToAlbum(ISong song, IAlbum album) { if (this.media.FirstOrDefault(a => a is IAlbum && a == album) == null) { throw new ArgumentException("The album does not exist in the database."); } if (this.media.FirstOrDefault(s => s is ISong && s == song) == null) { throw new ArgumentException("The song does not exist in the database."); } album.AddSong(song); this.Printer.PrintLine(string.Format("The song {0} has been added to the album {1}.", song.Title, album.Title)); }
public Editor(ISong song, GUI owner) { open = true; editor = this; this.AcceptButton = this.button1; InitializeComponent(); this.Height = 460; if (song != null) { this.song = song; this.textBox1.Text = song.Title; this.textBox2.Text = song.Number.ToString(); this.richTextBox1.Text = song.Text; this.button12.Enabled = true; if (song.Desc == "") { this.checkBox1.Checked = false; this.textBox3.Text = "---"; this.textBox3.Enabled = false; } else { this.checkBox1.Checked = true; this.textBox3.Text = song.Desc; this.textBox3.Enabled = true; } if (song.BackgroundPicture != "") { this.textBox4.Text = song.BackgroundPicture; this.trackBar1.Value = song.Transparency; this.checkBox2.Checked = song.Scale; } } else { this.textBox1.Text = ""; this.textBox2.Text = ""; this.richTextBox1.Text = ""; this.textBox2.Enabled = true; this.textBox3.Text = "---"; this.checkBox1.Checked = false; this.textBox3.Enabled = false; } this.owner = owner; this.toolbars.ToolClick += ToolbarsClickHandler; ComboBoxTool combo = (ComboBoxTool)this.toolbars.Toolbars[0].Tools["indentCombo"]; this.toolbars.Toolbars[0].Tools["undo"].SharedProps.Enabled = false; combo.SelectedIndex = 0; }
//consider changing the out parameter to a validation type object public void Save(ISong song, out bool success) { Checks.Argument.IsNotNull(song, "song"); success = false; if (null == _repo.FindBySongId(song.SongId)) { try { _repo.Add(song); success = true; } catch (Exception ex) { success = false; } } }
public void PlaySong(ISong song, IPlaylist currentPlaylist) { if(currentPlaylist == null) { return; } if(song == null) { song = currentPlaylist.Songs.First(); } if(Status == PlayStatus.Paused) { _player.Play(); _dispatcherTimer.IsEnabled = true; Status = PlayStatus.Playing; } else if(Status == PlayStatus.Stopped) { PlayASong(song, currentPlaylist); CurrentPlaylist = currentPlaylist; } else if (CurrentPlaylist != currentPlaylist) { PlayASong(song, currentPlaylist); CurrentPlaylist = currentPlaylist; } }
protected virtual string GetSongReport(ISong song) { var songSalesInfo = this.mediaSupplies[song]; StringBuilder songInfo = new StringBuilder(); songInfo.AppendFormat("{0} ({1}) by {2}", song.Title, song.Year, song.Performer.Name).AppendLine() .AppendFormat("Genre: {0}, Price: ${1:F2}", song.Genre, song.Price).AppendLine() .AppendFormat("Supplies: {0}, Sold: {1}", songSalesInfo.Supplies, songSalesInfo.QuantitySold); return songInfo.ToString(); }
public void RefreshSong(ISong song) { if (this._song != null) this._song.uncheck(); RefreshSong(song, null); }
public void AddSong(ISong song) { this.Add(this.Count, song); this.myNode.ChildNodes[3].InnerText = this.updateList(); }
public static void ShowSong(ISong song, GUI owner, ListBox navigate) { ShowSong(song, null, owner, navigate); _this._menuItem1.Visible = true; }
public void RefreshSong(ISong song, ITranslation trans) { this._song = song; this._trans = trans; RefreshSong(); }
public static void ShowSong(ISong song, ITranslation trans, GUI owner, ListBox navigate) { if (_this == null) { _this = new View(); _this._richTextBox1.ScrollDataChanged += OnRichTextBox1OnScrollDataChanged; } _this._song = song; _this._menuItem1.Visible = false; _this._owner = owner; _this.navigate = navigate; _this._menuItem6.Checked = Util.SHOWRIGHT; if (trans != null) { _this.RefreshSong(song, trans); } else { _this.RefreshSong(song); } _this._richTextBox1.Focus(); _this.pos = navigate.Items.IndexOf(_this._song); _this.Show(); }
private async Task<string> Save(ISong currentSong) { return await Writer.WriteFile(await currentSong.GetLyrics(), currentSong.Name); }
public void AddSongToCurrent(ISong song) { this.currentList.AddSong(song); this.update(); }
private void PlayASong(ISong song, IPlaylist currentPlaylist) { _currentSong = song; _player.Open(new Uri(song.Path)); SongTitle = song.Title; _player.Play(); _dispatcherTimer.IsEnabled = true; Status = PlayStatus.Playing; }
private static void addSongToHistory(ISong song) { if (_songHistory.Contains(song)) { _songHistory.Remove(song); } _songHistory.Add(song); if (HistoryChanged != null) { HistoryChanged(null, EventArgs.Empty); } }
public void AddSong(ISong song) { this.Songs.Add(song); }
public TEditor(ListBox lb, ISong song, GUI owner) : this(lb, song, owner, null) { }