Initial Commit
This commit is contained in:
parent
480f897bd0
commit
6aad2c2b99
42 changed files with 2397 additions and 0 deletions
8
Assets/Plugins.meta
Normal file
8
Assets/Plugins.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28ce6a0332a799d49876506c0ac1c283
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Linux.meta
Normal file
8
Assets/Plugins/Linux.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6f5080a4efe3d24081d6d73df1f6a60
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Linux/libportmidi.so
Normal file
BIN
Assets/Plugins/Linux/libportmidi.so
Normal file
Binary file not shown.
110
Assets/Plugins/Linux/libportmidi.so.meta
Normal file
110
Assets/Plugins/Linux/libportmidi.so.meta
Normal file
|
@ -0,0 +1,110 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 22e72e9afa5ab6e4399d010a48e8572a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 0
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Mac.meta
Normal file
8
Assets/Plugins/Mac.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a425b391f01c8894aa43b87c20214852
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Mac/libportmidi.dylib
Normal file
BIN
Assets/Plugins/Mac/libportmidi.dylib
Normal file
Binary file not shown.
7
Assets/Plugins/Mac/libportmidi.dylib.meta
Normal file
7
Assets/Plugins/Mac/libportmidi.dylib.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cc1e4960e482b2844b08013a26acb81e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Windows.meta
Normal file
8
Assets/Plugins/Windows.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db0ac4acc0f608449b230965b6888368
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Windows/portmidi.dll
Normal file
BIN
Assets/Plugins/Windows/portmidi.dll
Normal file
Binary file not shown.
110
Assets/Plugins/Windows/portmidi.dll.meta
Normal file
110
Assets/Plugins/Windows/portmidi.dll.meta
Normal file
|
@ -0,0 +1,110 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d8e64f45c558d542a7a304008255864
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude WebGL: 0
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scenes.meta
Normal file
8
Assets/Scenes.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e7fe0c5f8be97b4da570761a250a274
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
209
Assets/Scenes/SampleScene.unity
Normal file
209
Assets/Scenes/SampleScene.unity
Normal file
|
@ -0,0 +1,209 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 3
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 0
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 10
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ShowResolutionOverlay: 1
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 519420032}
|
||||
- component: {fileID: 519420031}
|
||||
- component: {fileID: 519420029}
|
||||
- component: {fileID: 519420030}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &519420029
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
--- !u!114 &519420030
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 55b2b2654c9faf64991e77f9882bdb0a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!20 &519420031
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 2
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_GateFitMode: 2
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 0
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 0
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &519420032
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
7
Assets/Scenes/SampleScene.unity.meta
Normal file
7
Assets/Scenes/SampleScene.unity.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd506f344a3065a4a8fd96d938c61f93
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts.meta
Normal file
8
Assets/Scripts.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e1af15aad36e56439bfb00f3ab8d9ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
165
Assets/Scripts/NativeMethods.cs
Normal file
165
Assets/Scripts/NativeMethods.cs
Normal file
|
@ -0,0 +1,165 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
namespace PortMidi
|
||||
{
|
||||
public static unsafe class NativeMethods
|
||||
{
|
||||
public const string NativeLibrary = "portmidi";
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern PmError Pm_Initialize();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_Terminate", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern PmError Pm_Terminate();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pt_Start", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pt_Start(int a,int b,int c);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pt_Stop", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void Pt_Stop();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_CountDevices", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pm_CountDevices();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_GetErrorText", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern string Pm_GetErrorText(PmError error);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_GetDefaultInputDeviceID", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pm_GetDefaultInputDeviceID();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_GetDefaultOutputDeviceID", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pm_GetDefaultOutputDeviceID();
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_GetDeviceInfo", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr Pm_GetDeviceInfo(int id);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_OpenOutput", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern PmError Pm_OpenOutput(IntPtr* stream, int outputDeviceID, IntPtr outputDriverInfo, int bufferSize, IntPtr time_proc, IntPtr time_info, int latency);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_Close", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern PmError Pm_Close(IntPtr stream);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pm_Write", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern PmError Pm_Write(IntPtr stream, PmEvent* buffer, int length);
|
||||
|
||||
[DllImport(NativeLibrary, EntryPoint = "Pt_Time", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pt_Time();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PmError error = Pm_Initialize();
|
||||
if (error != 0)
|
||||
{
|
||||
throw new Exception(ConvertToError(error));
|
||||
}
|
||||
Pt_Start(1, 0, 0);
|
||||
}
|
||||
|
||||
public static void Terminate()
|
||||
{
|
||||
Pt_Stop();
|
||||
PmError error = Pm_Terminate();
|
||||
if (error != 0)
|
||||
{
|
||||
throw new Exception(ConvertToError(error));
|
||||
}
|
||||
}
|
||||
|
||||
public static int CountDevices()
|
||||
{
|
||||
return Pm_CountDevices();
|
||||
}
|
||||
|
||||
public static string ConvertToError(PmError error)
|
||||
{
|
||||
return Pm_GetErrorText(error);
|
||||
}
|
||||
|
||||
public static PmDeviceInfo Info(int deviceID)
|
||||
{
|
||||
return Marshal.PtrToStructure<PmDeviceInfo>(Pm_GetDeviceInfo(deviceID));
|
||||
}
|
||||
|
||||
public static int DefaultInputDeviceID()
|
||||
{
|
||||
return Pm_GetDefaultInputDeviceID();
|
||||
}
|
||||
|
||||
public static int DefaultOutputDeviceID()
|
||||
{
|
||||
return Pm_GetDefaultOutputDeviceID();
|
||||
}
|
||||
|
||||
public static Stream NewOutputStream(int deviceID, int bufferSize, int latency)
|
||||
{
|
||||
IntPtr pmStream = IntPtr.Zero;
|
||||
|
||||
PmDeviceInfo deviceInfo = Info(deviceID);
|
||||
if (deviceInfo.output != 1) throw new Exception("Selected DeviceID is not an output");
|
||||
|
||||
PmError error = Pm_OpenOutput(&pmStream, deviceID, IntPtr.Zero, bufferSize, IntPtr.Zero, IntPtr.Zero, latency);
|
||||
if (error != 0)
|
||||
{
|
||||
throw new Exception(ConvertToError(error));
|
||||
}
|
||||
|
||||
return new Stream(deviceID, pmStream, StreamType.OUTPUT, bufferSize);
|
||||
}
|
||||
|
||||
public static void Write(Stream stream, Event[] events)
|
||||
{
|
||||
int size = events.Length;
|
||||
if (size > stream.bufferSize)
|
||||
{
|
||||
throw new Exception("Out of Stream");
|
||||
}
|
||||
|
||||
if (stream.streamType != StreamType.OUTPUT)
|
||||
{
|
||||
throw new Exception("Stream is not an Output Buffer");
|
||||
}
|
||||
|
||||
PmEvent[] buffer = new PmEvent[size];
|
||||
for (int i = 0; i < events.Length; i++)
|
||||
{
|
||||
PmEvent e = new PmEvent();
|
||||
Event evt = events[i];
|
||||
e.timestamp = evt.Timestamp;
|
||||
e.message = (((evt.Data2 << 16) & 0xFF0000) | ((evt.Data1 << 8) & 0xFF00) | (evt.Status & 0xFF));
|
||||
buffer[i] = e;
|
||||
}
|
||||
fixed (PmEvent* p = &buffer[0])
|
||||
{
|
||||
PmError error = Pm_Write(stream.pmStream, p, size);
|
||||
if (error != 0)
|
||||
{
|
||||
throw new Exception(ConvertToError(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteShort(Stream stream, int status, int data1, int data2)
|
||||
{
|
||||
Event evt = new Event();
|
||||
evt.Timestamp = Pt_Time();
|
||||
evt.Status = status;
|
||||
evt.Data1 = data1;
|
||||
evt.Data2 = data2;
|
||||
Write(stream, new Event[] { evt });
|
||||
}
|
||||
|
||||
public static void Close(Stream stream)
|
||||
{
|
||||
if (stream.pmStream == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PmError error = Pm_Close(stream.pmStream);
|
||||
if (error != 0)
|
||||
{
|
||||
throw new Exception(ConvertToError(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/NativeMethods.cs.meta
Normal file
11
Assets/Scripts/NativeMethods.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1dd5cd477f43c7479d7f99989927621
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/PortMidiEnum.cs
Normal file
29
Assets/Scripts/PortMidiEnum.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PortMidi
|
||||
{
|
||||
public enum PmError : int
|
||||
{
|
||||
pmNoError = 0,
|
||||
pmNoData = 0,
|
||||
pmGotData = 1,
|
||||
pmHostError = -10000,
|
||||
pmInvalidDeviceId,
|
||||
pmInsufficientMemory,
|
||||
pmBufferTooSmall,
|
||||
pmBufferOverflow,
|
||||
pmBadPtr,
|
||||
pmInternalError,
|
||||
pmBufferMaxSize
|
||||
}
|
||||
|
||||
public enum StreamType : int
|
||||
{
|
||||
OUTPUT = 0,
|
||||
INPUT = 1
|
||||
}
|
||||
}
|
11
Assets/Scripts/PortMidiEnum.cs.meta
Normal file
11
Assets/Scripts/PortMidiEnum.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d14b20f71d5dd6f44a9e6e20ba805e38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/PortMidiStruct.cs
Normal file
44
Assets/Scripts/PortMidiStruct.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
|
||||
namespace PortMidi
|
||||
{
|
||||
public struct PmDeviceInfo
|
||||
{
|
||||
public int structVersion;
|
||||
public string interf;
|
||||
public string name;
|
||||
public int input;
|
||||
public int output;
|
||||
public int opened;
|
||||
}
|
||||
|
||||
public struct PmEvent
|
||||
{
|
||||
public int message;
|
||||
public int timestamp;
|
||||
}
|
||||
|
||||
public struct Event
|
||||
{
|
||||
public int Timestamp;
|
||||
public int Status;
|
||||
public int Data1;
|
||||
public int Data2;
|
||||
}
|
||||
|
||||
public struct Stream
|
||||
{
|
||||
public int DeviceID;
|
||||
public IntPtr pmStream;
|
||||
public readonly StreamType streamType;
|
||||
public readonly int bufferSize;
|
||||
|
||||
public Stream(int DeviceID, IntPtr pmStream, StreamType streamType, int bufferSize)
|
||||
{
|
||||
this.streamType = streamType;
|
||||
this.DeviceID = DeviceID;
|
||||
this.pmStream = pmStream;
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PortMidiStruct.cs.meta
Normal file
11
Assets/Scripts/PortMidiStruct.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 71c219e3c5723c1449ecce4a18fc1ed9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
Assets/Test.cs
Normal file
55
Assets/Test.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using PortMidi;
|
||||
|
||||
public class Test : MonoBehaviour
|
||||
{
|
||||
Stream stream;
|
||||
float previousTime;
|
||||
bool state = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
NativeMethods.Initialize();
|
||||
Debug.Log("Default Input : " + NativeMethods.DefaultInputDeviceID());
|
||||
Debug.Log("Default Output : " + NativeMethods.DefaultOutputDeviceID());
|
||||
Debug.Log("Number of device " + NativeMethods.CountDevices());
|
||||
for (int i = 0; i < NativeMethods.CountDevices(); i++)
|
||||
{
|
||||
PmDeviceInfo deviceInfo = NativeMethods.Info(i);
|
||||
Debug.Log(" [" + i + "](" + deviceInfo.structVersion + "," + deviceInfo.interf + "," + deviceInfo.name + "," + deviceInfo.input + "," + deviceInfo.output + "," + deviceInfo.opened + ")");
|
||||
}
|
||||
stream = NativeMethods.NewOutputStream(3, 1024, 0);
|
||||
previousTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
NativeMethods.Close(stream);
|
||||
NativeMethods.Terminate();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Time.realtimeSinceStartup - previousTime >= 1)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
NativeMethods.WriteShort(stream, 0x90, 60, 100);
|
||||
NativeMethods.WriteShort(stream, 0x90, 64, 100);
|
||||
NativeMethods.WriteShort(stream, 0x90, 67, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeMethods.WriteShort(stream, 0x80, 60, 100);
|
||||
NativeMethods.WriteShort(stream, 0x80, 64, 100);
|
||||
NativeMethods.WriteShort(stream, 0x80, 67, 100);
|
||||
}
|
||||
state = !state;
|
||||
previousTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Test.cs.meta
Normal file
11
Assets/Test.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 55b2b2654c9faf64991e77f9882bdb0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue