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

v97i012: PC Mapper Tool [1.1] - Bars and Pipes Tool for mapping program changes, Part 01/01

3 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 12
Archive-name: music/PCMapperTool-1.1/part01
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html#programs

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

PC Mapper Tool: A Bars and Pipes Tool for mapping program changes to other
program changes.

The PC Mapper Tool uses a Program Change Map (PC Map) to map from one program
change to another. You can edit the program change map from within the PC Mapper
Tool.

#!/bin/sh
# This is music/PCMapperTool-1.1, 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 17:49 UTC by z...@ibx.com
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1253 -rw------- dmakefile
# 2288 -rw------- myheader.h
# 17441 -rw------- pcmappertool.c
# 5412 -rw------- pcmappertool.ptool
# 1769 -rw------- pcmappertool.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 = pcmappertool
X
#
# The source files that you need to build the tool.
#
MYSRCS = pcmappertool.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 1253 -eq "$Wc_c" ||
echo 'dmakefile: original size 1253, 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
/* Maximum CC value. */
#define CC_VALUE_MAX 127
X
/* Number of CC values. */
#define CC_VALUE_NUM (CC_VALUE_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 2288 -eq "$Wc_c" ||
echo 'myheader.h: original size 2288, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmappertool.c ==============
if test -f 'pcmappertool.c' -a X"$1" != X"-c"; then
echo 'x - skipping pcmappertool.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmappertool.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcmappertool.c' &&
/*
X PC Mapper Tool: A Bars and Pipes Tool for mapping program changes to other
X program changes.
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.1 (6 October 1997)
X Changed name to PC Mapper Tool. Added ``Randomise'' gadget and rearranged
X the interface.
X
X 1.0 (29 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 PC_MAPPER_TOOL_NAME "PC Mapper Tool 1.1"
X
#define PC_MAPPER_TOOL_ID MAKE_IDS("PCMT")
#define PC_MAPPER_TOOL_TYPE (TOOL_NORMAL | TOOL_NOTPAD)
X
/* ID string for the accessory - used in saving PC Map files. */
#define PC_MAPPER_ID_STRING "PCMP"
X
__chip static UWORD pc_mapper_tool[] = {
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 0x073c, 0xe400,
X 0xcafd, 0x5f00,
X 0xcafd, 0x5f00,
X 0xc6fc, 0xdf00,
X 0xcefd, 0xdf00,
X 0x0f3d, 0xe400,
X 0x1fff, 0xfc00,
X 0x1fff, 0xfc00,
X 0x0, 0x0,
X
X /*------ plane # 2: --------*/
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0010, 0x0,
X 0x0008, 0x0,
X 0x007c, 0x0,
X 0x0008, 0x0,
X 0x0010, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
};
X
static struct Image pc_mapper_tool_image = {
X 0,0,
X 24 , 12 , 3 ,
X &pc_mapper_tool[0],
X 0x1f,0x00,
X NULL
};
X
static struct ToolMaster master;
X
extern struct Functions *functions;
X
/* Puts up a simple requester for relaying error messages. */
static const char *error_title = "PC Mapper Tool Error";
X
static void
tool_error(struct Window *window, /* Window to open requester in. */
X const char *s) /* String to put in the requester. */
{
X const struct EasyStruct easy = {
X sizeof(struct EasyStruct),
X 0,
X error_title,
X s,
X "OK"
X };
X
X (void) EasyRequest(window, &easy, NULL);
}
X
/* A map from program change # to program change #. */
typedef BYTE PCMap[PC_CHANGE_NUM];
X
struct PCMapperTool {
X struct Tool tool;
X UBYTE display;
X PCMap pc_map;
};
X
__geta4
static void
pc_map_load(struct Window *window, PCMap pc_map)
{
X char filename[255];
X
X /* Get the filename */
X (*functions->FileName)(filename,"Load PC Map File:","pcmap",
X functions->screen,
X FILES_OPEN|FILES_DELETE|FILES_TYPE,0,0);
X if (filename[0])
X {
X /* Attempt to open the file and check to see if we
X succeeded. */
X const long file = (*functions->fastopen)(filename,MODE_OLDFILE);
X if (file != -1)
X {
X if ((*functions->areyousure)("replace the PC map?"))
X {
X char file_id[ID_LEN]; /* File ID. */
X (*functions->openwait)();
X
X /* Ensure that the file id is one for a pc map. */
X if ((*functions->fastread)(file, file_id, ID_LEN) < ID_LEN)
X {
X /* Failed to read the correct number of bytes for the file id. */
X return;
X }
X if (!STREQN(file_id, PC_MAPPER_ID_STRING, ID_LEN))
X {
X /* Incorrect id */
X return;
X }
X
X (*functions->fastread)(file, pc_map, sizeof(PCMap));
X (*functions->closewait)();
X }
X (*functions->fastclose)(file);
X }
X else
X {
X tool_error(window, "Couldn't open file for reading");
X }
X }
X
}
X
__geta4
static void
pc_map_save(struct Window *window, PCMap pc_map)
{
X char filename[255];
X
X /* Get the filename */
X (*functions->FileName)(filename,"Load PC Map File:","pcmap",
X functions->screen,
X FILES_SAVE|FILES_DELETE|FILES_TYPE,0,0);
X if (filename[0])
X {
X /* Attempt to open the file and check to see if we
X succeeded. */
X const long file = (*functions->fastopen)(filename,MODE_NEWFILE);
X if (file != -1)
X {
X (*functions->openwait)();
X
X (*functions->fastwrite)(file, PC_MAPPER_ID_STRING, ID_LEN);
X (*functions->fastwrite)(file, pc_map, sizeof(PCMap));
X (*functions->closewait)();
X (*functions->fastclose)(file);
X }
X else
X {
X tool_error(window, "Couldn't open file for saving");
X }
X }
}
X
static void
pc_map_clear(PCMap pc_map)
{
X for (int i = 0; i < PC_CHANGE_NUM; i++)
X {
X pc_map[i] = (UBYTE) i;
X }
}
X
static void
map_tool_init(struct PCMapperTool *tool)
{
X tool->tool.touched = TOUCH_INIT;
X
X tool->display = 0;
X pc_map_clear(tool->pc_map);
}
X
static void
pc_map_randomise(PCMap pc_map)
{
X for (int i = 0; i < PC_CHANGE_NUM; i++)
X {
X pc_map[i] = (*functions->random)(PC_CHANGE_NUM);
X }
}
X
__geta4
static struct Event *
processeventcode(struct Event *event)
{
X struct PCMapperTool *tool = (struct pcmappertool *) event->tool;
X event->tool = event->tool->next;
X
X if (event->status == MIDI_PCHANGE)
X {
X if (!tool->tool.touched)
X {
X map_tool_init(tool);
X }
X
X event->byte1 = tool->pc_map[event->byte1];
X }
X
X return(event);
}
X
#define LOAD_PC_MAP_GADGET 1
#define SAVE_PC_MAP_GADGET 2
#define CLEAR_PC_MAP_GADGET 3
#define RANDOMISE_GADGET 4
X
#define SCROLLER_GADGET 5
#define SCROLLERDOWN_GADGET 6
#define SCROLLERUP_GADGET 7
X
/* Number of first patch gadget. */
#define FIRST_PATCH_GADGET (SCROLLERUP_GADGET + 1)
X
/* Number of patches seen at once. */
#define NUM_PATCH_GADGETS 16
X
/* Load pc_map gadget. */
static const struct IntuiText itext1 = {
X 4,0,JAM1,
X 4,1,
X NULL,
X "Load PC Map",
X NULL
};
X
static const struct Gadget gadget1 = {
X NULL,
X 8, 14,
X 96, 9,
X (ULONG) NULL,
X RELVERIFY+GADGIMMEDIATE,
X BOOLGADGET,
X NULL,
X NULL,
X &itext1,
X (ULONG) NULL,
X NULL,
X LOAD_PC_MAP_GADGET,
X NULL
};
X
/* Save pc_map gadget. */
static const struct IntuiText itext2 = {
X 4,0,JAM1,
X 4,1,
X NULL,
X "Save PC Map",
X NULL
};
X
static const struct Gadget gadget2 = {
X &gadget1,
X 8, 25,
X 96, 9,
X (ULONG) NULL,
X RELVERIFY+GADGIMMEDIATE,
X BOOLGADGET,
X NULL,
X NULL,
X &itext2,
X (ULONG) NULL,
X NULL,
X SAVE_PC_MAP_GADGET,
X NULL
};
X
/* Clear map gadget. */
static const struct IntuiText itext5 = {
X 4,0,JAM1,
X 4, 1,
X NULL,
X "Clear Map",
X NULL
};
X
static const struct Gadget gadget5 = {
X &gadget2,
X 108, 14,
X 80, 9,
X (ULONG) NULL,
X RELVERIFY+GADGIMMEDIATE,
X BOOLGADGET,
X NULL,
X NULL,
X &itext5,
X (ULONG) NULL,
X NULL,
X CLEAR_PC_MAP_GADGET,
X NULL
};
X
/* Randomise gadget. */
static const struct IntuiText itext6 = {
X 4,0,JAM1,
X 4, 1,
X NULL,
X "Randomise",
X NULL
};
X
static const struct Gadget gadget6 = {
X &gadget5,
X 108, 25,
X 80, 9,
X (ULONG) NULL,
X RELVERIFY+GADGIMMEDIATE,
X BOOLGADGET,
X NULL,
X NULL,
X &itext6,
X (ULONG) NULL,
X NULL,
X RANDOMISE_GADGET,
X NULL
};
X
/* Patch select scroller. */
static const struct PropInfo scroller_gadget_info = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
static const struct Image scroller_gadget_image = {
X 0,0,
X 102, 6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
X };
X
static const struct Gadget scroller_gadget = {
X &gadget6,
X 54, 38,
X 100, 10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&scroller_gadget_image,
X NULL,
X NULL,
X NULL,
X &scroller_gadget_info,
X SCROLLER_GADGET,
X NULL
X };
X
/* Top Of the patch gadgets. */
#define PATCH_GADGETS_TOP 51
X
/* Initial templates for the gadget values. */
static const struct PropInfo init_patch_gadget_info = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
static const struct Image init_patch_gadget_image = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
X };
X
static const struct Gadget init_patch_gadget = {
X NULL, /* Initialised below. */
X 54, PATCH_GADGETS_TOP, /* Altered below. */
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X NULL, /* Initialised below. */
X NULL,
X NULL,
X NULL,
X NULL, /* Initialised below. */
X 0, /* Initialised below. */
X NULL
X };
X
/* All initialised in edittoolcode(). */
static struct Gadget patch_gadget[NUM_PATCH_GADGETS];
X
struct NewWindow PCMapperToolNewWindowStructure1 = {
X 75,85,
X 196, PATCH_GADGETS_TOP + (NUM_PATCH_GADGETS * 12) + 2,
X 0,6,
X GADGETDOWN+GADGETUP+CLOSEWINDOW,
X WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
X &patch_gadget[NUM_PATCH_GADGETS - 1],
X NULL,
X NULL,
X NULL,
X NULL,
X 5,5,
X -1,-1,
X CUSTOMSCREEN
};
X
/* Writes the value of a proportional slider. Thank goodness
X all the sliders are identical in range and behaviour! */
__geta4 /* Callback. */
long display_routine(struct Window *window, /* Window where the gadget lives. */
X struct Gadget *gadget, /* The gadget itself. */
X ULONG value) /* The value to display. */
{
X char text[10];
X struct RastPort *rp = window->RPort;
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X
X Move(rp, 159, PATCH_GADGETS_TOP + 8 + ((gadget->GadgetID - FIRST_PATCH_GADGET) / 3) * 12);
X sprintf(text, "%3ld", value);
X Text(rp, text, 3);
X
X return value;
}
X
__geta4
long scroller_display_routine(struct Window *window,
X struct Gadget *gadget,
X ULONG value)
{
X char text[10];
X struct RastPort *rp = window->RPort;
X
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X
X Move(rp, 19, 45);
X sprintf(text, "%3ld", value * NUM_PATCH_GADGETS);
X Text(rp, text, 3);
X
X Move(rp, 159, 45);
X sprintf(text, "%3ld", (value + 1) * NUM_PATCH_GADGETS - 1);
X Text(rp, text, 3);
X return value;
X
X return 0;
}
X
static void
patch_display(struct Window *window,
X struct PCMapperTool *tool)
{
X UBYTE patch = tool->display * NUM_PATCH_GADGETS;
X
X (*functions->DrawEmbossedProp)(window, SCROLLER_GADGET);
X for (int i = 0; i < NUM_PATCH_GADGETS; i++, patch++)
X {
X const short id = FIRST_PATCH_GADGET + i * 3;
X
X char text[10];
X struct RastPort *rp = window->RPort;
X
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X
X Move(rp, 7, PATCH_GADGETS_TOP + 8 + i * 12);
X sprintf(text, "%3ld->", i + tool->display * NUM_PATCH_GADGETS);
X Text(rp, text, 5);
X
X (*functions->ModifyEmbossedProp)(window,id, tool->pc_map[patch], 0, 0, 0, 0, 0);
X (*functions->DrawEmbossedProp)(window, id);
X }
}
X
static long
drag_embossed_prop(struct Window *window,
X short id)
{
X long value = (*functions->DragEmbossedProp)(window, id);
X (*functions->DrawEmbossedProp)(window, id);
X
X return value;
}
X
static long
shift_embossed_prop(struct Window *window,
X short id,
X short shift)
{
X long value = (*functions->ShiftEmbossedProp)(window, id, shift, 0);
X (*functions->DrawEmbossedProp)(window, id);
X
X return value;
}
X
__geta4
static void
edittoolcode(struct PCMapperTool *tool)
{
X struct IntuiMessage *message;
X struct Window *window;
X long class, code;
X struct Gadget *gadget;
X struct NewWindow *newwindow;
X
X struct Gadget *next;
X
X PCMapperToolNewWindowStructure1.Screen = functions->screen;
X
X if (tool->tool.touched & TOUCH_EDIT)
X {
X PCMapperToolNewWindowStructure1.LeftEdge = tool->tool.left;
X PCMapperToolNewWindowStructure1.TopEdge = tool->tool.top;
X PCMapperToolNewWindowStructure1.Width = tool->tool.width;
X PCMapperToolNewWindowStructure1.Height = tool->tool.height;
X }
X
X if (!tool->tool.touched)
X {
X map_tool_init(tool);
X }
X
X next = &scroller_gadget;
X for (int i = 0;
X i < NUM_PATCH_GADGETS;
X i++)
X {
X memcpy((char *)&patch_gadget[i],
X (char *)&init_patch_gadget, sizeof(struct Gadget));
X
X patch_gadget[i].NextGadget = next;
X patch_gadget[i].TopEdge = PATCH_GADGETS_TOP + i * 12;
X patch_gadget[i].GadgetRender = (APTR)&init_patch_gadget_image;
X patch_gadget[i].SpecialInfo = (APTR)&init_patch_gadget_info;
X patch_gadget[i].GadgetID = (i * 3) + FIRST_PATCH_GADGET;
X
X next = &patch_gadget[i];
X }
X
X newwindow = (struct NewWindow *)
X (*functions->DupeNewWindow)(&PCMapperToolNewWindowStructure1);
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)
X {
X return;
X }
X
X tool->tool.window = window;
X (*functions->EmbossWindowOn)(window,WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,
X PC_MAPPER_TOOL_NAME,(short)-1,(short)-1,0,0);
X
X (*functions->EmbossOn)(window,LOAD_PC_MAP_GADGET,1);
X (*functions->EmbossOn)(window,SAVE_PC_MAP_GADGET,1);
X (*functions->EmbossOn)(window,CLEAR_PC_MAP_GADGET,1);
X (*functions->EmbossOn)(window,RANDOMISE_GADGET,1);
X for (int j = 0; j < NUM_PATCH_GADGETS; j++)
X {
X const short gadget = (j * 3) + FIRST_PATCH_GADGET;
X (*functions->FatEmbossedPropOn)(window,
X gadget, gadget + 1, gadget + 2,
X (no_prototype) display_routine,
X 128, 1);
X }
X
X (*functions->FatEmbossedPropOn)(window,
X SCROLLER_GADGET, SCROLLERDOWN_GADGET,
X SCROLLERUP_GADGET,
X (no_prototype) scroller_display_routine,
X (PC_CHANGE_NUM / NUM_PATCH_GADGETS),
X 2);
X
X patch_display(window, tool);
X
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 if (class == CLOSEWINDOW)
X {
X break;
X }
X else if (class == GADGETDOWN)
X {
X const short id = gadget->GadgetID;
X switch (id)
X {
X case LOAD_PC_MAP_GADGET:
X (*functions->doscall)(pc_map_load, window, tool->pc_map);
X patch_display(window, tool);
X break;
X case SAVE_PC_MAP_GADGET:
X (*functions->doscall)(pc_map_save, window, tool->pc_map);
X break;
X case CLEAR_PC_MAP_GADGET:
X if ((*functions->areyousure)("clear the PC map?"))
X {
X (*functions->openwait)();
X pc_map_clear(tool->pc_map);
X patch_display(window, tool);
X (*functions->closewait)();
X }
X break;
X case RANDOMISE_GADGET:
X if ((*functions->areyousure)("randomise the PC map?"))
X {
X (*functions->openwait)();
X pc_map_randomise(tool->pc_map);
X patch_display(window, tool);
X (*functions->closewait)();
X }
X break;
X case SCROLLER_GADGET:
X tool->display = (UBYTE) drag_embossed_prop(window, SCROLLER_GADGET);
X patch_display(window, tool);
X break;
X case SCROLLERDOWN_GADGET:
X tool->display = (UBYTE) shift_embossed_prop(window, SCROLLER_GADGET, -1);
X patch_display(window, tool);
X break;
X case SCROLLERUP_GADGET:
X tool->display = (UBYTE) shift_embossed_prop(window, SCROLLER_GADGET, 1);
X patch_display(window, tool);
X break;
X default: /* Patch select gadgets. */
X {
X const UBYTE patch = (tool->display * NUM_PATCH_GADGETS) +
X (id - FIRST_PATCH_GADGET) / 3;
X switch ((id - FIRST_PATCH_GADGET) % 3)
X {
X case 0:
X tool->pc_map[patch] =
X (UBYTE) drag_embossed_prop(window, id);
X break;
X case 1:
X tool->pc_map[patch] =
X (UBYTE) shift_embossed_prop(window, id - 1, -1);
X break;
X case 2:
X tool->pc_map[patch] =
X (UBYTE) shift_embossed_prop(window, id - 2, 1);
X break;
X }
X }
X }
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->EmbossOff)(window,LOAD_PC_MAP_GADGET);
X (*functions->EmbossOff)(window,SAVE_PC_MAP_GADGET);
X (*functions->EmbossOff)(window,CLEAR_PC_MAP_GADGET);
X
X (*functions->FatEmbossedPropOff)(window,
X SCROLLER_GADGET, SCROLLERDOWN_GADGET,
X SCROLLERUP_GADGET);
X
X for (int j = 0; j < NUM_PATCH_GADGETS; j++)
X {
X const short gadget = (j * 3) + FIRST_PATCH_GADGET;
X (*functions->FatEmbossedPropOff)(window, gadget, gadget + 1, gadget + 2);
X }
X
X (*functions->EmbossWindowOff)(window);
X (*functions->FlashyCloseWindow)(window);
X (*functions->DeleteNewWindow)(newwindow);
}
X
struct ToolMaster *
inittoolmaster()
{
X memset((char *)&master,0,sizeof(struct ToolMaster));
X master.toolid = PC_MAPPER_TOOL_ID;
X master.image = &pc_mapper_tool_image;
X strcpy(master.name, PC_MAPPER_TOOL_NAME);
X master.edittool = (void_prototype) edittoolcode;
X master.processevent = (event_prototype) processeventcode;
X master.tooltype = PC_MAPPER_TOOL_TYPE;
X master.toolsize = sizeof(struct PCMapperTool);
X return(&master);
}
SHAR_EOF
chmod 0600 pcmappertool.c ||
echo 'restore of pcmappertool.c failed'
Wc_c="`wc -c < 'pcmappertool.c'`"
test 17441 -eq "$Wc_c" ||
echo 'pcmappertool.c: original size 17441, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmappertool.ptool ==============
if test -f 'pcmappertool.ptool' -a X"$1" != X"-c"; then
echo 'x - skipping pcmappertool.ptool (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmappertool.ptool (Binary)'
sed 's/^X//' << 'SHAR_EOF' > _shar_tmp_.tmp &&
begin 600 pcmappertool.ptool
<encoded_portion_removed>
end
SHAR_EOF
echo 'uudecoding file pcmappertool.ptool' &&
uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
chmod 0600 pcmappertool.ptool ||
echo 'restore of pcmappertool.ptool failed'
Wc_c="`wc -c < 'pcmappertool.ptool'`"
test 5412 -eq "$Wc_c" ||
echo 'pcmappertool.ptool: original size 5412, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmappertool.readme ==============
if test -f 'pcmappertool.readme' -a X"$1" != X"-c"; then
echo 'x - skipping pcmappertool.readme (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmappertool.readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcmappertool.readme' &&
Short: Bars & Pipes Tool for mapping program changes to other program changes.
Author: Richard Hagen (R.H...@mailbox.uq.edu.au)
Uploader: Richard Hagen (R.H...@mailbox.uq.edu.au)
Version: 1.1 (6 October 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
PC Mapper Tool: A Bars and Pipes Tool for mapping program changes to other program changes.
X
Version: 1.1 (6 October 1997)
X
Author: Richard Hagen
X R.H...@mailbox.uq.edu.au
X
Distribution: Freeware. See the copyright notice in
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 The PC Mapper Tool uses a Program Change Map (PC Map) to map from one
X program change to another. You can edit the program change map
X from within the PC Mapper Tool.
X
X The PC Mapper Tool can be used in the pipeline, but not in the pad.
X
X The PC Mapper Tool is controlled by *stacks* of gadgets.
X
X Load PC Map File, Save PC Map File and Clear PC Map should be pretty
X easy to figure out.
X
X The first proportional gadget selects the range of patches to display.
X For instance, to display the patche mapping for patches 32 to 47, you
X move this gadget to show this range.
X
X The 16 gadgets below this edit the individual patch mappings in the
X selected range.
X
Useful for:
X Mapping from one bunch of patches to another.
X
History:
X 1.1 (6 October 1997)
X Changed name to PC Mapper Tool. Added ``Randomise'' gadget and rearranged
X the interface.
X
X 1.0 (29 September 1997)
X Initial release.
X
richard
R.H...@mailbox.uq.edu.au
X
X
X
SHAR_EOF
chmod 0600 pcmappertool.readme ||
echo 'restore of pcmappertool.readme failed'
Wc_c="`wc -c < 'pcmappertool.readme'`"
test 1769 -eq "$Wc_c" ||
echo 'pcmappertool.readme: original size 1769, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0
--
Bill Zimmer - z...@ibx.com

0 new messages