Пример #1
0
        private string FormatDataFromSong(SongFile song)
        {
            string info = "";

            info += "Title\n";
            info += song.Tag.Title + "\n";
            info += "Artist(s)\n";
            info += song.Artist + "\n";
            info += "Genre \n";
            foreach (string genre in song.Tag.Genres)
            {
                info += genre;
                info += " ";
            }
            info += "\n";
            info += "Track Number\tTrack count\n";
            info += song.Tag.Track + "\t" + song.Tag.TrackCount + "\n";
            info += "Disco number\tDisc total\n";
            info += song.Tag.Disc + "\t" + song.Tag.DiscCount + "\n";
            info += "Album name\n";
            info += song.Tag.Album + "\n";
            info += "Album Artist\n";
            foreach (string albumArtist in song.Tag.AlbumArtists)
            {
                info += albumArtist;
                info += " ";
            }
            info += "\n";
            info += "Year\n";
            info += song.Tag.Year + "\n";
            info += "Lyrics\n";
            info += song.Tag.Lyrics;
            return(info);
        }
Пример #2
0
        /// <summary>
        /// Contructor for Gun
        /// </summary>
        /// <param name="t">Texture</param>
        /// <param name="pos">Position</param>
        /// <param name="game">reference to MainGame</param>
        /// <param name="d">Damage of bullets</param>
        /// <param name="magSize">Size of magazine</param>
        /// <param name="mv">Muzzle velocity</param>
        /// <param name="ammo">Starting ammo</param>
        /// <param name="fr">Fire rate in ms</param>
        /// <param name="rs">Reload speed in ms</param>
        public Gun(Texture2D t, Vector2 pos, MainGame game, int d, int magSize, float mv, int ammo, double fr, double rs, RobotRampage.MainGame.CreateProjectile cp, SongFile gunShot, SongFile gunEmpty)
        {
            Texture      = t;
            position     = pos;
            parent       = game;
            srcRect      = new Rectangle(0, 0, Texture.Width, Texture.Height);
            damage       = d;
            magazineSize = magSize;
            if (ammo > magSize)
            {
                LoadedAmmo  = ammo % magSize;
                ReserveAmmo = ammo - LoadedAmmo;
            }
            else
            {
                LoadedAmmo = ammo;
                LoadedAmmo = 0;
            }

            muzzleVelocity        = mv;
            LoadedAmmo            = magSize;
            fireRate              = fr;
            reloadSpeed           = rs;
            lastFire              = -1.0;
            reloadTime            = 0.0;
            shoot                 = cp;
            this.MarkedForRemoval = false;
            shootEffect           = gunShot;
            emptyEffect           = gunEmpty;
        }
Пример #3
0
        public void AnalyzeSong(string fileDirectory)
        {
            visualFacade.SetProgress("Loading Song...", 0.0f);

            SongFile songFile = MyAudioFileReader.ReadAudioFile(fileDirectory);

            visualFacade.SetSongFile(songFile);

            List <SongPropertyValues> songPropertyValuesList = new List <SongPropertyValues>();

            visualFacade.SetProgress("Analyze...", 0.1f);

            AudioAnalyzer audioAnalyzer = new AudioAnalyzer();

            audioAnalyzer.LoadAudioFromFile(fileDirectory);

            audioAnalyzer.Analyze();

            songPropertyValuesList.Add(GetSingleBeatsSPV(audioAnalyzer.SongElements));
            songPropertyValuesList.Add(GetHeldNoteSPV(audioAnalyzer.SongElements));

            visualFacade.PlotSongPropertyValues(songPropertyValuesList);

            visualFacade.SetProgress("done :)", 1);
        }
Пример #4
0
        public SongFile GetSong(string name)
        {
            if (name.Replace(" ", "") == "")
            {
                return((SongFile)null);
            }
            SongFile songFile = new SongFile();

            if (!File.Exists(this.sgPath + name))
            {
                return((SongFile)null);
            }
            string s = File.ReadAllText(this.sgPath + name);

            try
            {
                songFile.Title        = this.ExtractString(s, "title");
                songFile.Presentation = this.ExtractString(s, "presentation");
                songFile.Text         = this.ExtractString(s, "lyrics");
            }
            catch
            {
                return((SongFile)null);
            }
            return(songFile);
        }
Пример #5
0
        public static void SaveTags(SongFile songFile)
        {
            TagLib.File newFile = GetTagsFromFile(Caching.currentFile.fullPath);

            newFile.SetInterpret(songFile.Interpret);
            newFile.Tag.Title   = songFile.Title;
            newFile.Tag.Album   = songFile.Album;
            newFile.Tag.Comment = songFile.Comment;
            newFile.Tag.Track   = (uint)songFile.Track;
            newFile.Tag.Year    = (uint)songFile.Year;
            newFile.SetGenre(songFile.Genre);
            newFile.SetImage(Caching.currentFile.Cover.ConvertToPicture());

            newFile.Refresh(Caching.currentFile.fullPath);

            if (Caching.currentFile.Cover != null)
            {
                TagLib.File newFileTEMP = TagLib.File.Create(Caching.currentFile.fullPath);

                newFileTEMP.SetImage(Caching.currentFile.Cover.ConvertToPicture());

                newFileTEMP.Save();

                newFileTEMP.Dispose();
            }
        }
        private async void DeleteSong(object sender, EventArgs e)
        {
            // Get song item
            SongFile item = (SongFile)listSongs.SelectedItem;

            if (item == null)
            {
                return;
            }

            // Confirm deletion
            bool okay = await DisplayAlert("Delete file?", "File '" + item.GetName + "' will be deleted permanently.", "Okay", "Cancel");

            if (!okay)
            {
                return;
            }

            // Delete file (list view should update)
            bool success = await ParentPage.DeleteSong(item.GetName);

            if (success)
            {
                SongFiles.Remove(item);
                await DisplayAlert("Message", "Song deleted.", "OK");
            }
            else
            {
                await DisplayAlert("Issue", "Song could not be deleted.", "Oh, ok...");
            }
        }
Пример #7
0
 public MainPage()
 {
     m_SongSelected   = null;
     m_FolderPickerMV = new FolderPicker_MV();
     m_LastFMMV       = new LastFM_MV();
     m_LyricsMV       = new Lyrics_MV();
     SubscribeToEvents();
     this.InitializeComponent();
 }
Пример #8
0
 private void FolderPickerMV_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("Song"))
     {
         m_SongSelected = m_FolderPickerMV.Song;
     }
     if (e.PropertyName.Equals("CWD"))
     {
         m_CurrenFolder = m_FolderPickerMV.CWD;
     }
 }
Пример #9
0
        public void SearchThread()
        {
            string text = this.txtQuery.Text;

            for (int index1 = 0; index1 < this.songs.Count; ++index1)
            {
                SongFile song = this.GetSong(this.songs[index1]);
                if (song != null)
                {
                    string   str1      = song.Text.ToLower();
                    string[] strArray1 = new string[9]
                    {
                        ",",
                        ".",
                        "!",
                        "?",
                        "ă",
                        "î",
                        "â",
                        "ș",
                        "ț"
                    };
                    string[] strArray2 = new string[9]
                    {
                        "",
                        "",
                        "",
                        "",
                        "a",
                        "i",
                        "a",
                        "s",
                        "t"
                    };
                    for (int index2 = 0; index2 < strArray1.Length; ++index2)
                    {
                        str1 = str1.Replace(strArray1[index2], strArray2[index2]);
                    }
                    if (song.Title.ToLower().Contains(text))
                    {
                        this.AddItems(song.Title, "In title");
                    }
                    else if (str1.Contains(text))
                    {
                        int    num1 = str1.ToLower().IndexOf(text);
                        int    num2 = 30;
                        string str2 = num1 - num2 < 0 ? (num1 + num2 >= song.Text.Length ? song.Text.Substring(0) : song.Text.Substring(0, num2 * 2)) : (num1 + num2 >= song.Text.Length ? song.Text.Substring(num1 - num2) : song.Text.Substring(num1 - num2, num2 * 2));
                        this.AddItems(song.Title, "..." + str2 + "...");
                    }
                    this.UpdateStatus("Current Song : " + song.Title);
                }
            }
            this.UpdateStatus("Done. Found: " + (object)this.listVerses.Items.Count);
        }
        private async void LoadSong(object sender, EventArgs e)
        {
            // Return to song page and load the thing
            SongFile item = (SongFile)listSongs.SelectedItem;

            if (item == null)
            {
                return;
            }
            ParentPage.LoadSong(item.GetName);
            await Navigation.PopAsync();
        }
Пример #11
0
    private GameObject createSongFilePrefab(SongFile file)
    {
        GameObject filePrefab = Instantiate(songFilePrefab);

        SongFileController controller = filePrefab.GetComponent <SongFileController>();

        controller.filename.text   = file.filename;
        controller.playLength.text = generatePlayLengthString(file.playLength);
        controller.identifier      = file.identifier;

        return(filePrefab);
    }
Пример #12
0
        //private List<Level> CreateLevels()
        //{
        //    CreateEnemies();
        //    CreateFloors();
        //    CreateWalls();
        //    CreateWinPoint(ConvertUnits.ToSimUnits(1500, 700));
        //    List<Level> levels = new List<Level>();
        //    Dictionary<Type, List<List<float>>> levelObjects = GetLevelDictFromGameObjects(gameObjects);
        //    Level level1 = new Level(levelObjects, new Vector2(ConvertUnits.ToSimUnits(150), ConvertUnits.ToSimUnits(700)), levelMusic, "Level 1");
        //    levels.Add(level1);
        //    Rocket r = new Rocket(rocketTexture, this, 50, physicsWorld);
        //    r.Position = ConvertUnits.ToSimUnits(100, 100);
        //    Level level2 = new Level(levelObjects, new Vector2(ConvertUnits.ToSimUnits(150), ConvertUnits.ToSimUnits(700)), levelMusic, "Level 2");
        //    levels.Add(level2);

        //    return levels;
        //}



        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            LoadTextures();
            contentPath = System.IO.Path.Combine(Environment.CurrentDirectory + "\\Content");

            levelMusic = new SongFile(System.IO.Path.Combine(contentPath + "\\FailingDefense.wma"));



            menuMusic           = new SongFile(System.IO.Path.Combine(contentPath + "\\In a Heartbeat.mp3"));
            deathEffect         = new SongFile(System.IO.Path.Combine(contentPath + "\\death.wav"));
            explosionEffect     = new SongFile(System.IO.Path.Combine(contentPath + "\\explosion.wav"));
            JumpEffect          = new SongFile(System.IO.Path.Combine(contentPath + "\\jump.wav"));
            rifleShootSound     = new SongFile(System.IO.Path.Combine(contentPath + "\\smg.wav"));
            shotgunShootSound   = new SongFile(System.IO.Path.Combine(contentPath + "\\shotgun.wav"));
            emptyGunSound       = new SongFile(System.IO.Path.Combine(contentPath + "\\empty.wav"));
            laserGunSound       = new SongFile(System.IO.Path.Combine(contentPath + "\\laser.wav"));
            rocketLauncherSound = new SongFile(System.IO.Path.Combine(contentPath + "\\rocketShoot.wav"));
            successSound        = new SongFile(System.IO.Path.Combine(contentPath + "\\Success.mp3"));
            //TODO: uncomment for music
            //TryPlay(backgroundMusic);

            font = Content.Load <SpriteFont>("myFont");


            //var screen = Screen.AllScreens.First(e => e.Primary);
            //Window.IsBorderless = true;
            //Window.Position = new Point(screen.Bounds.X, screen.Bounds.Y);
            //graphics.PreferredBackBufferWidth = screen.Bounds.Width;
            //graphics.PreferredBackBufferHeight = screen.Bounds.Height;

            graphics.PreferredBackBufferHeight = ScreenHeight;
            graphics.PreferredBackBufferWidth  = ScreenWidth;
            graphics.IsFullScreen = true;
            graphics.ApplyChanges();

            Vector2 initialPlayerPosition = new Vector2(ScreenWidth / 2, 150);

            crosshair    = new Crosshair(crosshairTexture, new Vector2(ScreenWidth / 2, ScreenHeight / 2), this);
            assualtRifle = new Gun(defaultGunTexture, initialPlayerPosition, this, 35, 30, 7.5f, 200, 100.0, 1000.0, CreateBullet, rifleShootSound, emptyGunSound);
            shotGun      = new Gun(shotGunTexture, initialPlayerPosition, this, 50, 5, 7.5f, 20, 1000.0, 1500.0, CreateShotgunBullet, shotgunShootSound, emptyGunSound);
            //handGun = new Gun(handGunTexture, initialPlayerPosition, this, 40, 10, 5.0f, 200, 500.0, 800.0, CreateBullet, rifleShootSound, emptyGunSound);
            RocketLauncher = new Gun(rocketLauncherTexture, initialPlayerPosition, this, 100, 4, 7.5f, 20, 800.0, 1500.0, CreateRocket, rocketLauncherSound, emptyGunSound);
            mouseWheelLoc  = Mouse.GetState().ScrollWheelValue;
        }
Пример #13
0
        public void SetSongFile(SongFile songFile)
        {
            this.songFile = songFile;

            visualValues.SetSongDuration(songFile.SongDuration);

            songNameLabel.Text     = songFile.SongName;
            songDurationLabel.Text = visualValues.GetSongDurationString();

            audioPlayer.Dispose();
            audioPlayer.InitAudio(songFile);

            songWaveViewer.SetSongFile(songFile);

            togglePlaybackButton.Enabled = true;
        }
Пример #14
0
 public IEnumerable <SongFile> Get(string field = "", string value = "")
 {
     if (conn != null)
     {
         try {
             List <SongFile> list     = new List <SongFile>();
             string          queryStr = "SELECT id, title, artist, album, year, track FROM songs";
             if ((field != null) && (field.Length > 0) && (value != null) && (value.Length > 0))
             {
                 queryStr += " WHERE " + field + " LIKE '%" + value + "%'";
             }
             queryStr += " ORDER BY id";
             OdbcCommand    cmd    = new OdbcCommand(queryStr, conn);
             OdbcDataReader reader = cmd.ExecuteReader();
             if (reader.HasRows)
             {
                 while (reader.Read())
                 {
                     SongFile song = new SongFile();
                     if (reader.IsDBNull(0))
                     {
                         song.ID = 0;
                     }
                     else
                     {
                         song.ID = reader.GetInt32(0);
                     }
                     song.Title  = getDbString(reader, 1);
                     song.Artist = getDbString(reader, 2);
                     song.Album  = getDbString(reader, 3);
                     song.Year   = getDbString(reader, 4);
                     song.Track  = getDbString(reader, 5);
                     list.Add(song);
                 }
             }
             reader.Close();
             cmd.Dispose();
             return(list);
         } catch (Exception e) {
             Console.Error.WriteLine("Error reading from DB: " + e);
             // should throw exception so AJAX knows to execute error handler
             throw e;
         }
     }
     return(songs);
 }
Пример #15
0
        private async void UpdateSongList(IList<StorageFile> list)
        {
            m_SongList.Clear();
            foreach (StorageFile file in list)
            {
                try
                {
                    SongFile song = await ReadTagFromFile(file);
                    m_SongList.Add(song);
                }
                catch (CorruptFileException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }

            }
        }
Пример #16
0
        public void InitAudio(SongFile songFile)
        {
            this.songFile = songFile;

            string fileDirectory = songFile.FileDirectory;

            if (songFile.FileType == FileType.Mp3)
            {
                waveStream = new Mp3FileReader(fileDirectory);
            }
            else
            {
                waveStream = new WaveFileReader(fileDirectory);
            }

            waveOutEvent.Init(waveStream);
        }
Пример #17
0
        private async void SongListView_SongOnClick(object sender, ItemClickEventArgs e)
        {
            SongFile songClicked = e.ClickedItem as SongFile;

            m_ModelView.Song = songClicked;
            InfoBox.Text     = FormatDataFromSong(songClicked);
            if (songClicked.Tag.Pictures.Length == 0)
            {
                IEx_AlbumCover.Source = null;
                return;
            }
            else
            {
                MemoryStream stream = new MemoryStream(songClicked.Tag.Pictures?[0].Data.Data);
                BitmapImage  image  = new BitmapImage();
                await image.SetSourceAsync(stream.AsRandomAccessStream());

                songClicked.Image     = image;
                IEx_AlbumCover.Source = image;
            }
        }
Пример #18
0
    public void SaveFile(bool saveAs = true)
    {
        playback.Stop( );

        if (!saveAs && (m_OpenFile == "" || !File.Exists(m_OpenFile)))
        {
            saveAs = true;
        }

        if (!saveAs || m_TuneSave.ShowDialog())
        {
            SongFile song = new SongFile( );
            song.patternLength  = data.patternLength;
            song.lookupTable    = data.lookupTable;
            song.transposeTable = data.transposeTable;
            song.songData       = data.songData;

            int presetCount = instruments.presets.Length;
            song.instruments = new Instruments.InstrumentInstance [presetCount];
            Array.Copy(instruments.presets, song.instruments, presetCount);

            song.songName   = SongData.songName;
            song.artistName = SongData.artistName;

            IFormatter formatter = new BinaryFormatter();
            Stream     fs        = !saveAs ? new FileStream(m_OpenFile, FileMode.Create) : m_TuneSave.OpenFile( );
            formatter.Serialize(fs, song);
            fs.Close( );

            if (saveAs)
            {
                m_OpenFile = m_TuneSave.filePath;
            }

            fileModified = false;
        }
    }
Пример #19
0
 public void SetSongFile(SongFile songFile)
 {
     form.SetSongFile(songFile);
 }
Пример #20
0
        public void SetSongFile(SongFile songFile)
        {
            this.songFile = songFile;

            WaveStream = songFile.WaveStream;
        }
Пример #21
0
    public void OpenFile()
    {
        if (fileModified && !TinyFileDialogs.MessageBox("Opening tune", "Are you sure? You will lose all unsaved progress.", TinyFileDialogs.DialogType.YESNO, TinyFileDialogs.IconType.WARNING, false))
        {
            return;
        }

        playback.Stop( );
        data.currentPattern = 0;

        if (m_TuneOpen.ShowDialog())
        {
            IFormatter formatter = new BinaryFormatter( );
            Stream     fs        = m_TuneOpen.OpenFile( );

            SongFile open = (SongFile)formatter.Deserialize(fs);
            fs.Close( );

            if (!open.success)
            {
                return;
            }

            data.SetPatternLength(open.patternLength);
            data.lookupTable = open.lookupTable;
            if (open.transposeTable != null && open.transposeTable.Count == open.lookupTable.Count)
            {
                data.transposeTable = open.transposeTable;
            }
            else
            {
                Debug.Log("Transpose table too shourt!!");
                data.transposeTable = new List <int []> ( );
                for (int i = 0; i < data.lookupTable.Count; i++)
                {
                    int [] transposeEntry;

                    if (open.transposeTable != null && i < open.transposeTable.Count)
                    {
                        transposeEntry = open.transposeTable [i];
                    }
                    else
                    {
                        transposeEntry = new int [data.channels];
                    }

                    data.transposeTable.Add(transposeEntry);
                }
            }
            data.songData = open.songData;

            SongData.songName   = open.songName ?? "";
            SongData.artistName = open.artistName ?? "";

            keyboard.currentInstrument = 0;

            int presetCount = open.instruments.Length;
            Array.Resize(ref instruments.presets, presetCount);
            Array.Copy(open.instruments, instruments.presets, presetCount);

            m_OpenFile   = m_TuneOpen.filePath;
            fileModified = false;

            if (onFileOpen != null)
            {
                onFileOpen( );
            }

            patternMatrix.UpdateMatrix();
            patternView.UpdatePatternData();
            insEditor.UpdateInstruments();
            insEditor.UpdateInstrumentInfo();
            insEditor.SetSelectedInstrument(0);
            playback.playbackSpeed = 6;
        }
    }