Esempio n. 1
0
    List <Note> playMusic(float dspSongTime, SongTranslator songNotes, GameObject song)
    {
        Song songScript   = song.gameObject.GetComponent <Song>();
        int  songBpm      = songScript.getBpm();
        int  beatsPerLoop = songScript.getBeatsPerLoop();
        //Load the AudioSource attached to the Conductor GameObject
        AudioSource audioSource = song.GetComponent <AudioSource>();
        //Calculate the number of seconds in each beat
        float secPerBeat = 60f / songBpm;

        //determine how many seconds since the song started
        float songPosition = (float)(AudioSettings.dspTime - dspSongTime);

        //determine how many beats since the song started
        float songPositionInBeats = songPosition / secPerBeat;

        if (songPositionInBeats >= (songScript.getCurrLoop() + 1) * beatsPerLoop)
        {
            songScript.incrementLoop();
            loopMusic(audioSource, songNotes);
        }

        float loopPositionInBeats  = songPositionInBeats - songScript.getCurrLoop() * beatsPerLoop;
        float loopPositionInAnalog = loopPositionInBeats / beatsPerLoop;

        songNotes.removeNotes(loopPositionInBeats);
        songNotes.updateCurrNotes(loopPositionInBeats);
        List <Note> currNotes = songNotes.getCurrNotes();

        return(currNotes);
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        //button1 = GameObject.Find("Canvas").transform.Find("Button 1");
        //button1 = GameObject.Find("Canvas").transform.Find("Button 2");
        //button1 = GameObject.Find("Canvas").transform.Find("Button 3");
        //button1 = GameObject.Find("Canvas").transform.Find("Button 4");


        songNotes      = GameObject.FindWithTag("SongTranslator").gameObject.GetComponent <SongTranslator>();
        canvas         = GameObject.Find("Canvas");
        buttonColourer = canvas.gameObject.GetComponent <ButtonColourer>();

        song     = GameObject.FindWithTag("Track");
        musician = GameObject.FindWithTag("Player");
        //songScript = song.gameObject.GetComponent<Song>();
        //songBpm = songScript.getBpm();
        //beatsPerLoop = songScript.getBeatsPerLoop();
        //Load the AudioSource attached to the Conductor GameObject
        //musicSource = song.GetComponent<AudioSource>();
        wrongSource = this.GetComponent <AudioSource>();
        //Calculate the number of seconds in each beat
        //secPerBeat = 60f / songBpm;
        isTeaching = false;
    }
Esempio n. 3
0
 void loopMusic(AudioSource audioSource, SongTranslator songNotes)
 {
     songNotes.newLoop();
     audioSource.Play();
 }