001/* 002 * Title: CoreMIDI4J 003 * Description: Core MIDI Device Provider for Java on OS X 004 * Copyright: Copyright (c) 2015-2016 005 * Company: x.factory Librarians 006 * 007 * @author Derek Cook 008 * 009 * CoreMIDI4J is an open source Service Provider Interface for supporting external MIDI devices on MAC OS X 010 * 011 * CREDITS - This library uses principles established by OSXMIDI4J, but converted so it operates at the JNI level with no additional libraries required 012 * 013 */ 014 015package uk.co.xfactorylibrarians.coremidi4j; 016 017import javax.sound.midi.MidiDevice; 018 019/** 020 * CoreMidiDeviceInfo class 021 * 022 */ 023 024public class CoreMidiDeviceInfo extends MidiDevice.Info { 025 026 private final String deviceName; // OS X Device Name 027 private final int deviceReference; // OS X Device Reference 028 private final int deviceUniqueID; // OS X Device UID 029 030 private final String entityName; // OS X Entity Name 031 private final int entityReference; // OS X Entity Reference 032 private final int entityUniqueID; // OS X Entity UID 033 034 private final String endPointName; // OS X Endpoint Name 035 private final int endPointReference; // OS X Endpoint Reference 036 private final int endPointUniqueID; // OS X Endpoint UID 037 038 /** 039 * Substitutes a default value if the value is null 040 * 041 * @param value The value which may be null 042 * @param fallback The value to use if value is null 043 * 044 * @return The value string, or the fallback string if the value is null 045 * 046 */ 047 048 private static String defaultForNull(final String value, final String fallback) { 049 050 if (value == null) { 051 052 return fallback; 053 054 } 055 056 return value; 057 058 } 059 060 /** 061 * Constructs a CoreMidiDeviceInfo object from the parameters 062 * 063 * @param name The name of the device 064 * @param vendor The manufacturer of the device 065 * @param description A description of the device 066 * @param version The version number of the device driver 067 * @param deviceName The raw name of the device 068 * @param deviceReference The device reference 069 * @param deviceUniqueID The OS X unique identifier for the device 070 * @param entityName The raw name of the entity 071 * @param entityReference The entity reference 072 * @param entityUniqueID The OS X unique identifier for the entity 073 * @param endPointName The raw name of the end point 074 * @param endPointReference The end point reference 075 * @param endPointUniqueID The OS X unique identifier for the end point 076 * 077 */ 078 079 public CoreMidiDeviceInfo(final String name, 080 final String vendor, 081 final String description, 082 final String version, 083 final String deviceName, 084 final int deviceReference, 085 final int deviceUniqueID, 086 final String entityName, 087 final int entityReference, 088 final int entityUniqueID, 089 final String endPointName, 090 final int endPointReference, 091 final int endPointUniqueID) { 092 093 super("CoreMIDI4J - " + name, defaultForNull(vendor, "Unknown vendor"), defaultForNull(description, name), version); 094 095 this.deviceName = deviceName; 096 this.deviceReference = deviceReference; 097 this.deviceUniqueID = deviceUniqueID; 098 this.entityName = entityName; 099 this.entityReference = entityReference; 100 this.entityUniqueID = entityUniqueID; 101 this.endPointName = endPointName; 102 this.endPointReference = endPointReference; 103 this.endPointUniqueID = endPointUniqueID; 104 105 } 106 107 /** 108 * Gets a string describing the device 109 * 110 * @return A string describing the device 111 * 112 */ 113 114 public String getInformationString() { 115 116 return getVendor() + ": " + getName(); 117 118 } 119 120 /** 121 * Gets the endPoint name 122 * 123 * @return the endPoint name 124 * 125 */ 126 127 public String getEndPointName() { 128 129 return endPointName; 130 131 } 132 133 /** 134 * Gets the endPointReference value 135 * 136 * @return the endPointReference value 137 * 138 */ 139 140 public int getEndPointReference() { 141 142 return endPointReference; 143 144 } 145 146 /** 147 * Gets the OS X unique identifier for the end point 148 * 149 * @return The OS X unique identifier for the end point 150 * 151 */ 152 153 public int getEndPointUniqueID() { 154 155 return endPointUniqueID; 156 157 } 158 /** 159 * Replaced by getdeviceUniqueID, getEndpointUniqueID. 160 * 161 * @return Endpoint Reference UniqueId 162 */ 163 @Deprecated 164 public int getUniqueID() { 165 return endPointUniqueID; 166 } 167 /** 168 * Gets the entity name 169 * 170 * @return the entity name 171 * 172 */ 173 174 public String getEntityName() { 175 176 return endPointName; 177 178 } 179 180 /** 181 * Gets the entityReference value 182 * 183 * @return the entityReference value 184 * 185 */ 186 187 public int getEntityReference() { 188 189 return entityReference; 190 191 } 192 193 /** 194 * Gets the OS X unique identifier for the entity 195 * 196 * @return The OS X unique identifier for the entity 197 * 198 */ 199 200 public int getEntityUniqueID() { 201 202 return entityUniqueID; 203 204 } 205 206 /** 207 * Gets the device name 208 * 209 * @return the device name 210 * 211 */ 212 213 public String getDeviceName() { 214 215 return deviceName; 216 217 } 218 219 /** 220 * Gets the deviceReference value 221 * 222 * @return the deviceReference value 223 * 224 */ 225 226 public int getDeviceReference() { 227 228 return deviceReference; 229 230 } 231 232 /** 233 * Gets the OS X unique identifier for the device 234 * 235 * @return The OS X unique identifier for the device 236 * 237 */ 238 239 public int getdeviceUniqueID() { 240 241 return deviceUniqueID; 242 243 } 244 245}