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

v97i018: TM [1.2] - Bars and Pipes Transport Monitor, Part 01/01

2 views
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 18
Archive-name: music/TM-1.2/part01
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html#programs

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

TM: A Bars and Pipes Transport Monitor

Place it in a track. Open TM's window, then watch the commands
stream by as you play with the transport!

#!/bin/sh
# This is music/TM-1.2, 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:32 UTC by z...@ibx.com
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1233 -rw------- dmakefile
# 2170 -rw------- myheader.h
# 8469 -rw------- tm.c
# 2356 -rw------- tm.ptool
# 1386 -rw------- tm.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 = tm
X
#
# The source files that you need to build the tool.
#
MYSRCS = tm.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 1233 -eq "$Wc_c" ||
echo 'dmakefile: original size 1233, 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
# ============= tm.c ==============
if test -f 'tm.c' -a X"$1" != X"-c"; then
echo 'x - skipping tm.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting tm.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'tm.c' &&
/*
X TM: A Bars and Pipes Transport Monitor tool.
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 R.H...@mailbox.uq.edu.au
X
X History:
X 1.2 (22 September 1997)
X Made it a normal tool.
X
X 1.1 (15 September 1997)
X Improved efficiency of the code.
X
X 1.0 (13 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>
#include <intuition/sghooks.h>
X
#include "bars.h"
#include "myheader.h"
X
#define TM_NAME "Transport Monitor 1.2"
X
#define TM_ID MAKE_IDS("TMON")
X
#define TM_TYPE (TOOL_NORMAL | TOOL_NOTPAD)
X
__chip static UWORD tm[] = {
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 0x101b, 0xec00,
X 0xdef9, 0xcf00,
X 0xdefa, 0xaf00,
X 0xdefb, 0x6f00,
X 0xdefb, 0xef00,
X 0x1efb, 0xec00,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 2: --------*/
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0fe4, 0x1000,
X 0x0106, 0x3000,
X 0x0105, 0x5000,
X 0x0104, 0x9000,
X 0x0104, 0x1000,
X 0x0104, 0x1000,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X
};
X
static struct Image tm_image = {
X 0,0,
X 24 , 12 , 3 ,
X &tm[0],
X 0x1f,0x00,
X NULL
};
X
/* Length of a transport commmand name string. */
#define TC_NAME_LENGTH 13
X
/* Strings for the names of the transport commands. */
static const char *tc_names[8] = {
X " ", /* There is no transport command 0 */
X "TC_START ",
X "TC_STOP ",
X "TC_POSITION ",
X "TC_RECORDON ",
X "TC_RECORDOFF",
X "TC_PLAY ",
X "TC_TICK "
X };
X
/* For storing output information. */
struct Line {
X char command[TC_NAME_LENGTH]; /* String for transport command. */
X char start[MBC_STRING_LENGTH]; /* String for the start time. */
X char end[MBC_STRING_LENGTH]; /* String for the end time. */
};
X
#define LINE_LENGTH TC_NAME_LENGTH + MBC_STRING_LENGTH + MBC_STRING_LENGTH
#define NUM_LINES 20
X
#define WINDOW_WIDTH (LINE_LENGTH * 8) + 10
#define WINDOW_HEIGHT (NUM_LINES * 10) + 15
X
struct TMTool {
X struct Tool tool;
X
X int line;
X char lines[NUM_LINES][LINE_LENGTH]; /* The lines of output. */
};
X
extern struct Functions *functions;
X
static void
X tm_tool_init(struct TMTool *tool)
{
X tool->tool.touched = TOUCH_INIT;
X
X tool->line = 0;
X
X for (int i = 0;
X i < NUM_LINES;
X i++)
X {
X for (int j = 0;
X j < LINE_LENGTH - 1;
X j++)
X {
X tool->lines[i][j] = ' ';
X }
X tool->lines[i][LINE_LENGTH] = '\0';
X }
}
X
static struct ToolMaster master;
X
static void
display_lines(struct TMTool *tool)
{
X struct RastPort *rp = tool->tool.window->RPort;
X
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X
X int line = tool->line;
X
X for (int i = 0;
X i < NUM_LINES;
X i++)
X {
X Move(rp, 7, WINDOW_HEIGHT - 5 - i * 10);
X
X Text(rp, tool->lines[line], LINE_LENGTH - 1);
X line = (line == 0) ? NUM_LINES - 1 : line - 1;
X }
}
X
/* Update and display commands if necessary. */
static void
X transporttool(struct TMTool *tool,
X const long command, /* Transport command. */
X const long start, /* Start time for command. */
X const long end) /* End time for command. */
{
X char start_string[MBC_STRING_LENGTH];
X char end_string[MBC_STRING_LENGTH];
X
X (*functions->timetostring)(&(tool->tool.track->clip), start, start_string);
X (*functions->timetostring)(&(tool->tool.track->clip), end, end_string);
X
X tool->line = (tool->line + 1) % NUM_LINES;
X sprintf(tool->lines[tool->line], "%s %s %s",
X tc_names[command],
X start_string, end_string);
X
X /* Display the info if the window is open. */
X if (tool->tool.window)
X {
X display_lines(tool);
X }
}
X
/* Called whenever something happens in the transport. */
__geta4 /* Callback. */
void transportcode(long command, /* Transport command. */
X long start, /* Start time for command. */
X long end) /* End time for command. */
{
X /* Find all the TMTools and get them to do their thing. */
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 == TM_ID)
X {
X transporttool((struct TMTool *)tool, command, start, end);
X }
X }
X }
}
X
/* Process notes. */
__geta4 /* Callback. */
struct Event *
X processeventcode(struct Event *event)
{
X event->tool = event->tool->next; /* Doesn't do anything! */
X return(event);
}
X
struct NewWindow TMNewWindowStructure1 = {
X 20, 20,
X 305, WINDOW_HEIGHT,
X 0,6,
X GADGETDOWN+GADGETUP+CLOSEWINDOW,
X WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
X NULL,
X NULL,
X "Transport Monitor",
X NULL,
X NULL,
X 5,5,
X -1,-1,
X CUSTOMSCREEN
};
X
/* Interface driver called by Bars and Pipes. */
__geta4 /* Callback. */
void edittoolcode(struct TMTool *tool)
{
X struct IntuiMessage *message;
X struct Window *window;
X long class, code;
X struct Gadget *gadget;
X struct NewWindow *newwindow;
X
X if (!tool->tool.touched)
X {
X tm_tool_init(tool);
X }
X
X TMNewWindowStructure1.Screen = functions->screen;
X
X if (tool->tool.touched & TOUCH_EDIT)
X {
X TMNewWindowStructure1.LeftEdge = tool->tool.left;
X TMNewWindowStructure1.TopEdge = tool->tool.top;
X }
X
X newwindow = (struct NewWindow *)
X (*functions->DupeNewWindow)(&TMNewWindowStructure1);
X if (!newwindow)
X {
X return;
X }
X newwindow->Title = 0;
X newwindow->Flags |= BORDERLESS;
X newwindow->Flags &= ~0xF;
X newwindow->BlockPen = 0;
X newwindow->DetailPen = 0;
X
X window = (struct Window *) (*functions->FlashyOpenWindow)(newwindow);
X if (window == NULL)
X {
X return;
X }
X
X tool->tool.window = window;
X
X /* Make the various gadgets look pretty. */
X (*functions->EmbossWindowOn)(window,WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,
X TM_NAME, (short)-1, (short)-1, 0, 0);
X
X display_lines(tool);
X
X /* Process messages until a CLOSEWINDOW. */
X for (;;)
X {
X message = (struct IntuiMessage *) (*functions->GetIntuiMessage)(window);
X class = message->Class;
X code = message->Code;
X gadget = (struct Gadget *) message->IAddress;
X class = (*functions->SystemGadgets)(window,class,gadget,code);
X
X ReplyMsg((struct Message *)message);
X
X if (class == CLOSEWINDOW)
X {
X break; /* ... out of the for(;;) loop. */
X }
X else if (class == GADGETDOWN)
X {
X /* Nothing. */
X }
X else if (class == GADGETUP)
X {
X /* Nothing. */
X }
X }
X tool->tool.window = 0;
X tool->tool.left = window->LeftEdge;
X tool->tool.top = window->TopEdge;
X tool->tool.width = window->Width;
X tool->tool.height = window->Height;
X tool->tool.touched = TOUCH_INIT | TOUCH_EDIT;
X
X (*functions->EmbossWindowOff)(window);
X (*functions->FlashyCloseWindow)(window);
X (*functions->DeleteNewWindow)(newwindow);
}
X
/* Make sure we remove the transport routine. */
__geta4 /* Callback. */
void removetool()
{
X (*functions->removetransport)(transportcode);
}
X
struct ToolMaster *
X inittoolmaster()
{
X memset((char *)&master,0,sizeof(struct ToolMaster));
X master.toolid = TM_ID;
X master.image = &tm_image;
X strcpy(master.name, TM_NAME);
X master.edittool = (void_prototype) edittoolcode;
X master.processevent = (event_prototype) processeventcode;
X master.tooltype = TM_TYPE;
X master.removetool = removetool;
X master.toolsize = sizeof(struct TMTool);
X (*functions->installtransport)(transportcode);
X return(&master);
}
SHAR_EOF
chmod 0600 tm.c ||
echo 'restore of tm.c failed'
Wc_c="`wc -c < 'tm.c'`"
test 8469 -eq "$Wc_c" ||
echo 'tm.c: original size 8469, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= tm.ptool ==============
if test -f 'tm.ptool' -a X"$1" != X"-c"; then
echo 'x - skipping tm.ptool (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting tm.ptool (Binary)'
sed 's/^X//' << 'SHAR_EOF' > _shar_tmp_.tmp &&
begin 600 tm.ptool
<encoded_portion_removed>
end
SHAR_EOF
echo 'uudecoding file tm.ptool' &&
uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
chmod 0600 tm.ptool ||
echo 'restore of tm.ptool failed'
Wc_c="`wc -c < 'tm.ptool'`"
test 2356 -eq "$Wc_c" ||
echo 'tm.ptool: original size 2356, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= tm.readme ==============
if test -f 'tm.readme' -a X"$1" != X"-c"; then
echo 'x - skipping tm.readme (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting tm.readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'tm.readme' &&
Short: Bars & Pipes Transport Monitor Tool
Author: Richard Hagen (R.H...@mailbox.uq.edu.au)
Uploader: Richard Hagen (R.H...@mailbox.uq.edu.au)
Version: 1.2 (22 September 1997)
Type: mus/midi
Requires: Bars and Pipes Professional
Distribution: Freely distributable by anyone, anywhere.
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html
X
TM: A Bars and Pipes Transport Monitor
X
Version: 1.2 (22 September 1997)
X
Author: Richard Hagen
X R.H...@mailbox.uq.edu.au
X
Distribution: Freeware. See the copyright notice in tm.c.
X
Requirements for running:
X Bars and Pipes Professional
X
Requirements for recompiling:
X DICE (or some other C compiler)
X bars.h and toolstart.c from the Rules for Tools package.
X
Usage:
X TM is a normal tool. It can't be used as a padtool.
X
X Place it in a track. Open TM's window, then watch
X the commands stream by as you play with the transport!
X
Useful for:
X Finding out what sort of commands are being issued by the
X Bars and Pipes transport. Which I guess means that it's
X only useful for people who write their own tools.
X
History:
X 1.2 (22 September 1997)
X Made it a normal tool.
X
X 1.1 (15 September 1997)
X Improved efficiency of the code.
X
X 1.0 (13 September 1997)
X Initial release.
X
If you like this tool, please drop me a line.
X
richard
R.H...@mailbox.uq.edu.au
22 September 1997
X
X
SHAR_EOF
chmod 0600 tm.readme ||
echo 'restore of tm.readme failed'
Wc_c="`wc -c < 'tm.readme'`"
test 1386 -eq "$Wc_c" ||
echo 'tm.readme: original size 1386, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0
--
Bill Zimmer - z...@ibx.com

0 new messages