Exemplo n.º 1
0
    private float updateVelocity(float averageMagnitude)
    {
        MIDIPlayer player = GetComponent <MIDIPlayer>();

        player.velocityScale = averageMagnitude / VELOCITY_TO_MAGNITUDE_SCALE;
        return(player.velocityScale);
    }
Exemplo n.º 2
0
    private void OnMouseOver()
    {
        Debug.Log("Test");
        MIDIPlayer midiplayer = GameObject.FindGameObjectWithTag("MIDIPlayer").GetComponent <MIDIPlayer>();

        midiplayer.setNote(Random.Range(61, 75));
    }
Exemplo n.º 3
0
    void Start()
    {
        Controller = GetComponent <PianoController>();

        GameObject midiPlayer = GameObject.Find("MIDIPlayer");

        Player = midiPlayer.GetComponent <MIDIPlayer>();

        Player.ChannelMessagePlayed += onChannelMessagePlayed;
    }
Exemplo n.º 4
0
        public PianoBuilder(MIDIPlayer midiPlayer, PianoKeyObjectSettings whiteKeyObjectSettings, PianoKeyObjectSettings blackKeyObjectSettings)
        {
            this.midiPlayer             = midiPlayer;
            this.whiteKeyObjectSettings = whiteKeyObjectSettings;
            this.blackKeyObjectSettings = blackKeyObjectSettings;

            whiteKeyBounds = GetBounds(whiteKeyObjectSettings.prefab);

            Bounds blackKeyBounds = GetBounds(blackKeyObjectSettings.prefab);

            blackKeyOffset = new Vector3(0, blackKeyBounds.size.y * 0.5f, 0);
        }
    // Use this for initialization
    void Start()
    {
        this.midiPlayer = GameObject.FindGameObjectWithTag("MIDIPlayer").GetComponent <MIDIPlayer>();

        if (this.magicIndicator)
        {
            this.magicIndicator.GetComponent <Image>().color = Color.white;
        }

        if (this.noteManager)
        {
            this.noteManager.GetComponent <Text>().text = "None";
        }
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        string     midiFile = LoadGame.getSongPath();
        MIDIPlayer player   = GetComponent <MIDIPlayer> ();

        player.enabled = false;
        if (midiFile != "")
        {
            player.midiFilePath = midiFile;
        }
        player.enabled = true;

        magnitudeSum     = 0;
        magnitudeCount   = 0;
        expectedMovement = getMovementDirection(beatCounter);
    }
Exemplo n.º 7
0
    private uint updateTempo()
    {
        MIDIPlayer player = GetComponent <MIDIPlayer>();

        if (lastTime > 0)
        {
            //Debug.LogWarning (Time.time - lastTime);

            uint newTempo = (uint)(60 / (Time.time - lastTime));
            player.currentTempo = newTempo;
            thalmicMyo.Vibrate(Thalmic.Myo.VibrationType.Short);
        }

        lastTime = Time.time;
        return(player.currentTempo);
    }
    // Use this for initialization
    void Start()
    {
        teleport           = GetComponent <PlayerTeleport>();
        midiPlayer         = GetComponent <MIDIPlayer>();
        magicBallGenerator = GetComponent <MagicBallGenerator>();

        availableNotes = Configuration.availableNotes;

        // Set available notes
        if (magicBallGenerator != null && availableNotes != null)
        {
            magicBallGenerator.SetAvailableIndex(availableNotes);
        }

        projectileManager = GameObject.FindGameObjectWithTag("Terrain").GetComponent <ProjectileManager>();  // Get Projectile manager

        currentCamera = GetCameraObject();
    }
Exemplo n.º 9
0
        private void OnGUI()
        {
            parent = (Transform)EditorGUILayout.ObjectField("Parent: ", parent, typeof(Transform), true);

            GUILayout.Space(10);

            // Button: Clear parent
            EditorGUI.BeginDisabledGroup(parent == null);
            if (GUILayout.Button("Clear parent"))
            {
                PianoBuilder.ClearParentOfChildren(parent);
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.Space(10);

            midiPlayer             = (MIDIPlayer)EditorGUILayout.ObjectField("MidiPlayer: ", midiPlayer, typeof(MIDIPlayer), true);
            whiteKeyObjectSettings = (PianoKeyObjectSettings)EditorGUILayout.ObjectField("WhiteKey Object Settings: ", whiteKeyObjectSettings, typeof(PianoKeyObjectSettings), false);
            blackKeyObjectSettings = (PianoKeyObjectSettings)EditorGUILayout.ObjectField("BlackKey Object Settings: ", blackKeyObjectSettings, typeof(PianoKeyObjectSettings), false);

            GUILayout.Space(20);

            if (IsRequiredValuesSet())
            {
                PianoBuilder pianoBuilder = new PianoBuilder(midiPlayer, whiteKeyObjectSettings, blackKeyObjectSettings);

                octaves        = EditorGUILayout.IntField("Octaves: ", octaves);
                skippedOctaves = EditorGUILayout.IntField("Skipped Octaves: ", skippedOctaves);

                GUILayout.Space(20);

                distanceBetweenWhiteKeys = EditorGUILayout.FloatField("Distance Between WhiteKeys: ", distanceBetweenWhiteKeys);

                if (GUILayout.Button("Build"))
                {
                    pianoBuilder.BuildPiano(parent, octaves, skippedOctaves, distanceBetweenWhiteKeys);
                }
            }
        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.ActivityMain);
            Android.Support.V4.App.FragmentManager fm = SupportFragmentManager;
            playFragment = (PlayFragment)fm.FindFragmentById(Resource.Layout.FragmentPlay);
            if (playFragment == null)
            {
                playFragment = new PlayFragment();
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
                ft.Add(Resource.Id.main_container, playFragment);
                ft.Commit();
            }
            toolbarFragment = (ToolBarFragment)fm.FindFragmentById(Resource.Layout.FragmentToolBar);
            if (toolbarFragment == null)
            {
                toolbarFragment = new ToolBarFragment();
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
                ft.Add(Resource.Id.toolbar_container, toolbarFragment);
                ft.Commit();
            }

            chordRecognizer = new ChordRecognizer();

            MIDIStyle midiStyle = new MIDIStyle();

            midiStyle.LoadStyle("ddd");
            mplayer                       = new MIDIPlayer(/*this,*/ midiStyle);
            mplayer.OnTactEvent          += (object sender, OnTactEventArgs e) => playFragment.SetTempoAndTact(e.CurrentTempo, e.CurrentTact);
            mplayer.OnChordChangeEvent   += () => OnChordChanged();
            mplayer.OnSectionChangeEvent += () => OnSectionChanged();

            mplayer.Tracks = midiStyle.MidiSection.Tracks;
            mplayer.Start();
        }
Exemplo n.º 11
0
 public void SetMidiPlayer(MIDIPlayer midiPlayer)
 {
     this.midiPlayer = midiPlayer;
 }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (thalmicMyo.arm == Thalmic.Myo.Arm.Unknown)
        {
            return;                                                    // Ignore input if myo is not being worn
        }
        uiPanel.setArm(thalmicMyo.arm);

        MIDIPlayer player = GetComponent <MIDIPlayer>();
        Vector2    gyroXY = (Vector2)thalmicMyo.gyroscope;
        Vector2    expectedMovementVector = movementToVector(expectedMovement, thalmicMyo.arm);
        float      deltaTime = Time.time - lastTime;

        // We expect a movement in a certain direction (supposing a 4:4 time signature)
        // We look for a movement down/left/right/up (in that order) and register a beat when that movement ends
        // (That is, when the vector component is no longer present)

        float componentValue = Vector2.Dot(gyroXY, expectedMovementVector);

        if (Mathf.Abs(Vector2.Dot(gyroXY.normalized, expectedMovementVector)) < 0.5)
        {
            // To avoid false positives, we ignore readings where the target component is not the largest of the two
            // Nothing, early exit
        }
        else if (movingInTheRightDirection)
        {
            if (componentValue < 0 && deltaTime > MINIMUM_MOVEMENT_TIME)
            {
                // No longer moving in the right direction
                movingInTheRightDirection = false;
                updateTempo();

                float averageMagnitude = magnitudeSum / magnitudeCount;
                magnitudeSum   = 0;
                magnitudeCount = 0;
                updateVelocity(averageMagnitude);
                Debug.Log(averageMagnitude);

                // So the Virtual arm can reset itself
                if (expectedMovement == MovementDirection.DOWN && onDownMovement != null)
                {
                    onDownMovement();
                }

                beatCounter++;
                expectedMovement = getMovementDirection(beatCounter);
                uiPanel.showMovement(expectedMovement);
            }
            else
            {
                // Still moving in the right direction
                magnitudeSum += gyroXY.magnitude;
                magnitudeCount++;
            }
        }
        else
        {
            if (componentValue > START_MOVEMENT_SPEED_THRESH)
            {
                movingInTheRightDirection = true;
            }
        }

        /*
         * if (deltaTime > LONG_PAUSE_MINIMUM_DURATION) {
         *      // Let the wind out of the orchestra
         *      // TODO : Pause immediately if hand is raised
         *      player.currentTempo = (uint)(60 / deltaTime);
         * }
         */
    }
Exemplo n.º 13
0
    // Use this for initialization

    void Start()
    {
        this.accords[0] = new int[3];

        this.accords[0][0] = 60;

        this.accords[0][0] = 64;

        this.accords[0][0] = 67;



        this.littlestar = new int[] {
            60, 60, 67, 67, 69, 69, 67, -1,

            65, 65, 64, 64, 62, 62, 60, -1,

            67, 67, 65, 65, 64, 64, 62, -1,

            67, 67, 65, 65, 64, 64, 62, -1,

            60, 60, 67, 67, 69, 69, 67, -1,

            65, 65, 64, 64, 62, 62, 60, -1,
        };



        this.molihua = new int[] {
            NOTES.E3, -1, NOTES.E3, NOTES.G3, NOTES.A3, NOTES.C4, NOTES.C4, NOTES.A3,

            NOTES.G3, -1, NOTES.G3, NOTES.A3, NOTES.G3, -1, -1, -1,

            NOTES.E3, -1, NOTES.E3, NOTES.G3, NOTES.A3, NOTES.C4, NOTES.C4, NOTES.A3,

            NOTES.G3, -1, NOTES.G3, NOTES.A3, NOTES.G3, -1, -1, -1,

            NOTES.G3, -1, NOTES.G3, -1, NOTES.G3, -1, NOTES.E3, NOTES.G3,

            NOTES.A3, -1, NOTES.A3, -1, NOTES.G3, -1, -1, -1,

            NOTES.E3, -1, NOTES.D3, NOTES.E3, NOTES.G3, -1, NOTES.E3, NOTES.D3,

            NOTES.C3, -1, NOTES.C3, NOTES.D3, NOTES.C3, -1, -1, -1,

            NOTES.E3, NOTES.D3, NOTES.C3, NOTES.E3, NOTES.D3, -1, -1, NOTES.D3,

            NOTES.G3, -1, NOTES.A3, NOTES.C4, NOTES.G3, -1, -1, -1,

            NOTES.D3, -1, NOTES.E3, NOTES.G3, NOTES.D3, NOTES.E3, NOTES.C3, NOTES.A2,

            NOTES.G2, -1, -1, -1, NOTES.A2, -1, NOTES.C3, -1,

            NOTES.D3, -1, -1, NOTES.E3, NOTES.C3, NOTES.D3, NOTES.C3, NOTES.A2,

            NOTES.G2, -1,
        };



        this.sakura = new int[] {
            NOTES.A3, -1, NOTES.A3, -1, NOTES.B3, -1, -1, -1,

            NOTES.A3, -1, NOTES.A3, -1, NOTES.B3, -1, -1, -1,

            NOTES.A3, -1, NOTES.B3, -1, NOTES.C4, -1, NOTES.B3, -1,

            NOTES.A3, -1, NOTES.B3, NOTES.A3, NOTES.F3, -1, -1, -1,

            NOTES.E3, -1, NOTES.C3, -1, NOTES.E3, -1, NOTES.F3, -1,

            NOTES.E3, -1, NOTES.E3, NOTES.C3, NOTES.B2, -1, -1, -1,

            NOTES.A3, -1, NOTES.B3, -1, NOTES.C4, -1, NOTES.B3, -1,

            NOTES.A3, -1, NOTES.B3, NOTES.A3, NOTES.F3, -1, -1, -1,

            NOTES.E3, -1, NOTES.C3, -1, NOTES.E3, -1, NOTES.F3, -1,

            NOTES.E3, -1, NOTES.E3, NOTES.C3, NOTES.B2, -1, -1, -1,

            NOTES.A3, -1, NOTES.A3, -1, NOTES.B3, -1, -1, -1,

            NOTES.A3, -1, NOTES.A3, -1, NOTES.B3, -1, -1, -1,

            NOTES.E3, -1, NOTES.F3, -1, NOTES.B3, NOTES.A3, NOTES.F3, -1,

            NOTES.E3, -1,
        };



        this.player = this.GetComponent <MIDIPlayer>();
    }
Exemplo n.º 14
0
 void Start()
 {
     this.timer      = 0;
     this.midiPlayer = GameObject.FindGameObjectWithTag("MIDIPlayer").GetComponent <MIDIPlayer>();
     trackedObj      = GetComponent <SteamVR_TrackedObject>();
 }
    // Use this for initialization
    void Start()
    {
        midiPlayer = GetComponent <MIDIPlayer>();

        currentCamera = GetCameraObject();
    }