private void EndOfSongEvent(SongData songData) { if (!songData.bossBattle) { //id++: it's the previous song id actualIndex = CastSongIndex(songData.id + 1); FadeInNextSong(); } }
void OnGUI() { if (NewCoin != null) { coin.GetComponent<Text>().text = NewCoin(); } if (NewFans != null) { fan.GetComponent<Text>().text = NewFans(); } if( NewConcert != null) { concert.GetComponent<Text>().text = NewConcert(); } if (newSongData != null) { actualSongData = newSongData(); if (actualSongData != null) { song.GetComponent<Text>().text = actualSongData.title; } } if (TapPassed != null) { GUI.color = Color.yellow; GUI.Box( new Rect( Screen.width / 4-25f, startingVerticalPos, (TapPassed()/actualSongData.tapGoal)*(Screen.width/2)+50f, heightOfBar), "Tap"); } if (TimePassed != null) { GUI.color = Color.red; GUI.Box( new Rect( Screen.width / 4-25f, startingVerticalPos + heightOfBar + 5f, (TimePassed() * 5 /actualSongData.tapGoal)*(Screen.width/2)+50f, heightOfBar), "Time"); } }
private void IncomingTapStrength(float tapStrength) { if (currentSong != null) { actualTapAmount += tapStrength; if (currentSong.tapGoal < actualTapAmount) { if(GiveEndOfSong != null) { GiveEndOfSong(currentSong); } if(GiveRewardOfSong != null) { GiveRewardOfSong(currentSong.coinReward); } ResetControllerState(); currentSong = GiveNextSong(); } } }
public static Color ColorForBeatType(SongData.BeatType beatType) { Color retColor; switch (beatType) { case SongData.BeatType.SyncoBeat: retColor = Color.blue; break; case SongData.BeatType.OnBeat: retColor = Color.green; break; case SongData.BeatType.OffBeat: retColor = Color.red; break; case SongData.BeatType.None: default: retColor = Color.gray; break; } return retColor; }
/// <summary> /// Initializes a new instance of the <see cref="SongInstance" /> class. /// </summary> /// <param name="item">The item.</param> /// <param name="songData">The song data.</param> public SongInstance(SongItem item, SongData songData) { DiskItem = item; SongData = songData; }
//TODO something wrong with layout comparison, using layout index somewhere, and layout totalLanes in other void songLoaded(AudioClip clip) { Debug.Log("************* SONGLOADER.SONGLOADED " + clip.name + " " + clip.length); Debug.Log("Errors? " + importer.error); reset(); state = State.LOADED; songData.setClip(clip); if (clip.loadState == AudioDataLoadState.Unloaded) { Debug.Log("Clip not loaded, loading now"); clip.LoadAudioData(); } //string patternFilePath = getPatternPath(); //bool exists = File.Exists(patternFilePath); //TODO are we loading custom patterns correctly? Dictionary <string, string> patternFilePaths = new Dictionary <string, string>(); SongData.findPatterns(patternFilePaths, clip.name); //SongData.PatternType validTypesForLoading = SongData.PatternType.AUTO; //if (patternType == SongData.PatternType.CUSTOM) // patternType = SongData.PatternType.CUSTOM; string suffix = SongData.getPatternSuffix(patternLanes, patternType); //Debug.Log("Patterns found:"); //foreach (string s in patternFilePaths.Keys) // Debug.Log(s + "->" + patternFilePaths[s]); bool patternExists = patternFilePaths.ContainsKey(suffix); if (!patternExists) { Debug.Log("No existing pattern (" + suffix + "), will create"); } if (!Settings.instance.patternOverwriteAuto && patternExists) { //Debug.Log("Auto pattern files already exists, no need to create"); loadPattern(patternFilePaths[suffix]); //string[] fileContent = File.ReadAllLines(patternFilePaths[suffix]); ////List<SongRow> rows = new List<SongRow>(); //foreach (string rowStr in fileContent) //{ // SongRow row = SongRow.parse(rowStr); // if (row != null) // { // if (row.type == SongRow.Type.BEAT) // { // rowsBeat.Add(row); // } // else // { // if (row.type == SongRow.Type.BPM) // rowsBpm.Add(row); // else // if (row.type == SongRow.Type.BOX) // rowsBox.Add(row); // else // if (row.type == SongRow.Type.LANE_POS) // rowsLanePositions.Add(row); // } // } //} isLoading = false; Debug.Log("SongLoader loaded pattern " + rowsBeat.Count + " beats, " + rowsBox.Count + " boxes, " + rowsBpm.Count + " bpms, " + rowsLanePositions.Count + " lanePositions"); Dictionary <SongRow.Type, List <SongRow> > rows = new Dictionary <SongRow.Type, List <SongRow> >(); rows.Add(SongRow.Type.BPM, rowsBpm); rows.Add(SongRow.Type.BOX, rowsBox); rows.Add(SongRow.Type.BEAT, rowsBeat); rows.Add(SongRow.Type.LANE_POS, rowsLanePositions); songData.rows = rows; songReady(songData); //lane pos format: first three for 4,6,8 lanes, then 4,6,8,timestamp if it changes during song } else { //TODO rhythmAnalyzer.Abort if stopping before finished... but that should never happen Debug.Log("************* SONGLOADER.ANALYZE " + clip.name); //rhythmAnalyzer.Analyze(audioSource.clip, (int)(audioSource.clip.length - 1)); //clip.loadState == AudioDataLoadState.Loaded rhythmData = rhythmAnalyzer.Analyze(clip, (int)processedData); } }
public void setState(GameState newState) { sfxAudio.Stop(); mainAudio.Stop(); StopCoroutine("playTitleAnimation"); StopCoroutine("setUpKoreoStats"); switch (newState) { case GameState.Title: turnStuffOnOff(titleObjects, true); turnStuffOnOff(menuObjects, false); turnStuffOnOff(playingObjects, false); turnStuffOnOff(resultsObjects, false); StartCoroutine("playTitleAnimation"); StateUpdate = titleUpdate; break; case GameState.Menu: turnStuffOnOff(titleObjects, false); turnStuffOnOff(menuObjects, true); turnStuffOnOff(playingObjects, false); turnStuffOnOff(resultsObjects, false); if (firstLoadOfCarousel) { firstLoadOfCarousel = false; } else { myCarousel.playPreviewMusic(); } StateUpdate = menuUpdate; break; case GameState.Playing: sm.reset(); turnStuffOnOff(titleObjects, false); turnStuffOnOff(playingObjects, true); currentSong = myCarousel.getCurrentSelection(); myKoreor.GetComponent <SimpleMusicPlayer>().LoadSong(currentSong.koreography, 0, false); turnStuffOnOff(menuObjects, false); turnStuffOnOff(resultsObjects, false); StartCoroutine("setUpKoreoStats"); if (moviePlane != null) { moviePlane.GetComponent <Renderer>().enabled = false; } myKoreor.gameObject.GetComponent <AudioSource>().Play(); GetComponent <AudioSource>().clip = myKoreor.gameObject.GetComponent <AudioSource>().clip; StateUpdate = playingUpdate; break; case GameState.Result: om.clearAllObstacles(); setUpResultsText(); turnStuffOnOff(titleObjects, false); turnStuffOnOff(menuObjects, false); turnStuffOnOff(playingObjects, false); turnStuffOnOff(resultsObjects, true); mainAudio.clip = Resources.Load("Audio/results") as AudioClip; mainAudio.Play(); StateUpdate = resultUpdate; break; default: throw new System.ArgumentOutOfRangeException(); } currentState = newState; }
private void BufferStream(SongData songData) { var stream = songData.Stream.Value.Item1; var bufferDuration = songData.Stream.Value.Item3; var buffer = new byte[16384 * 4]; var waitTime = 0; var wait = new AutoResetEvent(false); using (var throttledStream = new ThrottledStream(stream)) using (var readFullyStream = new ReadFullyStream(throttledStream)) { IMp3FrameDecompressor decompressor = null; _bufferingComplete = false; do { if (songData.Cts.Token.IsCancellationRequested) { songData.Cts.Token.ThrowIfCancellationRequested(); } wait.WaitOne(waitTime); try { var frame = Mp3Frame.LoadFromStream(readFullyStream); var progress = (int)(readFullyStream.Position / (double)songData.Stream.Value.Item2 * 100); if (progress % 5 == 0) { OnBuffering(new ValueProgressEventArgs<int>(progress, 100)); } if (frame == null) { Trace.WriteLine("Mp3Frame is null"); break; } if (decompressor == null) { var waveFormat = new Mp3WaveFormat( 44100, frame.ChannelMode == ChannelMode.Mono ? 1 : 2, frame.FrameLength, frame.BitRate); double bufferTimeInSeconds = bufferDuration.TotalSeconds; if (bufferTimeInSeconds.LessThan(60)) { bufferTimeInSeconds = TimeSpan.FromMinutes(2).TotalSeconds; } decompressor = new AcmMp3FrameDecompressor(waveFormat); songData.WaveProvider = new BufferedWaveProvider(decompressor.OutputFormat) { BufferDuration = TimeSpan.FromSeconds(bufferTimeInSeconds), DiscardOnBufferOverflow = true }; // Adjust the maximum bytes to stream per second // This is done to avoid being blacklisted by Grooveshark for several hours throttledStream.MaximumBytesPerSecond = songData.WaveProvider.WaveFormat.AverageBytesPerSecond / 4; } if (songData.WaveProvider != null) { try { int decompressed = decompressor.DecompressFrame(frame, buffer, 0); songData.WaveProvider.AddSamples(buffer, 0, decompressed); if (songData.WaveProvider.BufferLength - songData.WaveProvider.BufferedBytes < songData.WaveProvider.WaveFormat.AverageBytesPerSecond / 4) { Trace.WriteLine("Buffer full. Waiting 500 ms"); waitTime = 500; } } catch (InvalidOperationException e) { Trace.WriteLine(e.Message + ". Wait time is 500ms"); waitTime = 500; } } } catch (Exception e) { Trace.WriteLine(e); break; } } while (_playerState != PlayerState.Stopped); if (decompressor != null) { decompressor.Dispose(); } } _bufferingComplete = true; Trace.WriteLine("Buffer-thread exiting"); }
private void RelativeOctave(SongData Song, TrackData Track, Command Command, MmlFileReader m) { Track.AddCommand(Command.Name == ">" ? CommandType.OctaveGt : CommandType.OctaveLt); }
public void Set(SongData data) { Card.SetSong(data); CostText.text = data.Cost.ToString(); }
private void Effect(SongData Song, TrackData Track, Command Command, MmlFileReader m) { ReadName(Track, m, CommandType.Effect); }
/// <summary> /// Post Process after command execution /// </summary> /// <returns></returns> public virtual bool PostProcess(SongData song) { return(false); }
private void Tempo(SongData Song, TrackData Track, Command Command, MmlFileReader m) { ReadValue(Track, m, CommandType.Tempo); }
private void Length(SongData Song, TrackData Track, Command Command, MmlFileReader m) { var Tick = ReadNoteLength(Track.DefaultTick, Song.MasterTick, m); Track.DefaultTick = Tick; }
private void Staccato(SongData Song, TrackData Track, Command Command, MmlFileReader m) { var cmd = Track.AddCommand(CommandType.Staccato); cmd.Value = ReadNumber(m); }
private void Slur(SongData Song, TrackData Track, Command Command, MmlFileReader m) { var cmd = Track.AddCommand(CommandType.Slur); cmd.Value = 1; }
private void Octave(SongData Song, TrackData Track, Command Command, MmlFileReader m) { ReadValue(Track, m, CommandType.Octave); }
protected bool insertFlg(string WID, string EDA, string typeId) { if ("".Equals(WID) || WID == null) { return false; } if ("".Equals(EDA) || EDA == null) { return false; } SongMediaData songMediaData = new SongMediaData(); ISearchTransaction tran = factory.GetSearchObject(songMediaData); tran.Where = songMediaData.ColSongMediaId + "='" + WID + EDA + "' and " + songMediaData.ColDelFlag + "='0'"; Execute(tran); if (!HasError) { if (tran.Count != 1) { SongData songData = new SongData(); ISearchTransaction tranExist = factory.GetSearchObject(songData); tranExist.Where = songData.ColSongId + "='" + WID + "' and " + songData.ColDelFlag + "='0'"; Execute(tranExist); if (!HasError) { if (tranExist.Count == 1) { return true; } } } } return false; }
private void Macro(SongData Song, TrackData Track, Command Command, MmlFileReader m) { ReadName(Track, m, CommandType.Macro); }
public static void Record(SongData songData) { uint lengthInSeconds = (uint)songData.duration; uint BPM = (uint)songData.BPM; Song song = new Song(songData.filePath, (uint)songData.BPM); double BPS = (double)BPM / 60; double beatTime = BPS / 4 / 4; int noteTime = (int)(15000 / BPM); char[] notes = new string('N', (int)(lengthInSeconds * 1000 / noteTime)).ToCharArray(); Stopwatch timer = new Stopwatch(); Stopwatch beatTimer = new Stopwatch(); bool activeBeat = true; song.Start(); timer.Start(); beatTimer.Start(); while (timer.Elapsed.TotalSeconds < songData.duration) { if (beatTimer.Elapsed.TotalSeconds >= songData.noteTimeSeconds) { activeBeat = true; beatTimer.Restart(); int currentBeat = (int)(timer.Elapsed.TotalSeconds / songData.noteTimeSeconds); if (currentBeat > 2) { Console.Write(notes[currentBeat - 2]); } } if (activeBeat && Console.KeyAvailable) { int currentNote = (int)(timer.Elapsed.TotalSeconds / songData.noteTimeSeconds); switch (Console.ReadKey().Key) { case ConsoleKey.UpArrow: notes[currentNote] = 'u'; activeBeat = false; break; case ConsoleKey.DownArrow: notes[currentNote] = 'd'; activeBeat = false; break; case ConsoleKey.LeftArrow: notes[currentNote] = 'l'; activeBeat = false; break; case ConsoleKey.RightArrow: notes[currentNote] = 'r'; activeBeat = false; break; } } } Console.WriteLine("\n\n"); foreach (char c in notes) { Console.Write(c); } System.IO.File.WriteAllText("Recording.mus", new string(notes)); Console.ReadLine(); return; }
private void ResetControllerState() { actualTapAmount = 0f; bossBattleCountDown = 0f; currentSong = null; }
void Start() { Debug.Log("star"); if (Line == 3) { this.songDataAsset = songData.Line3SongDataAsset; } else if (Line == 6) { this.songDataAsset = songData.Line6SongDataAsset; } audioManager.bgm.clip = songData.audio; Life = 1000; //note音量設定 loadVolume("audioNote"); audioManager.note.volume = volume; Life = 2500; //note音設定 loadNoteAudio("notePlay"); audioManager.note.clip = noteAudio; Debug.Log("bgm" + audioManager.bgm.volume); Debug.Log("note" + audioManager.note.volume); songName = audioManager.bgm.clip.name; //bgm音量設定 string name = songName; /*for (int i = 1; i <= songList.Length; i++) * { * if (string.Compare(songList[i], songName) == 0) * { * listNumber = i; * name = "song" + listNumber.ToString("D3"); * Debug.Log("name: " + name); * break; * } * } */ string txtName; txtName = name + " Audio"; Debug.Log("txtName " + txtName); loadVolume(txtName); audioManager.bgm.volume = volume; pauseEnabled = false; Time.timeScale = 1; // フレームレート設定 Application.targetFrameRate = 60; Score = 0; Life = 3000; maxLife = 30; Combo = 0; retryButton.onClick.AddListener(OnRetryButtonClick); stopButton.onClick.AddListener(Stop); // ボタンのリスナー設定と最終タップ時間の初期化 for (var i = 0; i < noteButtons.Length; i++) { noteButtons[i].onClick.AddListener(GetOnNoteButtonClickAction(i)); lastTappedMilliseconds.Add(noteButtons[i], 0); } Debug.Log("Hits.Length" + Hits.Length); for (int i = 0; i < Hits.Length; i++) { Debug.Log("set" + i); Hits[i].onClick.AddListener(GetOnNoteButtonClickAction(i)); lastTappedMilliseconds.Add(Hits[i], 0); } // ノートオブジェクトのプール for (var i = 0; i < 100; i++) { var obj = Instantiate(noteObjectPrefab, noteObjectContainer); obj.baseY = baseLine.localPosition.y; obj.gameObject.SetActive(false); noteObjectPool.Add(obj); } noteObjectPrefab.gameObject.SetActive(false); // メッセージオブジェクトのプール for (var i = 0; i < 50; i++) { var obj = Instantiate(messageObjectPrefab, messageObjectContainer); obj.baseY = baseLine.localPosition.y; obj.gameObject.SetActive(false); messageObjectPool.Add(obj); } messageObjectPrefab.gameObject.SetActive(false); // 楽曲データのロード song = SongData.LoadFromJson(songDataAsset.text); Regex re = new Regex("time"); mc = re.Matches(songDataAsset.text); noteQuantity = mc.Count; setMaxScore(); // Debug.Log("noteQuantity" + noteQuantity); audioManager.bgm.PlayDelayed(1f); //audioManager.bgm.time = 30; }
void Update() { float deltaTime = Time.deltaTime; if (currentSong == null) { if (GiveNextSong != null) { currentSong = GiveNextSong(); } } if (currentSong.bossBattle) { bossBattleCountDown += deltaTime; if (bossBattleCountDown > currentSong.duration) { ResetControllerState(); currentSong = GiveFirstSongOfActualConcert(); } } }
public override void Init(SongData songData, AController cont, TimeSpan totalTime, TimeSpan elapsed, bool doubletime) { base.Init(songData, cont, totalTime, elapsed, doubletime); }
private void RepeatStart(SongData Song, TrackData Track, Command Command, MmlFileReader m) { Track.AddCommand(CommandType.RepeatStart); }
private List <string> AllPlayersInLobby(List <string> rules, List <string> RulesMet, SongData song) { foreach (string rule in rules) { List <string> list = rule.Split(" ").ToList(); int correct = 0; foreach (Player player in song.players) { //Check if the player's name is part of the rule if (list.Exists(p => p.Equals(player.name))) { correct = correct + 1; } } //If all of the players were in the lobby then the rule has been met if (correct >= list.Count()) { RulesMet.Add(rule); } } return(RulesMet); }
private async static Task <SongData> CreateSongFromFile(StorageFile file) { SongData song = new SongData(); song.DateAdded = DateTime.Now; song.Filename = file.Name; song.Path = file.Path; song.PlayCount = 0; song.LastPlayed = DateTime.MinValue; song.IsAvailable = 1; song.Tag.Rating = 0; song.FileSize = 0; try { using (Stream fileStream = await file.OpenStreamForReadAsync()) { try { var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name, fileStream, fileStream)); try { song.Bitrate = (uint)tagFile.Properties.AudioBitrate; song.Duration = TimeSpan.FromSeconds(Convert.ToInt32(tagFile.Properties.Duration.TotalSeconds)); } catch (Exception ex) { song.Duration = TimeSpan.Zero; song.Bitrate = 0; } try { //TagLib.Id3v2.Tag.DefaultVersion = 3; //TagLib.Id3v2.Tag.ForceDefaultVersion = true; Tag tags; if (tagFile.TagTypes.ToString().Contains(TagTypes.Id3v2.ToString())) { tags = tagFile.GetTag(TagTypes.Id3v2); TagLib.Id3v2.PopularimeterFrame pop = TagLib.Id3v2.PopularimeterFrame.Get((TagLib.Id3v2.Tag)tags, "Windows Media Player 9 Series", false); if (pop != null) { if (224 <= pop.Rating && pop.Rating <= 255) { song.Tag.Rating = 5; } else if (160 <= pop.Rating && pop.Rating <= 223) { song.Tag.Rating = 4; } else if (96 <= pop.Rating && pop.Rating <= 159) { song.Tag.Rating = 3; } else if (32 <= pop.Rating && pop.Rating <= 95) { song.Tag.Rating = 2; } else if (1 <= pop.Rating && pop.Rating <= 31) { song.Tag.Rating = 1; } } } else if (tagFile.TagTypes.ToString().Contains(TagTypes.Id3v1.ToString())) { tags = tagFile.GetTag(TagTypes.Id3v1); } else if (tagFile.TagTypes.ToString().Contains(TagTypes.Apple.ToString())) { tags = tagFile.GetTag(TagTypes.Apple); } else { tags = tagFile.GetTag(tagFile.TagTypes); } song.Tag.Album = tags.Album ?? ""; song.Tag.AlbumArtist = tags.FirstAlbumArtist ?? ""; song.Tag.Artists = tags.JoinedPerformers ?? ""; song.Tag.Comment = tags.Comment ?? ""; song.Tag.Composers = tags.JoinedComposers ?? ""; song.Tag.Conductor = tags.Conductor ?? ""; song.Tag.Disc = (int)tags.Disc; song.Tag.DiscCount = (int)tags.DiscCount; song.Tag.FirstArtist = tags.FirstPerformer ?? ""; song.Tag.FirstComposer = tags.FirstComposer ?? ""; song.Tag.Genre = tags.FirstGenre ?? ""; song.Tag.Lyrics = tags.Lyrics ?? ""; song.Tag.Title = tags.Title ?? file.DisplayName; song.Tag.Track = (int)tags.Track; song.Tag.TrackCount = (int)tags.TrackCount; song.Tag.Year = (int)tags.Year; } catch (CorruptFileException e) { song.Tag.Album = ""; song.Tag.AlbumArtist = ""; song.Tag.Artists = ""; song.Tag.Comment = ""; song.Tag.Composers = ""; song.Tag.Conductor = ""; song.Tag.Disc = 0; song.Tag.DiscCount = 0; song.Tag.FirstArtist = ""; song.Tag.FirstComposer = ""; song.Tag.Genre = ""; song.Tag.Lyrics = ""; song.Tag.Title = file.DisplayName; song.Tag.Track = 0; song.Tag.TrackCount = 0; song.Tag.Year = 0; } } catch (Exception ex) { song.Tag.Album = ""; song.Tag.AlbumArtist = ""; song.Tag.Artists = ""; song.Tag.Comment = ""; song.Tag.Composers = ""; song.Tag.Conductor = ""; song.Tag.Disc = 0; song.Tag.DiscCount = 0; song.Tag.FirstArtist = ""; song.Tag.FirstComposer = ""; song.Tag.Genre = ""; song.Tag.Lyrics = ""; song.Tag.Title = file.DisplayName; song.Tag.Track = 0; song.Tag.TrackCount = 0; song.Tag.Year = 0; } } } catch (FileNotFoundException ex) { Logger.Save("CreateSongFromFile FileNotFound" + Environment.NewLine + ex.Message); Logger.SaveToFile(); song.FileSize = 0; song.IsAvailable = 0; song.Duration = TimeSpan.Zero; song.Bitrate = 0; song.Tag.Album = ""; song.Tag.AlbumArtist = ""; song.Tag.Artists = ""; song.Tag.Comment = ""; song.Tag.Composers = ""; song.Tag.Conductor = ""; song.Tag.Disc = 0; song.Tag.DiscCount = 0; song.Tag.FirstArtist = ""; song.Tag.FirstComposer = ""; song.Tag.Genre = ""; song.Tag.Lyrics = ""; song.Tag.Title = file.DisplayName; song.Tag.Track = 0; song.Tag.TrackCount = 0; song.Tag.Year = 0; return(song); } catch (Exception ex) { Logger.Save("CreateSongFromFile" + Environment.NewLine + ex.Message); Logger.SaveToFile(); song.FileSize = 0; } return(song); }
public void Start(Song song) { int songId; int artistId; if (!int.TryParse(song.Id, out songId)) { throw new InvalidOperationException("Unable to parse song id"); } if (!int.TryParse(song.Artist.Id, out artistId)) { throw new InvalidOperationException("Unable to parse artist id"); } Song oldSong = null; lock (_lockObject) { if (_currentSong != null) { oldSong = _currentSong.Song; if (!_currentSong.Cts.IsCancellationRequested) { _currentSong.Cts.Cancel(); } Task.WaitAll(new[] { _currentSong.BufferTask, _currentSong.PlayTask }, TimeSpan.FromSeconds(5)); } _currentSong = new SongData { Song = song, Stream = new Lazy<Tuple<Stream, int, TimeSpan>>(() => { if (song.TotalSeconds == 0) { var streamKey = _groove.Value.GetStreamKey(songId); double durationInMicroseconds; if (double.TryParse(streamKey.uSecs, out durationInMicroseconds)) { song.TotalSeconds = (int)(durationInMicroseconds / 1000000); } } var bufferPeriod = TimeSpan.FromSeconds(song.TotalSeconds); var stream = _groove.Value.GetMusicStream(songId, artistId); return Tuple.Create(stream.Stream, stream.Length, bufferPeriod); }) }; } OnCurrentSongChanged(new ValueChangedEventArgs<Song>(oldSong, _currentSong.Song)); _currentSong.BufferTask = Task.Factory .StartNew( d => BufferStream(((SongData)d)), _currentSong, _currentSong.Cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default) .ContinueWith(task => { Trace.WriteLineIf(task.IsFaulted, task.Exception); Trace.WriteLineIf(task.IsCanceled, "Buffer-thread was cancelled"); Trace.WriteLineIf(task.IsCompleted, "Buffer-thread completed"); _bufferingComplete = true; }); _currentSong.PlayTask = Task.Factory .StartNew( d => PlayBuffer(((SongData)d)), _currentSong, _currentSong.Cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default) .ContinueWith(task => { Trace.WriteLineIf(task.IsFaulted, task.Exception); Trace.WriteLineIf(task.IsCanceled, "Player-thread was cancelled"); Trace.WriteLineIf(task.IsCompleted, "Player-thread completed"); if (task.IsCanceled) { if (_currentSong.WaveOut != null) { _currentSong.WaveOut.Stop(); _currentSong.WaveOut.Dispose(); } if (_currentSong.WaveProvider != null) { _currentSong.WaveProvider.ClearBuffer(); } } _currentSong = null; _playerState = PlayerState.Stopped; _isPlaying = false; OnIsPlayingChanged(new ValueChangedEventArgs<bool>(false, true)); if (task.IsCompleted && !task.IsCanceled) { OnCurrentSongCompleted(new SongEventArgs(((SongData) task.AsyncState).Song)); } }); }
public async static Task ImportAndUpdateDatabase(IProgress <int> progress) { ApplicationSettingsHelper.SaveSettingsValue(AppConstants.MediaScan, true); IReadOnlyList <StorageFile> list = await KnownFolders.MusicLibrary.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName); int all = list.Count; int count = 1; Tuple <int, int> tuple; Dictionary <string, Tuple <int, int> > dict = DatabaseManager.GetFilePaths(); int w1; int w2; List <int> toAvailable = new List <int>();//lista songId List <SongData> newSongs = new List <SongData>(); foreach (var file in list) { string type = file.FileType.ToLower(); if (type == ".mp3" || type == ".m4a" || type == ".wma" || type == ".wav" || type == ".aac" || type == ".asf" || type == ".adt" || type == ".adts" || type == ".amr") { //Windows.Storage.FileProperties.BasicProperties bp = await file.GetBasicPropertiesAsync(); // Sprawdzanie rozmiaru nie działa if (dict.TryGetValue(file.Path, out tuple)) { if (tuple.Item1 == 0)//zaznaczony jako niedostepny { toAvailable.Add(tuple.Item2); } else//zaznaczony jako dostepny { toAvailable.Add(tuple.Item2); } } else { SongData song = await CreateSongFromFile(file); newSongs.Add(song); } } w1 = (100 * count / all); w2 = (100 * (count - 1) / all); if (progress != null && w1 != w2) { progress.Report(w1); } count++; } progress.Report(99); DatabaseManager.ChangeAvailability(toAvailable); Library.Current.CheckNPAfterUpdate(toAvailable); await DatabaseManager.InsertSongsAsync(newSongs); ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.MediaScan); OnMediaImported("Update"); SendToast(); }
private void PlayBuffer(SongData songData) { _playerState = PlayerState.Buffering; CancellationToken token = songData.Cts.Token; int currentTime = 0; while (_playerState != PlayerState.Stopped) { if (token.IsCancellationRequested) { songData.Cts.Token.ThrowIfCancellationRequested(); } if (songData.WaveOut == null && songData.WaveProvider != null) { try { Trace.WriteLine("Initializing wave out"); songData.VolumeProvider = new VolumeWaveProvider16(songData.WaveProvider) { Volume = Volume }; songData.WaveOut = new WaveOutEvent(); songData.WaveOut.Init(songData.VolumeProvider); } catch (Exception ex) { Trace.WriteLine(ex); } } else if (songData.WaveProvider != null && songData.WaveOut!= null) { var bufferedSeconds = songData.WaveProvider.BufferedDuration.TotalSeconds; // make it stutter less if we buffer up a decent amount before playing if (bufferedSeconds < 0.5 && _playerState == PlayerState.Playing && !_bufferingComplete) { Trace.WriteLine("Buffer are less than limit. Starting buffering"); Pause(); _playerState = PlayerState.Buffering; } else if (bufferedSeconds > 4 && _playerState == PlayerState.Buffering) { Trace.WriteLine("Buffer are more than limit. Starting playback"); Play(); } else if (bufferedSeconds.AreCloseTo(0) && _bufferingComplete) { break; } } if (_playerState == PlayerState.Playing) { currentTime += 250; if (currentTime % 1000 == 0) { OnProgress(new ValueProgressEventArgs<int>(currentTime / 1000, (int)songData.Stream.Value.Item3.TotalSeconds)); } } Thread.Sleep(250); } if (songData.WaveOut != null) { songData.WaveOut.Stop(); songData.WaveOut.Dispose(); } if (songData.WaveProvider != null) { songData.WaveProvider.ClearBuffer(); } _playerState = PlayerState.Stopped; Trace.WriteLine("Player-thread exiting"); }
public void UpdateData(SongData sd, byte[] bytes) { StopAllCoroutines(); StartCoroutine(DoUpdateData(sd, bytes)); }
private void UpdateUI(SongData songData) { songNameText.text = songData.SongName; artistNameText.text = songData.ArtistName; }
public SongDataObject(SongData data) { this.data = data; }
string getPatternPath() {//TODO take into account difficulty level and AUTO/SLOTABC //TODO auto files should not be used for default setting? (ie. always process and play from memory) //return Path.Combine(Path.Combine(AssetManager.instance.getBaseFolder(), "patterns"), clip.name + "_" + pattern + ".ptn"); return(Path.Combine(Path.Combine(AssetManager.instance.getBaseFolder(), "patterns"), SongData.getPatternFileName(songData.getClipName(), patternLanes, patternType))); }
public void SetSongPlayer(SongData songData) { m_SongPlayer.SetSong(songData); m_SongPlayer.Play(); }
public Boolean sendRequest(SongData nowPlaying, string template, string[] networks, int userId, string password) { string filename = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Plugin_SongPoster.log"; // Parse variable message template and fill in data from nowPlaying string sendTextVars = Variables.Update(template, nowPlaying, false); Boolean success = true; // For each selected network, build custom URL and start a "send" task foreach (string network in networks) { string sendText = "http://songposter.net/send-post/" + network.ToLower() + "/0/" + userId.ToString() + "/" + Uri.EscapeDataString(password) + "/" + Uri.EscapeDataString(sendTextVars); try { WebClient client = new WebClient(); client.Headers.Add("user-agent", "SongPoster/0.6 (RadioDJ)"); client.DownloadStringCompleted += (sender, e) => { if (!e.Cancelled && e.Error == null) { using (StreamWriter outputFile = new StreamWriter(filename, true)) { outputFile.WriteLine(sendText); outputFile.WriteLine(e.Result); } } else { HttpWebResponse response = (HttpWebResponse)((WebException)e.Error).Response; int statusCode = (int)response.StatusCode; string responseText; using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { responseText = reader.ReadToEnd(); } // Only show the messagebox if the success variable was previously set if (success) { success = false; MessageBox.Show(responseText, "SongPoster Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } using (StreamWriter outputFile = new StreamWriter(filename, true)) { outputFile.WriteLine(sendText); outputFile.WriteLine("[" + DateTime.Now.ToString("u") + "] ERROR: " + responseText); } } }; client.DownloadStringAsync(new Uri(sendText)); // @ToDo save the response to a log file or some internal RadioDJ log (investigate Utils.LogMe method) } catch (Exception e) { // @ToDo do some proper error handling Console.WriteLine(e.Message); success = false; } } return success; }
/// <summary> /// Execute the Command /// </summary> /// <param name="song"></param> /// <returns></returns> public virtual async Task <(bool Changed, SongData song)> Execute(SongData song) { return(false, song); }
public override void Init(SongData songData, AController cont, TimeSpan totalTime, TimeSpan elapsed, bool doubletime) { base.Init(songData, cont, totalTime, elapsed, doubletime); m_song = songData; float msPBeat = -1; float multiplier = -1; if (m_song.Times.Count > 0) { if (msPBeat == -1 || multiplier == -1) { for (int i = m_song.Times.Count - 1; i >= 0; i--) { if (totalTime.TotalMilliseconds >= m_song.Times[i].Time) { if (m_song.Times[i].Multiplier != -1 && multiplier == -1) { multiplier = m_song.Times[i].Multiplier; } if (m_song.Times[i].MSPerBeat != -1 && msPBeat == -1) { msPBeat = m_song.Times[i].MSPerBeat; } } } } } m_millisecondsToComplete = ((float)(((float)m_sliderData.DataDistance / 100) * ((float)msPBeat / 1000)) / m_song.SliderMultiplier); m_millisecondsToComplete *= 1000; if (multiplier > 0) { m_millisecondsToComplete /= multiplier; } /* if (m_song.Times.Count > 0) { for (int i = m_song.Times.Count - 1; i >= 0; i--) { if (totalTime.TotalMilliseconds >= m_song.Times[i].Time) { m_millisecondsToComplete /= m_song.Times[i].Multiplier; break; } } }*/ if (doubletime) { m_millisecondsToComplete /= Program.DOUBLE_TIME_MULTIPLIER; } m_curX = 0; m_curY = 0; m_init = true; m_curId = 0; m_curRep = 1; m_totalElapsed = new TimeSpan(); }
private bool validFormat(DataTable dt) { Hashtable tmpKey = new Hashtable(); SongData data = new SongData(); int k = 1; bool valid = true; for (int i = 0; i < dt.Rows.Count; i++) { string message = ""; string strWID = !(dt.Rows[i][0] is System.DBNull) ? (string)dt.Rows[i][0] : ""; if (strWID.IndexOf(data.ObjectType.Prefix) != 0) { mvImportMaster.AddError("WIDのフォーマットが間違っている:" + strWID); valid = false; continue; } if (tmpKey.Contains(strWID)) { mvImportMaster.AddError(strWID + "が重複です。"); valid = false; continue; } else { tmpKey.Add(strWID,strWID); } string strTitle = !(dt.Rows[i][7] is System.DBNull) ? (string)dt.Rows[i][7] : ""; string strTitleYomFull = !(dt.Rows[i][9] is System.DBNull) ? (string)dt.Rows[i][9] : ""; string strAlphabetTitle = !(dt.Rows[i][10] is System.DBNull) ? (string)dt.Rows[i][10] : ""; string strDcSearchTitle = !(dt.Rows[i][11] is System.DBNull) ? (string)dt.Rows[i][11] : ""; string strHaishinFull = !(dt.Rows[i][11 + k] is System.DBNull) ? (string)dt.Rows[i][11 + k] : ""; string strHaishinUta = !(dt.Rows[i][12 + k] is System.DBNull) ? (string)dt.Rows[i][12+k] : ""; string strHaishinVideo = !(dt.Rows[i][13 + k] is System.DBNull) ? (string)dt.Rows[i][13+k] : ""; string strHaishinTeishiFull = !(dt.Rows[i][14 + k] is System.DBNull) ? (string)dt.Rows[i][14 + k] : ""; string strHaishinTeishiUta = !(dt.Rows[i][15 + k] is System.DBNull) ? (string)dt.Rows[i][15 + k] : ""; string strHaishinTeishiVideo = !(dt.Rows[i][16 + k] is System.DBNull) ? (string)dt.Rows[i][16 + k] : ""; string strArtistAID = !(dt.Rows[i][17 + k] is System.DBNull) ? (string)dt.Rows[i][17 + k] : ""; string strAlphabetName = !(dt.Rows[i][21 + k] is System.DBNull) ? (string)dt.Rows[i][21 + k] : ""; string strAlbumID = !(dt.Rows[i][22 + k] is System.DBNull) ? (string)dt.Rows[i][22 + k] : ""; string strSaleDate = !(dt.Rows[i][29 + k] is System.DBNull) ? (string)dt.Rows[i][29 + k] : ""; string strPriceFull = !(dt.Rows[i][30 + k] is System.DBNull) ? (string)dt.Rows[i][30 + k] : ""; string strPriceUta = !(dt.Rows[i][31 + k] is System.DBNull) ? (string)dt.Rows[i][31 + k] : ""; string strPriceVideo = !(dt.Rows[i][32 + k] is System.DBNull) ? (string)dt.Rows[i][32 + k] : ""; string strLabelID = !(dt.Rows[i][33 + k] is System.DBNull) ? (string)dt.Rows[i][33 + k] : ""; string str契約者ID = !(dt.Rows[i][35 + k] is System.DBNull) ? (string)dt.Rows[i][35 + k] : ""; string strIVT = !(dt.Rows[i][36 + k] is System.DBNull) ? (string)dt.Rows[i][36 + k] : ""; string strIVT区分 = !(dt.Rows[i][37 + k] is System.DBNull) ? (string)dt.Rows[i][37 + k] : ""; string str著作権管理団体 = !(dt.Rows[i][38 + k] is System.DBNull) ? (string)dt.Rows[i][38 + k] : ""; string strJASRAC作品コード = !(dt.Rows[i][39 + k] is System.DBNull) ? (string)dt.Rows[i][39 + k] : ""; string strISRC番号 = !(dt.Rows[i][40 + k] is System.DBNull) ? (string)dt.Rows[i][40 + k] : ""; string str作詞者名 = !(dt.Rows[i][41 + k] is System.DBNull) ? (string)dt.Rows[i][41 + k] : ""; string str作曲者名 = !(dt.Rows[i][42 + k] is System.DBNull) ? (string)dt.Rows[i][42 + k] : ""; string strPOINT1 = !(dt.Rows[i][44 + k] is System.DBNull) ? (string)dt.Rows[i][44 + k] : ""; string strSabi1 = !(dt.Rows[i][45 + k] is System.DBNull) ? (string)dt.Rows[i][45 + k] : ""; string strSabi1end = !(dt.Rows[i][46 + k] is System.DBNull) ? (string)dt.Rows[i][46 + k] : ""; string strPOINT2 = !(dt.Rows[i][47 + k] is System.DBNull) ? (string)dt.Rows[i][47 + k] : ""; string strSabi2 = !(dt.Rows[i][48 + k] is System.DBNull) ? (string)dt.Rows[i][48 + k] : ""; string strSabi2end = !(dt.Rows[i][49 + k] is System.DBNull) ? (string)dt.Rows[i][49 + k] : ""; string strPOINT3 = !(dt.Rows[i][50 + k] is System.DBNull) ? (string)dt.Rows[i][50 + k] : ""; string strSabi3 = !(dt.Rows[i][51 + k] is System.DBNull) ? (string)dt.Rows[i][51 + k] : ""; string strSabi3end = !(dt.Rows[i][52 + k] is System.DBNull) ? (string)dt.Rows[i][52 + k] : ""; string strPRText = !(dt.Rows[i][53 + k] is System.DBNull) ? (string)dt.Rows[i][53 + k] : ""; string strFlag = !(dt.Rows[i][54 + k] is System.DBNull) ? (string)dt.Rows[i][54 + k] : ""; if ("".Equals(strWID)) { message += "【WID】" + Func.invalidNull(); } else if (strWID.Length > 8) { message += "【WID】" + Func.invalidLenght(8); } if ("".Equals(strTitle)) { message += "【曲名(半角)】" + Func.invalidNull(); } else if (strTitle.Length > 255) { message += "【曲名(半角)】" + Func.invalidLenght(255); } if (!"".Equals(strTitleYomFull) && strTitleYomFull.Length > 255) { message += "【曲名ヨミ(半角)】" + Func.invalidLenght(255); } if (!"".Equals(strAlphabetTitle) && strAlphabetTitle.Length > 200) { message += "【曲名英表記】" + Func.invalidLenght(200); } if (!"".Equals(strHaishinFull) && !Func.IsDate(strHaishinFull)) { message += "【解禁日(フル)】" + Func.invalidDate(); } if (!"".Equals(strHaishinUta) && !Func.IsDate(strHaishinUta)) { message += "【解禁日(うた)】" + Func.invalidDate(); } if (!"".Equals(strHaishinVideo) && !Func.IsDate(strHaishinVideo)) { message += "【解禁日(ビデオクリップ)】" + Func.invalidDate(); } if (!"".Equals(strHaishinTeishiFull) && !Func.IsDate(strHaishinTeishiFull)) { message += "【配信停止日】" + Func.invalidDate(); } if (!"".Equals(strHaishinTeishiUta) && !Func.IsDate(strHaishinTeishiUta)) { message += "【配信停止日(うた)】" + Func.invalidDate(); } if (!"".Equals(strHaishinTeishiVideo) && !Func.IsDate(strHaishinTeishiVideo)) { message += "【配信停止日(ビデオ)】" + Func.invalidDate(); } if (!"".Equals(strArtistAID) && strArtistAID.Length > 8) { message += "【アーティストID】" + Func.invalidLenght(8); } if (!"".Equals(strAlphabetName) && strArtistAID.Length > 200) { message += "アーティスト名英表記" + Func.invalidLenght(200); } //if (!"".Equals(strGEID) && strGEID.Length > 5) //{ // message += "【ジャンル】" + Func.invalidLenght(5); //} if (!"".Equals(strAlbumID) && strAlbumID.Length > 8) { message += "【アルバムID】" + Func.invalidLenght(8); } if (!"".Equals(strSaleDate) && !Func.IsDate(strSaleDate)) { message += "【発売日】" + Func.invalidDate(); } if (!"".Equals(strPriceFull) && !Func.IsInterger(strPriceFull)) { message += "【価格】" + Func.invalidNumber(); } if (!"".Equals(strPriceUta) && !Func.IsInterger(strPriceUta)) { message += "【価格(うた)】" + Func.invalidNumber(); } if (!"".Equals(strPriceVideo) && !Func.IsInterger(strPriceVideo)) { message += "【価格(ビデオクリップ)】" + Func.invalidNumber(); } if (!"".Equals(strLabelID) && strLabelID.Length > 8) { message += "【レーベルID】" + Func.invalidLenght(8); } if (!"".Equals(str契約者ID) && str契約者ID.Length > 6) { message += "【契約者】" + Func.invalidLenght(6); } if (!"".Equals(strIVT) && strIVT.Length > 1) { message += "【歌詞区分】" + Func.invalidLenght(1); } if (!"".Equals(strIVT区分) && strIVT区分.Length > 1) { message += "【IVT区分】" + Func.invalidLenght(1); } if (!"".Equals(str著作権管理団体) && str著作権管理団体.Length > 50) { message += "【著作権団体】" + Func.invalidLenght(50); } if (!"".Equals(strJASRAC作品コード) && strJASRAC作品コード.Length > 250) { message += "【著作権管理番号】" + Func.invalidLenght(250); } if (!"".Equals(strISRC番号) && strISRC番号.Length > 50) { message += "【ISRC番号】" + Func.invalidLenght(50); } if (!"".Equals(str作詞者名) && str作詞者名.Length > 250) { message += "【作詞者】" + Func.invalidLenght(250); } if (!"".Equals(str作曲者名) && str作曲者名.Length > 250) { message += "【作曲者】" + Func.invalidLenght(250); } if (!"".Equals(strPOINT1) && strPOINT1.Length > 50) { message += "【切り出し表記1】" + Func.invalidLenght(50); } /* if (!"".Equals(strSabi1) && strSabi1.Length != 7) { message += "【" + Constants.ImportDataHeader[43] + "】" + invalidEqual(7); } if (!"".Equals(strSabi1end) && strSabi1end.Length != 7) { message += "【" + Constants.ImportDataHeader[44] + "】" + invalidEqual(7); } */ if (!"".Equals(strSabi1) && strSabi1.Length > 7) { message += "【cut開始1】" + Func.invalidLenght(7); } if (!"".Equals(strSabi1end) && strSabi1end.Length > 7) { message += "【cut終了1】" + Func.invalidLenght(7); } if (!"".Equals(strPOINT2) && strPOINT2.Length > 50) { message += "【切り出し表記2】" + Func.invalidLenght(50); } /* if (!"".Equals(strSabi2) && strSabi2.Length != 7) { message += "【" + Constants.ImportDataHeader[46] + "】" + invalidEqual(7); } if (!"".Equals(strSabi2end) && strSabi2end.Length != 7) { message += "【" + Constants.ImportDataHeader[47] + "】" + invalidEqual(7); } */ if (!"".Equals(strSabi2) && strSabi2.Length > 7) { message += "【cut開始2】" + Func.invalidLenght(7); } if (!"".Equals(strSabi2end) && strSabi2end.Length > 7) { message += "【cut終了2】" + Func.invalidLenght(7); } if (!"".Equals(strPOINT3) && strPOINT3.Length > 50) { message += "【切り出し表記3】" + Func.invalidLenght(50); } /* if (!"".Equals(strSabi3) && strSabi3.Length != 7) { message += "【" + Constants.ImportDataHeader[49] + "】" + invalidEqual(7); } if (!"".Equals(strSabi3end) && strSabi3end.Length != 7) { message += "【" + Constants.ImportDataHeader[50] + "】" + invalidEqual(7); } */ if (!"".Equals(strSabi3) && strSabi3.Length > 7) { message += "【cut開始3】" + Func.invalidLenght(7); } if (!"".Equals(strSabi3end) && strSabi3end.Length > 7) { message += "【cut終了3】" + Func.invalidLenght(7); } if (!"".Equals(strPRText) && strPRText.Length > 255) { message += "【備考】" + Func.invalidLenght(255); } if (!"".Equals(strFlag) && strFlag.Length != 1) { message += "【fineflag】" + Func.invalidEqual(1); } if (!"".Equals(strFlag) && !"1".Equals(strFlag) && !"0".Equals(strFlag)) { message += "【fineflag】がTrue:1 False:0又はブランク"; } for (int j = 56; j <= 73; j++) { string strTitleUta = !(dt.Rows[i][j] is System.DBNull) ? (string)dt.Rows[i][j] : ""; string tmp = Constants.SongMediaExt[j - 56]; if (!"".Equals(strTitleUta) && strTitleUta.Length > 255) { message += "【うたタイトル名" + tmp + "】" + Func.invalidLenght(255); } } for (int j = 74; j <= 91; j++) { string strIsrcUta = !(dt.Rows[i][j] is System.DBNull) ? (string)dt.Rows[i][j] : ""; string tmp = Constants.SongMediaExt[j - 74]; if (!"".Equals(strIsrcUta) && strIsrcUta.Length > 50) { message += "【うたISRC" + tmp + "】" + Func.invalidLenght(50); } } string strTitleVideo = !(dt.Rows[i][92] is System.DBNull) ? (string)dt.Rows[i][92] : ""; if (!"".Equals(strTitleVideo) && strTitleVideo.Length > 255) { message += "【ビデオ枝番名V】" + Func.invalidLenght(255); } string strIsrcVideo = !(dt.Rows[i][93] is System.DBNull) ? (string)dt.Rows[i][93] : ""; if (!"".Equals(strIsrcVideo) && strIsrcVideo.Length > 50) { message += "【ビデオISRCV】" + Func.invalidLenght(50); } string strFullFileName = !(dt.Rows[i][94] is System.DBNull) ? (string)dt.Rows[i][94] : ""; if (!"".Equals(strFullFileName) && strFullFileName.Length > 200) { message += "【フルファイル名】" + Func.invalidLenght(200); } for (int j = 95; j <= 112; j++) { string strFileName = !(dt.Rows[i][j] is System.DBNull) ? (string)dt.Rows[i][j] : ""; string tmp = Constants.SongMediaExt[j - 95]; if (!"".Equals(strFileName) && strFileName.Length > 200) { message += "【うたファイル名" + tmp + "】" + Func.invalidLenght(255); } } string strVideoFileName = !(dt.Rows[i][113] is System.DBNull) ? (string)dt.Rows[i][113] : ""; if (!"".Equals(strVideoFileName) && strVideoFileName.Length > 200) { message += "【ビデオファイル名V】" + Func.invalidLenght(200); } if (!"".Equals(message)) { valid = false; mvImportMaster.AddError("Error (Line)" + (i+2) + ": " + message); } } return valid; }
public static void SaveSong(SongData.Song song, String filename) { // var jObjectResult = BonaJson. }
private void PopulateSongInfo(SongData song) { if (song != null) { if (song.AlbumArt != null) { AlbumArtPicture.Visible = true; AlbumArtPicture.Image = song.AlbumArt; } else { // AlbumArtPicture.Visible = false; AlbumArtPicture.Visible = true; AlbumArtPicture.Image = AlbumImage; } if (song.Name.HasValue()) { NameLabel.Visible = true; NameLabel.Text = song.Name; } else { NameLabel.Text = ""; NameLabel.Visible = false; } if (song.Artist.HasValue()) { ArtistLabel.Visible = true; ArtistLabel.Text = song.Artist; } else { ArtistLabel.Text = ""; ArtistLabel.Visible = false; } if (song.Album.HasValue()) { AlbumLabel.Visible = true; AlbumLabel.Text = song.Album; } else { AlbumLabel.Text = ""; AlbumLabel.Visible = false; } if (song.Genre.HasValue()) { GenreLabel.Visible = true; GenreLabel.Text = song.TidyGenre; } else { GenreLabel.Text = ""; GenreLabel.Visible = false; } if (song.Year > 0) { YearLabel.Visible = true; YearLabel.Text = song.Year.ToString(); } else { YearLabel.Text = ""; YearLabel.Visible = false; } DifficultyLayout.Visible = true; foreach (var diff in song.Difficulty) { Label label = null; switch (diff.Key) { case Instrument.Ambient: label = DifficultyBandValueLabel; break; case Instrument.Guitar: label = DifficultyGuitarValueLabel; break; case Instrument.Bass: label = DifficultyBassValueLabel; break; case Instrument.Drums: label = DifficultyDrumsValueLabel; break; case Instrument.Vocals: label = DifficultyVocalsValueLabel; break; } if (diff.Value == 0 && diff.Key != Instrument.Ambient) { label.Image = null; label.Text = "NO PART"; } else { label.Text = string.Empty; label.Image = Tiers[ImportMap.GetBaseTier(diff.Key, diff.Value)]; } } } else { AlbumArtPicture.Visible = true; AlbumArtPicture.Image = AlbumImage; NameLabel.Visible = false; ArtistLabel.Visible = false; AlbumLabel.Visible = false; GenreLabel.Visible = false; YearLabel.Visible = false; DifficultyLayout.Visible = false; // TODO: Show some sort of info... } }
private void Loop(SongData Song, TrackData Track, Command Command, MmlFileReader m) { Track.AddCommand(CommandType.Loop); }
/* void LoadMusic(string songName) { TimeScale = 1; SaveLoad.SongXml song = SaveLoad.SongSaveLoad.Load(songName); List<SaveLoad.NoteXml> songNotes = song.SongNotes; List<GameObject> noteList = new List<GameObject>(); foreach(SaveLoad.NoteXml nXml in songNotes) { Note newNote = (Note)Instantiate(noteBase); newNote.PlayTime = nXml.time; newNote.direction = (Direction)nXml.dir; newNote.Row = nXml.row; newNote.NoteType = (NoteType)nXml.type; // newNote.isGolden = nXml.isGolden; newNote.isStarter = nXml.isStarter; newNote.isEndNote = nXml.isEndNote; noteList.Add(newNote.gameObject); newNote.transform.SetParent(GameObject.Find("Song").transform); } musicList = noteList; }*/ void LoadMusic(SongData.Song song) { TimeScale = (int)song.BeatsPerSecond / 60.0f; Debug.Log("TimeScale = " + TimeScale); List<GameObject> noteList = new List<GameObject>(); var parent = GameObject.Find("Song").transform; foreach (var jsonNote in song.SongNotes) { Note note = Instantiate(noteBase) as Note; note.PlayTime = jsonNote.Beat; note.direction = jsonNote.Direction; note.NoteType = jsonNote.NoteType; note.Row = DirectionRowHelper.GetRowFromDirection(note.direction); noteList.Add(note.gameObject); note.transform.SetParent(parent); } musicList = noteList; }
public override async Task <(bool Changed, SongData song)> Execute(SongData song) { song.TagsRemoved.Add(_tagType); song = Song.ClearTag(song); return(true, song); }
/// <summary> /// Initializes a new instance of the <see cref="SongInstance"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="songData">The song data.</param> public SongInstance(SongItem item, SongData songData) { DiskItem = item; SongData = songData; }
private void Worker_Work(object sender, DoWorkEventArgs e) { BackgroundWorker bw = sender as BackgroundWorker; MusicArg args = (MusicArg)e.Argument; Random r = new Random(); if (args.Epoch <= 0) { double error = double.PositiveInfinity; double previous; do { Shuffle(args.SongData, r); previous = error; error = 0; for (int j = 0; j < args.SongData.Count; j++) { SongData song = args.SongData[j]; string songFile = System.IO.Path.Combine(args.FilePath, song.Source, song.Name + ".wav"); //// Console.WriteLine("Trying to load file...{0}", file); AudioEngineCSharp.AudioEngine.Audio audio = AudioEngineCSharp.AudioEngine.Load(songFile, false, false); //// load up the file unsafe { // error += args.Analyzer.AddData(audio.RawData, audio.DataSize, args.IsContext ? song.Context : song.Theme, true); } //// _themeAnalyzer.AddData(a.Data, data.Theme); audio.Dispose(); // float percent = ((float)(i * args.SongData.Count + (j + 1))) / totalNum; // int progress = (int)(Math.Round(percent * 100)); Debug.WriteLine(string.Format("Finished ({0}) {1}", song.Source, song.Name)); // bw.ReportProgress(progress); } Debug.WriteLine(string.Format("Error: {0}, Previous: {1}", error, previous)); // } while (Math.Abs(previous - error) >= 1e-10 * previous); } while (Math.Abs(previous - error) >= 1e-4); } else { int totalNum = args.SongData.Count * args.Epoch; // prepreprocess for (int i = 0; i < args.SongData.Count; i++) { SongData song = args.SongData[i]; string songFile = System.IO.Path.Combine(args.FilePath, song.Source, song.Name + ".wav"); AudioEngineCSharp.AudioEngine.Audio audio = AudioEngineCSharp.AudioEngine.Load(songFile, false, false); unsafe { args.Analyzer.PreprocessAddData(audio.RawData, audio.DataSize); } audio.Dispose(); } args.Analyzer.PreDeviation(); for (int i = 0; i < args.SongData.Count; i++) { SongData song = args.SongData[i]; string songFile = System.IO.Path.Combine(args.FilePath, song.Source, song.Name + ".wav"); AudioEngineCSharp.AudioEngine.Audio audio = AudioEngineCSharp.AudioEngine.Load(songFile, false, false); unsafe { args.Analyzer.ProcessDeviation(audio.RawData, audio.DataSize); } audio.Dispose(); } args.Analyzer.PreProcessData(); for (int i = 0; i < args.Epoch; i++) { Shuffle(args.SongData, r); for (int j = 0; j < args.SongData.Count; j++) { SongData song = args.SongData[j]; string songFile = System.IO.Path.Combine(args.FilePath, song.Source, song.Name + ".wav"); //// Console.WriteLine("Trying to load file...{0}", file); AudioEngineCSharp.AudioEngine.Audio audio = AudioEngineCSharp.AudioEngine.Load(songFile, false, false); //// load up the file unsafe { args.Analyzer.ProcessData(audio.RawData, audio.DataSize, args.IsContext ? song.Context : song.Theme); } //// _themeAnalyzer.AddData(a.Data, data.Theme); audio.Dispose(); float percent = ((float)(i * args.SongData.Count + (j + 1))) / totalNum; int progress = (int)(Math.Round(percent * 100)); Debug.WriteLine(string.Format("Percent: {0}, Finished ({1}) {2}", percent, song.Source, song.Name)); bw.ReportProgress(progress); } } } }
private List<SongData> LoadSongData() { currentSheet = "SongData"; currentRows = dataReader.GetRows(currentSheet); List<SongData> songDataList = new List<SongData>(); int rowNum = currentRows.Count; for (int i = 0; i < rowNum; i++) { SongData songDataObject = new SongData(); TryLoadInt(i, "ID", out songDataObject.id); TryLoadString(i, "Title", out songDataObject.title); TryLoadInt(i, "TapGoal", out songDataObject.tapGoal); TryLoadInt(i, "Duration", out songDataObject.duration); TryLoadInt(i, "CoinReward", out songDataObject.coinReward); TryLoadBool(i, "BossBattle", out songDataObject.bossBattle); TryLoadInt(i, "ConcertID", out songDataObject.concertID); songDataList.Add(songDataObject); } return songDataList; }
private bool ParseHeader_1_7(TabStream s) { m_fileType = s.LE_ReadUInt8(); switch (m_fileType) { case FILETYPE_SONG: m_songData = new SongData(); m_songData.contentType = s.LE_ReadUInt8(); m_songData.title = s.ReadStringWithLength(); m_songData.artist = s.ReadStringWithLength(); m_songData.releaseType = s.LE_ReadUInt8(); switch (m_songData.releaseType) { case RELEASETYPE_PUBLIC_AUDIO: m_songData.audioData = new SongData.AudioData(); m_songData.audioData.type = s.LE_ReadUInt8(); m_songData.audioData.title = s.ReadStringWithLength(); m_songData.audioData.year = s.LE_ReadUInt16(); m_songData.audioData.live = s.LE_ReadUInt8(); break; case RELEASETYPE_PUBLIC_VIDEO: m_songData.videoData = new SongData.VideoData(); m_songData.videoData.title = s.ReadStringWithLength(); m_songData.videoData.live = s.LE_ReadUInt8(); break; case RELEASETYPE_BOOTLEG: m_songData.bootlegData = new SongData.BootlegData(); m_songData.bootlegData.title = s.ReadStringWithLength(); m_songData.bootlegData.month = s.LE_ReadUInt16(); m_songData.bootlegData.day = s.LE_ReadUInt16(); m_songData.bootlegData.year = s.LE_ReadUInt16(); break; } m_songData.authorType = s.LE_ReadUInt8(); if (m_songData.authorType == AUTHORTYPE_AUTHORKNOWN) { m_songData.authorData = new SongData.AuthorData(); m_songData.authorData.composer = s.ReadStringWithLength(); m_songData.authorData.lyricist = s.ReadStringWithLength(); } m_songData.arranger = s.ReadStringWithLength(); m_songData.guitarScoreTranscriber = s.ReadStringWithLength(); m_songData.bassScoreTranscriber = s.ReadStringWithLength(); m_songData.copyright = s.ReadStringWithLength(); m_songData.lyrics = s.ReadStringWithLength(); m_songData.guitarScoreNotes = s.ReadStringWithLength(); m_songData.bassScoreNotes = s.ReadStringWithLength(); break; case FILETYPE_LESSON: m_lessonData = new LessonData(); m_lessonData.title = s.ReadStringWithLength(); m_lessonData.subtitle = s.ReadStringWithLength(); m_lessonData.musicStyle = s.LE_ReadUInt16(); m_lessonData.level = s.LE_ReadUInt8(); m_lessonData.author = s.ReadStringWithLength(); m_lessonData.notes = s.ReadStringWithLength(); m_lessonData.copyright = s.ReadStringWithLength(); break; } return true; }