home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / tclmidi / part08 < prev    next >
Internet Message Format  |  1994-07-21  |  63KB

  1. From: durian@boogie.com (Mike Durian)
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i116:  tclmidi - A language for manipulating MIDI files, v2.0, Part08/14
  4. Date: 21 Jul 1994 19:27:19 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <30n3p7$765@sparky.sterling.com>
  9. X-Md4-Signature: 858c7bfafc8f225597cc841c91a53844
  10.  
  11. Submitted-by: durian@boogie.com (Mike Durian)
  12. Posting-number: Volume 43, Issue 116
  13. Archive-name: tclmidi/part08
  14. Environment: POSIX, (BSDI, NetBSD, LINUX, SVR4 for optional driver), C++, TCL
  15. Supersedes: tclm: Volume 37, Issue 43-47
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  tclmidi-2.0/TclmInterp.C tclmidi-2.0/drivers/BSD/midivar.h
  22. #   tclmidi-2.0/drivers/LINUX/quad.h
  23. #   tclmidi-2.0/events/MetaChanPrefix.C tclmidi-2.0/events/MetaSMPTE.C
  24. #   tclmidi-2.0/events/MetaSeqSpec.C tclmidi-2.0/events/MetaTime.C
  25. #   tclmidi-2.0/events/MetaUnknown.C tclmidi-2.0/events/Note.h
  26. #   tclmidi-2.0/events/SystemExcl.C tclmidi-2.0/man/midievents.n
  27. #   tclmidi-2.0/rb/README
  28. # Wrapped by kent@sparky on Thu Jul 21 19:05:16 1994
  29. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  30. echo If this archive is complete, you will see the following message:
  31. echo '          "shar: End of archive 8 (of 14)."'
  32. if test -f 'tclmidi-2.0/TclmInterp.C' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'tclmidi-2.0/TclmInterp.C'\"
  34. else
  35.   echo shar: Extracting \"'tclmidi-2.0/TclmInterp.C'\" \(4921 characters\)
  36.   sed "s/^X//" >'tclmidi-2.0/TclmInterp.C' <<'END_OF_FILE'
  37. X/*-
  38. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  39. X *
  40. X * Redistribution and use in source and binary forms, with or without
  41. X * modification, are permitted provided that the following conditions
  42. X * are met:
  43. X * 1. Redistributions of source code must retain the above copyright
  44. X *    notice, this list of conditions and the following disclaimer.
  45. X * 2. Redistributions in binary form must reproduce the above copyright
  46. X *    notice, this list of conditions and the following disclaimer in the
  47. X *    documentation and/or other materials provided with the distribution.
  48. X * 3. All advertising materials mentioning features or use of this software
  49. X *    must display the following acknowledgement:
  50. X *    This product includes software developed by Michael B. Durian.
  51. X * 4. The name of the the Author may be used to endorse or promote 
  52. X *    products derived from this software without specific prior written 
  53. X *    permission.
  54. X *
  55. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  56. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  57. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  58. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  59. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65. X * SUCH DAMAGE.
  66. X */
  67. X#include <assert.h>
  68. X#include <strstream.h>
  69. X#include "TclmInterp.h"
  70. X
  71. XTclmInterp::TclmInterp() : current_song(0), next_event(0), device(0)
  72. X{
  73. X
  74. X    Tcl_InitHashTable(&hash_table, TCL_STRING_KEYS);
  75. X}
  76. X
  77. XTclmInterp::TclmInterp(const TclmInterp &ti)
  78. X{
  79. X    ostrstream *buf;
  80. X    Tcl_HashSearch search;
  81. X    Tcl_HashEntry *entry, *new_entry;
  82. X    Song *song, *new_song;
  83. X    char *key;
  84. X    int repeat;
  85. X
  86. X    device = ti.device;
  87. X    current_song = 0;
  88. X    Tcl_InitHashTable(&hash_table, TCL_STRING_KEYS);
  89. X    entry = Tcl_FirstHashEntry((Tcl_HashTable *)&ti.hash_table, &search);
  90. X    while (entry != 0) {
  91. X        song = (Song *)Tcl_GetHashValue(entry);
  92. X
  93. X        // make a new entry
  94. X        buf = new ostrstream;
  95. X        *buf << "song" << current_song << ends;
  96. X        key = buf->str();
  97. X        new_entry = Tcl_CreateHashEntry(&hash_table, key, &repeat);
  98. X        new_song = new Song(*song);
  99. X        assert(new_song != 0);
  100. X        Tcl_SetHashValue(new_entry, new_song);
  101. X        delete key;
  102. X        delete buf;
  103. X        current_song++;
  104. X
  105. X        // find next entry
  106. X        entry = Tcl_NextHashEntry(&search);
  107. X    }
  108. X}
  109. X
  110. XTclmInterp::~TclmInterp()
  111. X{
  112. X    Tcl_HashSearch search;
  113. X    Tcl_HashEntry *entry;
  114. X    Song *song;
  115. X
  116. X    // delete existing entries
  117. X    entry = Tcl_FirstHashEntry(&hash_table, &search);
  118. X    while (entry != 0) {
  119. X        song = (Song *)Tcl_GetHashValue(entry);
  120. X        delete song;
  121. X        Tcl_DeleteHashEntry(entry);
  122. X        entry = Tcl_NextHashEntry(&search);
  123. X    }
  124. X
  125. X    // delete table
  126. X    Tcl_DeleteHashTable(&hash_table);
  127. X
  128. X}
  129. X
  130. XSong *
  131. XTclmInterp::GetSong(const char *key) const
  132. X{
  133. X    Tcl_HashEntry *entry;
  134. X
  135. X    entry = Tcl_FindHashEntry((Tcl_HashTable *)&hash_table, (char *)key);
  136. X    if (entry == 0)
  137. X        return (0);
  138. X    return ((Song *)Tcl_GetHashValue(entry));
  139. X}
  140. X
  141. Xchar *
  142. XTclmInterp::AddSong(const Song *song)
  143. X{
  144. X    ostrstream buf;
  145. X    char *key;
  146. X    Tcl_HashEntry *entry;
  147. X    int repeat;
  148. X
  149. X    buf << "song" << current_song++ << ends;
  150. X    key = buf.str();
  151. X    entry = Tcl_CreateHashEntry(&hash_table, key, &repeat);
  152. X    Tcl_SetHashValue(entry, song);
  153. X    return (key);
  154. X}
  155. X
  156. Xint
  157. XTclmInterp::DeleteSong(const char *key)
  158. X{
  159. X    Tcl_HashEntry *entry;
  160. X    Song *song;
  161. X
  162. X    entry = Tcl_FindHashEntry(&hash_table, (char *)key);
  163. X    if (entry == 0)
  164. X        return (0);
  165. X    song = (Song *)Tcl_GetHashValue(entry);
  166. X    delete song;
  167. X    Tcl_DeleteHashEntry(entry);
  168. X    return (1);
  169. X}
  170. X
  171. Xvoid
  172. XTclmInterp::SetMidiDevice(MidiDevice *dev)
  173. X{
  174. X
  175. X    device = dev;
  176. X}
  177. X
  178. XMidiDevice *
  179. XTclmInterp::GetMidiDevice(void) const
  180. X{
  181. X
  182. X    return (device);
  183. X}
  184. X
  185. XTclmInterp &
  186. XTclmInterp::operator=(const TclmInterp &ti)
  187. X{
  188. X    ostrstream *buf;
  189. X    Tcl_HashSearch search;
  190. X    Tcl_HashEntry *entry, *new_entry;
  191. X    Song *song, *new_song;
  192. X    char *key;
  193. X    int repeat;
  194. X
  195. X    // delete existing entries
  196. X    entry = Tcl_FirstHashEntry(&hash_table, &search);
  197. X    while (entry != 0) {
  198. X        song = (Song *)Tcl_GetHashValue(entry);
  199. X        delete song;
  200. X        Tcl_DeleteHashEntry(entry);
  201. X        entry = Tcl_NextHashEntry(&search);
  202. X    }
  203. X
  204. X    current_song = 0;
  205. X    entry = Tcl_FirstHashEntry((Tcl_HashTable *)&ti.hash_table, &search);
  206. X    while (entry != 0) {
  207. X        song = (Song *)Tcl_GetHashValue(entry);
  208. X
  209. X        // make a new entry
  210. X        buf = new ostrstream;
  211. X        *buf << "song" << current_song << ends;
  212. X        key = buf->str();
  213. X        new_entry = Tcl_CreateHashEntry(&hash_table, key, &repeat);
  214. X        new_song = new Song(*song);
  215. X        assert(new_song != 0);
  216. X        Tcl_SetHashValue(new_entry, new_song);
  217. X        delete key;
  218. X        delete buf;
  219. X        current_song++;
  220. X
  221. X        // find next entry
  222. X        entry = Tcl_NextHashEntry(&search);
  223. X    }
  224. X
  225. X    device = ti.device;
  226. X    return (*this);
  227. X}
  228. END_OF_FILE
  229.   if test 4921 -ne `wc -c <'tclmidi-2.0/TclmInterp.C'`; then
  230.     echo shar: \"'tclmidi-2.0/TclmInterp.C'\" unpacked with wrong size!
  231.   fi
  232.   # end of 'tclmidi-2.0/TclmInterp.C'
  233. fi
  234. if test -f 'tclmidi-2.0/drivers/BSD/midivar.h' -a "${1}" != "-c" ; then 
  235.   echo shar: Will not clobber existing file \"'tclmidi-2.0/drivers/BSD/midivar.h'\"
  236. else
  237.   echo shar: Extracting \"'tclmidi-2.0/drivers/BSD/midivar.h'\" \(4491 characters\)
  238.   sed "s/^X//" >'tclmidi-2.0/drivers/BSD/midivar.h' <<'END_OF_FILE'
  239. X/*-
  240. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  241. X *
  242. X * Redistribution and use in source and binary forms, with or without
  243. X * modification, are permitted provided that the following conditions
  244. X * are met:
  245. X * 1. Redistributions of source code must retain the above copyright
  246. X *    notice, this list of conditions and the following disclaimer.
  247. X * 2. Redistributions in binary form must reproduce the above copyright
  248. X *    notice, this list of conditions and the following disclaimer in the
  249. X *    documentation and/or other materials provided with the distribution.
  250. X * 3. All advertising materials mentioning features or use of this software
  251. X *    must display the following acknowledgement:
  252. X *    This product includes software developed by Michael B. Durian.
  253. X * 4. The name of the the Author may be used to endorse or promote 
  254. X *    products derived from this software without specific prior written 
  255. X *    permission.
  256. X *
  257. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  258. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  259. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  260. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  261. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  262. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  263. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  264. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  265. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  266. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  267. X * SUCH DAMAGE.
  268. X */
  269. X/*
  270. X * midi port offsets
  271. X */
  272. X#define    MIDI_DATA            0
  273. X#define    MIDI_STATUS            1
  274. X#define    MIDI_COMMAND            1
  275. X
  276. X
  277. X/*
  278. X * midi data transfer status bits
  279. X */
  280. X#define    MIDI_RDY_RCV            (1 << 6)
  281. X#define    MIDI_DATA_AVL            (1 << 7)
  282. X
  283. X/*
  284. X * midi status flags
  285. X */
  286. X#define MIDI_UNAVAILABLE    (1 << 0) /* not in uart mode */
  287. X#define MIDI_READING        (1 << 1) /* open for reading */
  288. X#define MIDI_WRITING        (1 << 2) /* open for writing */
  289. X#define MIDI_CALLBACK_ISSUED    (1 << 3) /* waiting for a timer to expire */
  290. X#define MIDI_RD_BLOCK        (1 << 4) /* read will block */
  291. X#define MIDI_WR_BLOCK        (1 << 5) /* write will block */
  292. X#define MIDI_WR_ABORT        (1 << 6) /* write should abort */
  293. X#define MIDI_OPEN        (1 << 7) /* device is open */
  294. X#define MIDI_FLUSH_SLEEP    (1 << 8) /* blocking on flush */
  295. X#define MIDI_RD_SLEEP        (1 << 9) /* blocking on read */
  296. X#define MIDI_WR_SLEEP        (1 << 10) /* blocking on write */
  297. X#define MIDI_BUFFER_SLEEP    (1 << 11) /* blocking on buffer */
  298. X#define MIDI_NEED_ACK        (1 << 12) /* command needs and ack */
  299. X#define MIDI_ASYNC        (1 << 13) /* send sigios */
  300. X#define MIDI_SENDIO        (1 << 14) /* a sigio should be send at low h2o */
  301. X#define MIDI_THRU        (1 << 15) /* pass in port to out port? */
  302. X#define MIDI_RECONPLAY        (1 << 16) /* don't record until we start to play */
  303. X
  304. X/*
  305. X * These are the various input data states
  306. X */
  307. Xtypedef enum {START, NEEDDATA1, NEEDDATA2, SYSEX, SYSTEM1, SYSTEM2} InputState;
  308. X
  309. X/*
  310. X * midi command values
  311. X */
  312. X#define MIDI_RESET            0xff
  313. X#define MIDI_UART            0x3f
  314. X#define MIDI_ACK            0xfe
  315. X#define MIDI_TRIES            20000
  316. X
  317. X/*
  318. X * most events are short, so we use the static array,
  319. X * but occationally we get a long event (sysex) and
  320. X * we dynamically allocate that
  321. X */
  322. X#define STYNAMIC_SIZE 4
  323. X#define STYNAMIC_ALLOC 256
  324. X
  325. Xstruct stynamic {
  326. X    short    allocated;
  327. X    short    len;
  328. X    u_char    datas[4];
  329. X    u_char    *datad;
  330. X};
  331. X
  332. X/*
  333. X * data from the board that hasn't formed a complete event yet
  334. X */
  335. Xstruct partial_event {
  336. X    struct    stynamic event;        /* the data */
  337. X    struct    timeval time;        /* when the event occured */
  338. X                    /* will use ticks with 4.4 */
  339. X    long    tempo;            /* tempo setting when event arrived */
  340. X    InputState    state;        /* what we are expecting next */
  341. X    u_char    rs;            /* the midi running state */
  342. X};
  343. X
  344. X/*
  345. X * the internal representation of an event
  346. X */
  347. Xtypedef enum {NORMAL, TEMPO, TIMESIG, SYSX} EventType;
  348. X
  349. Xstruct event {
  350. X    u_long    time;        /* time until event in kernel clicks */
  351. X    long    tempo;        /*
  352. X                 * not used in play events, but contains
  353. X                 * the tempo setting current when the
  354. X                 * incoming event arrived.  Used for
  355. X                 * convert kernel ticks to smf ticks
  356. X                 */
  357. X    EventType    type;
  358. X    struct    stynamic data;
  359. X};
  360. X
  361. X/*
  362. X * A event queue, used for both incoming and outgoing
  363. X */
  364. X#define MIDI_Q_SIZE 150
  365. X#define MIDI_LOW_WATER 40
  366. X
  367. Xstruct event_queue {
  368. X    int    count;
  369. X    struct    event events[MIDI_Q_SIZE];
  370. X    struct    event *end;
  371. X    struct    event *head;
  372. X    struct    event *tail;
  373. X};
  374. END_OF_FILE
  375.   if test 4491 -ne `wc -c <'tclmidi-2.0/drivers/BSD/midivar.h'`; then
  376.     echo shar: \"'tclmidi-2.0/drivers/BSD/midivar.h'\" unpacked with wrong size!
  377.   fi
  378.   # end of 'tclmidi-2.0/drivers/BSD/midivar.h'
  379. fi
  380. if test -f 'tclmidi-2.0/drivers/LINUX/quad.h' -a "${1}" != "-c" ; then 
  381.   echo shar: Will not clobber existing file \"'tclmidi-2.0/drivers/LINUX/quad.h'\"
  382. else
  383.   echo shar: Extracting \"'tclmidi-2.0/drivers/LINUX/quad.h'\" \(4330 characters\)
  384.   sed "s/^X//" >'tclmidi-2.0/drivers/LINUX/quad.h' <<'END_OF_FILE'
  385. X/*-
  386. X * Copyright (c) 1992 The Regents of the University of California.
  387. X * All rights reserved.
  388. X *
  389. X * This software was developed by the Computer Systems Engineering group
  390. X * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  391. X * contributed to Berkeley.
  392. X *
  393. X * Redistribution and use in source and binary forms, with or without
  394. X * modification, are permitted provided that the following conditions
  395. X * are met:
  396. X * 1. Redistributions of source code must retain the above copyright
  397. X *    notice, this list of conditions and the following disclaimer.
  398. X * 2. Redistributions in binary form must reproduce the above copyright
  399. X *    notice, this list of conditions and the following disclaimer in the
  400. X *    documentation and/or other materials provided with the distribution.
  401. X * 3. All advertising materials mentioning features or use of this software
  402. X *    must display the following acknowledgement:
  403. X *    This product includes software developed by the University of
  404. X *    California, Berkeley and its contributors.
  405. X * 4. Neither the name of the University nor the names of its contributors
  406. X *    may be used to endorse or promote products derived from this software
  407. X *    without specific prior written permission.
  408. X *
  409. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  410. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  411. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  412. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  413. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  414. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  415. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  416. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  417. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  418. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  419. X * SUCH DAMAGE.
  420. X *
  421. X *    @(#)quad.h    5.9 (Berkeley) 7/28/92
  422. X */
  423. X
  424. X/*
  425. X * Quad arithmetic.
  426. X *
  427. X * This library makes the following assumptions:
  428. X *
  429. X *  - The type long long (aka quad_t) exists.
  430. X *
  431. X *  - A quad variable is exactly twice as long as `long'.
  432. X *
  433. X *  - The machine's arithmetic is two's complement.
  434. X *
  435. X * This library can provide 128-bit arithmetic on a machine with 128-bit
  436. X * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines
  437. X * with 48-bit longs.
  438. X */
  439. X
  440. X#ifdef __linux__
  441. X    /* Linux support added by L.Georgiev */
  442. X
  443. X    typedef   signed long long int    quad_t;
  444. X    typedef unsigned long long int    u_quad_t;
  445. X
  446. X    #define _QUAD_LOWWORD    0
  447. X    #define _QUAD_HIGHWORD    1
  448. X
  449. X    #include <sys/cdefs.h>
  450. X#else
  451. X    #include <cdefs.h>
  452. X#endif
  453. X#include <sys/types.h>
  454. X#include <limits.h>
  455. X
  456. X/*
  457. X * Depending on the desired operation, we view a `long long' (aka quad_t) in
  458. X * one or more of the following formats.
  459. X */
  460. Xunion uu {
  461. X    quad_t    q;        /* as a (signed) quad */
  462. X    quad_t    uq;        /* as an unsigned quad */
  463. X    long    sl[2];        /* as two signed longs */
  464. X    u_long    ul[2];        /* as two unsigned longs */
  465. X};
  466. X
  467. X/*
  468. X * Define high and low longwords.
  469. X */
  470. X#define    H        _QUAD_HIGHWORD
  471. X#define    L        _QUAD_LOWWORD
  472. X
  473. X/*
  474. X * Total number of bits in a quad_t and in the pieces that make it up.
  475. X * These are used for shifting, and also below for halfword extraction
  476. X * and assembly.
  477. X */
  478. X#define    QUAD_BITS    (sizeof(quad_t) * CHAR_BIT)
  479. X#define    LONG_BITS    (sizeof(long) * CHAR_BIT)
  480. X#define    HALF_BITS    (sizeof(long) * CHAR_BIT / 2)
  481. X
  482. X/*
  483. X * Extract high and low shortwords from longword, and move low shortword of
  484. X * longword to upper half of long, i.e., produce the upper longword of
  485. X * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be u_long.)
  486. X *
  487. X * These are used in the multiply code, to split a longword into upper
  488. X * and lower halves, and to reassemble a product as a quad_t, shifted left
  489. X * (sizeof(long)*CHAR_BIT/2).
  490. X */
  491. X#define    HHALF(x)    ((x) >> HALF_BITS)
  492. X#define    LHALF(x)    ((x) & ((1 << HALF_BITS) - 1))
  493. X#define    LHUP(x)        ((x) << HALF_BITS)
  494. X
  495. Xextern u_quad_t __qdivrem __P((u_quad_t u, u_quad_t v, u_quad_t *rem));
  496. X
  497. X/*
  498. X * XXX
  499. X * Compensate for gcc 1 vs gcc 2.  Gcc 1 defines ?sh?di3's second argument
  500. X * as u_quad_t, while gcc 2 correctly uses int.  Unfortunately, we still use
  501. X * both compilers.
  502. X */
  503. X#if __GNUC__ >= 2
  504. Xtypedef unsigned int    qshift_t;
  505. X#else
  506. Xtypedef u_quad_t    qshift_t;
  507. X#endif
  508. END_OF_FILE
  509.   if test 4330 -ne `wc -c <'tclmidi-2.0/drivers/LINUX/quad.h'`; then
  510.     echo shar: \"'tclmidi-2.0/drivers/LINUX/quad.h'\" unpacked with wrong size!
  511.   fi
  512.   # end of 'tclmidi-2.0/drivers/LINUX/quad.h'
  513. fi
  514. if test -f 'tclmidi-2.0/events/MetaChanPrefix.C' -a "${1}" != "-c" ; then 
  515.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/MetaChanPrefix.C'\"
  516. else
  517.   echo shar: Extracting \"'tclmidi-2.0/events/MetaChanPrefix.C'\" \(4353 characters\)
  518.   sed "s/^X//" >'tclmidi-2.0/events/MetaChanPrefix.C' <<'END_OF_FILE'
  519. X/*-
  520. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  521. X *
  522. X * Redistribution and use in source and binary forms, with or without
  523. X * modification, are permitted provided that the following conditions
  524. X * are met:
  525. X * 1. Redistributions of source code must retain the above copyright
  526. X *    notice, this list of conditions and the following disclaimer.
  527. X * 2. Redistributions in binary form must reproduce the above copyright
  528. X *    notice, this list of conditions and the following disclaimer in the
  529. X *    documentation and/or other materials provided with the distribution.
  530. X * 3. All advertising materials mentioning features or use of this software
  531. X *    must display the following acknowledgement:
  532. X *    This product includes software developed by Michael B. Durian.
  533. X * 4. The name of the the Author may be used to endorse or promote 
  534. X *    products derived from this software without specific prior written 
  535. X *    permission.
  536. X *
  537. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  538. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  539. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  540. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  541. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  542. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  543. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  544. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  545. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  546. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  547. X * SUCH DAMAGE.
  548. X */
  549. X#include <assert.h>
  550. X#include <string.h>
  551. X
  552. X#include "MetaChanPrefix.h"
  553. X
  554. XMetaChannelPrefixEvent::MetaChannelPrefixEvent() : data(0), length(0L)
  555. X{
  556. X}
  557. X
  558. XMetaChannelPrefixEvent::MetaChannelPrefixEvent(unsigned long t,
  559. X    const unsigned char *dat, long len) : MetaEvent(t), length(len)
  560. X{
  561. X
  562. X    data = new unsigned char[len];
  563. X    assert(data != 0);
  564. X//    memmove(data, dat, len);
  565. X    memcpy(data, dat, len);
  566. X}
  567. X
  568. XMetaChannelPrefixEvent::MetaChannelPrefixEvent(const MetaChannelPrefixEvent &e) :
  569. X    MetaEvent(e), length(e.length)
  570. X{
  571. X
  572. X    data = new unsigned char[e.length];
  573. X    assert(data != 0);
  574. X//    memmove(data, e.data, e.length);
  575. X    memcpy(data, e.data, e.length);
  576. X}
  577. X
  578. XMetaChannelPrefixEvent::~MetaChannelPrefixEvent()
  579. X{
  580. X
  581. X    delete data;
  582. X}
  583. X
  584. Xvoid
  585. XMetaChannelPrefixEvent::SetData(const unsigned char *dat, long len)
  586. X{
  587. X
  588. X    if (data != 0)
  589. X        delete data;
  590. X    data = new unsigned char[len];
  591. X    assert(data != 0);
  592. X//    memmove(data, dat, len);
  593. X    memcpy(data, dat, len);
  594. X}
  595. X
  596. XMetaChannelPrefixEvent &
  597. XMetaChannelPrefixEvent::operator=(const MetaChannelPrefixEvent &e)
  598. X{
  599. X
  600. X    (MetaEvent)*this = (MetaEvent)e;
  601. X    if (data != 0)
  602. X        delete data;
  603. X    data = new unsigned char[e.length];
  604. X    length = e.length;
  605. X    assert(data != 0);
  606. X//    memmove(data, e.data, e.length);
  607. X    memcpy(data, e.data, e.length);
  608. X    return (*this);
  609. X}
  610. X
  611. Xchar *
  612. XMetaChannelPrefixEvent::GetEventStr(void) const
  613. X{
  614. X    ostrstream buf;
  615. X    char *tbuf;
  616. X    long i;
  617. X
  618. X    tbuf = MetaEvent::GetEventStr();
  619. X    buf << tbuf << " Data:";
  620. X    buf.setf(ios::showbase | ios::internal);
  621. X    for (i = 0; i < length; i++)
  622. X        buf << " " << hex << setw(4) << setfill('0') << (int)data[i];
  623. X    buf << ends;
  624. X    delete tbuf;
  625. X    return (buf.str());
  626. X}
  627. X
  628. Xconst char *
  629. XMetaChannelPrefixEvent::SMFRead(SMFTrack &t)
  630. X{
  631. X    const unsigned char *ptr;
  632. X
  633. X    if (data != 0)
  634. X        delete data;
  635. X    if ((length = t.GetVarValue()) == -1)
  636. X        return ("Incomplete MetaChannelPrefixEvent - bad length");
  637. X    data = new unsigned char[length];
  638. X    if (data == 0)
  639. X        return ("Out of memory");
  640. X    if ((ptr = t.GetData(length)) == 0)
  641. X        return ("Incomplete MetaChannelPrefixEvent - bad data");
  642. X    memcpy(data, ptr, length);
  643. X    return (0);
  644. X}
  645. X
  646. Xconst char *
  647. XMetaChannelPrefixEvent::SMFWrite(SMFTrack &t) const
  648. X{
  649. X
  650. X    if (!t.PutFixValue(length))
  651. X        return ("Out of memory");
  652. X    if (!t.PutData(data, length))
  653. X        return ("Out of memory");
  654. X    return (0);
  655. X}
  656. X
  657. Xint
  658. XMetaChannelPrefixEvent::Equal(const Event *e) const
  659. X{
  660. X    long i;
  661. X    MetaChannelPrefixEvent *eptr = (MetaChannelPrefixEvent *)e;
  662. X
  663. X    if (!MetaEvent::Equal(e))
  664. X        return (0);
  665. X    if (length != eptr->length)
  666. X        return (0);
  667. X    for (i = 0; i < length; i++)
  668. X        if (data[i] != eptr->data[i])
  669. X            return (0);
  670. X    return (1);
  671. X}
  672. X
  673. Xostream &
  674. Xoperator<<(ostream &os, const MetaChannelPrefixEvent &e)
  675. X{
  676. X    char *str;
  677. X
  678. X    os << (str = e.GetEventStr());
  679. X    delete str;
  680. X    return (os);
  681. X}
  682. END_OF_FILE
  683.   if test 4353 -ne `wc -c <'tclmidi-2.0/events/MetaChanPrefix.C'`; then
  684.     echo shar: \"'tclmidi-2.0/events/MetaChanPrefix.C'\" unpacked with wrong size!
  685.   fi
  686.   # end of 'tclmidi-2.0/events/MetaChanPrefix.C'
  687. fi
  688. if test -f 'tclmidi-2.0/events/MetaSMPTE.C' -a "${1}" != "-c" ; then 
  689.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/MetaSMPTE.C'\"
  690. else
  691.   echo shar: Extracting \"'tclmidi-2.0/events/MetaSMPTE.C'\" \(4375 characters\)
  692.   sed "s/^X//" >'tclmidi-2.0/events/MetaSMPTE.C' <<'END_OF_FILE'
  693. X/*-
  694. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  695. X *
  696. X * Redistribution and use in source and binary forms, with or without
  697. X * modification, are permitted provided that the following conditions
  698. X * are met:
  699. X * 1. Redistributions of source code must retain the above copyright
  700. X *    notice, this list of conditions and the following disclaimer.
  701. X * 2. Redistributions in binary form must reproduce the above copyright
  702. X *    notice, this list of conditions and the following disclaimer in the
  703. X *    documentation and/or other materials provided with the distribution.
  704. X * 3. All advertising materials mentioning features or use of this software
  705. X *    must display the following acknowledgement:
  706. X *    This product includes software developed by Michael B. Durian.
  707. X * 4. The name of the the Author may be used to endorse or promote 
  708. X *    products derived from this software without specific prior written 
  709. X *    permission.
  710. X *
  711. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  712. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  713. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  714. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  715. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  716. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  717. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  718. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  719. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  720. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  721. X * SUCH DAMAGE.
  722. X */
  723. X#include "MetaSMPTE.h"
  724. X
  725. XMetaSMPTEEvent::MetaSMPTEEvent() : hour(0), minute(0), second(0), frame(0),
  726. X    fractional_frame(0)
  727. X{
  728. X}
  729. X
  730. XMetaSMPTEEvent::MetaSMPTEEvent(unsigned long t, unsigned char h,
  731. X    unsigned char m, unsigned char s, unsigned char f, unsigned char ff) :
  732. X    MetaEvent(t), hour(h), minute(m), second(s), frame(f), fractional_frame(ff)
  733. X{
  734. X}
  735. X
  736. XMetaSMPTEEvent::MetaSMPTEEvent(const MetaSMPTEEvent &e) : MetaEvent(e),
  737. X    hour(e.hour), minute(e.minute), second(e.second), frame(e.frame),
  738. X    fractional_frame(e.fractional_frame)
  739. X{
  740. X}
  741. X
  742. XMetaSMPTEEvent &
  743. XMetaSMPTEEvent::operator=(const MetaSMPTEEvent &e)
  744. X{
  745. X
  746. X    (MetaEvent)*this = (MetaEvent)e;
  747. X    hour = e.hour;
  748. X    minute = e.minute;
  749. X    second = e.second;
  750. X    frame = e.frame;
  751. X    fractional_frame = e.fractional_frame;
  752. X    return (*this);
  753. X}
  754. X
  755. Xchar *
  756. XMetaSMPTEEvent::GetEventStr(void) const
  757. X{
  758. X    ostrstream buf;
  759. X    char *tbuf;
  760. X
  761. X    tbuf = MetaEvent::GetEventStr();
  762. X    buf << tbuf << " Hour: " << (int)hour << " Minute: " << (int)minute
  763. X        << " Second: " << (int)second << " Frame: " << (int)frame
  764. X        << " Fractional Frame: " << (int)fractional_frame << ends;
  765. X    delete tbuf;
  766. X    return (buf.str());
  767. X}
  768. X
  769. Xconst char *
  770. XMetaSMPTEEvent::SMFRead(SMFTrack &t)
  771. X{
  772. X    const unsigned char *ptr;
  773. X
  774. X    // get and throw away length
  775. X    if (t.GetVarValue() != 5)
  776. X        return ("Incomplete metaSMPTEEvent - bad length");
  777. X
  778. X    if ((ptr = t.GetByte()) == 0)
  779. X        return ("Incomplete MetaSMPTEEvent - missing hour");
  780. X    hour = *ptr;
  781. X    if ((ptr = t.GetByte()) == 0)
  782. X        return ("Incomplete MetaSMPTEEvent - missing minute");
  783. X    minute = *ptr;
  784. X    if ((ptr = t.GetByte()) == 0)
  785. X        return ("Incomplete MetaSMPTEEvent - missing second");
  786. X    second = *ptr;
  787. X    if ((ptr = t.GetByte()) == 0)
  788. X        return ("Incomplete MetaSMPTEEvent - missing frame");
  789. X    frame = *ptr;
  790. X    if ((ptr = t.GetByte()) == 0)
  791. X        return ("Incomplete MetaSMPTEEvent - missing fractional "
  792. X            "frame");
  793. X    fractional_frame = *ptr;
  794. X    return (0);
  795. X}
  796. X
  797. Xconst char *
  798. XMetaSMPTEEvent::SMFWrite(SMFTrack &t) const
  799. X{
  800. X
  801. X    if (!t.PutFixValue(5))
  802. X        return ("Out of memory");
  803. X    if (!t.PutByte(hour))
  804. X        return ("Out of memory");
  805. X    if (!t.PutByte(minute))
  806. X        return ("Out of memory");
  807. X    if (!t.PutByte(second))
  808. X        return ("Out of memory");
  809. X    if (!t.PutByte(frame))
  810. X        return ("Out of memory");
  811. X    if (!t.PutByte(fractional_frame))
  812. X        return ("Out of memory");
  813. X    return (0);
  814. X}
  815. X
  816. Xint
  817. XMetaSMPTEEvent::Equal(const Event *e) const
  818. X{
  819. X    MetaSMPTEEvent *eptr = (MetaSMPTEEvent *)e;
  820. X
  821. X    return (MetaEvent::Equal(e) && hour == eptr->hour &&
  822. X        minute == eptr->minute && second == eptr->second &&
  823. X        frame == eptr->frame &&
  824. X        fractional_frame == eptr->fractional_frame);
  825. X}
  826. X
  827. Xostream &
  828. Xoperator<<(ostream &os, const MetaSMPTEEvent &e)
  829. X{
  830. X    char *str;
  831. X
  832. X    os << (str = e.GetEventStr());
  833. X    delete str;
  834. X    return (os);
  835. X}
  836. END_OF_FILE
  837.   if test 4375 -ne `wc -c <'tclmidi-2.0/events/MetaSMPTE.C'`; then
  838.     echo shar: \"'tclmidi-2.0/events/MetaSMPTE.C'\" unpacked with wrong size!
  839.   fi
  840.   # end of 'tclmidi-2.0/events/MetaSMPTE.C'
  841. fi
  842. if test -f 'tclmidi-2.0/events/MetaSeqSpec.C' -a "${1}" != "-c" ; then 
  843.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/MetaSeqSpec.C'\"
  844. else
  845.   echo shar: Extracting \"'tclmidi-2.0/events/MetaSeqSpec.C'\" \(4428 characters\)
  846.   sed "s/^X//" >'tclmidi-2.0/events/MetaSeqSpec.C' <<'END_OF_FILE'
  847. X/*-
  848. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  849. X *
  850. X * Redistribution and use in source and binary forms, with or without
  851. X * modification, are permitted provided that the following conditions
  852. X * are met:
  853. X * 1. Redistributions of source code must retain the above copyright
  854. X *    notice, this list of conditions and the following disclaimer.
  855. X * 2. Redistributions in binary form must reproduce the above copyright
  856. X *    notice, this list of conditions and the following disclaimer in the
  857. X *    documentation and/or other materials provided with the distribution.
  858. X * 3. All advertising materials mentioning features or use of this software
  859. X *    must display the following acknowledgement:
  860. X *    This product includes software developed by Michael B. Durian.
  861. X * 4. The name of the the Author may be used to endorse or promote 
  862. X *    products derived from this software without specific prior written 
  863. X *    permission.
  864. X *
  865. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  866. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  867. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  868. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  869. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  870. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  871. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  872. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  873. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  874. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  875. X * SUCH DAMAGE.
  876. X */
  877. X#include <assert.h>
  878. X#include <string.h>
  879. X
  880. X#include "MetaSeqSpec.h"
  881. X
  882. XMetaSequencerSpecificEvent::MetaSequencerSpecificEvent() : data(0), length(0L)
  883. X{
  884. X}
  885. X
  886. XMetaSequencerSpecificEvent::MetaSequencerSpecificEvent(unsigned long t,
  887. X    const unsigned char *dat, long len) : MetaEvent(t), length(len)
  888. X{
  889. X
  890. X    data = new unsigned char[len];
  891. X    assert(data != 0);
  892. X//    memmove(data, dat, len);
  893. X    memcpy(data, dat, len);
  894. X}
  895. X
  896. XMetaSequencerSpecificEvent::MetaSequencerSpecificEvent(
  897. X    const MetaSequencerSpecificEvent &e) : MetaEvent(e), length(e.length)
  898. X{
  899. X
  900. X    data = new unsigned char[e.length];
  901. X    assert(data != 0);
  902. X//    memmove(data, e.data, e.length);
  903. X    memcpy(data, e.data, e.length);
  904. X}
  905. X
  906. XMetaSequencerSpecificEvent::~MetaSequencerSpecificEvent()
  907. X{
  908. X
  909. X    delete data;
  910. X}
  911. X
  912. Xvoid
  913. XMetaSequencerSpecificEvent::SetData(const unsigned char *dat, long len)
  914. X{
  915. X
  916. X    if (data != 0)
  917. X        delete data;
  918. X    data = new unsigned char[len];
  919. X    assert(data != 0);
  920. X//    memmove(data, dat, len);
  921. X    memcpy(data, dat, len);
  922. X}
  923. X
  924. XMetaSequencerSpecificEvent &
  925. XMetaSequencerSpecificEvent::operator=(const MetaSequencerSpecificEvent &e)
  926. X{
  927. X
  928. X    (MetaEvent)*this = (MetaEvent)e;
  929. X    if (data != 0)
  930. X        delete data;
  931. X    length = e.length;
  932. X    data = new unsigned char[e.length];
  933. X    assert(data != 0);
  934. X//    memmove(data, e.data, e.length);
  935. X    memcpy(data, e.data, e.length);
  936. X    return (*this);
  937. X}
  938. X
  939. Xchar *
  940. XMetaSequencerSpecificEvent::GetEventStr(void) const
  941. X{
  942. X    ostrstream buf;
  943. X    long i;
  944. X    char *tbuf;
  945. X
  946. X    tbuf =  MetaEvent::GetEventStr();
  947. X    buf << tbuf << " Data:";
  948. X    buf.setf(ios::showbase | ios::internal);
  949. X    for (i = 0; i < length; i++)
  950. X        buf << " " << hex << setw(4) << setfill('0') << (int)data[i];
  951. X    buf << ends;
  952. X    delete tbuf;
  953. X    return (buf.str());
  954. X}
  955. X
  956. Xconst char *
  957. XMetaSequencerSpecificEvent::SMFRead(SMFTrack &t)
  958. X{
  959. X    const unsigned char *ptr;
  960. X
  961. X    if (data != 0)
  962. X        delete data;
  963. X    if ((length = t.GetVarValue()) == -1)
  964. X        return ("Incomplete MetaSequenceSpecificEvent - bad length");
  965. X    data = new unsigned char[length];
  966. X    if (data == 0)
  967. X        return ("Out of memory");
  968. X    if ((ptr = t.GetData(length)) == 0)
  969. X        return ("Incomplete MetaSequencerSpecificEvent");
  970. X    memcpy(data, ptr, length);
  971. X    return (0);
  972. X}
  973. X
  974. Xconst char *
  975. XMetaSequencerSpecificEvent::SMFWrite(SMFTrack &t) const
  976. X{
  977. X
  978. X    if (!t.PutFixValue(length))
  979. X        return ("Out of memory");
  980. X    if (!t.PutData(data, length))
  981. X        return ("Out of memory");
  982. X    return (0);
  983. X}
  984. X
  985. Xint
  986. XMetaSequencerSpecificEvent::Equal(const Event *e) const
  987. X{
  988. X    long i;
  989. X    MetaSequencerSpecificEvent *eptr = (MetaSequencerSpecificEvent *)e;
  990. X
  991. X    if (!MetaEvent::Equal(e))
  992. X        return (0);
  993. X    if (length != eptr->length)
  994. X        return (0);
  995. X    for (i = 0; i < length; i++)
  996. X        if (data[i] != eptr->data[i])
  997. X            return (0);
  998. X    return (1);
  999. X}
  1000. X
  1001. Xostream &
  1002. Xoperator<<(ostream &os, const MetaSequencerSpecificEvent &e)
  1003. X{
  1004. X    char *str;
  1005. X
  1006. X    os << (str = e.GetEventStr());
  1007. X    delete str;
  1008. X    return (os);
  1009. X}
  1010. END_OF_FILE
  1011.   if test 4428 -ne `wc -c <'tclmidi-2.0/events/MetaSeqSpec.C'`; then
  1012.     echo shar: \"'tclmidi-2.0/events/MetaSeqSpec.C'\" unpacked with wrong size!
  1013.   fi
  1014.   # end of 'tclmidi-2.0/events/MetaSeqSpec.C'
  1015. fi
  1016. if test -f 'tclmidi-2.0/events/MetaTime.C' -a "${1}" != "-c" ; then 
  1017.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/MetaTime.C'\"
  1018. else
  1019.   echo shar: Extracting \"'tclmidi-2.0/events/MetaTime.C'\" \(4380 characters\)
  1020.   sed "s/^X//" >'tclmidi-2.0/events/MetaTime.C' <<'END_OF_FILE'
  1021. X/*-
  1022. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  1023. X *
  1024. X * Redistribution and use in source and binary forms, with or without
  1025. X * modification, are permitted provided that the following conditions
  1026. X * are met:
  1027. X * 1. Redistributions of source code must retain the above copyright
  1028. X *    notice, this list of conditions and the following disclaimer.
  1029. X * 2. Redistributions in binary form must reproduce the above copyright
  1030. X *    notice, this list of conditions and the following disclaimer in the
  1031. X *    documentation and/or other materials provided with the distribution.
  1032. X * 3. All advertising materials mentioning features or use of this software
  1033. X *    must display the following acknowledgement:
  1034. X *    This product includes software developed by Michael B. Durian.
  1035. X * 4. The name of the the Author may be used to endorse or promote 
  1036. X *    products derived from this software without specific prior written 
  1037. X *    permission.
  1038. X *
  1039. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  1040. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1041. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  1042. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  1043. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1044. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1045. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1046. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1047. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1048. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1049. X * SUCH DAMAGE.
  1050. X */
  1051. X#include "MetaTime.h"
  1052. X
  1053. XMetaTimeEvent::MetaTimeEvent() : numerator(4), denominator(4), clocks(24),
  1054. X    thirty_seconds(8)
  1055. X{
  1056. X}
  1057. X
  1058. XMetaTimeEvent::MetaTimeEvent(unsigned long time, unsigned char n,
  1059. X    unsigned char d, unsigned char c, unsigned char t) : MetaEvent(time),
  1060. X    numerator(n), denominator(d), clocks(c), thirty_seconds(t)
  1061. X{
  1062. X}
  1063. X
  1064. XMetaTimeEvent::MetaTimeEvent(const MetaTimeEvent &e) : MetaEvent(e),
  1065. X    numerator(e.numerator), denominator(e.denominator), clocks(e.clocks),
  1066. X    thirty_seconds(e.thirty_seconds)
  1067. X{
  1068. X}
  1069. X
  1070. XMetaTimeEvent &
  1071. XMetaTimeEvent::operator=(const MetaTimeEvent &e)
  1072. X{
  1073. X
  1074. X    (MetaEvent)*this = (MetaEvent)e;
  1075. X    numerator = e.numerator;
  1076. X    denominator = e.denominator;
  1077. X    clocks = e.clocks;
  1078. X    thirty_seconds = e.thirty_seconds;
  1079. X    return (*this);
  1080. X}
  1081. X
  1082. Xchar *
  1083. XMetaTimeEvent::GetEventStr(void) const
  1084. X{
  1085. X    ostrstream buf;
  1086. X    char *tbuf;
  1087. X
  1088. X    tbuf = MetaEvent::GetEventStr();
  1089. X    buf << tbuf << " Numerator: " << (int)numerator
  1090. X        << " Denominator: " << (int)denominator
  1091. X        << " Clocks Per Metronome Beat: " << (int)clocks
  1092. X        << " 32nd Notes Per Quarter Note: " << (int)thirty_seconds
  1093. X        << ends;
  1094. X    delete tbuf;
  1095. X    return (buf.str());
  1096. X}
  1097. X
  1098. Xconst char *
  1099. XMetaTimeEvent::SMFRead(SMFTrack &t)
  1100. X{
  1101. X    const unsigned char *ptr;
  1102. X    unsigned char i, powof2;
  1103. X
  1104. X    // get and throw away length
  1105. X    if (t.GetVarValue() != 4)
  1106. X        return ("Incomplete MetaTimeEvent - bad length");
  1107. X    if ((ptr = t.GetByte()) == 0)
  1108. X        return ("Incomplete MetaTimeEvent - missing numerator");
  1109. X    numerator = *ptr;
  1110. X    if ((ptr = t.GetByte()) == 0)
  1111. X        return ("Incomplete MetaTimeEvent - missing denominator");
  1112. X    powof2 = *ptr;
  1113. X    denominator = 1;
  1114. X    for (i = 0; i < powof2; i++)
  1115. X        denominator *= 2;
  1116. X    if ((ptr = t.GetByte()) == 0)
  1117. X        return ("Incomplete MetaTimeEvent - missing clocks");
  1118. X    clocks = *ptr;
  1119. X    if ((ptr = t.GetByte()) == 0)
  1120. X        return ("Incomplete MetaTimeEvent - missing 32nds");
  1121. X    thirty_seconds = *ptr;
  1122. X    return (0);
  1123. X}
  1124. X
  1125. Xconst char *
  1126. XMetaTimeEvent::SMFWrite(SMFTrack &t) const
  1127. X{
  1128. X    unsigned char i, powof2;
  1129. X
  1130. X    if (!t.PutFixValue(4))
  1131. X        return ("Out of memory");
  1132. X    if (!t.PutByte(numerator))
  1133. X        return ("Out of memory");
  1134. X    for (i = 0, powof2 = 1; powof2 <= denominator; powof2 *= 2, i++);
  1135. X    i--;
  1136. X    if (!t.PutByte(i))
  1137. X        return ("Out of memory");
  1138. X    if (!t.PutByte(clocks))
  1139. X        return ("Out of memory");
  1140. X    if (!t.PutByte(thirty_seconds))
  1141. X        return ("Out of memory");
  1142. X    return (0);
  1143. X}
  1144. X
  1145. Xint
  1146. XMetaTimeEvent::Equal(const Event *e) const
  1147. X{
  1148. X    MetaTimeEvent *eptr = (MetaTimeEvent *)e;
  1149. X
  1150. X    return (MetaEvent::Equal(e) && numerator == eptr->numerator &&
  1151. X        denominator == eptr->denominator && clocks == eptr->clocks &&
  1152. X        thirty_seconds == eptr->thirty_seconds);
  1153. X}
  1154. X
  1155. Xostream &
  1156. Xoperator<<(ostream &os, const MetaTimeEvent &e)
  1157. X{
  1158. X    char *str;
  1159. X
  1160. X    os << (str = e.GetEventStr());
  1161. X    delete str;
  1162. X    return (os);
  1163. X}
  1164. END_OF_FILE
  1165.   if test 4380 -ne `wc -c <'tclmidi-2.0/events/MetaTime.C'`; then
  1166.     echo shar: \"'tclmidi-2.0/events/MetaTime.C'\" unpacked with wrong size!
  1167.   fi
  1168.   # end of 'tclmidi-2.0/events/MetaTime.C'
  1169. fi
  1170. if test -f 'tclmidi-2.0/events/MetaUnknown.C' -a "${1}" != "-c" ; then 
  1171.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/MetaUnknown.C'\"
  1172. else
  1173.   echo shar: Extracting \"'tclmidi-2.0/events/MetaUnknown.C'\" \(4474 characters\)
  1174.   sed "s/^X//" >'tclmidi-2.0/events/MetaUnknown.C' <<'END_OF_FILE'
  1175. X/*-
  1176. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  1177. X *
  1178. X * Redistribution and use in source and binary forms, with or without
  1179. X * modification, are permitted provided that the following conditions
  1180. X * are met:
  1181. X * 1. Redistributions of source code must retain the above copyright
  1182. X *    notice, this list of conditions and the following disclaimer.
  1183. X * 2. Redistributions in binary form must reproduce the above copyright
  1184. X *    notice, this list of conditions and the following disclaimer in the
  1185. X *    documentation and/or other materials provided with the distribution.
  1186. X * 3. All advertising materials mentioning features or use of this software
  1187. X *    must display the following acknowledgement:
  1188. X *    This product includes software developed by Michael B. Durian.
  1189. X * 4. The name of the the Author may be used to endorse or promote 
  1190. X *    products derived from this software without specific prior written 
  1191. X *    permission.
  1192. X *
  1193. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  1194. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1195. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  1196. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  1197. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1198. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1199. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1200. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1201. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1202. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1203. X * SUCH DAMAGE.
  1204. X */
  1205. X#include <assert.h>
  1206. X#include <string.h>
  1207. X
  1208. X#include "MetaUnknown.h"
  1209. X
  1210. XMetaUnknownEvent::MetaUnknownEvent() : data(0), length(0L), type(0x60)
  1211. X{
  1212. X}
  1213. X
  1214. XMetaUnknownEvent::MetaUnknownEvent(unsigned char t) : type(t), data(0),
  1215. X    length(0L)
  1216. X{
  1217. X}
  1218. X
  1219. XMetaUnknownEvent::MetaUnknownEvent(unsigned long t, const unsigned char *dat,
  1220. X    long len, unsigned char ty) : MetaEvent(t), length(len), type(ty)
  1221. X{
  1222. X
  1223. X    data = new unsigned char[len];
  1224. X    assert(data != 0);
  1225. X//    memmove(data, dat, len);
  1226. X    memcpy(data, dat, len);
  1227. X}
  1228. X
  1229. XMetaUnknownEvent::MetaUnknownEvent(const MetaUnknownEvent &e) : MetaEvent(e),
  1230. X    length(e.length), type(e.type)
  1231. X{
  1232. X
  1233. X    data = new unsigned char[e.length];
  1234. X    assert(data != 0);
  1235. X//    memmove(data, e.data, e.length);
  1236. X    memcpy(data, e.data, e.length);
  1237. X}
  1238. X
  1239. XMetaUnknownEvent::~MetaUnknownEvent()
  1240. X{
  1241. X
  1242. X    delete data;
  1243. X}
  1244. X
  1245. Xvoid
  1246. XMetaUnknownEvent::SetData(const unsigned char *dat, long len)
  1247. X{
  1248. X
  1249. X    if (data != 0)
  1250. X        delete data;
  1251. X    data = new unsigned char[len];
  1252. X    assert(data != 0);
  1253. X//    memmove(data, dat, len);
  1254. X    memcpy(data, dat, len);
  1255. X}
  1256. X
  1257. XMetaUnknownEvent &
  1258. XMetaUnknownEvent::operator=(const MetaUnknownEvent &e)
  1259. X{
  1260. X
  1261. X    (MetaEvent)*this = (MetaEvent)e;
  1262. X    if (data != 0)
  1263. X        delete data;
  1264. X    length = e.length;
  1265. X    type = e.type;
  1266. X    data = new unsigned char[e.length];
  1267. X    assert(data != 0);
  1268. X//    memmove(data, e.data, e.length);
  1269. X    memcpy(data, e.data, e.length);
  1270. X    return (*this);
  1271. X}
  1272. X
  1273. Xchar *
  1274. XMetaUnknownEvent::GetEventStr(void) const
  1275. X{
  1276. X    ostrstream buf;
  1277. X    long i;
  1278. X    char *tbuf;
  1279. X
  1280. X    tbuf =  MetaEvent::GetEventStr();
  1281. X    buf.setf(ios::showbase | ios::internal);
  1282. X    buf << tbuf << " Type: " << hex << setw(4) << setfill('0') << (int)type
  1283. X        << " Data:";
  1284. X    for (i = 0; i < length; i++)
  1285. X        buf << " " << hex << setw(4) << setfill('0') << (int)data[i];
  1286. X    buf << ends;
  1287. X    delete tbuf;
  1288. X    return (buf.str());
  1289. X}
  1290. X
  1291. Xconst char *
  1292. XMetaUnknownEvent::SMFRead(SMFTrack &t)
  1293. X{
  1294. X    const unsigned char *ptr;
  1295. X
  1296. X    if (data != 0)
  1297. X        delete data;
  1298. X    if ((length = t.GetVarValue()) == -1)
  1299. X        return ("Incomplete MetaUnknownEvent - bad length");
  1300. X    data = new unsigned char[length];
  1301. X    if (data == 0)
  1302. X        return ("Out of memory");
  1303. X    if ((ptr = t.GetData(length)) == 0)
  1304. X        return ("Incomplete MetaUnknownEvent");
  1305. X    memcpy(data, ptr, length);
  1306. X    return (0);
  1307. X}
  1308. X
  1309. Xconst char *
  1310. XMetaUnknownEvent::SMFWrite(SMFTrack &t) const
  1311. X{
  1312. X
  1313. X    if (!t.PutFixValue(length))
  1314. X        return ("Out of memory");
  1315. X    if (!t.PutData(data, length))
  1316. X        return ("Out of memory");
  1317. X    return (0);
  1318. X}
  1319. X
  1320. Xint
  1321. XMetaUnknownEvent::Equal(const Event *e) const
  1322. X{
  1323. X    long i;
  1324. X    MetaUnknownEvent *eptr = (MetaUnknownEvent *)e;
  1325. X
  1326. X    if (!MetaEvent::Equal(e))
  1327. X        return (0);
  1328. X    if (length != eptr->length)
  1329. X        return (0);
  1330. X    if (type != eptr->type)
  1331. X        return (0);
  1332. X    for (i = 0; i < length; i++)
  1333. X        if (data[i] != eptr->data[i])
  1334. X            return (0);
  1335. X    return (1);
  1336. X}
  1337. X
  1338. Xostream &
  1339. Xoperator<<(ostream &os, const MetaUnknownEvent &e)
  1340. X{
  1341. X    char *str;
  1342. X
  1343. X    os << (str = e.GetEventStr());
  1344. X    delete str;
  1345. X    return (os);
  1346. X}
  1347. END_OF_FILE
  1348.   if test 4474 -ne `wc -c <'tclmidi-2.0/events/MetaUnknown.C'`; then
  1349.     echo shar: \"'tclmidi-2.0/events/MetaUnknown.C'\" unpacked with wrong size!
  1350.   fi
  1351.   # end of 'tclmidi-2.0/events/MetaUnknown.C'
  1352. fi
  1353. if test -f 'tclmidi-2.0/events/Note.h' -a "${1}" != "-c" ; then 
  1354.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/Note.h'\"
  1355. else
  1356.   echo shar: Extracting \"'tclmidi-2.0/events/Note.h'\" \(2843 characters\)
  1357.   sed "s/^X//" >'tclmidi-2.0/events/Note.h' <<'END_OF_FILE'
  1358. X/*-
  1359. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  1360. X *
  1361. X * Redistribution and use in source and binary forms, with or without
  1362. X * modification, are permitted provided that the following conditions
  1363. X * are met:
  1364. X * 1. Redistributions of source code must retain the above copyright
  1365. X *    notice, this list of conditions and the following disclaimer.
  1366. X * 2. Redistributions in binary form must reproduce the above copyright
  1367. X *    notice, this list of conditions and the following disclaimer in the
  1368. X *    documentation and/or other materials provided with the distribution.
  1369. X * 3. All advertising materials mentioning features or use of this software
  1370. X *    must display the following acknowledgement:
  1371. X *    This product includes software developed by Michael B. Durian.
  1372. X * 4. The name of the the Author may be used to endorse or promote 
  1373. X *    products derived from this software without specific prior written 
  1374. X *    permission.
  1375. X *
  1376. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  1377. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1378. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  1379. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  1380. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1381. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1382. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1383. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1384. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1385. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1386. X * SUCH DAMAGE.
  1387. X */
  1388. X#ifndef NOTEEVENT_H
  1389. X#define NOTEEVENT_H
  1390. X
  1391. X#include "NormalEvent.h"
  1392. X
  1393. Xclass NoteEvent : public NormalEvent {
  1394. X    friend ostream &operator<<(ostream &os, const NoteEvent &e);
  1395. Xpublic:
  1396. X    NoteEvent();
  1397. X    NoteEvent(unsigned long t, unsigned char chan, unsigned char pit,
  1398. X        unsigned char vel, const NoteEvent *np = 0);
  1399. X    NoteEvent(const NoteEvent &e);
  1400. X    virtual Event *Dup(void) const {return (new NoteEvent(*this));}
  1401. X
  1402. X    virtual EventType GetType(void) const {return (NOTE);}
  1403. X    virtual char *GetTypeStr(void) const {return ("NoteEvent");}
  1404. X    virtual char *GetEventStr(void) const;
  1405. X    unsigned char GetPitch(void) const {return (pitch);}
  1406. X    unsigned char GetVelocity(void) const {return (velocity);}
  1407. X    NoteEvent *GetNotePair(void) const {return (note_pair);}
  1408. X
  1409. X    void SetPitch(unsigned char pit) {pitch = pit;}
  1410. X    void SetVelocity(unsigned char vel) {velocity = vel;}
  1411. X    void SetNotePair(NoteEvent *np) {note_pair = np;}
  1412. X
  1413. X    NoteEvent &operator=(const NoteEvent &e);
  1414. X
  1415. X    virtual const char *SMFRead(SMFTrack &t);
  1416. X    virtual const char *SMFWrite(SMFTrack &t) const;
  1417. Xprotected:
  1418. X    virtual int Equal(const Event *e) const;
  1419. Xprivate:
  1420. X    unsigned char pitch;
  1421. X    unsigned char velocity;
  1422. X    NoteEvent *note_pair;
  1423. X};
  1424. X#endif
  1425. END_OF_FILE
  1426.   if test 2843 -ne `wc -c <'tclmidi-2.0/events/Note.h'`; then
  1427.     echo shar: \"'tclmidi-2.0/events/Note.h'\" unpacked with wrong size!
  1428.   fi
  1429.   # end of 'tclmidi-2.0/events/Note.h'
  1430. fi
  1431. if test -f 'tclmidi-2.0/events/SystemExcl.C' -a "${1}" != "-c" ; then 
  1432.   echo shar: Will not clobber existing file \"'tclmidi-2.0/events/SystemExcl.C'\"
  1433. else
  1434.   echo shar: Extracting \"'tclmidi-2.0/events/SystemExcl.C'\" \(4546 characters\)
  1435.   sed "s/^X//" >'tclmidi-2.0/events/SystemExcl.C' <<'END_OF_FILE'
  1436. X/*-
  1437. X * Copyright (c) 1993, 1994 Michael B. Durian.  All rights reserved.
  1438. X *
  1439. X * Redistribution and use in source and binary forms, with or without
  1440. X * modification, are permitted provided that the following conditions
  1441. X * are met:
  1442. X * 1. Redistributions of source code must retain the above copyright
  1443. X *    notice, this list of conditions and the following disclaimer.
  1444. X * 2. Redistributions in binary form must reproduce the above copyright
  1445. X *    notice, this list of conditions and the following disclaimer in the
  1446. X *    documentation and/or other materials provided with the distribution.
  1447. X * 3. All advertising materials mentioning features or use of this software
  1448. X *    must display the following acknowledgement:
  1449. X *    This product includes software developed by Michael B. Durian.
  1450. X * 4. The name of the the Author may be used to endorse or promote 
  1451. X *    products derived from this software without specific prior written 
  1452. X *    permission.
  1453. X *
  1454. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  1455. X * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1456. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
  1457. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  1458. X * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1459. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1460. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1461. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1462. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1463. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1464. X * SUCH DAMAGE.
  1465. X */
  1466. X#include <assert.h>
  1467. X#include <string.h>
  1468. X
  1469. X#include "SystemExcl.h"
  1470. X
  1471. XSystemExclusiveEvent::SystemExclusiveEvent() : data(0), length(0L),
  1472. X    continued(0)
  1473. X{
  1474. X}
  1475. X
  1476. XSystemExclusiveEvent::SystemExclusiveEvent(unsigned char c) : data(0),
  1477. X    length(0L), continued(c)
  1478. X{
  1479. X}
  1480. X
  1481. XSystemExclusiveEvent::SystemExclusiveEvent(unsigned long t,
  1482. X    const unsigned char *dat, long len) : Event(t), length(len),
  1483. X    continued(0)
  1484. X{
  1485. X
  1486. X    data = new unsigned char[len];
  1487. X    assert(data != 0);
  1488. X//    memmove(data, dat, len);
  1489. X    memcpy(data, dat, len);
  1490. X}
  1491. X
  1492. XSystemExclusiveEvent::SystemExclusiveEvent(const SystemExclusiveEvent &e) :
  1493. X    Event(e), length(e.length), continued(e.continued)
  1494. X{
  1495. X
  1496. X    data = new unsigned char[e.length];
  1497. X    assert(data != 0);
  1498. X//    memmove(data, e.data, e.length);
  1499. X    memcpy(data, e.data, e.length);
  1500. X}
  1501. X
  1502. XSystemExclusiveEvent::~SystemExclusiveEvent()
  1503. X{
  1504. X
  1505. X    delete data;
  1506. X}
  1507. X
  1508. Xvoid
  1509. XSystemExclusiveEvent::SetData(const unsigned char *dat, long len)
  1510. X{
  1511. X
  1512. X    if (data != 0)
  1513. X        delete data;
  1514. X    data = new unsigned char[len];
  1515. X    assert(data != 0);
  1516. X//    memmove(data, dat, len);
  1517. X    memcpy(data, dat, len);
  1518. X}
  1519. X
  1520. XSystemExclusiveEvent &
  1521. XSystemExclusiveEvent::operator=(const SystemExclusiveEvent &e)
  1522. X{
  1523. X
  1524. X    (Event)*this = (Event)e;
  1525. X    if (data != 0)
  1526. X        delete data;
  1527. X    data = new unsigned char[e.length];
  1528. X    assert(data != 0);
  1529. X//    memmove(data, e.data, e.length);
  1530. X    memcpy(data, e.data, e.length);
  1531. X    length = e.length;
  1532. X    continued = e.continued;
  1533. X    return (*this);
  1534. X}
  1535. X
  1536. Xchar *
  1537. XSystemExclusiveEvent::GetEventStr(void) const
  1538. X{
  1539. X    ostrstream buf;
  1540. X    long i;
  1541. X    char *tbuf;
  1542. X
  1543. X    tbuf = Event::GetEventStr();
  1544. X    buf << tbuf << " Continued: " << (int)continued << " Data:";
  1545. X    buf.setf(ios::showbase | ios::internal);
  1546. X    for (i = 0; i < length; i++)
  1547. X        buf << " " << hex << setw(4) << setfill('0') << (int)data[i];
  1548. X    buf << ends;
  1549. X    delete tbuf;
  1550. X    return (buf.str());
  1551. X}
  1552. X
  1553. Xconst char *
  1554. XSystemExclusiveEvent::SMFRead(SMFTrack &t)
  1555. X{
  1556. X    const unsigned char *ptr;
  1557. X
  1558. X    if (data != 0)
  1559. X        delete data;
  1560. X    if ((length = t.GetVarValue()) == -1)
  1561. X        return ("Incomplete SystemExclusiveEvent - bad length");
  1562. X    data = new unsigned char[length];
  1563. X    if (data == 0)
  1564. X        return ("Out of memory");
  1565. X    if ((ptr = t.GetData(length)) == 0)
  1566. X        return ("Incomplete SystemExclusiveEvent");
  1567. X    memcpy(data, ptr, length);
  1568. X    return (0);
  1569. X}
  1570. X
  1571. Xconst char *
  1572. XSystemExclusiveEvent::SMFWrite(SMFTrack &t) const
  1573. X{
  1574. X
  1575. X    if (!t.PutFixValue(length))
  1576. X        return ("Out of memory");
  1577. X    if (!t.PutData(data, length))
  1578. X        return ("Out of memory");
  1579. X    return (0);
  1580. X}
  1581. X
  1582. Xint
  1583. XSystemExclusiveEvent::Equal(const Event *e) const
  1584. X{
  1585. X    long i;
  1586. X    SystemExclusiveEvent *eptr = (SystemExclusiveEvent *)e;
  1587. X
  1588. X    if (!Event::Equal(e))
  1589. X        return (0);
  1590. X    if (continued != eptr->continued)
  1591. X        return (0);
  1592. X    if (length != eptr->length)
  1593. X        return (0);
  1594. X    for (i = 0; i < length; i++)
  1595. X        if (data[i] != eptr->data[i])
  1596. X            return (0);
  1597. X    return (1);
  1598. X}
  1599. X
  1600. Xostream &
  1601. Xoperator<<(ostream &os, const SystemExclusiveEvent &e)
  1602. X{
  1603. X    char *str;
  1604. X
  1605. X    os << (str = e.GetEventStr());
  1606. X    delete str;
  1607. X    return (os);
  1608. X}
  1609. END_OF_FILE
  1610.   if test 4546 -ne `wc -c <'tclmidi-2.0/events/SystemExcl.C'`; then
  1611.     echo shar: \"'tclmidi-2.0/events/SystemExcl.C'\" unpacked with wrong size!
  1612.   fi
  1613.   # end of 'tclmidi-2.0/events/SystemExcl.C'
  1614. fi
  1615. if test -f 'tclmidi-2.0/man/midievents.n' -a "${1}" != "-c" ; then 
  1616.   echo shar: Will not clobber existing file \"'tclmidi-2.0/man/midievents.n'\"
  1617. else
  1618.   echo shar: Extracting \"'tclmidi-2.0/man/midievents.n'\" \(4691 characters\)
  1619.   sed "s/^X//" >'tclmidi-2.0/man/midievents.n' <<'END_OF_FILE'
  1620. X.Dd January 30, 1994
  1621. X.Dt MIDIEVENTS N
  1622. X.Os
  1623. X.Sh NAME
  1624. X.Nm midievents
  1625. X.Nd "the description tclmidi events"
  1626. X.Sh DESCRIPTION
  1627. XThe
  1628. X.Xr midiget n
  1629. Xand
  1630. X.Xr midiput n
  1631. Xcommands both use MIDI events in the same form.
  1632. XA
  1633. X.Xr tclmidi 1
  1634. Xevent consists of a list, where the first element
  1635. Xis the time at which the event occurs and the second
  1636. Xis the name of the event.
  1637. XThe list may contain other elements too, depending on
  1638. Xthe event type.
  1639. XThis is a list of all currently supported event types:
  1640. X.Bl -tag -width {time
  1641. X.It {time NoteOff channel pitch [velocity]}
  1642. XThe NoteOff event has three arguments: the first is the channel,
  1643. Xthe second the pitch, and the optional third is the velocity.
  1644. XIf a velocity is not specified, 0 is used.
  1645. X.It {time NoteOn channel pitch velocity}
  1646. XThe NoteOn event has three arguments: the first is the channel,
  1647. Xthe second the pitch and the third the velocity.
  1648. X.It {time Note channel pitch velocity duration}
  1649. XThe Note event is really a combination of the NoteOn and NoteOff
  1650. Xevents.
  1651. XIn fact, two events exist in the \%MIDI song with a link connecting
  1652. Xthem.
  1653. XThe Note event takes four arguments.
  1654. XThe first is the channel,
  1655. Xand the second is the pitch.
  1656. XThe third is the velocity of the NoteOn, and the fourth is
  1657. Xthe duration
  1658. Xuntil the corresponding NoteOff.
  1659. XThe implied NoteOff event assumes a velocity of zero.
  1660. X.It {time KeyPressure channel pitch value}
  1661. XThe KeyPressure event takes three arguments.
  1662. XThe first is the channel, the second the pitch and the third
  1663. Xthe pressure value.
  1664. X.It {time Parameter channel parameter value}
  1665. XThe Parameter event has three arguments.
  1666. XThe first is the channel, the second the parameter number and
  1667. Xthe third the associated value.
  1668. X.It {time Program channel value}
  1669. XThe Program event has two arguments.
  1670. XThis first is the channel and the second the program value.
  1671. X.It {time ChannelPressure channel value}
  1672. XThe ChannelPressure event has two arguments.
  1673. XThe first is the channel and the second the pressure associated
  1674. Xwith that channel.
  1675. X.It {time PitchWheel channel value}
  1676. XThe PitchWheel event has two arguments.
  1677. XThe first is the channel number and the second the pitch wheel
  1678. Xsetting.
  1679. X.It {time SystemExclusive {byte byte ...}}
  1680. XThe SystemExclusive event has one argument.
  1681. XIt is a list of data bytes to be sent as a system exclusive
  1682. Xevent.
  1683. X.It {time MetaSequenceNumber number}
  1684. XThe MetaSequenceNumber event has one argument.
  1685. XIt is the sequence number.
  1686. X.It {time MetaText text}
  1687. XThe MetaText event has one argument.
  1688. XIt is a text string.
  1689. X.It {time MetaCopyright copyright}
  1690. XThe MetaCopyright event has one argument.
  1691. XIt is a text string.
  1692. X.It {time MetaSequenceName name}
  1693. XThe MetaSequenceName event has one argument.
  1694. XIt is a text string.
  1695. X.It {time MetaInstrumentName name}
  1696. XThe MetaInstrumentName event has one argument.
  1697. XIt is a text string.
  1698. X.It {time MetaLyric lyric}
  1699. XThe MetaLyric event has one argument.
  1700. XIt is a text string.
  1701. X.It {time MetaMarker mark}
  1702. XThe MetaMarker event has one argument.
  1703. XIt is a text string.
  1704. X.It {time MetaCue cue}
  1705. XThe MetaCue event has one argument.
  1706. XIt is a text string.
  1707. X.It {time MetaChannelPrefix {byte byte ...}}
  1708. X.Xr tclmidi 1
  1709. Xdoes not know the proper form for a MetaChannelPrefix
  1710. Xevent, thus it has one argument.
  1711. XThis argument is a list of data bytes.
  1712. X.It {time MetaPortNumber port}
  1713. XThis event determines which port to use on a multiport
  1714. Xsystem.
  1715. XIt takes one argument, which is the port number.
  1716. X.It {time MetaEndOfTrack}
  1717. XThe MetaEndOfTrack event has no arguments.
  1718. X.It {time MetaTempo bpm}
  1719. XThe MetaTempo event has one argument.
  1720. XIt is the tempo specified in beats per minute.
  1721. X.It {time MetaSMPTE hour minute second frame fractional_frame}
  1722. XThe MetaSMPTE event has five arguments.
  1723. XThey are the hour, minute, second, frame and fractional frame.
  1724. X.It {time MetaTime numerator denominator clocks 32nds}
  1725. XThe MetaTime event has four arguments.
  1726. XThe first is the numerator of the time signature and the
  1727. Xsecond is the denominator.
  1728. XThe third argument is clock ticks per beat, and the fourth
  1729. Xis the number of 32nd notes per quarter note.
  1730. X.It {time MetaKey key major|minor}
  1731. XThe MetaKey event has two arguments.
  1732. XThe first is a text string describing the key and the
  1733. Xsecond is either
  1734. X.Dq major
  1735. Xor
  1736. X.Dq minor.
  1737. XThe key strings may be the key name, A - G, followed by
  1738. Xan optional ``flat'' or ``sharp.''
  1739. X.It {time MetaSequencerSpecific {byte byte ...}}
  1740. XThe MetaSequencerSpecific event has one argument.
  1741. XIt is a list of data bytes.
  1742. X.It {time MetaUnknown code {byte byte ...}}
  1743. XThe MetaUnknown event is for events not directly supported
  1744. Xby
  1745. X.Xr tclmidi 1 .
  1746. XIt has two arguments.
  1747. XThe first is the one byte code of the meta event, and
  1748. Xthe second is a list of the data bytes.
  1749. X.El
  1750. X.Sh SEE ALSO
  1751. X.Xr tclmidi 1 ,
  1752. X.Xr midiput n ,
  1753. X.Xr midiget n
  1754. X.Sh AUTHOR
  1755. XMike Durian - durian@boogie.com
  1756. END_OF_FILE
  1757.   if test 4691 -ne `wc -c <'tclmidi-2.0/man/midievents.n'`; then
  1758.     echo shar: \"'tclmidi-2.0/man/midievents.n'\" unpacked with wrong size!
  1759.   fi
  1760.   # end of 'tclmidi-2.0/man/midievents.n'
  1761. fi
  1762. if test -f 'tclmidi-2.0/rb/README' -a "${1}" != "-c" ; then 
  1763.   echo shar: Will not clobber existing file \"'tclmidi-2.0/rb/README'\"
  1764. else
  1765.   echo shar: Extracting \"'tclmidi-2.0/rb/README'\" \(4989 characters\)
  1766.   sed "s/^X//" >'tclmidi-2.0/rb/README' <<'END_OF_FILE'
  1767. X1.1.1.1
  1768. X
  1769. XRb.c, Rb.h, List.h, and list.c are files for doing red-black trees and 
  1770. Xdoubly linked lists, respectively.
  1771. X
  1772. XRb.h, Rb.c:
  1773. X
  1774. XRb.h contains the typedef for red-black tree structures.  Basically, 
  1775. Xred-black trees are balanced trees whose external nodes are sorted
  1776. Xby a key, and connected in a linked list.  The following is how
  1777. Xyou use rb.c and rb.h:
  1778. X
  1779. XInclude rb.h in your source.
  1780. X
  1781. XMake_rb() returns the head of a red-black tree.  It serves two functions:
  1782. XIts p.root pointer points to the root of the red-black tree.  Its 
  1783. Xc.list.flink and c.list.blink pointers point to the first and last 
  1784. Xexternal nodes of the tree.  When the tree is empty, all these pointers
  1785. Xpoint to itself.
  1786. X
  1787. XThe external nodes can be traversed in sorted order with their
  1788. Xc.list.flink and c.list.blink pointers.  The macros rb_first, rb_last,
  1789. Xrb_next, rb_prev, and rb_traverse can be used to traverse external node lists.
  1790. X
  1791. XExternal nodes hold two pieces of information: the key and the value
  1792. X(in k.key and v.val, respectively).   The key can be a character 
  1793. Xstring, an integer, or a general pointer.  Val is typed as a character
  1794. Xpointer, but can be any pointer.  If the key is a character string, 
  1795. Xthen one can insert it, and a value into a tree with rb_insert().  If
  1796. Xit is an integer, then rb_inserti() should be used.  If it is a general 
  1797. Xpointer, then rb_insertg() must be used, with a comparison function 
  1798. Xpassed as the fourth argument.  This function takes two keys as arguments,
  1799. Xand returns a negative value, positive value, or 0, depending on whether
  1800. Xthe first key is less than, greater than or equal to the second.  Thus,
  1801. Xone could use rb_insertg(t, s, v, strcmp) to insert the value v with 
  1802. Xa character string s into the tree t.
  1803. X
  1804. XRb_find_key(t, k) returns the external node in t whose value is equal
  1805. Xk or whose value is the smallest value greater than k.  (Here, k is
  1806. Xa string).  If there is no value greater than or equal to k, then 
  1807. Xt is returned.  Rb_find_ikey(t,k) works when k is an integer, and 
  1808. XRb_find_gkey(t,k,cmp) works for general pointers.
  1809. X
  1810. XRb_find_key_n(t, k, n) is the same as rb_find_key, except that it
  1811. Xreturns whether or not k was found in n (n is an int *).  Rb_find_ikey_n
  1812. Xand Rb_find_gkey_n are the analogous routines for integer and general
  1813. Xkeys.
  1814. X
  1815. XRb_insert_b(e, k, v) makes a new external node with key k and val v, and 
  1816. Xinserts it before the external node e.  If e is the head of a tree, 
  1817. Xthen the new node is inserted at the end of the external node list.
  1818. XIf this insertion violates sorted order, no error is flagged.  It is 
  1819. Xassumed that the user knows what he/she is doing.  Rb_insert_a(e,k,v)
  1820. Xinserts the new node after e (if e = t, it inserts the new node at the
  1821. Xbeginning of the list).
  1822. X
  1823. XRb_insert() is therefore really a combination of Rb_find_key() and
  1824. XRb_insert_b().
  1825. X
  1826. XRb_delete_node(e) deletes the external node e from a tree (and thus from 
  1827. Xthe linked list of external nodes).  The node is free'd as well, so
  1828. Xdon't retain pointers to it.
  1829. X
  1830. XRed-black trees are spiffy because find_key, insert, and delete are all
  1831. Xdone in log(n) time.  Thus, they can be freely used instead of hash-tables,
  1832. Xwith the benifit of having the elements in sorted order at all times, and
  1833. Xwith the guarantee of operations being in log(n) time.
  1834. X
  1835. XOther routines:
  1836. X
  1837. XRb_print_tree() will grossly print out a red-black tree with string keys.
  1838. XRb_iprint_tree() will do the same with trees with integer keys.
  1839. XRb_nblack(e) will report the number of black nodes on the path from external
  1840. X  node e to the root.  The path length is less than twice this value.
  1841. XRb_plength(e) reports the length of the path from e to the root.
  1842. X
  1843. X
  1844. XList.c and list.h
  1845. X
  1846. XThese are routines for generic doubly linked lists.  Doubly linked lists
  1847. Xare any structs whose first two fields are flink and blink pointers.
  1848. XMk_list(t) returns an empty list with the type t.  The empty list is 
  1849. Xa struct whose flink and blink point to itself.  Insert() and delete_item()
  1850. Xinsert and delete nodes from a list -- unlike the rb routines, no allocation
  1851. Xis done here.  In insert(), the node to be inserted is assumed to be allocated,
  1852. Xand in delete_item(), the deleted node is not free'd.
  1853. X
  1854. XGet_node() allocates a node from a node list.  The head element in the linked
  1855. Xlist has info about how big of a node to allocate.  Free_node() deallocates
  1856. Xa node.  In actuality, free_node doesn't call free, but chains the node onto
  1857. Xa queue of nodes.  That way, get_node first returns nodes from this queue, 
  1858. Xand malloc need not be called.  This is quite a possible memory leak.  To
  1859. Xbe safe, you can malloc and free your own nodes, instead of calling get_node()
  1860. Xand free_node().
  1861. X
  1862. XList.c and list.h are kind of gross, and should be generally avoided because
  1863. Xof allocation problems.  Try dlist.c & dlist.h for doubly linked lists which
  1864. Xare more like the red-black tree structs.
  1865. X
  1866. XIf you have any questions or comments about this, please let me know.
  1867. X
  1868. XTake it Easy,
  1869. X
  1870. XJim Plank
  1871. Xjsp@princeton.edu or
  1872. Xplank@cs.utk.edu
  1873. X
  1874. X35 Olden St
  1875. XPrinceton University
  1876. XPrinceton, NJ 80544-2087
  1877. END_OF_FILE
  1878.   if test 4989 -ne `wc -c <'tclmidi-2.0/rb/README'`; then
  1879.     echo shar: \"'tclmidi-2.0/rb/README'\" unpacked with wrong size!
  1880.   fi
  1881.   # end of 'tclmidi-2.0/rb/README'
  1882. fi
  1883. echo shar: End of archive 8 \(of 14\).
  1884. cp /dev/null ark8isdone
  1885. MISSING=""
  1886. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1887.     if test ! -f ark${I}isdone ; then
  1888.     MISSING="${MISSING} ${I}"
  1889.     fi
  1890. done
  1891. if test "${MISSING}" = "" ; then
  1892.     echo You have unpacked all 14 archives.
  1893.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1894. else
  1895.     echo You still must unpack the following archives:
  1896.     echo "        " ${MISSING}
  1897. fi
  1898. exit 0
  1899. exit 0 # Just in case...
  1900.