-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMidiController.cs
More file actions
45 lines (37 loc) · 1.03 KB
/
MidiController.cs
File metadata and controls
45 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MidiController : MonoBehaviour
{
public PMSynth pMSynth;
private int[] voices = new int[15];
private bool first = true;
void NoteOn(byte pitch, byte velocity)
{
}
void NoteOn(float pitch, float velocity, int midiVoice)
{
int? voice = pMSynth.NoteOn(pitch, velocity);
if (voice == null)
Debug.Log("No voices available");
else
voices[midiVoice] = (int)voice;
}
void OnAudioFilterRead(float[] data, int channels)
{
if (first)
{
NoteOn(440f, 1, 0);
/*
NoteOn(98.00f, 127, 0);
NoteOn(220.00f, 127, 0);
NoteOn(261.63f, 127, 0);
NoteOn(329.63f, 127, 0);
NoteOn(392.00f, 127, 0);
NoteOn(493.88f, 127, 0);
NoteOn(587.33f, 127, 0);
*/
first = false;
}
}
}