/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The next line is a regrettable hack, because it drops all pitch
* adjustment midisyn has supplied in miditune, so this synth will
* not respond to tuning, pitchbend, etc. It seems it ought to be
* possible to DTRT if the formula that generated the cms_note_table
* can be found, but I've had no luck, and a plot of the numbers in
* the table clearly curves the wrong way to be derived any obvious
* way from the equal tempered scale. (Or maybe the table's wrong?
* Has this device been playing flat up the scale? I don't have
* access to one to try.)
*/
note = MIDIPITCH_TO_KEY(mp);
/* set the volume */
/* this may be the wrong curve but will do something. no docs! */
vol = 15 + ((level_cB > -75) ? level_cB/5 : -15);
CMS_WRITE(sc, chip, CMS_IREG_VOL0 + voice, ((vol<<4)|vol));
/*
* These registers don't appear to be useful, but must be
* cleared otherwise certain voices don't work properly
*/
CMS_WRITE(sc, 0, 0x18, 0x00);
CMS_WRITE(sc, 1, 0x18, 0x00);
CMS_WRITE(sc, 0, 0x19, 0x00);
CMS_WRITE(sc, 1, 0x19, 0x00);