True tracker port, with native OpenBSD audio, synchronization of the display

with sounds, numerous minor bug-fix, and authorization to redistribute.
This commit is contained in:
espie 1998-10-02 17:19:44 +00:00
parent c82d7eb030
commit 65dc494456
14 changed files with 541 additions and 167 deletions

View File

@ -3,7 +3,7 @@
# Date created: May 21 1998
# Whom: Angelos D. Keromytis
#
# $OpenBSD: Makefile,v 1.1.1.1 1998/05/22 01:00:50 angelos Exp $
# $OpenBSD: Makefile,v 1.2 1998/10/02 17:19:44 espie Exp $
#
DISTNAME= tracker-5.3
@ -11,24 +11,30 @@ CATEGORIES= audio
MASTER_SITES= ftp://ftp.ens.fr/pub/dmi/users/espie/beta/
EXTRACT_SUFX= .tgz
MAINTAINER= angelos@openbsd.org
MAINTAINER= espie@openbsd.org
RESTRICTED= "Non-redistributable beta"
# No restriction, but ONLY for OpenBSD, not Free, nor NetBSD.
#RESTRICTED= "Non-redistributable beta"
WRKSRC= ${WRKDIR}/tracker
USE_GMAKE= yes
MAKE_FLAGS= MACHINE=freebsd CC=$(CC) INSTALL="$(INSTALL)" \
PATCH_STRIP=-p2
MAKE_FLAGS= MACHINE=openbsd CC=$(CC) INSTALL="$(INSTALL)" \
INST_BIN_OPT="-c -s -m $(BINMODE) -o $(BINOWN) -g $(BINGRP)" \
INST_MAN_OPT="-c -m 644 -o $(BINOWN) -g $(BINGRP)" \
COMPRESSION_FILE=$(PREFIX)/etc/compression_methods \
-f
post-extract:
mkdir ${WRKSRC}/Arch/OpenBSD
cp files/audio.c files/config.h ${WRKSRC}/Arch/OpenBSD
post-install:
cd ${WRKSRC}/Docs && \
makeinfo --no-split tracker.texinfo -o tracker.info && \
gzip -f tracker.info && \
$(INSTALL_MAN) tracker.info.gz ${PREFIX}/info && \
rm -f tracker.info.gz *.orig
$(INSTALL_MAN) tracker.info ${PREFIX}/info && \
rm -f tracker.info *.orig
-${MKDIR} ${PREFIX}/share/doc/tracker
cp -R ${WRKSRC}/Docs/* ${PREFIX}/share/doc/tracker

277
audio/tracker/files/audio.c Normal file
View File

@ -0,0 +1,277 @@
/* openbsd/audio.c
vi:ts=3 sw=3:
*/
/* Native BSD interface */
#include "defs.h"
#include <unistd.h>
#include <fcntl.h>
#include "extern.h"
#include "prefs.h"
#include "autoinit.h"
#include "watched_var.h"
#include <sys/ioctl.h>
struct options_set *port_options=0;
#define DEFAULT_BUFFERS
#define UNSIGNED8
#define DEFAULT_SET_MIX
#define NEW_OUTPUT_SAMPLES_AWARE
#define NEW_FUNCS
/* fine-tune to get the scrolling display in sync with the music */
#define ADVANCE_TAGS 20000
#include "Arch/common.c"
#include <sys/types.h>
#include <sys/audioio.h>
ID("$Id: audio.c,v 1.1 1998/10/02 17:19:44 espie Exp $")
LOCAL unsigned long samples_max;
LOCAL int audio;
LOCAL unsigned long current_freq;
unsigned long total;
LOCAL int dsp_samplesize = 0;
unsigned long open_audio(unsigned long f, int s)
{
int buf_max;
unsigned long possible, current;
audio = open("/dev/audio", O_WRONLY, 0);
if (audio == -1)
end_all("Error opening audio device");
/* iterate and find true native formats */
{
struct audio_encoding query;
for (query.index = 0;
ioctl(audio, AUDIO_GETENC, &query) != -1;
query.index++)
{
if (query.flags & AUDIO_ENCODINGFLAG_EMULATED)
continue;
if (query.precision == 16 &&
query.encoding == AUDIO_ENCODING_SLINEAR)
dsp_samplesize = 16;
if (!dsp_samplesize && query.precision == 8 &&
query.encoding == AUDIO_ENCODING_ULINEAR)
dsp_samplesize = 8;
}
}
if (dsp_samplesize == 0)
end_all("Sorry, no audio format supported by this binary is available");
if (!f)
f = 22050;
{
struct audio_info current;
AUDIO_INITINFO(&current);
switch(dsp_samplesize)
{
case 8:
dsize = 1;
current.play.encoding = AUDIO_ENCODING_ULINEAR;
break;
case 16:
dsize = 2;
current.play.encoding = AUDIO_ENCODING_SLINEAR;
break;
default:
end_all("Error: unknown dsp_samplesize");
}
current.play.sample_rate = f;
current.play.channels = s ? 2 : 1;
{
int ok = ioctl(audio, AUDIO_SETINFO, &current);
/* maybe we are trying some stunt our card can't do ?
* Try lowering our expectations
*/
if (ok == -1 && current.play.channels == 2 && current.play.sample_rate > 22050)
{
current.play.sample_rate = 22050;
ok = ioctl(audio, AUDIO_SETINFO, &current);
}
if (ok == -1 && current.play.channels == 2)
{
current.play.channels = 1;
ok = ioctl(audio, AUDIO_SETINFO, &current);
}
while (ok == -1 && current.play.sample_rate > 8000)
{
current.play.sample_rate /= 2;
ok = ioctl(audio, AUDIO_SETINFO, &current);
}
if (ok == -1)
end_all("Can't find a suitable format");
if (ioctl(audio, AUDIO_GETINFO, &current) == -1)
end_all("Error retrieving format");
}
buf_max = current.blocksize;
current_freq = current.play.sample_rate;
stereo = current.play.channels == 2 ? 1 : 0;
}
buffer = malloc(buf_max);
buffer16 = (short *)buffer;
idx = 0;
samples_max = buf_max / dsize;
set_watched_scalar(FREQUENCY, current_freq);
total = 0;
return current_freq;
}
/* synchronize stuff with audio output */
LOCAL struct tagged
{
struct tagged *next; /* simply linked list */
void (*f)(GENERIC p); /* function to call */
void (*f2)(GENERIC p); /* function to call for flush */
GENERIC p; /* and parameter */
unsigned long when; /* number of bytes to let go before
calling */
}
*start, /* what still to output */
*end; /* where to add new tags */
/* flush_tags: use tags that have gone by recently */
LOCAL void flush_tags(void)
{
audio_offset_t off;
if (audio != -1)
ioctl(audio, AUDIO_GETOOFFS, &off);
if (start)
{
while (start && start->when <= off.samples + ADVANCE_TAGS)
{
struct tagged *tofree;
(*start->f)(start->p);
tofree = start;
start = start->next;
free(tofree);
}
}
}
/* remove unused tags at end */
LOCAL void remove_pending_tags(void)
{
while (start)
{
struct tagged *tofree;
(*start->f2)(start->p);
tofree = start;
start = start->next;
free(tofree);
}
}
void sync_audio(void (*function)(void *p), void (*f2)(void *p), void *parameter)
{
struct tagged *t;
if (audio != -1)
{
t = malloc(sizeof(struct tagged));
if (!t)
{
(*function)(parameter);
return;
}
/* build new tag */
t->next = 0;
t->f = function;
t->f2 = f2;
t->p = parameter;
t->when = total;
/* add it to list */
if (start)
end->next = t;
else
start = t;
end = t;
/* set up for next tag */
}
else
(*function)(parameter);
}
LOCAL void actually_flush_buffer(void)
{
int l,i;
if (idx)
{
total += idx * dsize;
write(audio, buffer, dsize * idx);
}
idx = 0;
}
void output_samples(long left, long right, int n)
{
if (idx >= samples_max - 1)
actually_flush_buffer();
switch(dsp_samplesize)
{
case 16: /* Cool! 16 bits samples */
add_samples16(left, right, n);
break;
case 8:
add_samples8(left, right, n);
break;
default: /* should not happen */
}
}
void flush_buffer(void)
{
actually_flush_buffer();
flush_tags();
}
/*
* Closing the Linux sound device waits for all pending samples to play.
*/
void close_audio(void)
{
actually_flush_buffer();
close(audio);
free(buffer);
}
unsigned long update_frequency(void)
{
return 0;
}
void discard_buffer(void)
{
if (audio)
ioctl(audio, AUDIO_FLUSH, 0);
remove_pending_tags();
total = 0;
}
void audio_ui(char c)
{
}

View File

@ -0,0 +1,19 @@
/* config.h
vi:ts=3 sw=3:
*/
/* Configuration for OpenBSD */
#define IS_POSIX
#define USE_TERMIOS
#define USE_AT_EXIT
#define SCO_ANSI_COLOR
typedef void *GENERIC;
#define P(args) args
/* #define ID(x) */
#define ID(x) LOCAL char id[]= x ;
#define stricmp strcasecmp

View File

@ -1,73 +1,13 @@
*** Makefile.orig Tue May 7 19:20:50 1996
--- Makefile Tue Nov 12 06:56:18 1996
***************
*** 20,26 ****
OPTS=-c
! PREFIX=/users/algo/espie/pub
# Destination directory for tracker binaries and manpage.
#
# If you don't wish to use the 'make install' and 'make install.man'
--- 20,26 ----
OPTS=-c
! PREFIX?=/users/algo/espie/pub
# Destination directory for tracker binaries and manpage.
#
# If you don't wish to use the 'make install' and 'make install.man'
***************
*** 166,172 ****
UI_linux = Unix/
SHELL_linux = /bin/sh
! CFLAGS_freebsd = -O2 -funroll-loops -finline-functions -fno-strength-reduce
! LIBS_freebsd = -lm
AUDIODIR_freebsd=PCux/
CONFIG_freebsd = PCux/freebsd_
--- 166,172 ----
UI_linux = Unix/
SHELL_linux = /bin/sh
! CFLAGS_freebsd = -O2 -funroll-loops -finline-functions
! LIBS_freebsd = -lm -lossaudio
AUDIODIR_freebsd=PCux/
CONFIG_freebsd = PCux/freebsd_
***************
*** 250,256 ****
display$O prefs$O autoinit$O $(UI)ui$O empty$O color$O version$O \
st_virt$O automaton$O
! all: tracker${EXE} randomize${EXE} splitmod${EXE} Docs/tracker.text
config.h: $(CONFIG)config.h
rm -f config.h
--- 250,256 ----
display$O prefs$O autoinit$O $(UI)ui$O empty$O color$O version$O \
st_virt$O automaton$O
! all: tracker${EXE} randomize${EXE}
config.h: $(CONFIG)config.h
rm -f config.h
***************
*** 272,280 ****
install:
$(INSTALL) $(INST_BIN_OPT) tracker $(BIN_DIR)
$(INSTALL) $(INST_BIN_OPT) randomize $(BIN_DIR)
- $(INSTALL) $(INST_BIN_OPT) splitmod $(BIN_DIR)
[ -f ${COMPRESSION_FILE} ] || \
! $(INSTALL) $(INST_MAN_OPT) compression_methods ${COMPRESSION_FILE}
# no manpage available, use the texinfo manual.
install.man:
--- 272,279 ----
install:
$(INSTALL) $(INST_BIN_OPT) tracker $(BIN_DIR)
$(INSTALL) $(INST_BIN_OPT) randomize $(BIN_DIR)
[ -f ${COMPRESSION_FILE} ] || \
! $(INSTALL) $(INST_MAN_OPT) Lib/compression_methods ${COMPRESSION_FILE}
# no manpage available, use the texinfo manual.
install.man:
diff -u -r w2/tracker/Docs/Html/Availability.html work/tracker/Docs/Html/Availability.html
--- w2/tracker/Docs/Html/Availability.html Thu Apr 11 19:21:06 1996
+++ work/tracker/Docs/Html/Availability.html Sun Sep 27 17:17:37 1998
@@ -53,7 +53,7 @@
</P>
<DL><DT><DD>
<PRE>
-Marc.Espie@ens.fr
+Marc.Espie@openbsd.org
</PRE>
</DL>

View File

@ -1,33 +1,24 @@
*** Docs/tracker.texinfo.orig Thu Apr 11 21:21:05 1996
--- Docs/tracker.texinfo Tue Nov 12 07:08:17 1996
***************
*** 979,992 ****
* Other Architectures: Porting tracker.
@end menu
! @node Aix, Amiga, Architecture dependent problems, Architecture Dependent problems
@subsection Aix
The Aix port is slightly outdated and won't run with most recent versions of
Aix. There is nothing I can do about it until somebody sends me an up-to-date
version as I don't have access to Aix machines.
! @node Amiga, DECstation, Architecture dependent problems, Architecture dependent problems
@subsection Amiga
There is currently one Amiga version running under AmigaDos.
--- 979,992 ----
* Other Architectures: Porting tracker.
@end menu
! @node Aix, Amiga, Architecture dependent problems, Architecture dependent problems
@subsection Aix
The Aix port is slightly outdated and won't run with most recent versions of
Aix. There is nothing I can do about it until somebody sends me an up-to-date
version as I don't have access to Aix machines.
! @node Amiga, DECstation, Aix, Architecture dependent problems
@subsection Amiga
There is currently one Amiga version running under AmigaDos.
diff -u -r w2/tracker/Docs/readme work/tracker/Docs/readme
--- w2/tracker/Docs/readme Thu Apr 11 19:21:05 1996
+++ work/tracker/Docs/readme Sun Sep 27 17:16:04 1998
@@ -5,6 +5,12 @@
From version 4.29 on, commercial use of tracker is forbidden without
negotiating an agreement with me first.
+In particular, I'd appreciate if commercial Linux distributions would
+contact me first before distributing tracker... I'd love some free CD-Roms.
+
+The OpenBSD projects is explicitly allowed to distribute tracker on its
+CD-Roms.
+
For personal use purposes: I've spent quite some time supporting this
program now. If you use it much, and feel like it, you can send me
some money, or software you've written for the amiga, I won't
@@ -37,5 +43,5 @@
I can deal with french francs, or US checks. Anything else you'll
have to try.
- Marc Espie
+ Marc Espie, Marc.Espie@openbsd.org

View File

@ -1,53 +1,34 @@
*** Arch/PCux/audio.c.orig Fri Apr 12 12:30:37 1996
--- Arch/PCux/audio.c Thu May 21 20:30:57 1998
***************
*** 9,15 ****
#include <unistd.h>
#include <fcntl.h>
#include "extern.h"
!
struct options_set *port_options=0;
#define DEFAULT_BUFFERS
--- 9,18 ----
#include <unistd.h>
#include <fcntl.h>
#include "extern.h"
! #include "prefs.h"
! #include "autoinit.h"
! #include "watched_var.h"
! #include <sys/ioctl.h>
struct options_set *port_options=0;
#define DEFAULT_BUFFERS
***************
*** 26,34 ****
#else
#ifndef __FreeBSD__
/* This should be sys/soundcard.h */
! #include <sys/soundcard.h>
#else
! #include <machine/soundcard.h>
#endif
#endif
--- 29,37 ----
#else
#ifndef __FreeBSD__
/* This should be sys/soundcard.h */
! #include <soundcard.h>
#else
! #include <soundcard.h>
#endif
#endif
***************
*** 116,121 ****
--- 119,125 ----
}
samples_max = buf_max / dsize;
current_freq = f;
+ set_watched_scalar(FREQUENCY, f);
total = 0;
return f;
}
diff -u -r w2/tracker/Docs/tracker.texinfo work/tracker/Docs/tracker.texinfo
--- w2/tracker/Docs/tracker.texinfo Thu Apr 11 19:21:05 1996
+++ work/tracker/Docs/tracker.texinfo Sun Sep 27 17:16:43 1998
@@ -1,10 +1,10 @@
\input texinfo
@setfilename tracker.info
-@set VERSION 4.44
+@set VERSION 5.3-OpenBSD edition
@settitle Tracker @value{VERSION}
@c End of header
-@set EMAIL Marc.Espie@@ens.fr
+@set EMAIL Marc.Espie@@openbsd.org
@set POSTAL Marc Espie@*60 rue du 4 septembre@*87100 Limoges@*France
@titlepage
@@ -979,14 +979,14 @@
* Other Architectures: Porting tracker.
@end menu
-@node Aix, Amiga, Architecture dependent problems, Architecture Dependent problems
+@node Aix, Amiga, Architecture dependent problems, Architecture dependent problems
@subsection Aix
The Aix port is slightly outdated and won't run with most recent versions of
Aix. There is nothing I can do about it until somebody sends me an up-to-date
version as I don't have access to Aix machines.
-@node Amiga, DECstation, Architecture dependent problems, Architecture dependent problems
+@node Amiga, DECstation, Aix, Architecture dependent problems
@subsection Amiga
There is currently one Amiga version running under AmigaDos.

View File

@ -0,0 +1,67 @@
diff -u -r w2/tracker/Makefile work/tracker/Makefile
--- w2/tracker/Makefile Tue May 7 17:20:50 1996
+++ work/tracker/Makefile Sun Sep 27 17:20:35 1998
@@ -1,5 +1,5 @@
# Makefile for any machine
-# - based on my newer makefile and the GREATE
+# - based on my newer makefile and the GREAT
# modifications by Mike Battersby
###############################################################################
#
@@ -10,8 +10,8 @@
# hpalib, hplow, hp3, dec, solaris, sparc, linux, freebsd, sgi,
# soundblaster, aix, next, MM1, NAS, sbos2, SVR4
# gmake needed to handle this file in FreeBSD
-MACHINE = sparc
-VERSION = 5.3
+#MACHINE = sparc
+VERSION = 5.3-OpenBSD
#VPATH=..
# The name of your C compiler. For most machines this will be
@@ -20,7 +20,7 @@
OPTS=-c
-PREFIX=/users/algo/espie/pub
+PREFIX?=/users/algo/espie/pub
# Destination directory for tracker binaries and manpage.
#
# If you don't wish to use the 'make install' and 'make install.man'
@@ -175,6 +175,15 @@
UI_freebsd = Unix/
SHELL_freebsd = /bin/sh
+CFLAGS_openbsd = -O3 -funroll-loops -finline-functions
+LIBS_openbsd = -lm
+AUDIODIR_openbsd = OpenBSD/
+CONFIG_openbsd = OpenBSD/
+O_openbsd = .o
+EXE_openbsd =
+UI_openbsd = Unix/
+SHELL_openbsd = /bin/sh
+
CFLAGS_aix = -O
LIBS_aix = -lm
AUDIODIR_aix = Aix/
@@ -250,7 +259,7 @@
display$O prefs$O autoinit$O $(UI)ui$O empty$O color$O version$O \
st_virt$O automaton$O
-all: tracker${EXE} randomize${EXE} splitmod${EXE} Docs/tracker.text
+all: tracker${EXE} randomize${EXE}
config.h: $(CONFIG)config.h
rm -f config.h
@@ -272,9 +281,8 @@
install:
$(INSTALL) $(INST_BIN_OPT) tracker $(BIN_DIR)
$(INSTALL) $(INST_BIN_OPT) randomize $(BIN_DIR)
- $(INSTALL) $(INST_BIN_OPT) splitmod $(BIN_DIR)
[ -f ${COMPRESSION_FILE} ] || \
- $(INSTALL) $(INST_MAN_OPT) compression_methods ${COMPRESSION_FILE}
+ $(INSTALL) $(INST_MAN_OPT) Lib/compression_methods ${COMPRESSION_FILE}
# no manpage available, use the texinfo manual.
install.man:

View File

@ -0,0 +1,15 @@
diff -u -r w2/tracker/handle_options.c work/tracker/handle_options.c
--- w2/tracker/handle_options.c Tue May 7 17:22:08 1996
+++ work/tracker/handle_options.c Sun Sep 27 16:39:25 1998
@@ -235,7 +235,9 @@
print_usage();
end_all(0);
}
- ask_freq = args[1].scalar * 1000;
+ ask_freq = args[1].scalar;
+ if (ask_freq < 1000)
+ ask_freq *= 1000;
stereo = args[2].scalar;
loop = args[3].scalar;
set_watched_scalar(OVERSAMPLE, args[4].scalar);

View File

@ -0,0 +1,16 @@
diff -u -r w2/tracker/parse_options.c work/tracker/parse_options.c
--- w2/tracker/parse_options.c Tue May 7 00:48:28 1996
+++ work/tracker/parse_options.c Sun Sep 27 16:33:45 1998
@@ -238,10 +238,11 @@
switch(type)
{
case 's':
+ case 'm':
if (i == argindex)
set->args[argindex].scalar = 1;
else
- set->args[i].scalar = 0;
+ set->args[argindex].scalar = 0;
return 0;
case 'n':
{

View File

@ -0,0 +1,16 @@
diff -u -r w2/tracker/Modules/Pro/effects.c work/tracker/Modules/Pro/effects.c
--- w2/tracker/Modules/Pro/effects.c Sat Apr 13 19:16:54 1996
+++ work/tracker/Modules/Pro/effects.c Sun Sep 27 19:44:20 1998
@@ -207,8 +207,9 @@
/* temporary update of only the step value,
* note that we do not change the saved pitch.
*/
- set_temp_pitch(ch,
- ch->pitch + sinusoid_value(&(ch->vib))/256);
+ if (ch->pitch)
+ set_temp_pitch(ch,
+ ch->pitch + sinusoid_value(&(ch->vib))/256);
}
LOCAL void set_vibrato(struct channel *ch, struct event *e)

View File

@ -0,0 +1,20 @@
diff -u -r w2/tracker/display.c work/tracker/display.c
--- w2/tracker/display.c Mon May 6 16:28:52 1996
+++ work/tracker/display.c Sun Sep 27 21:02:33 1998
@@ -543,7 +543,14 @@
copy3(note2name(note));
copy4(" off");
if (ch->samp->length)
- num3(para * 25600/ch->samp->length);
+ {
+ int percent;
+ percent = para * 25600/ch->samp->length;
+ if (percent <= 105)
+ num3(percent);
+ else
+ copy3("???");
+ }
else
copy3(empty);
*base++ = '%';

View File

@ -0,0 +1,13 @@
diff -u -r w2/tracker/play_list.c work/tracker/play_list.c
--- w2/tracker/play_list.c Mon May 6 23:53:20 1996
+++ work/tracker/play_list.c Sun Sep 27 21:12:12 1998
@@ -243,6 +243,8 @@
ENTRY e;
unsigned i, k;
+ if (idx == 0)
+ return;
for (i = idx-1; i > 0; i--)
{
k = random_range(i+1);

View File

@ -1,6 +1,19 @@
Tracker plays soundtracker music modules on a Unix machine.
Soundtracker modules originated on the amiga, where several composing
playing programs are available, that give results mostly compatible
with each other. tracker just plays the specified files in sequence
according with the current options.
tracker development currently continues. Version 5.3 was a beta which
never should have reached the distribution stage.
However, since I'm now a part of the OpenBSD team, I can fix the most
blatant problems with it to let you wait for the real version.
So this port features a full adaptation of the audio system to OpenBSD,
complete with synchronization of the scrolling partition with audio output.
It also corrects some blatant bugs, such as some options not working, e.g.,
-mono.
Marc Espie

View File

@ -1,7 +1,7 @@
bin/tracker
bin/randomize
etc/compression_methods
info/tracker.info.gz
info/tracker.info
share/doc/tracker/Html/Aix.html
share/doc/tracker/Html/Introduction.html
share/doc/tracker/Html/Availability.html