Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v97i014: Ravenous Bug Blatter [1.0] - Bars and Pipes Tool for overcoming a bug, Part 01/01

1 view
Skip to first unread message

Richard Hagen

unread,
Nov 18, 1997, 3:00:00 AM11/18/97
to

Submitted-by: Richard Hagen <R.H...@mailbox.uq.edu.au>
Posting-number: Volume 97, Issue 14
Archive-name: music/rbb-1.0/part01
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html#programs

[ Executable (rbb.ptool) included. ...zim ]

Ravenous Bug Blatter: A Bars and Pipes Tool for overcoming a bug that
causes hung notes when the transport is switched to record mode while
a note is sounding.

#!/bin/sh
# This is music/rbb-1.0, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 11/18/1997 18:02 UTC by z...@ibx.com
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1235 -rw------- dmakefile
# 2170 -rw------- myheader.h
# 4624 -rw------- rbb.c
# 1212 -rw------- rbb.ptool
# 1096 -rw------- rbb.readme
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= dmakefile ==============
if test -f 'dmakefile' -a X"$1" != X"-c"; then
echo 'x - skipping dmakefile (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting dmakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'dmakefile' &&
#
# The name of the tool.
#
TOOL = rbb
X
#
# The source files that you need to build the tool.
#
MYSRCS = rbb.c
X
MYHDRS = myheader.h
X
#
# You might want to tinker with the compiler flags and libraries.
#
# -3.0 - Compile for a 3.0 system (optional)
# -mc - Small code model
# -md - Small data model
#
CFLAGS = -3.0 -mc -md
X
#
# Required libraries
#
# amiga30s.lib - The small code version of the Amiga library
# cs.lib - The small code version of the C library
#
LIBS = amiga30s.lib cs.lib
X
#
# You shouldn't have to touch anything below here.
#
# (FYI: (It's important that toolstart.c gets listed first... toolstart.o
# has to be the first thing mentioned when the tool is linked
# together.)
#
PTOOL = $(TOOL).ptool
README = $(TOOL).readme
ARCHIVE = $(TOOL).lha
X
SRCS = toolstart.c $(MYSRCS)
OBJS = $(SRCS:*.c:*.o)
X
all: $(PTOOL)
X
$(PTOOL): $(OBJS)
X dlink $(OBJS) $(LIBS) -o $(PTOOL)
X
$(OBJS): $(SRCS)
X dcc $(CFLAGS) -c %(right) -o %(left)
X
# I use emacs, so I tend to have a lot of backup files ending in ``!''
# lying around.
clean:
X delete $(OBJS) *!
X
clobber: clean
X delete $(PTOOL) $(ARCHIVE)
X
distribution: $(ARCHIVE)
X
$(ARCHIVE): clobber $(PTOOL) clean
X lha a $(ARCHIVE) dmakefile $(PTOOL) $(MYHDRS) $(MYSRCS) $(README)
X
X
X
SHAR_EOF
chmod 0600 dmakefile ||
echo 'restore of dmakefile failed'
Wc_c="`wc -c < 'dmakefile'`"
test 1235 -eq "$Wc_c" ||
echo 'dmakefile: original size 1235, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= myheader.h ==============
if test -f 'myheader.h' -a X"$1" != X"-c"; then
echo 'x - skipping myheader.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting myheader.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'myheader.h' &&
/*
X myheader.h - Useful #defines and typedefs for tool/accessory programs.
*/
X
#ifndef MYHEADER_H
#define MYHEADER_H
X
/* Length of tool/accessory id. */
#define ID_LEN 4
X
/* Make an id out of four characters. */
#define MAKE_ID(a, b, c, d) ((ULONG) ((((a << 8) + b << 8) + c << 8) + d))
X
/* Make an id out of a string. */
#define MAKE_IDS(s) (MAKE_ID(s[0], s[1], s[2], s[3]))
X
/* Split an id into four characters. */
#define SPLIT_ID(id, a, b, c, d) \
do { \
X a = (UBYTE) ((id >> 24) & 0xff); \
X b = (UBYTE) ((id >> 16) & 0xff); \
X c = (UBYTE) ((id >> 8) & 0xff); \
X d = (UBYTE) (id & 0xff); \
} while (0)
X
/* Split an id into a string. */
#define SPLIT_IDS(id, s) \
do { \
X SPLIT_ID(id, s[0], s[1], s[2], s[3]); \
} while (0)
X
/* Maximum MIDI note # */
#define MIDI_NOTE_MAX (127)
X
/* Number of MIDI notes. */
#define MIDI_NOTE_NUM (MIDI_NOTE_MAX + 1)
X
/* Maximum program change number. */
#define PC_CHANGE_MAX 127
X
/* Number of program changes. */
#define PC_CHANGE_NUM (PC_CHANGE_MAX + 1)
X
/* Flags for use in the BRB file requester. */
#define FILES_DELETE 1 /* Delete button */
#define FILES_OPEN 2 /* Open button */
#define FILES_SAVE 4 /* Save button */
#define FILES_TEST 8 /* ??? */
#define FILES_TYPE 16 /* Type string gadget */
#define FILES_PATH 32 /* Path string gadget */
X
/* Initial placement of tool/accessory windows. */
#define INITIAL_LEFT 50
#define INITIAL_TOP 50
X
/* Unprototyping cast. */
typedef __geta4 long (*no_prototype)();
X
/* Void cast. */
typedef __geta4 void (*void_prototype)();
X
/* Event *cast. */
typedef __geta4 struct Event *(*event_prototype)();
X
/* For non-stdio debugging messages. */
#define DEBUG(message) \
do { \
X struct EasyStruct es = { \
X sizeof(struct EasyStruct), \
X 0, \
X "Debugging information", \
X "Message: %s", \
X "OK" \
X }; \
X (void) EasyRequest(functions->window, &es, 0, message); \
} while (0)
X
#define NOTE_LENGTH(x) (768 >> (x))
X
#define MBC_STRING_LENGTH 12
X
#define CLOCKSPERMEASURE 768L
X
#define STREQ(x, y) (strcmp((x), (y)) == 0)
#define STREQN(x, y, n) (strncmp((x), (y), (n)) == 0)
X
#endif /* MYHEADER_H */
SHAR_EOF
chmod 0600 myheader.h ||
echo 'restore of myheader.h failed'
Wc_c="`wc -c < 'myheader.h'`"
test 2170 -eq "$Wc_c" ||
echo 'myheader.h: original size 2170, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= rbb.c ==============
if test -f 'rbb.c' -a X"$1" != X"-c"; then
echo 'x - skipping rbb.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting rbb.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'rbb.c' &&
/*
X Ravenous Bug Blatter: A Bars and Pipes tool that helps work around
X a bug that causes notes to hang when the transport is switched
X to record mode while a note is sounding.
X
X Copyright (C) 1997 Richard Hagen
X
X This code is released into the Public Domain, and may be freely
X distributed in its original form.
X
X It is supplied ``as is'', and comes with no warranty.
X This program code was released because it might be useful as a
X starting point for other programmers. However, if any damage arises
X from its use, the original author will not be held liable.
X
X You are free to use and modify this code to your heart's content,
X provided you acknowledge me as the original author in any code
X that you might distribute which is based largely on this code.
X
X I acknowledge that the design of this accessory is influenced
X strongly by the example code supplied with the Rules for Tools
X package. However, I have made substantial contributions of my
X own.
X
X Richard Hagen
X ric...@it.uq.edu.au
X
X History:
X 1.0 (22 September 1997)
X Initial release.
*/
X
#include <libraries/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <exec/memory.h>
#include <string.h>
#include <intuition/intuition.h>
X
#include "bars.h"
#include "myheader.h"
X
#define RBB_NAME "Ravenous Bug Blatter 1.0"
#define RBB_ID MAKE_IDS("RBBL")
#define RBB_TYPE (TOOL_NORMAL | TOOL_NOTPAD)
X
__chip static UWORD rbb[] = {
X /*------ plane # 0: --------*/
X 0x0, 0x0,
X 0x3fff, 0xfc00,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x2000, 0x0400,
X 0x3fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 1: --------*/
X 0x0, 0x0,
X 0x0, 0x0,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0xdfff, 0xff00,
X 0xdfff, 0xff00,
X 0xdfff, 0xff00,
X 0xdfff, 0xff00,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 2: --------*/
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x007c, 0x0,
X 0x0066, 0x0,
X 0x0066, 0x0,
X 0x007c, 0x0,
X 0x0066, 0x0,
X 0x0066, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0
};
X
static struct Image rbb_image = {
X 0,0,
X 24 , 12 , 3 ,
X &rbb[0],
X 0x1f,0x00,
X NULL
};
X
struct RBBTool {
X struct Tool tool;
X
X /* Count of notes that have been played. */
X char played[MIDI_NOTE_NUM];
};
X
static struct ToolMaster master;
X
extern struct Functions *functions;
X
static void
rbb_tool_init(struct RBBTool *tool)
{
X tool->tool.touched = TOUCH_INIT;
X
X memset(tool->played, 0, MIDI_NOTE_NUM);
}
X
__geta4
static void
transportcode(const long command,
X const long time,
X const long end)
{
X switch (command)
X {
X case TC_RECORDON:
X case TC_START:
X case TC_PLAY:
X case TC_STOP:
X for (struct Track *track = functions->tracklist;
X track;
X track = track->next)
X {
X for (struct Tool *tool = track->toollist;
X tool;
X tool = tool->next)
X {
X if (tool->toolid == RBB_ID)
X {
X struct RBBTool *rbb = (struct RBBTool *) tool;
X
X if (!rbb->tool.touched ||
X command == TC_PLAY ||
X command == TC_START ||
X command == TC_STOP)
X {
X rbb_tool_init(rbb);
X }
X
X if (command == TC_RECORDON)
X {
X for (int i = 0; i < MIDI_NOTE_NUM; i++)
X {
X if (rbb->played[i])
X {
X struct NoteEvent *note =
X (struct NoteEvent *)(*functions->allocevent)();
X if (note)
X {
X note->status = MIDI_NOTEOFF;
X note->value = i;
X note->time = time;
X note->tool = tool->next;
X note->next = NULL;
X (*functions->qevent)(note);
X }
X }
X }
X }
X }
X }
X }
X break;
X
X default:
X break;
X }
}
X
__geta4
static struct Event *
processeventcode(struct Event *event)
{
X struct RBBTool *tool = (struct RBBTool *) event->tool;
X if (!tool->tool.touched)
X {
X rbb_tool_init(tool);
X }
X
X if (event->status == MIDI_NOTEON &&
X ((struct NoteEvent *)event)->duration > 0)
X {
X tool->played[event->byte1] = 1;
X }
X
X event->tool = event->tool->next;
X return(event);
}
X
__geta4
static void
removetool()
{
X (*functions->removetransport)(transportcode);
}
X
struct ToolMaster *
inittoolmaster()
{
X memset((char *)&master,0,sizeof(struct ToolMaster));
X master.toolid = RBB_ID;
X master.image = &rbb_image;
X strcpy(master.name, RBB_NAME);
X master.processevent = (event_prototype) processeventcode;
X master.tooltype = RBB_TYPE;
X master.toolsize = sizeof(struct RBBTool);
X master.removetool = removetool;
X (*functions->installtransport)(transportcode);
X return(&master);
}
X
SHAR_EOF
chmod 0600 rbb.c ||
echo 'restore of rbb.c failed'
Wc_c="`wc -c < 'rbb.c'`"
test 4624 -eq "$Wc_c" ||
echo 'rbb.c: original size 4624, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= rbb.ptool ==============
if test -f 'rbb.ptool' -a X"$1" != X"-c"; then
echo 'x - skipping rbb.ptool (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting rbb.ptool (Binary)'
sed 's/^X//' << 'SHAR_EOF' > _shar_tmp_.tmp &&
begin 600 rbb.ptool
<encoded_portion_removed>
end
SHAR_EOF
echo 'uudecoding file rbb.ptool' &&
uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
chmod 0600 rbb.ptool ||
echo 'restore of rbb.ptool failed'
Wc_c="`wc -c < 'rbb.ptool'`"
test 1212 -eq "$Wc_c" ||
echo 'rbb.ptool: original size 1212, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= rbb.readme ==============
if test -f 'rbb.readme' -a X"$1" != X"-c"; then
echo 'x - skipping rbb.readme (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting rbb.readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'rbb.readme' &&
Short: Bars & Pipes Tool that works around a bug that causes hung notes.
Author: Richard Hagen (R.H...@mailbox.uq.edu.au)
Uploader: Richard Hagen (R.H...@mailbox.uq.edu.au)
Version: 1.0 (22 September 1997)
Type: mus/midi
Requires: Bars and Pipes Professional
Distribution: Freely distributable by anyone, anywhere.
X
Ravenous Bug Blatter: A Bars and Pipes Tool for overcoming a bug that causes hung
X notes when the transport is switched to record mode while a note is
X sounding.
X
Version: 1.0 (22 September 1997)
X
Author: Richard Hagen
X R.H...@mailbox.uq.edu.au
X
Distribution: Freeware. See the copyright notice in rbb.c.
X
Requirements for running:
X Bars and Pipes Professional
X
Requirements for recompiling:
X DICE (or some other C compiler).
X toolstart.c and bars.h from the Rules for Tools package.
X
Usage:
X Put it in the right side of the pipeline, as close to the MIDI Out as you can.
X
X That's it!
X
Useful for:
X Overcoming a bug in Bars and Pipes.
X
History:
X 1.0 (22 September 1997)
X Initial release.
X
richard
R.H...@mailbox.uq.edu.au
22 September 1997
X
X
SHAR_EOF
chmod 0600 rbb.readme ||
echo 'restore of rbb.readme failed'
Wc_c="`wc -c < 'rbb.readme'`"
test 1096 -eq "$Wc_c" ||
echo 'rbb.readme: original size 1096, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0
--
Bill Zimmer - z...@ibx.com

0 new messages