AlsaMidiSequencerDevice.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /* AlsaMidiSequencerDevice.java -- The ALSA MIDI sequencer device
  2. Copyright (C) 2005, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.javax.sound.midi.alsa;
  32. import java.io.IOException;
  33. import java.io.InputStream;
  34. import javax.sound.midi.ControllerEventListener;
  35. import javax.sound.midi.InvalidMidiDataException;
  36. import javax.sound.midi.MetaEventListener;
  37. import javax.sound.midi.MidiUnavailableException;
  38. import javax.sound.midi.Receiver;
  39. import javax.sound.midi.Sequence;
  40. import javax.sound.midi.Sequencer;
  41. import javax.sound.midi.Track;
  42. import javax.sound.midi.Transmitter;
  43. /**
  44. * The ALSA MIDI sequencer device. This is a singleton device.
  45. *
  46. * @author green@redhat.com
  47. *
  48. */
  49. public class AlsaMidiSequencerDevice implements Sequencer
  50. {
  51. // The singleton instance.
  52. public final static AlsaMidiSequencerDevice instance = new AlsaMidiSequencerDevice();
  53. // A pointer to a native chunk of memory
  54. private long nativeState;
  55. // The sequence to process
  56. private Sequence sequence;
  57. /**
  58. * A private constructor. There should only be one instance of this
  59. * device.
  60. */
  61. private AlsaMidiSequencerDevice()
  62. {
  63. super();
  64. }
  65. /**
  66. * Return the sequencer singleton.
  67. *
  68. * @return the sequencer singleton
  69. */
  70. public static AlsaMidiSequencerDevice getInstance()
  71. {
  72. return instance;
  73. }
  74. /* (non-Javadoc)
  75. * @see javax.sound.midi.Sequencer#setSequence(javax.sound.midi.Sequence)
  76. */
  77. public void setSequence(Sequence seq) throws InvalidMidiDataException
  78. {
  79. sequence = seq;
  80. }
  81. /* (non-Javadoc)
  82. * @see javax.sound.midi.Sequencer#setSequence(java.io.InputStream)
  83. */
  84. public void setSequence(InputStream istream) throws IOException,
  85. InvalidMidiDataException
  86. {
  87. // TODO Auto-generated method stub
  88. }
  89. /* (non-Javadoc)
  90. * @see javax.sound.midi.Sequencer#getSequence()
  91. */
  92. public Sequence getSequence()
  93. {
  94. return sequence;
  95. }
  96. /* (non-Javadoc)
  97. * @see javax.sound.midi.Sequencer#start()
  98. */
  99. public void start()
  100. {
  101. // TODO Auto-generated method stub
  102. }
  103. /* (non-Javadoc)
  104. * @see javax.sound.midi.Sequencer#stop()
  105. */
  106. public void stop()
  107. {
  108. // TODO Auto-generated method stub
  109. }
  110. /* (non-Javadoc)
  111. * @see javax.sound.midi.Sequencer#isRunning()
  112. */
  113. public boolean isRunning()
  114. {
  115. // TODO Auto-generated method stub
  116. return false;
  117. }
  118. /* (non-Javadoc)
  119. * @see javax.sound.midi.Sequencer#startRecording()
  120. */
  121. public void startRecording()
  122. {
  123. // TODO Auto-generated method stub
  124. }
  125. /* (non-Javadoc)
  126. * @see javax.sound.midi.Sequencer#stopRecording()
  127. */
  128. public void stopRecording()
  129. {
  130. // TODO Auto-generated method stub
  131. }
  132. /* (non-Javadoc)
  133. * @see javax.sound.midi.Sequencer#isRecording()
  134. */
  135. public boolean isRecording()
  136. {
  137. // TODO Auto-generated method stub
  138. return false;
  139. }
  140. /* (non-Javadoc)
  141. * @see javax.sound.midi.Sequencer#recordEnable(javax.sound.midi.Track, int)
  142. */
  143. public void recordEnable(Track track, int channel)
  144. {
  145. // TODO Auto-generated method stub
  146. }
  147. /* (non-Javadoc)
  148. * @see javax.sound.midi.Sequencer#recordDisable(javax.sound.midi.Track)
  149. */
  150. public void recordDisable(Track track)
  151. {
  152. // TODO Auto-generated method stub
  153. }
  154. /* (non-Javadoc)
  155. * @see javax.sound.midi.Sequencer#getTempoInBPM()
  156. */
  157. public float getTempoInBPM()
  158. {
  159. // TODO Auto-generated method stub
  160. return 0;
  161. }
  162. /* (non-Javadoc)
  163. * @see javax.sound.midi.Sequencer#setTempoInBPM(float)
  164. */
  165. public void setTempoInBPM(float bpm)
  166. {
  167. // TODO Auto-generated method stub
  168. }
  169. /* (non-Javadoc)
  170. * @see javax.sound.midi.Sequencer#getTempoInMPQ()
  171. */
  172. public float getTempoInMPQ()
  173. {
  174. // TODO Auto-generated method stub
  175. return 0;
  176. }
  177. /* (non-Javadoc)
  178. * @see javax.sound.midi.Sequencer#setTempoInMPQ(float)
  179. */
  180. public void setTempoInMPQ(float mpq)
  181. {
  182. // TODO Auto-generated method stub
  183. }
  184. /* (non-Javadoc)
  185. * @see javax.sound.midi.Sequencer#setTempoFactor(float)
  186. */
  187. public void setTempoFactor(float factor)
  188. {
  189. // TODO Auto-generated method stub
  190. }
  191. /* (non-Javadoc)
  192. * @see javax.sound.midi.Sequencer#getTempoFactor()
  193. */
  194. public float getTempoFactor()
  195. {
  196. // TODO Auto-generated method stub
  197. return 0;
  198. }
  199. /* (non-Javadoc)
  200. * @see javax.sound.midi.Sequencer#getTickLength()
  201. */
  202. public long getTickLength()
  203. {
  204. // TODO Auto-generated method stub
  205. return 0;
  206. }
  207. /* (non-Javadoc)
  208. * @see javax.sound.midi.Sequencer#getTickPosition()
  209. */
  210. public long getTickPosition()
  211. {
  212. // TODO Auto-generated method stub
  213. return 0;
  214. }
  215. /* (non-Javadoc)
  216. * @see javax.sound.midi.Sequencer#setTickPosition(long)
  217. */
  218. public void setTickPosition(long tick)
  219. {
  220. // TODO Auto-generated method stub
  221. }
  222. /* (non-Javadoc)
  223. * @see javax.sound.midi.Sequencer#getMicrosecondLength()
  224. */
  225. public long getMicrosecondLength()
  226. {
  227. // TODO Auto-generated method stub
  228. return 0;
  229. }
  230. /* (non-Javadoc)
  231. * @see javax.sound.midi.Sequencer#getMicrosecondPosition()
  232. */
  233. public long getMicrosecondPosition()
  234. {
  235. // TODO Auto-generated method stub
  236. return 0;
  237. }
  238. /* (non-Javadoc)
  239. * @see javax.sound.midi.Sequencer#setMicrosecondPosition(long)
  240. */
  241. public void setMicrosecondPosition(long microsecond)
  242. {
  243. // TODO Auto-generated method stub
  244. }
  245. /* (non-Javadoc)
  246. * @see javax.sound.midi.Sequencer#setMasterSyncMode(javax.sound.midi.Sequencer.SyncMode)
  247. */
  248. public void setMasterSyncMode(SyncMode sync)
  249. {
  250. // TODO Auto-generated method stub
  251. }
  252. /* (non-Javadoc)
  253. * @see javax.sound.midi.Sequencer#getMasterSyncMode()
  254. */
  255. public SyncMode getMasterSyncMode()
  256. {
  257. // TODO Auto-generated method stub
  258. return null;
  259. }
  260. /* (non-Javadoc)
  261. * @see javax.sound.midi.Sequencer#getMasterSyncModes()
  262. */
  263. public SyncMode[] getMasterSyncModes()
  264. {
  265. // TODO Auto-generated method stub
  266. return null;
  267. }
  268. /* (non-Javadoc)
  269. * @see javax.sound.midi.Sequencer#setSlaveSyncMode(javax.sound.midi.Sequencer.SyncMode)
  270. */
  271. public void setSlaveSyncMode(SyncMode sync)
  272. {
  273. // TODO Auto-generated method stub
  274. }
  275. /* (non-Javadoc)
  276. * @see javax.sound.midi.Sequencer#getSlaveSyncMode()
  277. */
  278. public SyncMode getSlaveSyncMode()
  279. {
  280. // TODO Auto-generated method stub
  281. return null;
  282. }
  283. /* (non-Javadoc)
  284. * @see javax.sound.midi.Sequencer#getSlaveSyncModes()
  285. */
  286. public SyncMode[] getSlaveSyncModes()
  287. {
  288. // TODO Auto-generated method stub
  289. return null;
  290. }
  291. /* (non-Javadoc)
  292. * @see javax.sound.midi.Sequencer#setTrackMute(int, boolean)
  293. */
  294. public void setTrackMute(int track, boolean mute)
  295. {
  296. // TODO Auto-generated method stub
  297. }
  298. /* (non-Javadoc)
  299. * @see javax.sound.midi.Sequencer#getTrackMute(int)
  300. */
  301. public boolean getTrackMute(int track)
  302. {
  303. // TODO Auto-generated method stub
  304. return false;
  305. }
  306. /* (non-Javadoc)
  307. * @see javax.sound.midi.Sequencer#setTrackSolo(int, boolean)
  308. */
  309. public void setTrackSolo(int track, boolean solo)
  310. {
  311. // TODO Auto-generated method stub
  312. }
  313. /* (non-Javadoc)
  314. * @see javax.sound.midi.Sequencer#getTrackSolo(int)
  315. */
  316. public boolean getTrackSolo(int track)
  317. {
  318. // TODO Auto-generated method stub
  319. return false;
  320. }
  321. /* (non-Javadoc)
  322. * @see javax.sound.midi.Sequencer#addMetaEventListener(javax.sound.midi.MetaEventListener)
  323. */
  324. public boolean addMetaEventListener(MetaEventListener listener)
  325. {
  326. // TODO Auto-generated method stub
  327. return false;
  328. }
  329. /* (non-Javadoc)
  330. * @see javax.sound.midi.Sequencer#removeMetaEventListener(javax.sound.midi.MetaEventListener)
  331. */
  332. public void removeMetaEventListener(MetaEventListener listener)
  333. {
  334. // TODO Auto-generated method stub
  335. }
  336. /* (non-Javadoc)
  337. * @see javax.sound.midi.Sequencer#addControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
  338. */
  339. public int[] addControllerEventListener(ControllerEventListener listener,
  340. int[] controllers)
  341. {
  342. // TODO Auto-generated method stub
  343. return null;
  344. }
  345. /* (non-Javadoc)
  346. * @see javax.sound.midi.Sequencer#removeControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
  347. */
  348. public int[] removeControllerEventListener(ControllerEventListener listener,
  349. int[] controllers)
  350. {
  351. // TODO Auto-generated method stub
  352. return null;
  353. }
  354. /* (non-Javadoc)
  355. * @see javax.sound.midi.MidiDevice#getDeviceInfo()
  356. */
  357. public Info getDeviceInfo()
  358. {
  359. // TODO Auto-generated method stub
  360. return null;
  361. }
  362. /* (non-Javadoc)
  363. * @see javax.sound.midi.MidiDevice#open()
  364. */
  365. public void open() throws MidiUnavailableException
  366. {
  367. synchronized(this)
  368. {
  369. // Check to see if we're open already.
  370. if (nativeState != 0)
  371. return;
  372. nativeState = open_();
  373. }
  374. }
  375. /**
  376. * Allocate the native state object, and open the sequencer.
  377. *
  378. * @return a long representation of a pointer to the nativeState.
  379. */
  380. private native long open_();
  381. /**
  382. * Close the sequencer and free the native state object.
  383. */
  384. private native void close_(long nativeState);
  385. /* (non-Javadoc)
  386. * @see javax.sound.midi.MidiDevice#close()
  387. */
  388. public void close()
  389. {
  390. synchronized(this)
  391. {
  392. close_(nativeState);
  393. nativeState = 0;
  394. }
  395. }
  396. /* (non-Javadoc)
  397. * @see javax.sound.midi.MidiDevice#isOpen()
  398. */
  399. public boolean isOpen()
  400. {
  401. synchronized(this)
  402. {
  403. return (nativeState != 0);
  404. }
  405. }
  406. /* (non-Javadoc)
  407. * @see javax.sound.midi.MidiDevice#getMaxReceivers()
  408. */
  409. public int getMaxReceivers()
  410. {
  411. return -1;
  412. }
  413. /* (non-Javadoc)
  414. * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
  415. */
  416. public int getMaxTransmitters()
  417. {
  418. return -1;
  419. }
  420. /* (non-Javadoc)
  421. * @see javax.sound.midi.MidiDevice#getReceiver()
  422. */
  423. public Receiver getReceiver() throws MidiUnavailableException
  424. {
  425. // TODO Auto-generated method stub
  426. return null;
  427. }
  428. /* (non-Javadoc)
  429. * @see javax.sound.midi.MidiDevice#getTransmitter()
  430. */
  431. public Transmitter getTransmitter() throws MidiUnavailableException
  432. {
  433. // TODO Auto-generated method stub
  434. return null;
  435. }
  436. }