1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 06:10:06 +02:00
Leland Lucius 68eec279fb Update nyquist to SVN r288 (r3.15+)
------------------------------------------------------------------------
    r288 | rbd | 2018-09-25 13:47:35 -0500 (Tue, 25 Sep 2018) | 2 lines

    removed some redundant files that moved to nyquist extensions

    ------------------------------------------------------------------------
    r287 | rbd | 2018-09-25 13:02:34 -0500 (Tue, 25 Sep 2018) | 2 lines

    Cleaning up: many things in demos have moved to Nyquist extensions

    ------------------------------------------------------------------------
    r286 | rbd | 2018-09-11 08:21:16 -0500 (Tue, 11 Sep 2018) | 2 lines

    Releasing 3.15 on Mac, finished extension manager update to allow a custom extension list file set in Preferences. Allow text copy of checksum when checksums do not match (so IDE can calculate the checksum for new extensions), describe this in manual.

    ------------------------------------------------------------------------
    r285 | rbd | 2018-09-05 08:00:03 -0500 (Wed, 05 Sep 2018) | 2 lines

    Changes for 3.15 on Mac and hopefully good for Windows too.

    ------------------------------------------------------------------------
    r284 | rbd | 2018-09-01 21:21:47 -0500 (Sat, 01 Sep 2018) | 2 lines

    Final change? for v3.14 on Mac

    ------------------------------------------------------------------------
    r283 | rbd | 2018-09-01 21:14:11 -0500 (Sat, 01 Sep 2018) | 2 lines

    Took out unicode char from fm-voices-chowning, added README to extensions directory

    ------------------------------------------------------------------------
    r282 | rbd | 2018-09-01 21:12:47 -0500 (Sat, 01 Sep 2018) | 1 line

    fixed some instrument defns for sound browser
    ------------------------------------------------------------------------
    r281 | rbd | 2018-09-01 19:56:55 -0500 (Sat, 01 Sep 2018) | 1 line

    Small changes for release on Windows: v3.14
    ------------------------------------------------------------------------
    r280 | rbd | 2018-09-01 19:56:07 -0500 (Sat, 01 Sep 2018) | 2 lines

    path problems in some extensions and minor changes for mac release

    ------------------------------------------------------------------------
    r279 | rbd | 2018-09-01 15:03:26 -0500 (Sat, 01 Sep 2018) | 2 lines

    change doc/README.txt to doc/readme-mac.txt in install dmg

    ------------------------------------------------------------------------
    r278 | rbd | 2018-09-01 14:58:10 -0500 (Sat, 01 Sep 2018) | 2 lines

    minor fix for mac release

    ------------------------------------------------------------------------
    r277 | rbd | 2018-09-01 14:40:10 -0500 (Sat, 01 Sep 2018) | 2 lines

    Retry release on Mac, minor changes.

    ------------------------------------------------------------------------
    r276 | rbd | 2018-08-31 23:44:45 -0500 (Fri, 31 Aug 2018) | 3 lines

    Updated documentation; building 3.14 for mac release

    ------------------------------------------------------------------------
    r275 | rbd | 2018-08-31 21:20:41 -0500 (Fri, 31 Aug 2018) | 1 line

    Fixed extension manager to update installed flags correctly (in Swing thread). Tested browser on Windows.
    ------------------------------------------------------------------------
    r274 | rbd | 2018-08-31 14:35:22 -0500 (Fri, 31 Aug 2018) | 1 line

    Forgot to add new file.
    ------------------------------------------------------------------------
    r273 | rbd | 2018-08-31 14:33:02 -0500 (Fri, 31 Aug 2018) | 1 line

    Changes for Windows including making paths look prettier using backslash or slash more consistently, adding some tests for empty lists, setting up nyquist directory using Registry's XLISPPATH.
    ------------------------------------------------------------------------
    r272 | rbd | 2018-08-31 14:12:12 -0500 (Fri, 31 Aug 2018) | 2 lines

    Everything seems to be working on OS X. Latest fix was to Sound Browser.

    ------------------------------------------------------------------------
    r271 | rbd | 2018-08-31 13:00:54 -0500 (Fri, 31 Aug 2018) | 2 lines

    Adapting to Java 10, fixing sound browser in the face of unloaded extensions.

    ------------------------------------------------------------------------
    r270 | rbd | 2018-08-30 13:18:11 -0500 (Thu, 30 Aug 2018) | 2 lines

    Installer code sets registry to user-selected nyquist directory.

    ------------------------------------------------------------------------
    r269 | rbd | 2018-08-30 12:53:21 -0500 (Thu, 30 Aug 2018) | 1 line

    Getting ready to releasea 3.14. These changes are from Windows.
    ------------------------------------------------------------------------
    r268 | rbd | 2018-08-29 20:06:41 -0500 (Wed, 29 Aug 2018) | 2 lines

    Changes for simpler installation with nyquist (lib, doc, runtime, demos) in user read/write file space.

    ------------------------------------------------------------------------
    r267 | rbd | 2018-08-26 20:45:14 -0500 (Sun, 26 Aug 2018) | 2 lines

    Added some documentation, worked on browser #anchor urls.

    ------------------------------------------------------------------------
    r266 | rbd | 2018-08-22 18:27:01 -0500 (Wed, 22 Aug 2018) | 2 lines

    Fixed some extensions to deal with piano, which now autoloads.

    ------------------------------------------------------------------------
    r265 | rbd | 2018-08-22 12:18:40 -0500 (Wed, 22 Aug 2018) | 2 lines

    added one more missing file for v3.13

    ------------------------------------------------------------------------
    r264 | rbd | 2018-08-22 10:54:15 -0500 (Wed, 22 Aug 2018) | 2 lines

    left out piano/autoload.lsp, needed for v3.13

    ------------------------------------------------------------------------
    r263 | rbd | 2018-08-22 10:09:16 -0500 (Wed, 22 Aug 2018) | 2 lines

    More cleanup for 3.13 release

    ------------------------------------------------------------------------
    r262 | rbd | 2018-08-22 09:54:45 -0500 (Wed, 22 Aug 2018) | 2 lines

    More changes for 3.13 including status dialog while downloading extensions.

    ------------------------------------------------------------------------
    r261 | rbd | 2018-08-19 21:34:23 -0500 (Sun, 19 Aug 2018) | 2 lines

    Updated documentation for v3.13

    ------------------------------------------------------------------------
    r260 | rbd | 2018-08-19 11:14:07 -0500 (Sun, 19 Aug 2018) | 2 lines

    Converted to using Extension Manager

    ------------------------------------------------------------------------
    r259 | rbd | 2018-05-20 19:08:34 -0500 (Sun, 20 May 2018) | 2 lines

    Forgot to commit this new file

    ------------------------------------------------------------------------
    r258 | rbd | 2018-03-10 12:11:22 -0600 (Sat, 10 Mar 2018) | 2 lines

    Substantial changes to pattern classes in xm.lsp to fix bug. The problems were obscure and unnoticed for a long time, but this new implementation is a major rewrite. I still need to test online course examples to make sure nothing is broken there. Otherwise, my assumption is there are few users and incompatibilities will not matter, so this is regarded as a minor bug fix. Also in this commit is some work on turning libraries and demos into Nyquist extensions supported by an extension manager within NyquistIDE.

    ------------------------------------------------------------------------
    r257 | rbd | 2018-01-21 14:40:58 -0600 (Sun, 21 Jan 2018) | 2 lines

    Built nyquist and NyquistIDE on Ubuntu 14.04 LTS and using Oracle Java 9. Minor changes (former build specified Java version 1.7).

    ------------------------------------------------------------------------
    r256 | rbd | 2017-09-24 14:05:06 -0500 (Sun, 24 Sep 2017) | 2 lines

    Fix type-checking bug in score-voice

    ------------------------------------------------------------------------
    r255 | rbd | 2017-09-24 10:35:08 -0500 (Sun, 24 Sep 2017) | 2 lines

    Updated nyqrelide.iss for Roger's newer windows laptop

    ------------------------------------------------------------------------
    r254 | rbd | 2017-09-24 10:27:05 -0500 (Sun, 24 Sep 2017) | 2 lines

    After testing on Windows 7, removed Test button from IDE, made fft_demo not depend so much on XLISPPATH to find pmorales/*.lsp

    ------------------------------------------------------------------------
    r253 | rbd | 2017-09-23 18:44:41 -0500 (Sat, 23 Sep 2017) | 1 line

    Changes to compile on MSVS Community 2015
    ------------------------------------------------------------------------
    r252 | rbd | 2017-09-23 17:01:44 -0500 (Sat, 23 Sep 2017) | 2 lines

    A few adjustments made to allow examples.sal to run even if "demos" is not on the XLISPPATH

    ------------------------------------------------------------------------
    r251 | rbd | 2017-09-23 16:14:27 -0500 (Sat, 23 Sep 2017) | 2 lines

    Minor changes to make this work on Ubuntu linux (or maybe any other linux)

    ------------------------------------------------------------------------
    r250 | rbd | 2017-09-23 14:32:52 -0500 (Sat, 23 Sep 2017) | 2 lines

    Fixed version number in IDE About box

    ------------------------------------------------------------------------
    r249 | rbd | 2017-09-23 14:17:16 -0500 (Sat, 23 Sep 2017) | 2 lines

    More fixes for 3.12. OS X version setting up symbolic links had bugs.

    ------------------------------------------------------------------------
    r248 | rbd | 2017-09-23 00:31:29 -0500 (Sat, 23 Sep 2017) | 2 lines

    Processed documentation for v3.12

    ------------------------------------------------------------------------
    r247 | rbd | 2017-09-22 21:59:18 -0500 (Fri, 22 Sep 2017) | 2 lines

    Preparing v3.12.

    ------------------------------------------------------------------------
    r246 | rbd | 2017-09-05 09:27:29 -0500 (Tue, 05 Sep 2017) | 1 line

    Fixes for Win10 and many changes to rounding throughout to avoid truncating to 32-bit ints when 64-bits might be available on some architectures. In particular, round() which returns double has been replaced by ROUND32, returning int, and ROUNDBIG returning intptr_t.
    ------------------------------------------------------------------------
    r245 | rbd | 2017-08-24 11:15:22 -0500 (Thu, 24 Aug 2017) | 2 lines

    Fixed bug affecting Linux: seq-write-smf was trying to close file twice causing nyquist crash. Fixed by adding intermediate helper function in seqinterf.c so SEQ-WRITE-SMF does not directly call seq_write_smf.

    ------------------------------------------------------------------------
    r244 | rbd | 2016-11-02 13:33:49 -0500 (Wed, 02 Nov 2016) | 2 lines

    Forgot to include this in the repo

    ------------------------------------------------------------------------
    r243 | rbd | 2016-10-11 12:23:21 -0500 (Tue, 11 Oct 2016) | 1 line

    Prepare for v3.11b
    ------------------------------------------------------------------------
    r242 | rbd | 2016-10-11 12:19:31 -0500 (Tue, 11 Oct 2016) | 2 lines

    Improved documentation and formatting. This is for version 3.11b (64-bit Windows only)

    ------------------------------------------------------------------------
    r241 | rbd | 2016-10-11 10:59:51 -0500 (Tue, 11 Oct 2016) | 2 lines

    Fixed bug in fftlib.c which took the negative of an unsigned long.

    ------------------------------------------------------------------------
    r240 | rbd | 2016-10-06 15:49:51 -0500 (Thu, 06 Oct 2016) | 2 lines

    Fixed spec-plot parameter checking, which was totally broken before.

    ------------------------------------------------------------------------
    r239 | rbd | 2016-10-06 15:23:22 -0500 (Thu, 06 Oct 2016) | 2 lines

    Better conversion into Latex and pdf manual. Other minor fixes.

    ------------------------------------------------------------------------
    r238 | rbd | 2016-08-25 13:01:45 -0500 (Thu, 25 Aug 2016) | 1 line

    Adding readme for top level download folder on SourceForge.
    ------------------------------------------------------------------------
    r237 | rbd | 2016-08-25 09:07:08 -0500 (Thu, 25 Aug 2016) | 1 line

    Install is now for x64 architecture. Fixed cell_aut demo to run in IDE sound browser. Modified NyquistThread to create default XLISPPATH from Nyquist dir instead of cwd.
    ------------------------------------------------------------------------
    r236 | rbd | 2016-08-24 21:25:56 -0500 (Wed, 24 Aug 2016) | 2 lines

    minor change during release from OS X

    ------------------------------------------------------------------------
    r235 | rbd | 2016-08-24 21:16:55 -0500 (Wed, 24 Aug 2016) | 2 lines

    Making new release

    ------------------------------------------------------------------------
    r234 | rbd | 2016-08-24 21:05:22 -0500 (Wed, 24 Aug 2016) | 2 lines

    Adding missing file to repo.

    ------------------------------------------------------------------------
    r233 | rbd | 2016-08-24 09:23:39 -0500 (Wed, 24 Aug 2016) | 1 line

    Fixed undefined freeimage problem by moving freeimage out of the conditional compilation. freeimage is defined so that when Nyquist shuts down it can free most of the memory it allocated, minimizing (false positive) reports of memory leaks, which are harmless (except that they obscure true positive messages and seem surprising to non-xlisp experts). Undefined SAVERESTORE flag the way it used to be because save and restore functions (other than freeimage) do not work with the Nyquist SOUND type extension to XLISP.
    ------------------------------------------------------------------------
    r232 | rbd | 2016-07-19 09:39:45 -0500 (Tue, 19 Jul 2016) | 2 lines

    I was going to keep "debug" versions separate because of the runtime overhead, but the code started to diverge and it's hard to maintain two versions, so we're going to make all the type checking standard. If you want an optimized version, you could strip out the calls to ny:typecheck using list processing and it would probably work. You could even write NY:OPTIMIZE that would poke into all the function definitions and destructively edit the code.

    ------------------------------------------------------------------------
    r231 | rbd | 2016-07-19 09:34:16 -0500 (Tue, 19 Jul 2016) | 2 lines

    moved to test/

    ------------------------------------------------------------------------
    r230 | rbd | 2016-07-19 09:32:11 -0500 (Tue, 19 Jul 2016) | 2 lines

    Added extensive type checking to nyquist built-in (but not primitive) functions, and added unit tests for type checking, and incorporated unit tests into regression-test.lsp, a new "grand" test sequence.

    ------------------------------------------------------------------------
    r229 | rbd | 2016-06-23 14:28:03 -0500 (Thu, 23 Jun 2016) | 2 lines

    New code to build NyquistIDE.app -- the old appbundler stuff is no longer needed

    ------------------------------------------------------------------------
    r228 | rbd | 2016-06-23 06:44:49 -0500 (Thu, 23 Jun 2016) | 2 lines

    Appbundler is Oracle software used to build NyquistIDE - originally from java.net, but it seems to be not an active project (maybe that is good) so let's keep a copy just in case.

    ------------------------------------------------------------------------
    r227 | rbd | 2016-06-22 16:02:26 -0500 (Wed, 22 Jun 2016) | 2 lines

    previous change to snd_list_unref was VERY wrong; here is the fix.

    ------------------------------------------------------------------------
    r226 | rbd | 2016-06-22 13:46:44 -0500 (Wed, 22 Jun 2016) | 2 lines

    inserted some memory-freeing code from upstream (Audacity); made snd_list_unref non-recursive; CMakeLists.txt was not working on Mac 10.11.5 -- still can't build NyquistIDE, so more changes are on the way

    ------------------------------------------------------------------------
    r225 | rbd | 2016-05-11 10:54:16 -0500 (Wed, 11 May 2016) | 2 lines

    Overhaul of new typechecking and parameter validation and error reporting code. Mostly untested, but tests to be done are in typechecks.sal

    ------------------------------------------------------------------------
    r224 | rbd | 2016-05-06 07:56:11 -0500 (Fri, 06 May 2016) | 2 lines

    Improved plot in nyqide, progress on validating parameters for SAL, spec-plot defined, autoload spec-plot and piano synthesis functions

    ------------------------------------------------------------------------
    r223 | rbd | 2016-05-03 13:07:14 -0500 (Tue, 03 May 2016) | 2 lines

    This contains work in progress on validating parameters in many nyquist functions, fixing liblo for win64, and some security (integer overflow) problems - probably does not compile

    ------------------------------------------------------------------------
    r222 | rbd | 2016-03-16 10:34:15 -0500 (Wed, 16 Mar 2016) | 2 lines

    Updated documentation with minor additions and corrections.

    ------------------------------------------------------------------------
    r221 | rbd | 2016-01-15 18:59:45 -0600 (Fri, 15 Jan 2016) | 2 lines

    Fixed file name for Browser

    ------------------------------------------------------------------------
    r220 | rbd | 2016-01-15 18:49:15 -0600 (Fri, 15 Jan 2016) | 2 lines

    Changes to fix compilation on OS X

    ------------------------------------------------------------------------
    r219 | rbd | 2016-01-15 18:31:23 -0600 (Fri, 15 Jan 2016) | 2 lines

    fixed build code for linux, made some c code more compatible

    ------------------------------------------------------------------------
    r218 | rbd | 2016-01-14 17:08:39 -0600 (Thu, 14 Jan 2016) | 1 line

    modifications from Windows 7 port (static libraries) and browser files pointed to demos/src new location.
    ------------------------------------------------------------------------
    r217 | rbd | 2016-01-14 13:04:24 -0600 (Thu, 14 Jan 2016) | 2 lines

    Now that cmake is in use, we do not need old Makefiles

    ------------------------------------------------------------------------
    r216 | rbd | 2016-01-11 02:00:08 -0600 (Mon, 11 Jan 2016) | 1 line

    fixed to compile on XCode
    ------------------------------------------------------------------------
    r215 | rbd | 2016-01-11 01:32:58 -0600 (Mon, 11 Jan 2016) | 1 line

    examples tried to play drums, but they may not be installed
    ------------------------------------------------------------------------
    r214 | rbd | 2016-01-11 01:05:00 -0600 (Mon, 11 Jan 2016) | 1 line

    more win7 fixes
    ------------------------------------------------------------------------
    r213 | rbd | 2016-01-11 00:42:57 -0600 (Mon, 11 Jan 2016) | 2 lines

    more file and path problems fixed

    ------------------------------------------------------------------------
    r212 | rbd | 2016-01-11 00:19:55 -0600 (Mon, 11 Jan 2016) | 2 lines

    fixed lpc demo

    ------------------------------------------------------------------------
    r211 | rbd | 2016-01-10 23:45:50 -0600 (Sun, 10 Jan 2016) | 1 line

    fix read-float, restore pianosyn.lsp
    ------------------------------------------------------------------------
    r210 | rbd | 2016-01-10 23:36:35 -0600 (Sun, 10 Jan 2016) | 1 line

    fix references to demo-snd.aiff which is in demos/audio now
    ------------------------------------------------------------------------
    r209 | rbd | 2016-01-10 22:32:08 -0600 (Sun, 10 Jan 2016) | 1 line

    getting 3.10 to run on windows, has temp debug info in pianosyn.lsp
    ------------------------------------------------------------------------
    r208 | rbd | 2016-01-10 20:49:37 -0600 (Sun, 10 Jan 2016) | 2 lines

    Forgot to add new demo files

    ------------------------------------------------------------------------
    r207 | rbd | 2016-01-10 20:31:40 -0600 (Sun, 10 Jan 2016) | 2 lines

    fixed downsample.c, other minor release problems

    ------------------------------------------------------------------------
    r206 | rbd | 2016-01-10 14:01:58 -0600 (Sun, 10 Jan 2016) | 2 lines

    missing files (maybe only cmupvdbg.h is really needed)

    ------------------------------------------------------------------------
    r205 | rbd | 2016-01-10 12:10:01 -0600 (Sun, 10 Jan 2016) | 2 lines

    No more scribe, so no more auto generation of text-only documentation. Hopefully HTML will suffice. PDF is now done by latex (but I forgot to move it into the doc directory before).

    ------------------------------------------------------------------------
    r204 | rbd | 2016-01-10 12:01:55 -0600 (Sun, 10 Jan 2016) | 2 lines

    Nearing release of 3.10 -- major changes are phasevocoder, convolution, demo documentation

    ------------------------------------------------------------------------
    r203 | rbd | 2016-01-10 11:38:35 -0600 (Sun, 10 Jan 2016) | 2 lines

    Made revisions for 3.10. Not quite done yet.

    ------------------------------------------------------------------------
    r202 | rbd | 2015-12-28 22:33:51 -0600 (Mon, 28 Dec 2015) | 2 lines

    Updating demos to SAL syntax and better "front page".

    ------------------------------------------------------------------------
    r201 | rbd | 2015-05-20 19:46:16 -0500 (Wed, 20 May 2015) | 2 lines

    Fixed more warnings about types. Still working on convolve though.

    ------------------------------------------------------------------------
    r200 | rbd | 2015-05-20 06:16:32 -0500 (Wed, 20 May 2015) | 2 lines

    Forgot to move the final pdf of the manual to doc.

    ------------------------------------------------------------------------
    r199 | rbd | 2015-05-20 06:14:25 -0500 (Wed, 20 May 2015) | 2 lines

    Fixed some documentation -- it might be complete now. Removed extra play command from organ.lsp.

    ------------------------------------------------------------------------
    r198 | rbd | 2015-05-19 21:32:24 -0500 (Tue, 19 May 2015) | 2 lines

    Fixed some problems and warnings when compiling on Ubuntu Linux

    ------------------------------------------------------------------------
    r197 | rbd | 2015-05-19 20:55:04 -0500 (Tue, 19 May 2015) | 2 lines

    Merged Win32 changes with OS X, removed some .sln and .vcproj files that are not needed now that we are using CMake

    ------------------------------------------------------------------------
    r196 | rbd | 2015-05-19 20:27:30 -0500 (Tue, 19 May 2015) | 1 line

    Got nyquist and jnyqide to build on Windows under Visual Studio Express 2013. Many changes to remove some compiler warnings.
    ------------------------------------------------------------------------
    r195 | rbd | 2015-05-14 21:52:33 -0500 (Thu, 14 May 2015) | 2 lines

    better device selection for ALSA and added cross-platform help to find and select devices; added icon to jny on Linux (should work on Windows)

    ------------------------------------------------------------------------
    r194 | rbd | 2015-05-12 21:08:59 -0500 (Tue, 12 May 2015) | 2 lines

    still more missing files

    ------------------------------------------------------------------------
    r193 | rbd | 2015-05-12 21:07:41 -0500 (Tue, 12 May 2015) | 2 lines

    more missing files

    ------------------------------------------------------------------------
    r192 | rbd | 2015-05-12 21:04:50 -0500 (Tue, 12 May 2015) | 2 lines

    another missing file

    ------------------------------------------------------------------------
    r191 | rbd | 2015-05-12 20:56:39 -0500 (Tue, 12 May 2015) | 2 lines

    repo missing a file

    ------------------------------------------------------------------------
    r190 | rbd | 2015-05-12 20:28:25 -0500 (Tue, 12 May 2015) | 2 lines

    repo is missing a file

    ------------------------------------------------------------------------
    r189 | rbd | 2015-05-12 20:16:10 -0500 (Tue, 12 May 2015) | 2 lines

    cleaned out files we don't use

    ------------------------------------------------------------------------
    r188 | rbd | 2015-05-12 12:42:57 -0500 (Tue, 12 May 2015) | 2 lines

    Updated liblo to v0.28 and tested that it compiles with nyquist on XCode

    ------------------------------------------------------------------------
    r187 | rbd | 2015-05-12 07:00:06 -0500 (Tue, 12 May 2015) | 2 lines

    FLAC changes were incomplete. This revision compiles.

    ------------------------------------------------------------------------
    r186 | rbd | 2015-05-12 06:39:06 -0500 (Tue, 12 May 2015) | 2 lines

    Updated FLAC to 1.3.1, removed unnecessary files from local copy of sources.

    ------------------------------------------------------------------------
    r185 | rbd | 2015-05-11 22:51:11 -0500 (Mon, 11 May 2015) | 2 lines

    I updated libvorbis from 1.3.5 and deleted unneeded files

    ------------------------------------------------------------------------
    r184 | rbd | 2015-05-11 22:29:41 -0500 (Mon, 11 May 2015) | 2 lines

    I decided to just keep sources in libraries that are needed to build Nyquist, so I'm removing lots of build and configuration files. So far, portaudio is updated to V19 and libogg is updated to 1.3.2

    ------------------------------------------------------------------------
    r183 | rbd | 2015-05-11 15:00:14 -0500 (Mon, 11 May 2015) | 2 lines

    macosxproject/CMakeLists.txt is now in place to generate nyquist.xcodeproj. Since it is generated by CMake, I removed it from the repo.

    ------------------------------------------------------------------------
    r182 | rbd | 2015-05-11 14:03:53 -0500 (Mon, 11 May 2015) | 2 lines

    Added sliders, documentation is now in latex, new Java build, CMake is used to create project in OS X, many other changes. This is NOT a release! Next step will be to get the CMake-built project into the right name and directory.

    ------------------------------------------------------------------------
    r181 | rbd | 2015-03-19 19:40:00 -0500 (Thu, 19 Mar 2015) | 2 lines

    This is a failed attempt to use PanDoc to make a Nyquist manual, now that Scribe seems to have died. This is the point where I am changing the code to write directly to Latex.

    ------------------------------------------------------------------------
    r180 | rbd | 2015-03-18 10:17:44 -0500 (Wed, 18 Mar 2015) | 2 lines

    Update version numbers to 3.10

    ------------------------------------------------------------------------
    r179 | rbd | 2015-03-17 20:17:35 -0500 (Tue, 17 Mar 2015) | 2 lines

    minor bug fixes

    ------------------------------------------------------------------------
    r178 | rbd | 2015-03-17 20:05:13 -0500 (Tue, 17 Mar 2015) | 1 line

    Various changes from Windows version.res
2019-12-15 19:34:50 -06:00

1891 lines
50 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*****************************************************************************
* midifns.c
* Copyright 1989 Carnegie Mellon University
* Date | Change
*-----------+-----------------------------------------------------------------
* 29-Mar-88 | Created from IBM PC version of mpu.c
* | Added settime()
* 02-May-88 | AMIGA 2000 version. portable version.
* 12-Oct-88 | JCD : Exclusive AMIGA Version.
* 13-Apr-89 | JCD : New portable version.
* 19-Apr-89 | JCD : Amiga CAMD Version added.
* 5-Apr-91 | JDW : Further modification
* 17-Feb-92 | GWL : incorporate JMN's new mpu.c
* 8-Jun-92 | JDZ : add support for ITC midi interface
* 16-Dec-92 | RBD : replace JMN's mpu.c with LMS's mpu.c
* 11-Mar-94 | PLu : port to IRIX
* 25-Apr-97 | RBD : it looks like SGI changed their interface. I
* | made it compile again, but MIDI does not work, so
* | took out calls to actually send/recv MIDI data
* 28-Apr-03 | DM : Renamed random -> cmtrand, true->TRUE, false->FALSE
* | Use features rather than system names in #ifdef's
*****************************************************************************/
#include "switches.h"
#ifdef UNIX
#include <sys/resource.h>
#include <sys/param.h>
#ifndef OPEN_MAX
/* this is here for compiling the UNIX version under AIX. This is a BSDism */
#define OPEN_MAX 2000
#endif /* OPEN_MAX */
#endif /* UNIX */
#ifdef UNIX_MACH
#include "machmidi.h"
#endif
#ifdef AMIGA
#ifdef AZTEC
#include "functions.h"
#endif /* AZTEC */
#include "midi/camd.h"
#include "clib/camd_protos.h"
/* note: azt_camd_pragmas.h was produced by running MAPFD on the
* lib/camd_lib.fd file included in the CAMD disk from Commodore.
* The "CamdClient" calls are manually removed from
*/
#ifdef AZTEC
#include "pragmas/azt_camd_pragmas.h"
#else /* !AZTEC */
#include "pragmas/lat_camd_pragmas.h"
#endif /* AZTEC */
#include "camdmidi.h"
#include "ctype.h"
#endif /* AMIGA */
#ifdef UNIX_IRIX
/* #define UNIX_IRIX_MIDIFNS -- this would enable actual midi I/O
* if the actual midi I/O code worked
*/
/* IRIX changed the MIDI interface,
* retain this for older systems:
*/
#ifdef UNIX_IRIX_MIDIFNS
#include <dmedia/midi.h>
#endif
#endif
#include "stdio.h"
#include "cext.h"
#include "midicode.h"
#include "cmdline.h"
#include "pitch.h"
#include "midifns.h"
#include "userio.h"
#include "string.h"
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
#include "midibuff.h"
#endif
#endif
#ifdef UNIX_ITC /* was ITC */
#include "sys/param.h"
/* since boolean is defined, block its definition in midistruct.h.
* CMT defines boolean as ushort, but midistruct.h uses int.
* This is not a problem on RS/6000s, but beware!
*/
/* the following would be included if we had the BSD switch set. I think
we should try to avoid BSDisms; when fixed, the following should be
removed
*/
#define NBBY 8
#include "sys/select.h" /* defines fd_set */
#define MIDI_HAS_BOOLEAN
#include "midistruct.h"
#include "cmtio.h"
#endif /* UNIX_ITC */
#ifdef DOS
#ifndef WINDOWS
#include "timer.h"
#include "mpu.h"
#endif /* ifndef WINDOWS */
#endif /* ifdef DOS */
#ifndef BREAKTEST
#define BREAKTEST
#endif
#ifdef UNIX_MACH
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#else
#ifdef UNIX
#ifndef UNIX_IRIX
#include "sys/time.h"
#include "sys/timeb.h"
#include "cmtio.h"
#else
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#ifdef UNIX_IRIX_MIDIFNS
#include <midi.h>
#include <midiio.h>
#endif /* UNIX_IRIX_MIDIFNS */
#endif /* UNIX_IRIX */
#endif /* UNIX */
#endif /* UNIX_MACH */
#ifdef ITC
static int ignore_realtime = 0;
#endif /* ITC */
#ifdef MACINTOSH
/* added for ThinkC 7: */
#include <OSUtils.h>
/* port numbers are in the range 0..MAX_PORTS-1 */
#define CHANNELS_PER_PORT 16
#define MAX_PORTS ((MAX_CHANNELS + CHANNELS_PER_PORT - 1) / CHANNELS_PER_PORT)
/* here are some MIDIMGR specific definitions */
#ifdef MIDIMGR
#include "MIDI.h"
#include "midimgr.h"
#define TICKS_TO_MS(t) t
#define MS_TO_TICKS(t) t
#else
/* here are some non-MIDIMGR definitions for the Mac */
/****************************************************************************
*
* DMH: constants from macmidi.c
*
****************************************************************************/
/* the modem port, also called port A */
#define portA 0
/* the printer port, also called port B */
#define portB 1
/* a tick is 1/60 of a second
*
* the following tables and routines are used to convert
* between ticks and milliseconds
*/
#define TICKS_TO_MS(t) (((t) * 50) / 3)
#define MS_TO_TICKS(t) (((t) * 3) / 50)
#endif /* def MIDIMGR */
#endif /* def MACINTOSH */
#ifdef WINDOWS
#define huge
#endif
/****************************************************************************
*
* exported flags
*
****************************************************************************/
boolean miditrace = FALSE; /* enables printed trace of MIDI output */
boolean musictrace = FALSE; /* enables printed trace of commands */
#ifdef MACINTOSH_OR_DOS
boolean ctrlFilter = TRUE; /* suppress continuous controller data */
boolean exclFilter = TRUE; /* suppress exclusive messages */
boolean realFilter = TRUE; /* suppress realtime messages */
#endif
/****************************************************************************
*
* exported variables
*
****************************************************************************/
public int keyloud; /* set to velocity of last getkey event */
/* public long error; */
public short midi_error_flags = 0;
/* The following midifns_syntax lists command line switches and options.
Since these are machine dependent, use conditional compilation.
Conditional compilation within a string is a bit tricky: you want to
write "\" for line continuation within the string, but "\" gets eaten
by the macro preprocessor.
That's why we define macros like AMIGAINPORT.
Regretably it doesn't work for all compilers.
*/
/* Lattice and RT/Unix aren't happy expanding the embedded macros below, so
I made a separate declaration of midifns_syntax for Unix
*/
#ifdef UNIX
public char *midifns_syntax = "block<s>Turn off midi THRU;\
miditrace<s>Trace low-level midi functions;\
noalloff<s>Do not send alloff message when done;\
trace<s>Trace music operations;\
tune<o>Load a tuning file";
#else
#ifdef MACINTOSH
#ifdef MIDIMGR
public char *midifns_syntax = "miditrace<s>Trace low-level midi functions;\
noalloff<s>Do not send alloff message when done;\
patch<s>Remember/reuse Midi Mgr patches;\
trace<s>Trace music operations;\
keep<s>Keep other processes running;\
tune<o>Load a tuning file";
#else /* no MIDIMGR */
public char *midifns_syntax = "miditrace<s>Trace low-level midi functions;\
noalloff<s>Do not send alloff message when done;\
patch<s>Remember/reuse Midi Mgr patches;\
trace<s>Trace music operations;\
tune<o>Load a tuning file";
#endif /* MIDIMGR */
#else
#ifdef AMIGA
public char *midifns_syntax = "block<s>Turn off midi THRU;\
inport<o>Inpur port number;\
miditrace<s>Trace low-level midi functions;\
noalloff<s>Do not send alloff message when done;\
outport<o>Output port number;\
trace<s>Trace music operations;\
tune<o>Load a tuning file";
#else /* not UNIX or MACINTOSH or MIDIMGR or AMIGA */
#ifdef DOS
public char *midifns_syntax = "miditrace<s>Trace low-level midi functions;\
noalloff<s>Do not send alloff message when done;\
trace<s>Trace music operations;\
tune<o>Load a tuning file";
#endif /* DOS */
#endif /* AMIGA */
#endif /* MACINTOSH */
#endif /* UNIX */
#ifdef MACINTOSH
boolean do_midi_thru = FALSE; /* exported: copy midi in to midi out */
#endif
/****************************************************************************
*
* local module variables
*
****************************************************************************/
private int initialized = FALSE; /* set by musicinit, cleared by musicterm */
private boolean tune_flag = FALSE; /* set by musicinit, never cleared */
#ifdef DOS
private boolean metroflag = FALSE; /* flag to turn on metronome */
#endif
private int user_scale = FALSE; /* TRUE if user-defined scale */
private int bend[MAX_CHANNELS]; /* current pitch bend on channel */
short cur_midi_prgm[MAX_CHANNELS];
private pitch_table pit_tab[128]; /* scale definition */
#ifdef DOS
private ulong timeoffset = 0;
public boolean exclerr = FALSE;
public byte xcodemask; /* mask (00 or FF) */
public byte xcode; /* mfr code */
#endif
#ifdef MACINTOSH_OR_DOS
boolean sysex_pending = FALSE;
#endif
#ifdef AMIGA
#define CONTCONT ((CMF_Ctrl & ~CMF_CtrlSwitch) | CMF_PitchBend | \
CMF_ChanPress)
#endif /* def AMIGA */
#ifdef UNIX
private ulong timeoffset = 0;
#endif
#ifdef UNIX_IRIX_MIDIFNS
static MIport *miport;
static int ignore_realtime = 0;
private byte *sysex_p;
private int sysex_n;
#endif
#ifdef ITC
mi_id midiconn;
#endif
#ifdef MACINTOSH
private ulong ticksAtStart = 0L;
/* clock ticks at time of last musicinit or timereset
* ASSUME: tick clock never wraps. this is a good assumption, since
* the tick clock is set to zero when the power is turned on and the
* tick counter is 32 bits. the Macintosh would need to be on for
* 828.5 days for the tick counter to wrap around! */
#endif /* def MACINTOSH */
/****************************************************************************
*
* functions declared in this module
*
****************************************************************************/
private void fixup();
private void midi_init();
extern boolean check_ascii(); /*userio.c*/
private void musicterm();
/****************************************************************************
* alloff
* Inputs:
* none
* Effect:
* Sends MIDI all notes off command on every channel.
****************************************************************************/
#define ALL_NOTES_OFF 0x7B /*DMH: from macmidi.c*/
void alloff()
{
int c;
if (!initialized) fixup();
if (musictrace)
gprintf(TRANS,"alloff()\n");
for (c = 1; c <= MAX_CHANNELS; c++) {
midi_write(3, MIDI_PORT(c), (byte) (0xb0 | MIDI_CHANNEL(c)), ALL_NOTES_OFF, 0);
}
}
/***************************************************************
* eventwait
*
* Input : wakeup time, -1 means forever
* Output : none
* Return: none
* Effect: waits until ascii or midi input or timeout
***************************************************************/
#ifdef UNIX_ITC
void eventwait(timeout)
long timeout;
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
fd_set readfds;
struct rlimit file_limit;
FD_ZERO(&readfds);
FD_SET(MI_CONNECTION(midiconn), &readfds);
FD_SET(fileno(stdin), &readfds);
if (timeout >= 0) {
timeout -= gettime(); /* convert to millisecond delay */
unix_timeout.tv_sec = timeout / 1000;
/* remainder become microsecs: */
unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000;
waitspec = &unix_timeout;
}
getrlimit(RLIMIT_NOFILE, &file_limit);
select(file_limit.rlim_max+1, &readfds, 0, 0, waitspec);
return;
}
#else /* !UNIX_ITC */
#ifdef UNIX
/* see machmidi.c for UNIX_MACH (OS X) implementation */
#ifndef UNIX_MACH
#ifdef UNIX_IRIX_MIDIFNS
void eventwait(timeout)
long timeout;
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(mdGetFd(miport), &readfds);
FD_SET(fileno(stdin), &readfds);
if (timeout >= 0) {
timeout -= gettime(); /* convert to millisecond delay */
unix_timeout.tv_sec = timeout / 1000;
/* remainder become microsecs: */
unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000;
waitspec = &unix_timeout;
}
select(FD_SETSIZE, &readfds, 0, 0, waitspec);
return;
}
#else
#ifdef BUFFERED_SYNCHRONOUS_INPUT
void eventwait(timeout)
long timeout;
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
struct rlimit file_limit;
if (timeout >= 0) {
timeout -= gettime(); /* convert to millisecond delay */
unix_timeout.tv_sec = timeout / 1000;
/* remainder become microsecs: */
unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000;
waitspec = &unix_timeout;
getrlimit(RLIMIT_NOFILE, &file_limit);
select(file_limit.rlim_max+1, 0, 0, 0, waitspec);
} else {
int c = getc(stdin);
ungetc(c, stdin);
}
return;
}
#else
void eventwait(timeout)
long timeout;
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
int readfds = 1 << IOinputfd;
struct rlimit file_limit;
if (timeout >= 0) {
timeout -= gettime(); /* convert to millisecond delay */
unix_timeout.tv_sec = timeout / 1000;
/* remainder become microsecs: */
unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000;
waitspec = &unix_timeout;
}
getrlimit(RLIMIT_NOFILE, &file_limit);
select(file_limit.rlim_max+1, &readfds, 0, 0, waitspec);
return;
}
#endif /* BUFFERED_SYNCHRONOUS_INPUT */
#endif /* UNIX_IRIX */
#endif /* UNIX_MACH */
#endif /* UNIX */ /* I wanted to put an else here, but this confused a Unix C compiler */
#endif /* UNIX_ITC */
#ifdef AMIGA
/* see camdmidi.c for Amiga implementation */
#else
#ifndef UNIX /* since I couldn't use an else above, have to check UNIX here */
#ifdef WINDOWS
void eventwait(timeout)
long timeout;
{
if (timeout >= 0) {
gprintf(TRANS, "eventwait: not implemented\n");
return;
} else {
int c = getc(stdin);
ungetc(c, stdin);
}
return;
}
#else
void eventwait(timeout)
long timeout;
{
while (timeout > gettime() || timeout == -1) {
if (check_ascii() || check_midi()) return;
}
}
#endif /* WINDOWS */
#endif /* UNIX */
#endif /* AMIGA */
/****************************************************************************
* exclusive
* Inputs:
* boolean onflag -- set to TRUE to receive midi exclusive data
* Effect:
* Tells module to read exclusive messages into buffer
****************************************************************************/
void exclusive(boolean onflag)
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS, "exclusive: %d\n", onflag);
#ifdef AMIGA
if (onflag) SetMidiFilters(cmt_mi,
cmt_mi->PortFilter, cmt_mi->TypeFilter | CMF_SysEx, cmt_mi->ChanFilter);
else SetMidiFilters(cmt_mi,
cmt_mi->PortFilter, cmt_mi->TypeFilter & ~CMF_SysEx, cmt_mi->ChanFilter);
#endif
#ifdef MACINTOSH_OR_DOS
exclFilter = !onflag;
#endif
}
/****************************************************************************
* fixup
* Effect:
* Print error message and call musicinit
****************************************************************************/
private void fixup()
{
gprintf(ERROR, "You forgot to call musicinit. I'll do it for you.\n");
musicinit();
}
#ifdef UNIX_IRIX_MIDIFNS
private void flush_sysex(void);
#endif
long get_excl(byte *buffer, long len)
{
long ret = 0;
#ifdef UNIX_IRIX_MIDIFNS
byte *sxp = sysex_p;
long l = len;
#endif
#ifdef UNIX_ITC /* was ITC */
ret = mi_getx(midiconn, FALSE, len, (char *) buffer);
#endif
#ifdef UNIX_MACH
ret = mi_getx(midiconn, FALSE, len, (unsigned char *)buffer);
#endif
#ifdef UNIX_IRIX_MIDIFNS
if (!sysex_p) return 0;
if (len > sysex_n) len = sysex_n;
while (l--)
{
*buffer = *(sxp++);
if (*(buffer++) == CMT_MIDI_EOX)
{
flush_sysex();
break;
}
}
ret = len - l - 1;
#endif
#ifdef AMIGA
ret = GetSysEx(cmt_mi, (UBYTE *) buffer, len);
AMIGA_ERROR_CHECK;
#endif
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
/* I'm not sure the following line is a good thing: it forces the
* caller to wait until a full sysex message is received and the
* 1st 4 bytes are fetched via getbuf() before a sysex message can
* be read via get_excl(). Without this, both mm.c and exget.c
* were fetching ahead and getting out of sync with getbuf(). I
* fixed mm.c and exget.c to work (by checking for EOX), but I added
* this line (which should never have any effect) just to make the
* DOS interface behave more like the Amiga and Mac interfaces. The
* drawback is that you can't fetch bytes until the EOX is seen,
* because nothing goes into the getbuf() buffer until then.
*/
if (!sysex_pending) return 0;
while (len-- && (xbufhead != xbuftail)) {
*buffer = xbuff[xbufhead++];
ret++;
if (*buffer == MIDI_EOX) {
sysex_pending = FALSE;
break;
}
buffer++;
xbufhead &= xbufmask;
}
#endif
#endif
return ret;
}
/****************************************************************************
* getbuf
* Inputs:
* boolean waitflag: TRUE if routine should wait for data
* byte * p: Pointer to data destination
* Result: boolean
* TRUE if data was written to *p
* FALSE if data not written to *p
* Effect:
* copies data from buffer to *p
* will wait for buffer to become nonempty if waitflag is TRUE
*
* Modified 24 May 1988 for AMIGA (JCD)
****************************************************************************/
#ifdef UNIX_IRIX_MIDIFNS
private void setup_sysex(MDevent *event, u_char *buffer);
#endif /* UNIX_IRIX */
boolean getbuf(boolean waitflag, unsigned char * p)
{
#ifdef UNIX_IRIX_MIDIFNS
MDevent event;
int ret;
#endif /* UNIX_IRIX */
if (!initialized) fixup();
#ifdef UNIX
#ifdef UNIX_IRIX_MIDIFNS
/* current IRIX version ignores the waitflag (it never waits) */
if (sysex_p) flush_sysex();
if (ignore_realtime == 0) {
ret = mdReceive(miport, &event, 1);
if (ret) {
if (event.msg[0] != 0xF0) {
*((u_long*) p) = *((u_long*) event.msg);
} else {
setup_sysex(&event, p);
}
}
return ret;
} else {
do /* skip realtime messages */
{
ret = mdReceive(miport, &event, 1);
if (ret == -1) return ret;
} while (event.msg[0] == 0xf8);
if (event.msg[0] != 0xF0) {
*((u_long*) p) = *((u_long*) event.msg);
} else {
setup_sysex(&event, p);
}
return ret;
}
#endif /* UNIX_IRIX */
#ifdef UNIX_ITC
if (ignore_realtime == 0) {
return(mi_get(midiconn, waitflag, (char *) p));
}
else {
boolean ret=false;
/* filter out realtime msgs */
do {
ret = mi_get(midiconn, waitflag, (char *) p);
if (ret == FALSE)
return(ret);
} while(p[0] == 0xf8);
return(ret);
}
#else /* UNIX_ITC */
#ifndef UNIX_IRIX
if (waitflag) {
gprintf(ERROR, "getbuf called with waitflag!");
EXIT(1);
}
return FALSE;
#endif /* UNIX_IRIX */
#endif /* UNIX_ITC */
#endif /* UNIX */
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
if (sysex_pending) { /* flush sysex to keep buffers in sync */
while (xbuff[xbufhead++] != MIDI_EOX) {
xbufhead &= xbufmask;
if (xbufhead == xbuftail) break;
}
sysex_pending = FALSE;
}
if (waitflag) while (buffhead == bufftail) /* wait */ ;
else if (buffhead == bufftail) return(false);
*(long *)p = *(long *)(((char *)buff)+buffhead);
buffhead = (buffhead + 4) & BUFF_MASK;
if (*p == MIDI_SYSEX) { /* if sys-ex, remember to fetch from xbuff */
sysex_pending = TRUE;
}
return(true);
#else
return FALSE;
#endif /* WINDOWS */
#endif /* MACINTOSH_OR_DOS */
#ifdef AMIGA
if (waitflag) {
do {
WaitMidi(cmt_mi, &cmt_msg);
AMIGA_ERROR_CHECK;
} while (amigaerrflags);
} else {
AMIGA_ERROR_CHECK;
if (!GetMidi(cmt_mi, &cmt_msg)) return(false);
}
*(long *)p = *(long *)&cmt_msg;
clearmsg(cmt_msg);
return(true);
#endif /* AMIGA */
}
#ifdef UNIX_IRIX_MIDIFNS
private void setup_sysex(MDevent *event, u_char *buffer)
/* N.B. do not leak memory remember to call free(sysex_p) */
{
u_char *sxp = (u_char *) event->sysexmsg;
int i;
for (i=0;i<4;i++)
*(buffer++) = *(sxp++);
sysex_p = event->sysexmsg;
sysex_n = event->msglen;
}
private void flush_sysex()
{
mdFree(sysex_p);
sysex_p = 0;
sysex_n = 0;
}
#endif
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
public boolean check_midi()
{
if (buffhead == bufftail) return FALSE;
else return TRUE;
}
#endif
#endif
/****************************************************************************
* getkey
* Inputs:
* boolean waitflag: TRUE if wait until key depression, FALSE if
* return immediately
* Result: int
* key number of key which has been depressed
* It returns -1 if waitflag is FALSE and no key has been pressed
* If waitflag is TRUE this routine will block until a key is pressed
* Effect:
* reads a key
****************************************************************************/
/*DMH: in previous version, macmidi.c subtracted 12 from msg to get key at each occurence...*/
short getkey(boolean waitflag)
{
byte msg[4];
short k;
if (!initialized) fixup();
while (TRUE) { /* process data until you find a note */
/* look for data and exit if none found */
/* NOTE: waitflag will force waiting until data arrives */
if (!getbuf(waitflag, msg)) { /* nothing there */
k = -1;
break;
} else if ((msg[0] & MIDI_CODE_MASK) == MIDI_ON_NOTE) {
if (msg[2] == 0) { /* velocity 0 -> note off */
keyloud = 0;
k = msg[1] + 128;
} else {
keyloud = msg[2];
k = msg[1];
}
break;
} else if ((msg[0] & MIDI_CODE_MASK) == MIDI_OFF_NOTE) {
keyloud = 0;
k = msg[1] + 128;
break;
}
}
if (musictrace) {
if (k != -1) gprintf(TRANS,"getkey got %d\n", k);
}
return k;
}
/****************************************************************************
* gettime
* Result: ulong
* current timestamp since the last call to
* musicinit or timereset
* Effect:
* fakes it
****************************************************************************/
ulong gettime() /*DMH: ulong is from mpu->midifns conversion, for Mac*/
{
#if HAS_GETTIMEOFDAY
struct timeval timeval;
#endif
#if HAS_FTIME
struct timeb ftime_res;
#endif
register ulong ticks = 0L;
BREAKTEST /* abort if user typed Ctrl Break */
if (!initialized) fixup();
#ifdef MACINTOSH
#ifdef MIDIMGR
ticks = MIDIGetCurTime(OutputRefNum) - ticksAtStart;
#else
ticks = TickCount() - ticksAtStart;
#endif
if (initialized) abort_check(); /* give user a chance to abort */
ticks = TICKS_TO_MS(ticks);
#endif
#ifdef AMIGA
ticks = (*camdtime - timeoffset) << 1; /* return milliseconds */
#endif
#ifdef DOS
#ifndef WINDOWS
ticks = elapsedtime(timeoffset, readtimer()); /* return milliseconds */
/* gprintf(TRANS, "currtime = %ld, timeoffset = %ld\n", currtime, timeoffset); */
#endif
#endif /* ifdef DOS */
#if HAS_GETTIMEOFDAY
gettimeofday(&timeval, 0);
ticks = timeval.tv_sec * 1000 + timeval.tv_usec / 1000 - timeoffset;
#endif
#if HAS_FTIME
ftime(&ftime_res);
ticks = ((ftime_res.time - timeoffset) * 1000) + ftime_res.millitm;
#endif
/* if (miditrace) gprintf(TRANS, "."); */
return(ticks);
}
/****************************************************************************
* l_rest
* Inputs:
* long time: Amount of time to rest
* Effect:
* Waits until the amount of time specified has lapsed
****************************************************************************/
void l_rest(time)
long time;
{
if (!initialized) fixup();
l_restuntil(time + gettime());
}
/****************************************************************************
* l_restuntil
* Inputs:
* long time: Event time to rest until
* Effect:
* Waits until the specified time has been reached (absolute time)
****************************************************************************/
void l_restuntil(time)
long time;
{
#ifdef MACINTOSH
ulong now = gettime();
ulong junk; /* changed from ulong for ThinkC 7, back to ulong for CW5 */
#endif
#ifdef AMIGA
while (time > gettime()) eventwait(time);
#else
for(; (time_type) time > gettime(););
#endif
#ifdef MACINTOSH
now = gettime();
if (time > now) Delay(MS_TO_TICKS(time - now), &junk);
/* else time <= now, so return immediately */
#endif
}
/****************************************************************************
* metronome
* Inputs:
* boolean onflag: TRUE or FALSE
* Effect:
* enables (true) or disables (false) MPU-401 metronome function.
* must be called before musicinit
****************************************************************************/
void metronome(boolean onflag)
{
#ifdef DOS
metroflag = onflag;
#endif
}
/****************************************************************************
* midi_bend
* Inputs:
* int channel: midi channel on which to send data
* int value: pitch bend value
* Effect:
* Sends a midi pitch bend message
****************************************************************************/
void midi_bend(int channel, int value)
{
if (!initialized) fixup();
if (musictrace)
gprintf(TRANS,"midi_bend: ch %d, val %d\n", channel, value - (1 << 13));
bend[MIDI_CHANNEL(channel)] = value;
midi_write(3, MIDI_PORT(channel), (byte) (MIDI_BEND | MIDI_CHANNEL(channel)),
(byte) MIDI_DATA(value), (byte) MIDI_DATA(value >> 7));
}
/****************************************************************************
* midi_buffer
* Inputs:
* byte * buffer: the buffer address
* int size: number of bytes in buffer
* Returns:
* FALSE if size is less than 16 or buffer is NULL, otherwise TRUE
* Effect: DOS, MAC:
* tells interrupt routine to store system exclusive messages in
* buffer. The largest power of 2 bytes less than size will be
* used. xbufhead and xbuftail will be initialized to zero,
* and xbuftail will be one greater than the index of the last
* system exclusive byte read. Since there may already be a buffer
* and therefore the normal midi message buffer may have the first
* 4 bytes of some sysex messages, clear the normal midi buffer too.
* AMIGA:
* adds buffer to midi interface
*
****************************************************************************/
boolean midi_buffer(byte huge *buffer, ulong size)
{
if (!buffer) return FALSE;
#ifdef AMIGA
if (!SetSysExQueue(cmt_mi, (UBYTE *) buffer, (ULONG) size)) return(false);
cu_register(remove_sysex_buffer, buffer);
#endif
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
{
int mask = 0x000F;
if (size < 16) return(false);
while (mask < size && mask > 0) mask = ((mask << 1) | 1);
midi_flush();
xbuff = NULL; /* turn off buffering */
xbufmask = mask >> 1;
xbufhead = xbuftail = 0;
xbuff = buffer; /* set buffer, turn on buffering */
}
#endif
#endif
#ifdef UNIX
return FALSE;
#else
exclusive(TRUE);
return TRUE;
#endif
}
/* midi_clock -- send a midi time clock message */
/**/
void midi_clock()
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS, "+");
midi_write(1, 0, MIDI_TIME_CLOCK, 0, 0);
}
/****************************************************************************
* midi_cont
* Inputs:
* boolean onflag: TRUE or FALSE
* Effect:
* enables (true) or disables (false) continuous control
****************************************************************************/
void midi_cont(boolean onflag)
{
if (!initialized) fixup();
if (onflag) {
#ifdef AMIGA
SetMidiFilters(cmt_mi, cmt_mi->PortFilter,
cmt_mi->TypeFilter | CONTCONT, cmt_mi->ChanFilter);
#endif
#ifdef DOS
#ifndef WINDOWS
mPutCmd(BENDERON);
#endif
#endif
} else {
#ifdef AMIGA
SetMidiFilters(cmt_mi, cmt_mi->PortFilter,
cmt_mi->TypeFilter & ~CONTCONT, cmt_mi->ChanFilter);
#endif
}
#ifdef MACINTOSH_OR_DOS
ctrlFilter = !onflag;
#endif
if (musictrace) gprintf(TRANS,"midi_cont: %d\n", onflag);
}
/****************************************************************************
* midi_ctrl
* Inputs:
* int channel: midi channel on which to send data
* int control: control number
* int value: control value
* Effect:
* Sends a midi control change message
****************************************************************************/
void midi_ctrl(int channel, int control, int value)
{
if (!initialized) fixup();
if (musictrace)
gprintf(TRANS,"midi_ctrl: ch %d, ctrl %d, val %d\n",
channel, control, value);
midi_write(3, MIDI_PORT(channel), (byte) (MIDI_CTRL | MIDI_CHANNEL(channel)),
(byte) MIDI_DATA(control), (byte) MIDI_DATA(value));
}
/****************************************************************************
* midi_exclusive
* Inputs:
* byte *msg: pointer to a midi exclusive message, terminated by 0xF7
* Effect:
* Sends a midi exclusive message
* Bugs:
* 18-mar-94 PLu : This function does not know which port to send to in
* case of multiple midi-ports (MAC, IRIX)
****************************************************************************/
#ifdef MACINTOSH
#define INTERBYTE_DELAY 10
#endif
void midi_exclusive(msg)
unsigned char *msg; /* the data to be sent */
{
#ifdef ITC
int count, done, tosend, willsend;
unsigned char *m;
mi_status ret;
#endif
#ifdef UNIX_IRIX_MIDIFNS
unsigned char *m;
MDevent mdevent;
#endif
#ifdef MACINTOSH
#ifndef NYQUIST
int i; /* for DX7 delay loop */
int count = 0; /* counter for formatting midi byte trace */
MIDIPacket TheMIDIPacket;
unsigned char prev = 0;
boolean first_packet = TRUE;
#endif
#endif
/*
* if user mistakenly called midi_exclusive instead of exclusive,
* the argument will be TRUE or FALSE, both of which are highly
* unlikely valid arguments for midi_exclusive:
*/
if (msg == (byte *) FALSE || msg == (byte *) TRUE) {
gprintf(ERROR,"midi_exclusive: invalid argument %u.\n", msg);
EXIT(1);
}
if (!initialized) fixup();
if (musictrace) gprintf(TRANS,"midi_exclusive\n");
#ifdef AMIGA
PutSysEx(cmt_mi, msg);
#endif
#ifdef MACINTOSH
#ifndef NYQUIST /* if NYQUIST, do nothing */
#ifdef MIDIMGR
while (prev != MIDI_EOX) {
int len = 0;
while (prev != MIDI_EOX && len < 249) {
TheMIDIPacket.data[len++] = prev = *msg++;
}
TheMIDIPacket.len = 6 + len;
TheMIDIPacket.tStamp = 0;
if (first_packet && (prev != MIDI_EOX)) {
TheMIDIPacket.flags = midiTimeStampCurrent + midiStartCont;
first_packet = FALSE;
} else if (first_packet) {
TheMIDIPacket.flags = midiTimeStampCurrent + midiNoCont;
} else if (prev == MIDI_EOX) {
TheMIDIPacket.flags = midiTimeStampCurrent + midiEndCont;
} else {
TheMIDIPacket.flags = midiTimeStampCurrent + midiMidCont;
}
MIDIWritePacket(OutputRefNum, &TheMIDIPacket);
}
#else
while (*msg != MIDI_EOX) {
Xmit(0, *msg);
msg++;
count++;
/* this is a delay loop, without which your DX7 will crash */
for (i = INTERBYTE_DELAY; i > 0; i--)
abort_check();
}
Xmit(0, MIDI_EOX);
#endif /* MIDIMGR */
#endif /* NYQUIST */
#endif /* MACINTOSH */
#ifdef DOS
#ifndef WINDOWS
do {
mPutData(*msg);
} while (*msg++ != MIDI_EOX);
#endif
#endif
#ifdef ITC
for (m = msg, tosend = 1; (*m) != MIDI_EOX; m++, tosend++);
for (count = 0; count < tosend; count += done) {
willsend = min(16384, tosend);
ret = mi_exclusive(midiconn, 1, msg, (short) willsend);
if (ret != MI_SUCCESS) {
gprintf(GWARN, "Got %d from mi_exclusive\n", ret);
}
done = willsend;
}
#endif
#ifdef UNIX_IRIX_MIDIFNS
/* we don't know which device to sent SYSEX messages to so port zero is
assumed. */
for (m = msg, mdevent.msglen = 1; (*m) != CMT_MIDI_EOX; m++, mdevent.msglen++);
mdevent.sysexmsg = msg;
if (mdSend(miport, &mdevent, 1) == -1) {
gprintf(GWARN, "could not send SYSEX message\n");
}
#endif
if (miditrace) {
do { gprintf(TRANS, "~%2x", *msg);
#ifdef UNIX_IRIX_MIDIFNS
} while (*msg++ != CMT_MIDI_EOX);
#else
} while (*msg++ != MIDI_EOX);
#endif
}
}
/****************************************************************************
* midi_note
* Inputs:
* int channel: midi channel on which to send data
* int pitch: midi pitch code
* int velocity: velocity with which to sound it (0=> release)
* Effect:
* Sends a midi note-play request out
****************************************************************************/
void midi_note(int channel, int pitch, int velocity)
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS,"midi_note: ch %d, key %d, vel %d\n",
channel, pitch, velocity);
if (user_scale) {
/* check for correct pitch bend */
if ((pit_tab[pitch].pbend != bend[MIDI_CHANNEL(channel)])
&& (velocity != 0)) {
midi_bend(channel, pit_tab[pitch].pbend);
bend[channel] = pit_tab[pitch].pbend;
}
pitch = pit_tab[pitch].ppitch;
}
midi_write(3, MIDI_PORT(channel), (byte) (MIDI_ON_NOTE | MIDI_CHANNEL(channel)),
(byte) MIDI_DATA(pitch), (byte) MIDI_DATA(velocity));
}
/****************************************************************************
* midi_program
* Inputs:
* int channel: Channel on which to send midi program change request
* int program: Program number to send (decremented by 1 before
* being sent as midi data)
* Effect:
* Sends a program change request out the channel
****************************************************************************/
void midi_program(int channel, int program)
{
#ifdef MACINTOSH
int port, midi_chan;
#endif
if (!initialized) fixup();
if (musictrace) gprintf(TRANS,"midi_program: ch %d, prog %d\n",
channel, program);
channel = MIDI_CHANNEL(channel);
if (cur_midi_prgm[channel] != program) {
midi_write(2, MIDI_PORT(channel), (byte) (MIDI_CH_PROGRAM | channel),
(byte) (MIDI_PROGRAM(program)), 0);
cur_midi_prgm[channel] = program;
}
}
/****************************************************************************
* midi_real
* Inputs:
* boolean onflag: TRUE or FALSE
* Effect:
* enables (true) or disables (false) midi realtime messages F8-FF
****************************************************************************/
void midi_real(boolean onflag)
{
if (!initialized) fixup();
#ifdef UNIX_ITC
{
mi_status ret;
ret = mi_realtime(midiconn, onflag);
if (ret != MI_SUCCESS) {
gprintf(ERROR, "Warning: bad ret = %d in midi_real\n", ret);
}
}
#endif /* UNIX_ITC */
#ifdef ITC
ignore_realtime = !onflag;
#endif /* ITC */
#ifdef AMIGA
if (onflag) {
SetMidiFilters(cmt_mi, cmt_mi->PortFilter,
cmt_mi->TypeFilter | CMF_RealTime, cmt_mi->ChanFilter);
} else {
SetMidiFilters(cmt_mi, cmt_mi->PortFilter,
cmt_mi->TypeFilter & ~CMF_RealTime, cmt_mi->ChanFilter);
}
#endif
#ifdef MACINTOSH_OR_DOS
realFilter = !onflag;
#endif
if (musictrace) gprintf(TRANS,"midi_real: %d\n", onflag);
}
/* midi_start -- send a midi start message */
/**/
void midi_start()
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS, "`");
midi_write(1, 0, MIDI_START, 0, 0);
}
/* midi_stop -- send a midi stop message */
/**/
void midi_stop()
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS, "'");
midi_write(1, 0 /* ignored */, MIDI_STOP, 0, 0);
}
/****************************************************************************
* midi_thru
* Inputs:
* boolean onflag: TRUE or FALSE
* Effect:
* DOS: enables (true) or disables (false) midi thru info from
* MPU-401 to host. (Default is set; reset with cmdline -block.)
* AMIGA: enables (true) or disables (false) midi route from AMIGA
* midi input to AMIGA midi output.
****************************************************************************/
void midi_thru(boolean onflag) /* DMH: midi thru is not supported on the MAC or DOS */
{
if (!initialized) fixup();
#ifndef MIDI_THRU
gprintf(ERROR, "midi_thru called but not implemented\n");
#else
#ifdef AMIGA
MidiThru(0L, (long) onflag);
#endif
#ifdef MACINTOSH
/* this currently does not do anything - Mac driver doesn't
* support THRU
*/
do_midi_thru = onflag;
#endif
#endif
if (musictrace) gprintf(TRANS,"midi_thru: %d\n", onflag);
}
/****************************************************************************
* midi_touch
* Inputs:
* int channel: midi channel on which to send data
* int value: control value
* Effect:
* Sends a midi after touch message
****************************************************************************/
void midi_touch(int channel, int value)
{
if (!initialized) fixup();
if (musictrace) gprintf(TRANS,"midi_touch: ch %d, val %d\n",channel,value);
midi_write(2, MIDI_PORT(channel), (byte) (MIDI_TOUCH | MIDI_CHANNEL(channel)),
(byte) MIDI_DATA(value), 0);
}
/****************************************************************************
* midi_write
* Inputs:
* UBYTE n: number of characters to send (1, 2 or 3);
int port: the port number (usually 0), on MAC, this may be 1
* char c1,c2,c3: Character(s) to write to MIDI data port
* Effect:
* Writes the data to the serial interface designated by port
****************************************************************************
* Change log
* Date | Change
*-----------+----------------------------------------------------------------
* 15-Mar-94 | PLu : Added IRIX version
****************************************************************************/
#ifdef UNIX
#ifdef UNIX_IRIX_MIDIFNS
void midi_write(int n, int port, unsigned char c1, unsigned char c2, unsigned char c3)
{
MDevent event;
if (port < 0) return;
* ((u_long *) event.msg) = 0xe0000000 | ((port & 0x1f) << 24) | (c1 << 16) |
(c2 << 8) | c3;
if (mdSend(miport, &event, 1) == -1)
gprintf(ERROR, "Can not send midi message in midi_write");
midi_write_trace(n, port, c1, c2, c3);
}
#else
#ifdef ITC
void midi_write(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
unsigned char outb[3];
mi_channel mch;
mi_status ret;
if (port < 0) return;
outb[0] = c1;
outb[1] = c2;
outb[2] = c3;
mch = (16*port)+((int)MI_CHANNEL(c1));
ret = mi_put(midiconn, mch, outb);
if (ret != MI_SUCCESS)
gprintf(ERROR, "Warning: bad ret = %d in midi_write\n", (int)ret);
midi_write_trace(n, port, c1, c2, c3);
}
#else
void midi_write(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
/* no output */
midi_write_trace(n, port, c1, c2, c3);
}
#endif /* ITC */
#endif /* UNIX_IRIX */
#endif /* UNIX */
#ifdef DOS
#ifndef WINDOWS
void midi_write(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
if (n >= 1) mPutData(c1);
if (n >= 2) mPutData(c2);
if (n >= 3) mPutData(c3);
midi_write_trace(n, port, c1, c2, c3);
}
#else
void midi_write(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
midi_write_trace(n, port, c1, c2, c3);
}
#endif
#endif
#ifdef MACINTOSH
#ifdef MIDIMGR
void midi_write(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
MIDIPacket TheMIDIPacket;
TheMIDIPacket.flags = midiTimeStampCurrent;
TheMIDIPacket.len = 6 + n;
TheMIDIPacket.tStamp = 0;
TheMIDIPacket.data[0] = c1;
TheMIDIPacket.data[1] = c2;
TheMIDIPacket.data[2] = c3;
MIDIWritePacket(OutputRefNum, &TheMIDIPacket);
midi_write_trace(n, port, c1, c2, c3);
}
#else
void midi_write(int n, int port, unsigned char c1, unsigned char c2, unsigned char c3)
{
#ifndef NYQUIST
Xmit(port, c1);
if (n >= 2) Xmit(port, c2);
if (n >= 3) Xmit(port, c3);
#endif
midi_write_trace(n, port, c1, c2, c3);
}
#endif
#endif
void midi_write_trace(int n, int port,
unsigned char c1, unsigned char c2, unsigned char c3)
{
if (miditrace) {
/* to indicate bytes going out on port 1, put message in brackets
* with the port number, e.g. [1:~90~3c~64]
*/
if (port > 0) gprintf(TRANS, "[%d:", port);
if (n >= 1) gprintf(TRANS, "~%2x", c1);
if (n >= 2) gprintf(TRANS, "~%2x", c2);
if (n >= 3) gprintf(TRANS, "~%2x", c3);
if (port > 0) gprintf(TRANS, "]", port);
}
}
/*****************************************************************
* set_pitch_default
*****************************************************************/
private void set_pitch_default()
{
int i;
for (i = 0; i < 128; i++) {
pit_tab[i].pbend = 8192;
pit_tab[i].ppitch = i;
}
}
/*****************************************************************
* read_tuning
*****************************************************************/
void read_tuning(filename)
char *filename;
{
int index, pit, lineno = 0;
float bend;
FILE *fpp;
user_scale = TRUE;
set_pitch_default();
fpp = fileopen(filename, "tun", "r", "Tuning definition file");
while ((fscanf(fpp, "%d %d %f\n", &index, &pit, &bend) > 2) &&
(lineno < 128)) {
lineno++;
if (index >= 0 && index <= 127) {
pit_tab[index].pbend = (int)(8192 * bend/100 + 8192);
pit_tab[index].ppitch = pit;
}
}
}
/****************************************************************************
* musicinit
* Effect:
****************************************************************************/
void musicinit()
{
int i;
char *filename;
if (!tune_flag) { /* do this code only once */
miditrace = cl_switch("miditrace");
musictrace = cl_switch("trace");
}
if (!initialized) {
cu_register((cu_fn_type) musicterm, NULL);
midi_init();
}
initialized = TRUE;
/* this does some random cleanup activity */
#ifndef APPLICATION
if (!tune_flag) { /* do this code only once */
#ifdef DOS
#ifndef WINDOWS
#if 0
version = mPutGetCmd(GETMPUVER);
revision = mPutGetCmd(GETMPUREV);
gprintf(TRANS, "MPU version %d.%d%c\n", version >> 4, version & 0x0f,
revision + 'A' - 1);
#endif
mPutCmd(UARTMODE);
mPutCmd(NOREALTIME); /* initially prevent Real Time MIDI info */
mPutCmd(EXCLUSIVOFF); /* initially prevent Sys-Ex data */
#endif
#endif
tune_flag = TRUE;
filename = cl_option("tune");
if (filename != NULL) read_tuning(filename);
}
/* now that flags are set, print the trace message */
if (musictrace) gprintf(TRANS, "musicinit()\n");
if (user_scale) {
for (i = 0; i < MAX_CHANNELS; i++) {
midi_bend(i, 8192);
bend[i] = 8192;
}
}
#endif /* ifndef APPLICATION */
for (i = 0; i < MAX_CHANNELS; i++) {
/* initialize to impossible values so that the
* next call to midi_bend or midi_program will
* not match and therefore send an output:
*/
bend[i] = -1;
cur_midi_prgm[i] = -1;
}
#ifdef MIDI_THRU
midi_thru(!(cl_switch("block"))); /* set MIDI thru */
#endif
timereset(); /* Reset clock */
#ifdef AMIGA
event_mask |= (1L << ascii_signal()) | (1L << cmt_mi->AlarmSigBit) |
(1L << cmt_mi->RecvSigBit);
#endif
}
/****************************************************************************
* musicterm
* Effect:
* Miscellaneous cleanup of things done by musicinit.
****************************************************************************/
private void musicterm()
{
if (musictrace) gprintf(TRANS, "musicterm()\n");
initialized = FALSE;
}
/****************************************************************************
* cmtrand
* Inputs:
* int lo: Lower limit of value
* int hi: Upper limit of value
* Result: int
* random number (lo <= result <= hi)
****************************************************************************/
/* to avoid confusion and dead code, take this out */
#ifdef ALL_CMT
long randseed = 1534781L;
short cmtrand(short lo, short hi)
{
randseed *= 13L;
randseed += 1874351L;
return((short)(lo + (((hi + 1 - lo) * ((0x00ffff00 & randseed) >> 8)) >> 16)));
}
#ifdef AMIGA
/* remove_sysex_buffer -- a cleanup procedure for the Amiga */
/**/
void remove_sysex_buffer(void *obj)
{
ClearSysExQueue(cmt_mi);
}
#endif /* AMIGA */
/****************************************************************************
* settime
* Inputs: new time
* Effect:
* Sets the current time to the new time.
* DMH: for MAC, sets the clock to absTime
* implemented by adjusting ticksATStart
****************************************************************************/
void settime(newtime)
time_type newtime;
{
if (musictrace) gprintf(TRANS, "settime(%lu)\n", newtime);
#ifdef AMIGA
timeoffset = *camdtime - (newtime >> 1);
#endif
#ifdef MACINTOSH
#ifdef MIDIMGR
ticksAtStart = MIDIGetCurTime(OutputRefNum);
#else
ticksAtStart = TickCount() - MS_TO_TICKS(newtime);
#endif
#endif
}
#endif //ALL_CMT
/****************************************************************************
* timereset
* Effect:
* Resets the time.
* DMH: for MAC, implemented by setting ticksAtStart to
* current value of system tick counter
* JMN: for DOS, resets the time on the MPU-401. Ticks is reset to 0
****************************************************************************/
void timereset()
{
#if HAS_GETTIMEOFDAY
struct timeval timeval;
#endif
#if HAS_FTIME
struct timeb ftime_res;
#endif
if (!initialized) fixup();
if (musictrace) gprintf(TRANS,"timereset()\n");
#ifdef AMIGA
timeoffset = *camdtime;
#endif
#ifdef DOS
#ifndef WINDOWS
timeoffset = (ulong) readtimer();
#endif
#endif
#ifdef MACINTOSH
#ifdef MIDIMGR
ticksAtStart = MIDIGetCurTime(OutputRefNum);
#else
ticksAtStart = TickCount();
#endif
#endif
#if HAS_GETTIMEOFDAY
gettimeofday(&timeval, 0);
timeoffset = timeval.tv_sec * 1000 + timeval.tv_usec / 1000 - timeoffset;
#endif
#if HAS_FTIME
ftime(&ftime_res);
timeoffset = ftime_res.time;
#endif
}
/****************************************************************************
* trace
* Inputs:
* boolean flag: TRUE for trace on
* Effect:
* turns tracing on (flag == TRUE) or off (flag == FALSE)
****************************************************************************/
void trace(boolean flag)
{
musictrace = flag;
}
/****************************************************************************
* tracemidi
* Inputs:
* boolean flag: TRUE for trace on
* Effect:
* turns midi tracing on (flag == TRUE) or off (flag == FALSE)
****************************************************************************/
void tracemidi(boolean flag)
{
miditrace = flag;
}
/***********************************************************************
*
* midi and timer initialization
*
***********************************************************************/
#ifdef DOS
#include <ctype.h>
/* binary value of hex char */
private int xval(int c)
{
int i;
static char t[]="0123456789abcdef";
for (i=0; i<16; i++)
if (tolower(c)==t[i]) return(i);
return (-1);
}
/* binary value of hex string */
private int atox(char *t)
{
int i=0;
int x;
while(*t)
{
if ((x=xval(*t++))<0)return (0);
i=(i<<4)+x;
}
return (i);
}
#endif /* def DOS */
private void midi_init()
{
#ifdef UNIX_IRIX_MIDIFNS
#define PBUFLEN 4
MIconfig *config;
static u_int pbuf[] = { MI_STAMPING, MINOSTAMP, MI_BLOCKING, MINONBLOCKING};
#endif
#ifdef UNIX_MACH
mach_midi_init();
#else
#ifdef ITC
midiconn = mi_open(NULL);
if (midiconn == NULL) {
gprintf(FATAL, "could not open a MIDI device\n");
EXIT(1);
}
cu_register((cu_fn_type) mi_close, (void *) midiconn);
#endif
#endif
#ifdef AMIGA
amiga_midi_init();
#endif /* def AMIGA */
#ifdef DOS
#ifndef WINDOWS
int err;
int irq=SEARCHIRQ;
int base=MPUBASEADDR;
char *t;
if (t=getenv("MPUIRQ")) {
if (musictrace)
gprintf(TRANS,"MPUIRQ %s\n",t);
irq=atoi(t);
}
if (t=getenv("MPUBASE")) {
if (musictrace)
gprintf(TRANS,"MPUBASE %s\n",t);
base=atox(t);
}
if (err = mOpen(base, irq)) {
mClose(err);
EXIT(1);
}
cu_register((cu_fn_type) mClose, 0);
cu_register((cu_fn_type) mPutCmd, (cu_parm_type) MPURESET);
initializetimer();
cu_register((cu_fn_type) restoretimer, NULL);
#endif
#endif
#ifdef MACINTOSH
#ifndef NYQUIST /* if NYQUIST, do nothing */
#ifdef MIDIMGR
setup_midimgr(); /* this registers itself for cleanup */
#else
init_abort_handler();
cu_register(cleanup_abort_handler, NULL);
setupMIDI(portA, 0x80);
cu_register(restoreMIDI, (long) portA);
/* only initialize portB if necessary */
if (MAX_CHANNELS > CHANNELS_PER_PORT) {
setupMIDI(portB, 0x80);
cu_register(restoreMIDI, (long) portB);
}
#endif
#endif /* NYQUIST */
#ifdef MIDIMGR
ticksAtStart = MIDIGetCurTime(OutputRefNum);
#else
ticksAtStart = TickCount(); /* reset the clock */
#endif
#endif /* def MACINTOSH */
if (!(cl_switch("noalloff")))
cu_register((cu_fn_type) alloff, NULL);
}
#ifdef DOS
/****************************************************************************
* set_x_mfr
* Inputs:
* unsigned char mfr: Manufacturer ID for MIDI
* Result: void
*
* Effect:
* Sets the xcode and xcodemask to allow only these sysex messages
****************************************************************************/
void set_x_mfr(mfr)
unsigned char mfr;
{
xcode = mfr;
xcodemask = 0xFF;
}
/****************************************************************************
* clear_x_mfr
* Result: void
*
* Effect:
* Clears sysex manufacturer code filter; accepts all sysex messages
****************************************************************************/
void clear_x_mfr()
{
xcode = 0;
xcodemask = 0;
}
#endif /* DOS */