home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
app
/
omtd
/
click.c
next >
Wrap
C/C++ Source or Header
|
1991-08-21
|
3KB
|
109 lines
/*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <sys/types.h>
#include <sundev/midi.h>
#include "readline.h"
#include "event.h"
#include "setting.h"
#include "etime.h"
/*
* XXX Read these settings (and others) from environment or init file.
*/
#define ACCENT_CLICK_VELOC 120
#define CLICKLEN 10
#define CLICKNOTE (0x3a+11)
#define CLICKVELOC 80
#define CLICKCHAN 7
static u_long curclick;
void
advance_click(p)
struct event *p;
{
if (p->m.mm_data[2] != 0) {
/* was an on tick - get next off */
curclick += s.click.click_len;
p->m.mm_time = warp_time(s.tempo, curclick);
p->m.mm_data[2] = 0;
} else {
/* was an off tick - get next on tick */
curclick += s.ticks_per_beat - s.click.click_len;
p->m.mm_time = warp_time(s.tempo, curclick);
if((curclick / s.ticks_per_beat) % s.beats_per_bar == 0)
p->m.mm_data[2] = ACCENT_CLICK_VELOC;
else
p->m.mm_data[2] = s.click.click_veloc;
}
}
struct event *
first_click(start)
u_long start;
{
static struct event e;
if (s.click.click_len == 0)
return 0;
/* Round down to next whole beat. */
start -= start % s.ticks_per_beat;
curclick = start;
e.m.mm_time = warp_time(s.tempo, start);
e.m.mm_data[0] = 0x90 | s.click.click_chan;
e.m.mm_data[1] = s.click.click_note;
if((start / s.ticks_per_beat) % s.beats_per_bar == 0)
e.m.mm_data[2] = ACCENT_CLICK_VELOC;
else
e.m.mm_data[2] = s.click.click_veloc;
return &e;
}
click_off()
{
s.click.click_len = 0;
printf("click off\n");
}
void
click_on(chan, note)
int chan;
int note;
{
if (note < 0)
note = CLICKNOTE;
else
note &= 0x7f;
if (chan < 0)
chan = CLICKCHAN;
else
chan = (chan - 1) & 0xf;
s.click.click_len = CLICKLEN;
s.click.click_veloc = CLICKVELOC;
s.click.click_note = note;
s.click.click_chan = chan;
printf("click on (channel %d, note %d)\n", chan + 1, note);
}