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

v97i016: Scaler [2.0] - Bars and Pipes Tool for scaling control change messages, Part 01/01

0 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 16
Archive-name: music/Scaler-2.0/part01
URL: http://www.it.uq.edu.au/~richard/music/bars-and-pipes/index.html#programs

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

Scaler: A Bars and Pipes Tool for scaling control change messages.

#!/bin/sh
# This is music/Scaler-2.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:23 UTC by z...@ibx.com
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1241 -rw------- dmakefile
# 2170 -rw------- myheader.h
# 15262 -rw------- scaler.c
# 3844 -rw------- scaler.ptool
# 1931 -rw------- scaler.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 = scaler
X
#
# The source files that you need to build the tool.
#
MYSRCS = scaler.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 1241 -eq "$Wc_c" ||
echo 'dmakefile: original size 1241, 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
# ============= scaler.c ==============
if test -f 'scaler.c' -a X"$1" != X"-c"; then
echo 'x - skipping scaler.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting scaler.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'scaler.c' &&
/*
X Scaler: A Bars and Pipes tool for scaling control change values.
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 2.0 (22 September 1997)
X Added input range.
X
X 1.2 (22 September 1997)
X Code improvement.
X
X 1.1 (13 September 1997)
X Redrew icon. Ensured that tool was properly initialised.
X
X 1.0 (8 September 1997)
X Initial release.
*/
X
#include "bars.h"
#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 "myheader.h"
X
#define SCALER_NAME "Scaler 2.0"
X
#define SCALER_ID MAKE_IDS("CCSC")
X
#define SCALER_TYPE (TOOL_NORMAL)
X
__chip static UWORD scaler[] = {
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 0x2003, 0xc400,
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 0xdc2f, 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 0x00ff, 0x0,
X 0x0199, 0x8000,
X 0x025a, 0x4000,
X 0x043c, 0x2000,
X 0x03db, 0xc000,
X 0x003c, 0x0000,
X 0x0, 0x0,
X 0x0, 0x0,
X 0x0, 0x0,
X
};
X
static struct Image scaler_image = {
X 0,0,
X 24 , 12 , 3 ,
X &scaler[0],
X 0x1f,0x00,
X NULL
};
X
struct ScalerTool {
X struct Tool tool;
X UBYTE controller; /* The Control Change number that we're scaling. */
X UBYTE input_min; /* The minimum value of inputs. */
X UBYTE input_max; /* The maximum value of inputs. */
X UBYTE output_min; /* The maximum value of outputs. */
X UBYTE output_max; /* The maximum value of outputs. */
};
X
static struct ToolMaster master;
X
extern struct Functions *functions;
X
#define INIT_CC 10
#define INIT_MIN 0
#define INIT_MAX 127
X
static void
scaler_tool_init(struct ScalerTool *tool)
{
X tool->tool.touched = TOUCH_INIT;
X
X tool->controller = INIT_CC;
X tool->input_min = tool->output_min = INIT_MIN;
X tool->input_max = tool->output_max = INIT_MAX;
}
X
#define CC_GADGET 1
#define CCDOWN_GADGET 2
#define CCUP_GADGET 3
X
#define INPUT_MIN_GADGET 4
#define INPUT_MINDOWN_GADGET 5
#define INPUT_MINUP_GADGET 6
X
#define INPUT_MAX_GADGET 7
#define INPUT_MAXDOWN_GADGET 8
#define INPUT_MAXUP_GADGET 9
X
#define OUTPUT_MIN_GADGET 10
#define OUTPUT_MINDOWN_GADGET 11
#define OUTPUT_MINUP_GADGET 12
X
#define OUTPUT_MAX_GADGET 13
#define OUTPUT_MAXDOWN_GADGET 14
#define OUTPUT_MAXUP_GADGET 15
X
/* CC# gadget. */
struct PropInfo ScalerScalerGadget1SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image ScalerImage1 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText ScalerIText1 = {
X 2,0,JAM1,
X -90,1,
X NULL,
X "CC #:",
X NULL
};
X
struct Gadget ScalerGadget1 = {
X NULL,
X 95,14,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&ScalerImage1,
X NULL,
X &ScalerIText1,
X NULL,
X (APTR)&ScalerScalerGadget1SInfo,
X CC_GADGET,
X NULL
};
X
/* Input min gadget. */
struct PropInfo ScalerScalerGadget2SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image ScalerImage2 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText ScalerIText2 = {
X 2,0,JAM1,
X -90,1,
X NULL,
X "Input Min:",
X NULL
};
X
struct Gadget ScalerGadget2 = {
X &ScalerGadget1,
X 95,26,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&ScalerImage2,
X NULL,
X &ScalerIText2,
X NULL,
X (APTR)&ScalerScalerGadget2SInfo,
X INPUT_MIN_GADGET,
X NULL
};
X
/* Input max gadget. */
struct PropInfo ScalerScalerGadget3SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image ScalerImage3 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText ScalerIText3 = {
X 2,0,JAM1,
X -90,1,
X NULL,
X "Input max:",
X NULL
};
X
struct Gadget ScalerGadget3 = {
X &ScalerGadget2,
X 95,38,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&ScalerImage3,
X NULL,
X &ScalerIText3,
X NULL,
X (APTR)&ScalerScalerGadget3SInfo,
X INPUT_MAX_GADGET,
X NULL
};
X
/* Output min gadget. */
struct PropInfo ScalerScalerGadget4SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image ScalerImage4 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText ScalerIText4 = {
X 2,0,JAM1,
X -90,1,
X NULL,
X "Output Min:",
X NULL
};
X
struct Gadget ScalerGadget4 = {
X &ScalerGadget3,
X 95,50,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&ScalerImage4,
X NULL,
X &ScalerIText4,
X NULL,
X (APTR)&ScalerScalerGadget4SInfo,
X OUTPUT_MIN_GADGET,
X NULL
};
X
/* Output max gadget. */
struct PropInfo ScalerScalerGadget5SInfo = {
X AUTOKNOB+FREEHORIZ,
X -16384, -1,
X 16384, -1,
};
X
struct Image ScalerImage5 = {
X 0,0,
X 102,6,
X 0,
X NULL,
X 0x0000,0x0000,
X NULL
};
X
struct IntuiText ScalerIText5 = {
X 2,0,JAM1,
X -90,1,
X NULL,
X "Output max:",
X NULL
};
X
struct Gadget ScalerGadget5 = {
X &ScalerGadget4,
X 95,62,
X 100,10,
X GFLG_GADGHBOX|GFLG_GADGHIMAGE,
X RELVERIFY|GADGIMMEDIATE,
X PROPGADGET,
X (APTR)&ScalerImage5,
X NULL,
X &ScalerIText5,
X NULL,
X (APTR)&ScalerScalerGadget5SInfo,
X OUTPUT_MAX_GADGET,
X NULL
};
X
struct NewWindow ScalerNewWindowStructure1 = {
X 75,85,
X 233, 76,
X 0,6,
X GADGETDOWN+GADGETUP+CLOSEWINDOW,
X WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
X &ScalerGadget5,
X NULL,
X "Scaler",
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 Scaler 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 unsigned long value) /* The value to display. */
{
X char text[10];
X struct RastPort *rp = window->RPort;
X Move(rp, 200, 21 + ((gadget->GadgetID - 1) / 3) * 12);
X SetAPen(rp, 1);
X SetBPen(rp, 0);
X SetDrMd(rp, JAM2);
X sprintf(text, "%3ld", value);
X Text(rp, text, 3);
X return value;
}
X
__geta4 /* Callback. */
static struct Event *
processeventcode(struct Event *event)
{
X if (event->status == MIDI_CCHANGE)
X {
X struct ScalerTool *tool = (struct ScalerTool *) event->tool;
X if (!tool->tool.touched)
X {
X scaler_tool_init(tool);
X }
X
X if (event->byte1 == tool->controller)
X {
X UBYTE value = event->byte2;
X
X const short input_diff = tool->input_max - tool->input_min + 1;
X const short output_diff = tool->output_max - tool->output_min + 1;
X
X if (value < tool->input_min)
X {
X value = 0;
X }
X else if (value > tool->input_max)
X {
X value = input_diff;
X }
X else
X {
X value = value - tool->input_min;
X }
X
X event->byte2 =
X tool->output_min + (value * output_diff) / input_diff;
X }
X }
X
X event->tool = event->tool->next;
X return(event);
}
X
static long
drag_embossed_prop(struct Window *window,
X short id)
{
X const long value = (*functions->DragEmbossedProp)(window, id);
X (*functions->DrawEmbossedProp)(window, id);
X
X return value;
}
X
static long
drag_embossed_prop_range(struct Window *window,
X short id,
X long min,
X long max)
{
X long value = (*functions->DragEmbossedProp)(window, id);
X if (value < min)
X {
X value = min;
X (*functions->ModifyEmbossedProp)(window, id,
X value, 0, 0, 0, 0, 0);
X }
X else if (value > max)
X {
X value = max;
X (*functions->ModifyEmbossedProp)(window, id,
X value, 0, 0, 0, 0, 0);
X }
X
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 const long value = (*functions->ShiftEmbossedProp)(window, id, shift, 0);
X (*functions->DrawEmbossedProp)(window, id);
X
X return value;
}
X
static long
shift_embossed_prop_range(struct Window *window,
X short id,
X short shift,
X long min,
X long max)
{
X long value = (*functions->ShiftEmbossedProp)(window, id, shift, 0);
X if (value < min)
X {
X value = min;
X (*functions->ModifyEmbossedProp)(window, id,
X value, 0, 0, 0, 0, 0);
X }
X else if (value > max)
X {
X value = max;
X (*functions->ModifyEmbossedProp)(window, id,
X value, 0, 0, 0, 0, 0);
X }
X
X (*functions->DrawEmbossedProp)(window, id);
X
X return value;
}
X
__geta4 /* Callback. */
void
edittoolcode(struct ScalerTool *tool)
{
X struct IntuiMessage *message;
X struct Window *window;
X long class, code;
X struct Gadget *gadget;
X struct NewWindow *newwindow;
X ScalerNewWindowStructure1.Screen = functions->screen;
X
X if (tool->tool.touched & TOUCH_EDIT)
X {
X ScalerNewWindowStructure1.LeftEdge = tool->tool.left;
X ScalerNewWindowStructure1.TopEdge = tool->tool.top;
X ScalerNewWindowStructure1.Width = tool->tool.width;
X ScalerNewWindowStructure1.Height = tool->tool.height;
X }
X
X if (!tool->tool.touched)
X {
X scaler_tool_init(tool);
X }
X
X newwindow = (struct NewWindow *)
X (*functions->DupeNewWindow)(&ScalerNewWindowStructure1);
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 SCALER_NAME,(short)-1,(short)-1,0,0);
X
X for (short i = CC_GADGET;
X i <= OUTPUT_MAX_GADGET;
X i += 3)
X {
X (*functions->FatEmbossedPropOn)(window,i, i + 1, i + 2,
X (no_prototype) display_routine,
X 128, 1);
X }
X
X (*functions->ModifyEmbossedProp)(window, CC_GADGET,
X tool->controller, 0, 0, 0, 0, 0);
X (*functions->ModifyEmbossedProp)(window, INPUT_MIN_GADGET,
X tool->input_min, 0, 0, 0, 0, 0);
X (*functions->ModifyEmbossedProp)(window, INPUT_MAX_GADGET,
X tool->input_max, 0, 0, 0, 0, 0);
X (*functions->ModifyEmbossedProp)(window, OUTPUT_MIN_GADGET,
X tool->output_min, 0, 0, 0, 0, 0);
X (*functions->ModifyEmbossedProp)(window, OUTPUT_MAX_GADGET,
X tool->output_max, 0, 0, 0, 0, 0);
X
X for (short i = CC_GADGET;
X i <= OUTPUT_MAX_GADGET;
X i += 3)
X {
X (*functions->DrawEmbossedProp)(window, i);
X }
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
X switch (id)
X {
X case CC_GADGET:
X tool->controller = (UBYTE) drag_embossed_prop(window, CC_GADGET);
X break;
X case CCDOWN_GADGET:
X tool->controller = (UBYTE) shift_embossed_prop(window, CC_GADGET, -1);
X break;
X case CCUP_GADGET:
X tool->controller = (UBYTE) shift_embossed_prop(window, CC_GADGET, 1);
X break;
X case INPUT_MIN_GADGET:
X tool->input_min =
X (UBYTE) drag_embossed_prop_range(window, INPUT_MIN_GADGET,
X 0, tool->input_max);
X break;
X case INPUT_MINDOWN_GADGET:
X tool->input_min =
X (UBYTE) shift_embossed_prop_range(window, INPUT_MIN_GADGET, -1,
X 0, tool->input_max);
X break;
X case INPUT_MINUP_GADGET:
X tool->input_min =
X (UBYTE) shift_embossed_prop_range(window, INPUT_MIN_GADGET, 1,
X 0, tool->input_max);
X break;
X case INPUT_MAX_GADGET:
X tool->input_max =
X (UBYTE) drag_embossed_prop_range(window, INPUT_MAX_GADGET,
X tool->input_min, 127);
X break;
X case INPUT_MAXDOWN_GADGET:
X tool->input_max =
X (UBYTE) shift_embossed_prop_range(window, INPUT_MAX_GADGET, -1,
X tool->input_min, 127);
X break;
X case INPUT_MAXUP_GADGET:
X tool->input_max =
X (UBYTE) shift_embossed_prop_range(window, INPUT_MAX_GADGET, 1,
X tool->input_min, 127);
X break;
X case OUTPUT_MIN_GADGET:
X tool->output_min =
X (UBYTE) drag_embossed_prop_range(window, OUTPUT_MIN_GADGET,
X 0, tool->output_max);
X break;
X case OUTPUT_MINDOWN_GADGET:
X tool->output_min =
X (UBYTE) shift_embossed_prop_range(window, OUTPUT_MIN_GADGET, -1,
X 0, tool->output_max);
X break;
X case OUTPUT_MINUP_GADGET:
X tool->output_min =
X (UBYTE) shift_embossed_prop_range(window, OUTPUT_MIN_GADGET, 1,
X 0, tool->output_max);
X break;
X case OUTPUT_MAX_GADGET:
X tool->output_max =
X (UBYTE) drag_embossed_prop_range(window, OUTPUT_MAX_GADGET,
X tool->output_min, 127);
X break;
X case OUTPUT_MAXDOWN_GADGET:
X tool->output_max =
X (UBYTE) shift_embossed_prop_range(window, OUTPUT_MAX_GADGET, -1,
X tool->output_min, 127);
X break;
X case OUTPUT_MAXUP_GADGET:
X tool->output_max =
X (UBYTE) shift_embossed_prop_range(window, OUTPUT_MAX_GADGET, 1,
X tool->output_min, 127);
X break;
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 for (short i = CC_GADGET;
X i <= OUTPUT_MAX_GADGET;
X i += 3)
X {
X (*functions->FatEmbossedPropOff)(window, i, i + 1, i + 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 = SCALER_ID;
X master.image = &scaler_image;
X strcpy(master.name, SCALER_NAME);
X master.edittool = (void_prototype) edittoolcode;
X master.processevent = (event_prototype) processeventcode;
X master.tooltype = SCALER_TYPE;
X master.toolsize = sizeof(struct ScalerTool);
X return(&master);
}
SHAR_EOF
chmod 0600 scaler.c ||
echo 'restore of scaler.c failed'
Wc_c="`wc -c < 'scaler.c'`"
test 15262 -eq "$Wc_c" ||
echo 'scaler.c: original size 15262, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= scaler.ptool ==============
if test -f 'scaler.ptool' -a X"$1" != X"-c"; then
echo 'x - skipping scaler.ptool (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting scaler.ptool (Binary)'
sed 's/^X//' << 'SHAR_EOF' > _shar_tmp_.tmp &&
begin 600 scaler.ptool
<encoded_portion_removed>
end
SHAR_EOF
echo 'uudecoding file scaler.ptool' &&
uudecode < _shar_tmp_.tmp && rm -f _shar_tmp_.tmp &&
chmod 0600 scaler.ptool ||
echo 'restore of scaler.ptool failed'
Wc_c="`wc -c < 'scaler.ptool'`"
test 3844 -eq "$Wc_c" ||
echo 'scaler.ptool: original size 3844, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= scaler.readme ==============
if test -f 'scaler.readme' -a X"$1" != X"-c"; then
echo 'x - skipping scaler.readme (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting scaler.readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'scaler.readme' &&
Short: Bars & Pipes Tool for scaling control change messages.
Author: Richard Hagen (R.H...@mailbox.uq.edu.au)
Uploader: Richard Hagen (R.H...@mailbox.uq.edu.au)
Version: 2.0 (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
Scaler: A Bars and Pipes Tool for scaling control change messages.
X
Version: 2.0 (22 September 1997)
X
Author: Richard Hagen
X R.H...@mailbox.uq.edu.au
X
Distribution: Freeware. See the copyright notice in scaler.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 This is a normal tool, which can be used anywhere in Bars and Pipes.
X Scaler takes control change messages and scales them into some
X specified range.
X
X It is controlled by five gadgets:
X
X CC# (proportional gadget, range [0 .. 127])
X Selects the control change number that is to be scaled.
X
X Input min (proportional gadget, range [0 .. 127])
X The minimum end of the range of the input CC values.
X
X Input max (proportional gadget, range [0 .. 127])
X The maximum end of the range of the input CC values.
X
X Output min (proportional gadget, range [0 .. 127])
X The minimum end of the range of the output CC values.
X
X Output max (proportional gadget, range [0 .. 127])
X The maximum end of the range of the output CC values.
X
Useful for:
X Combining with my CCCC tool.
X
History:
X 2.0 (22 September 1997)
X Added input range.
X
X 1.2 (22 September 1997)
X Code improvement.
X
X 1.1 (13 September 1997)
X Redrew icon. Ensured that tool was properly initialised.
X
X 1.0 (8 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
SHAR_EOF
chmod 0600 scaler.readme ||
echo 'restore of scaler.readme failed'
Wc_c="`wc -c < 'scaler.readme'`"
test 1931 -eq "$Wc_c" ||
echo 'scaler.readme: original size 1931, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0
--
Bill Zimmer - z...@ibx.com

0 new messages