2005-12-11 15:16:03 +03:00
|
|
|
/* $NetBSD: midisyn.c,v 1.16 2005/12/11 12:20:53 christos Exp $ */
|
1998-08-12 22:14:01 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-11-26 01:17:06 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2003-12-04 16:57:30 +03:00
|
|
|
* by Lennart Augustsson (augustss@NetBSD.org).
|
1998-08-12 22:14:01 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 08:32:49 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-12-11 15:16:03 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: midisyn.c,v 1.16 2005/12/11 12:20:53 christos Exp $");
|
2001-11-13 08:32:49 +03:00
|
|
|
|
1998-08-12 22:14:01 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <sys/midiio.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <dev/audio_if.h>
|
1998-08-18 01:16:09 +04:00
|
|
|
#include <dev/midi_if.h>
|
1998-08-12 22:14:01 +04:00
|
|
|
#include <dev/midivar.h>
|
|
|
|
#include <dev/midisynvar.h>
|
|
|
|
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
#define DPRINTF(x) if (midisyndebug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (midisyndebug >= (n)) printf x
|
|
|
|
int midisyndebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
2001-10-03 02:41:22 +04:00
|
|
|
int midisyn_findvoice(midisyn *, int, int);
|
|
|
|
void midisyn_freevoice(midisyn *, int);
|
|
|
|
int midisyn_allocvoice(midisyn *, u_int32_t, u_int32_t);
|
|
|
|
u_int32_t midisyn_note_to_freq(int);
|
|
|
|
u_int32_t midisyn_finetune(u_int32_t, int, int, int);
|
1998-08-12 22:14:01 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int midisyn_open(void *, int,
|
2001-10-03 02:41:22 +04:00
|
|
|
void (*iintr)(void *, int),
|
|
|
|
void (*ointr)(void *), void *arg);
|
|
|
|
void midisyn_close(void *);
|
|
|
|
int midisyn_output(void *, int);
|
|
|
|
void midisyn_getinfo(void *, struct midi_info *);
|
2005-12-11 15:16:03 +03:00
|
|
|
int midisyn_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
1998-08-12 22:14:01 +04:00
|
|
|
|
2004-10-29 16:57:15 +04:00
|
|
|
const struct midi_hw_if midisyn_hw_if = {
|
1998-08-12 22:14:01 +04:00
|
|
|
midisyn_open,
|
|
|
|
midisyn_close,
|
|
|
|
midisyn_output,
|
|
|
|
midisyn_getinfo,
|
|
|
|
midisyn_ioctl,
|
|
|
|
};
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const int midi_lengths[] = { 3,3,3,3,2,2,3,1 };
|
1998-08-12 22:14:01 +04:00
|
|
|
/* Number of bytes in a MIDI command, including status */
|
|
|
|
#define MIDI_LENGTH(d) (midi_lengths[((d) >> 4) & 7])
|
|
|
|
|
|
|
|
int
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_open(void *addr, int flags, void (*iintr)(void *, int),
|
|
|
|
void (*ointr)(void *), void *arg)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
midisyn *ms = addr;
|
|
|
|
|
|
|
|
DPRINTF(("midisyn_open: ms=%p ms->mets=%p\n", ms, ms->mets));
|
|
|
|
if (ms->mets->open)
|
|
|
|
return (ms->mets->open(ms, flags));
|
|
|
|
else
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_close(void *addr)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
midisyn *ms = addr;
|
1998-09-13 08:41:34 +04:00
|
|
|
struct midisyn_methods *fs;
|
|
|
|
int v;
|
1998-08-12 22:14:01 +04:00
|
|
|
|
|
|
|
DPRINTF(("midisyn_close: ms=%p ms->mets=%p\n", ms, ms->mets));
|
1998-09-13 08:41:34 +04:00
|
|
|
fs = ms->mets;
|
|
|
|
for (v = 0; v < ms->nvoice; v++)
|
|
|
|
if (ms->voices[v].inuse) {
|
|
|
|
fs->noteoff(ms, v, 0, 0);
|
|
|
|
midisyn_freevoice(ms, v);
|
|
|
|
}
|
|
|
|
if (fs->close)
|
|
|
|
fs->close(ms);
|
1998-08-12 22:14:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_getinfo(void *addr, struct midi_info *mi)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
midisyn *ms = addr;
|
|
|
|
|
|
|
|
mi->name = ms->name;
|
|
|
|
mi->props = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-12-11 15:16:03 +03:00
|
|
|
midisyn_ioctl(void *maddr, u_long cmd, caddr_t addr, int flag, struct lwp *l)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
midisyn *ms = maddr;
|
|
|
|
|
|
|
|
if (ms->mets->ioctl)
|
2005-12-11 15:16:03 +03:00
|
|
|
return (ms->mets->ioctl(ms, cmd, addr, flag, l));
|
1998-08-12 22:14:01 +04:00
|
|
|
else
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_findvoice(midisyn *ms, int chan, int note)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
u_int cn;
|
|
|
|
int v;
|
|
|
|
|
|
|
|
if (!(ms->flags & MS_DOALLOC))
|
|
|
|
return (chan);
|
1998-08-18 01:16:09 +04:00
|
|
|
cn = MS_CHANNOTE(chan, note);
|
1998-08-12 22:14:01 +04:00
|
|
|
for (v = 0; v < ms->nvoice; v++)
|
1998-08-18 01:16:09 +04:00
|
|
|
if (ms->voices[v].chan_note == cn && ms->voices[v].inuse)
|
1998-08-12 22:14:01 +04:00
|
|
|
return (v);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_attach(struct midi_softc *sc, midisyn *ms)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
if (ms->flags & MS_DOALLOC) {
|
2005-02-27 03:26:58 +03:00
|
|
|
ms->voices = malloc(ms->nvoice * sizeof (struct voice),
|
2002-01-13 22:28:06 +03:00
|
|
|
M_DEVBUF, M_WAITOK|M_ZERO);
|
1998-08-12 22:14:01 +04:00
|
|
|
ms->seqno = 1;
|
|
|
|
if (ms->mets->allocv == 0)
|
|
|
|
ms->mets->allocv = &midisyn_allocvoice;
|
|
|
|
}
|
|
|
|
sc->hw_if = &midisyn_hw_if;
|
|
|
|
sc->hw_hdl = ms;
|
|
|
|
DPRINTF(("midisyn_attach: ms=%p\n", sc->hw_hdl));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_freevoice(midisyn *ms, int voice)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
if (!(ms->flags & MS_DOALLOC))
|
|
|
|
return;
|
1998-08-18 01:16:09 +04:00
|
|
|
ms->voices[voice].inuse = 0;
|
1998-08-12 22:14:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_allocvoice(midisyn *ms, u_int32_t chan, u_int32_t note)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
int bestv, v;
|
|
|
|
u_int bestseq, s;
|
|
|
|
|
|
|
|
if (!(ms->flags & MS_DOALLOC))
|
|
|
|
return (chan);
|
|
|
|
/* Find a free voice, or if no free voice is found the oldest. */
|
|
|
|
bestv = 0;
|
1998-08-18 01:16:09 +04:00
|
|
|
bestseq = ms->voices[0].seqno + (ms->voices[0].inuse ? 0x40000000 : 0);
|
1998-08-12 22:14:01 +04:00
|
|
|
for (v = 1; v < ms->nvoice; v++) {
|
|
|
|
s = ms->voices[v].seqno;
|
1998-08-18 01:16:09 +04:00
|
|
|
if (ms->voices[v].inuse)
|
|
|
|
s += 0x40000000;
|
1998-08-12 22:14:01 +04:00
|
|
|
if (s < bestseq) {
|
|
|
|
bestseq = s;
|
|
|
|
bestv = v;
|
|
|
|
}
|
|
|
|
}
|
1998-08-18 01:16:09 +04:00
|
|
|
DPRINTFN(10,("midisyn_allocvoice: v=%d seq=%d cn=%x inuse=%d\n",
|
2005-02-27 03:26:58 +03:00
|
|
|
bestv, ms->voices[bestv].seqno,
|
1998-08-18 01:16:09 +04:00
|
|
|
ms->voices[bestv].chan_note,
|
|
|
|
ms->voices[bestv].inuse));
|
|
|
|
#ifdef AUDIO_DEBUG
|
|
|
|
if (ms->voices[bestv].inuse)
|
2005-02-27 03:26:58 +03:00
|
|
|
DPRINTFN(1,("midisyn_allocvoice: steal %x\n",
|
1998-08-18 01:16:09 +04:00
|
|
|
ms->voices[bestv].chan_note));
|
|
|
|
#endif
|
|
|
|
ms->voices[bestv].chan_note = MS_CHANNOTE(chan, note);
|
1998-08-12 22:14:01 +04:00
|
|
|
ms->voices[bestv].seqno = ms->seqno++;
|
1998-08-18 01:16:09 +04:00
|
|
|
ms->voices[bestv].inuse = 1;
|
1998-08-12 22:14:01 +04:00
|
|
|
return (bestv);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_output(void *addr, int b)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
midisyn *ms = addr;
|
|
|
|
u_int8_t status, chan;
|
|
|
|
int voice = 0; /* initialize to keep gcc quiet */
|
|
|
|
struct midisyn_methods *fs;
|
|
|
|
u_int32_t note, vel;
|
|
|
|
|
1998-08-13 04:13:56 +04:00
|
|
|
DPRINTF(("midisyn_output: ms=%p b=0x%02x\n", ms, b));
|
1998-08-12 22:14:01 +04:00
|
|
|
fs = ms->mets;
|
|
|
|
if (ms->pos < 0) {
|
|
|
|
/* Doing SYSEX */
|
1998-08-13 04:13:56 +04:00
|
|
|
DPRINTF(("midisyn_output: sysex 0x%02x\n", b));
|
1998-08-12 22:14:01 +04:00
|
|
|
if (fs->sysex)
|
|
|
|
fs->sysex(ms, b);
|
|
|
|
if (b == MIDI_SYSEX_END)
|
|
|
|
ms->pos = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (ms->pos == 0 && !MIDI_IS_STATUS(b))
|
|
|
|
ms->pos++; /* repeat last status byte */
|
|
|
|
ms->buf[ms->pos++] = b;
|
|
|
|
status = ms->buf[0];
|
|
|
|
if (ms->pos < MIDI_LENGTH(status))
|
|
|
|
return (0);
|
|
|
|
/* Decode the MIDI command */
|
|
|
|
chan = MIDI_GET_CHAN(status);
|
|
|
|
note = ms->buf[1];
|
|
|
|
if (ms->flags & MS_FREQXLATE)
|
|
|
|
note = midisyn_note_to_freq(note);
|
|
|
|
vel = ms->buf[2];
|
|
|
|
switch (MIDI_GET_STATUS(status)) {
|
|
|
|
case MIDI_NOTEOFF:
|
|
|
|
voice = midisyn_findvoice(ms, chan, ms->buf[1]);
|
|
|
|
if (voice >= 0) {
|
|
|
|
fs->noteoff(ms, voice, note, vel);
|
|
|
|
midisyn_freevoice(ms, voice);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MIDI_NOTEON:
|
|
|
|
voice = fs->allocv(ms, chan, ms->buf[1]);
|
|
|
|
fs->noteon(ms, voice, note, vel);
|
|
|
|
break;
|
|
|
|
case MIDI_KEY_PRESSURE:
|
|
|
|
if (fs->keypres) {
|
|
|
|
voice = midisyn_findvoice(ms, voice, ms->buf[1]);
|
|
|
|
if (voice >= 0)
|
|
|
|
fs->keypres(ms, voice, note, vel);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MIDI_CTL_CHANGE:
|
|
|
|
if (fs->ctlchg)
|
|
|
|
fs->ctlchg(ms, chan, ms->buf[1], vel);
|
|
|
|
break;
|
|
|
|
case MIDI_PGM_CHANGE:
|
|
|
|
if (fs->pgmchg)
|
|
|
|
fs->pgmchg(ms, chan, ms->buf[1]);
|
|
|
|
break;
|
|
|
|
case MIDI_CHN_PRESSURE:
|
|
|
|
if (fs->chnpres) {
|
|
|
|
voice = midisyn_findvoice(ms, chan, ms->buf[1]);
|
|
|
|
if (voice >= 0)
|
|
|
|
fs->chnpres(ms, voice, note);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MIDI_PITCH_BEND:
|
|
|
|
if (fs->pitchb) {
|
|
|
|
voice = midisyn_findvoice(ms, chan, ms->buf[1]);
|
|
|
|
if (voice >= 0)
|
|
|
|
fs->pitchb(ms, chan, note, vel);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MIDI_SYSTEM_PREFIX:
|
|
|
|
if (fs->sysex)
|
|
|
|
fs->sysex(ms, status);
|
|
|
|
ms->pos = -1;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
ms->pos = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a MIDI note to the corresponding frequency.
|
|
|
|
* The frequency is scaled by 2^16.
|
|
|
|
*/
|
|
|
|
u_int32_t
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_note_to_freq(int note)
|
1998-08-12 22:14:01 +04:00
|
|
|
{
|
|
|
|
int o, n, f;
|
|
|
|
#define BASE_OCTAVE 5
|
2001-01-18 23:28:15 +03:00
|
|
|
static const u_int32_t notes[] = {
|
1998-08-12 22:14:01 +04:00
|
|
|
17145893, 18165441, 19245614, 20390018, 21602472, 22887021,
|
|
|
|
24247954, 25689813, 27217409, 28835840, 30550508, 32367136
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
o = note / 12;
|
|
|
|
n = note % 12;
|
|
|
|
|
|
|
|
f = notes[n];
|
|
|
|
|
|
|
|
if (o < BASE_OCTAVE)
|
|
|
|
f >>= (BASE_OCTAVE - o);
|
|
|
|
else if (o > BASE_OCTAVE)
|
|
|
|
f <<= (o - BASE_OCTAVE);
|
|
|
|
return (f);
|
|
|
|
}
|
|
|
|
|
1998-08-18 01:16:09 +04:00
|
|
|
u_int32_t
|
2001-10-03 02:41:22 +04:00
|
|
|
midisyn_finetune(u_int32_t base_freq, int bend, int range, int vibrato_cents)
|
1998-08-18 01:16:09 +04:00
|
|
|
{
|
2005-02-27 03:26:58 +03:00
|
|
|
static const u_int16_t semitone_tuning[24] =
|
1998-08-18 01:16:09 +04:00
|
|
|
{
|
2005-02-27 03:26:58 +03:00
|
|
|
/* 0 */ 10000, 10595, 11225, 11892, 12599, 13348, 14142, 14983,
|
|
|
|
/* 8 */ 15874, 16818, 17818, 18877, 20000, 21189, 22449, 23784,
|
1998-08-18 01:16:09 +04:00
|
|
|
/* 16 */ 25198, 26697, 28284, 29966, 31748, 33636, 35636, 37755
|
|
|
|
};
|
2001-01-18 23:28:15 +03:00
|
|
|
static const u_int16_t cent_tuning[100] =
|
1998-08-18 01:16:09 +04:00
|
|
|
{
|
2005-02-27 03:26:58 +03:00
|
|
|
/* 0 */ 10000, 10006, 10012, 10017, 10023, 10029, 10035, 10041,
|
|
|
|
/* 8 */ 10046, 10052, 10058, 10064, 10070, 10075, 10081, 10087,
|
|
|
|
/* 16 */ 10093, 10099, 10105, 10110, 10116, 10122, 10128, 10134,
|
|
|
|
/* 24 */ 10140, 10145, 10151, 10157, 10163, 10169, 10175, 10181,
|
|
|
|
/* 32 */ 10187, 10192, 10198, 10204, 10210, 10216, 10222, 10228,
|
|
|
|
/* 40 */ 10234, 10240, 10246, 10251, 10257, 10263, 10269, 10275,
|
|
|
|
/* 48 */ 10281, 10287, 10293, 10299, 10305, 10311, 10317, 10323,
|
|
|
|
/* 56 */ 10329, 10335, 10341, 10347, 10353, 10359, 10365, 10371,
|
|
|
|
/* 64 */ 10377, 10383, 10389, 10395, 10401, 10407, 10413, 10419,
|
|
|
|
/* 72 */ 10425, 10431, 10437, 10443, 10449, 10455, 10461, 10467,
|
|
|
|
/* 80 */ 10473, 10479, 10485, 10491, 10497, 10503, 10509, 10515,
|
|
|
|
/* 88 */ 10521, 10528, 10534, 10540, 10546, 10552, 10558, 10564,
|
1998-08-18 01:16:09 +04:00
|
|
|
/* 96 */ 10570, 10576, 10582, 10589
|
|
|
|
};
|
|
|
|
u_int32_t amount;
|
|
|
|
int negative, semitones, cents, multiplier;
|
|
|
|
|
|
|
|
if (range == 0)
|
|
|
|
return base_freq;
|
|
|
|
|
|
|
|
if (base_freq == 0)
|
|
|
|
return base_freq;
|
|
|
|
|
|
|
|
if (range >= 8192)
|
|
|
|
range = 8192;
|
|
|
|
|
|
|
|
bend = bend * range / 8192;
|
|
|
|
bend += vibrato_cents;
|
|
|
|
|
|
|
|
if (bend == 0)
|
|
|
|
return base_freq;
|
|
|
|
|
|
|
|
if (bend < 0) {
|
|
|
|
bend = -bend;
|
|
|
|
negative = 1;
|
2005-02-27 03:26:58 +03:00
|
|
|
} else
|
1998-08-18 01:16:09 +04:00
|
|
|
negative = 0;
|
|
|
|
|
|
|
|
if (bend > range)
|
|
|
|
bend = range;
|
|
|
|
|
|
|
|
multiplier = 1;
|
|
|
|
while (bend > 2399) {
|
|
|
|
multiplier *= 4;
|
|
|
|
bend -= 2400;
|
|
|
|
}
|
|
|
|
|
|
|
|
semitones = bend / 100;
|
|
|
|
if (semitones > 99)
|
|
|
|
semitones = 99;
|
|
|
|
cents = bend % 100;
|
|
|
|
|
|
|
|
amount = semitone_tuning[semitones] * multiplier * cent_tuning[cents]
|
|
|
|
/ 10000;
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
return (base_freq * 10000 / amount); /* Bend down */
|
|
|
|
else
|
|
|
|
return (base_freq * amount / 10000); /* Bend up */
|
|
|
|
}
|
|
|
|
|