+1999-08-11 Masanao Izumo <mo@goice.co.jp>
+
+ * Version 2.4.1 released.
+
+1999-08-11 Masanao Izumo <mo@goice.co.jp>
+
+ * timidity/linux_a.c: Fixed to adjust PM_REQ_GETSAMPLES.
+ * interface/x_sherry.c (sry_text): Do nothing if string length is zero.
+ * interface/soundspec.c: Multipuly 1.5 to results.
+ * interface/w32g_c.c(ctl_read): In Windows GUI interface, if
+ play_pause_flag is true, wait until any control message is received.
+ There is no CPU usage during pause.
+ * libarc/arc.c (regist_archive): Static function. This function is
+ no longer library interface function.
+ * timidity/timidity.c (read_config_file): Don't remove the end of
+ '#' followed by non-space.
+ * timidity/{playmidi.h,playmidi.c,readmidi.c,mac_c.c}:
+ Make a new MidiEvent type `ME_GSLCD' and the interface control message
+ `CTLE_GSLCD'. If ME_GSLCD is received, TiMidity sends CTLE_GSLCD to
+ the interface.
+ * timidity/{common.c,timidity.c} (open_file_noise_mode): new global
+ variable to pass `noise_mode' of open_file() to arc_error_handler.
+ * wrdt.c: Make more elevant.
+ * x_wrdwindow.c (gscreen_plane_mask): Bug fix.
+
+1999-08-10 Masanao Izumo <mo@goice.co.jp>
+
+ * libarc/arc.c: Bug fixed.
+ * interface/x_sherry.c: Bug fixed.
+ * libarc/{arc.h,arc.c}: Removed `pool' from ArchiveHandler.
+ Use static variable arc_buffer in arc.c instead of ArchiveHandler.pool.
+ `arc_buffer' which is internal usage only.
+ * timidity/playmidi.c (apply_controls): usleep(300000) if play_pause_flag.
+ * interface/{w32g_c.c,w32g_canvas.c}:
+ Fixed update timing for channel bar mode.
+
+1999-08-10 Masanao Izumo <mo@goice.co.jp>
+
+ * libarc/arc.c (): Bug fixed to extract `-lh0-' and `-lz4-' of the lha.
+ * interface/x_sherry.c: Bug fixed to create SHM pixmap.
+ * libarc/{arc.h,arc.c}: Removed `pool' from ArchiveHandler.
+ Use static variable arc_buffer in arc.c instead of ArchiveHandler.pool.
+ `arc_buffer' is internal usage only.
+ * timidity/playmidi.c (apply_controls): usleep(300000) if play_pause_flag.
+ * interface/{w32g_c.c,w32g_canvas.c}:
+ Fixed update timing for channel bar mode.
+
+
1999-08-09 Masanao Izumo <mo@goice.co.jp>
* Version 2.4.0 released.
+8/11, 1999
+ * Version 2.4.1 released.
+ * Bug fix.
+
8/9, 1999
* Version 2.4.0 released.
* Make archive library (libarc) code more simple.
#CC= @CC@
#CFLAGS = @CFLAGS@
# For pentium gcc
-#CFLAGS = -O6 -Os -mpentium -march=pentium -fomit-frame-pointer \
-# -funroll-all-loops -malign-double -malign-jumps=0 \
-# -malign-functions=0 -ffast-math -malign-loops=0
+#CFLAGS = -O3 -mpentium -march=pentium -fomit-frame-pointer \
+# -funroll-all-loops -malign-double -ffast-math
#CPPFLAGS = @CPPFLAGS@
#DEFS = @DEFS@
PACKAGE=TiMidity++
-VERSION=2.4.0
+VERSION=2.4.1
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
AC_INIT(timidity/timidity.c)
AC_CANONICAL_SYSTEM
-AM_INIT_AUTOMAKE(TiMidity++, 2.4.0, no-define)
+AM_INIT_AUTOMAKE(TiMidity++, 2.4.1, no-define)
dnl To use CONTAINS() macro (See acinclude.m4)
CONTAINS_INIT
lyric = event2string(lyricid);
if(lyric == NULL) return;
+ ctl.cmsg(CMSG_TEXT, VERB_VERBOSE, "%s", lyric + 1);
+}
+
+static void ctl_gslcd(int lyricid)
+{
+ char *lyric;
+
+ lyric = event2string(lyricid);
+ if(lyric == NULL) return;
- if( strncmp(lyric+1, "gslcd: ",7)==0 ){
+ if( lyric[0] == ME_GSLCD ){
int i,j, data, mask;
char tmp[3]= "00";
- lyric+=8;
+ lyric++;
for( j=0; j<4; j++ ){
for( i=0; i<16; i++ ){
tmp[0]= lyric[0]; tmp[1]= lyric[1]; lyric+=2;
case CTLE_LYRIC:
ctl_lyric((int)e->v1);
break;
+ case CTLE_GSLCD:
+ ctl_gslcd((int)e->v1);
+ break;
case CTLE_REFRESH:
ctl_refresh();
break;
static void ctl_event(CtlEvent *e)
{
+ if(midi_trace.flush_flag)
+ return;
switch(e->type)
{
case CTLE_NOW_LOADING:
static void display_aq_ratio(void)
{
-#if 1
static int last_rate = -1;
int rate, devsiz;
wprintw(dftwin, " Audio queue:%3d%% ", rate);
scr_modified_flag = 1;
}
-#else
- wmove(dftwin, VOICE_LINE + 1, 30);
- wprintw(dftwin, " Audio queue: %d %d %d %d",
- aq_get_dev_queuesize(), aq_filled(), aq_soft_filled(), aq_fillable());
-#endif
}
static void update_indicator(void)
#define SCOPE_WIDTH 512 /* You can specified any positive value */
#define SCROLL_THRESHOLD 256 /* 1 <= SCROLL_THRESHOLD <= SCOPE_WIDTH */
#define NCOLOR 64 /* 1 <= NCOLOR <= 255 */
-/*#define AMP 0.35*/
#define AMP 1.0
-/*#define AMP 0.27*/
+#define AMP2 1.5
#define DEFAULT_ZOOM (44100.0/1024.0*2.0) /* ~86Hz */
-#define MIN_ZOOM 15.0 /* 15Hz is lower bound that human can be heard. */
+#define MIN_ZOOM 15.0 /* 15Hz is the lowest bound that human can be heard. */
#define MAX_ZOOM 440.0
#define DEFAULT_UPDATE 0.05
for(i = 0; i < SCOPE_HEIGHT; i++)
{
- v = (unsigned)val[i];
+ v = (unsigned)(val[i] * AMP2);
if(v > NCOLOR - 1)
val[i] = NCOLOR - 1;
+ else
+ val[i] = v;
}
switch(depth) {
extern void TmCanvasReset(void);\r
extern void TmCanvasNote(int status, int ch, int note, int vel);\r
extern int TmCanvasChange(void);\r
+extern void TmCanvasUpdateInterval();\r
extern int TmCanvasMode;\r
\r
/* w32g_c.c */\r
static int ctl_open(int using_stdin, int using_stdout)\r
{\r
ctl.opened = 1;\r
+ set_trace_loop_hook(TmCanvasUpdateInterval);\r
return w32g_open();\r
}\r
\r
{\r
int rc;\r
\r
- rc = w32g_get_rc(valp, 0);\r
+ rc = w32g_get_rc(valp, play_pause_flag);\r
if(rc >= RC_EXT_BASE)\r
return w32g_ext_control(rc, *valp);\r
return rc;\r
break;\r
case CTLE_REFRESH:\r
TmPanelRefresh();\r
- TmCanvasRefresh();\r
+ if(TmCanvasMode == TMCM_TRACER)\r
+ TmCanvasRefresh();\r
break;\r
case CTLE_RESET:\r
TmCanvasReset();\r
static void TmCanvasRepaint(HWND hwnd);\r
static void TmCanvasFillRect(RECT *r, COLORREF c);\r
static HGDIOBJ hgdiobj_hpen, hgdiobj_hbrush;\r
+static void TmCanvasUpdateChannel(void);\r
\r
void w32g_init_canvas(HWND hwnd)\r
{\r
\r
static void TmCanvasChannelNote(int status, int ch, int note, int vel)\r
{\r
- int v;\r
- double t, past_time;\r
+ int i, v;\r
unsigned int onoff;\r
- int i;\r
+ double t;\r
\r
if(ch >= TCTM_MAX_CHANNELS)\r
return;\r
onoff <<= (8 * sizeof(onoff) - 1);\r
set_bitset(&TmCanvas.channel_on_flags[ch], &onoff, note, 1);\r
\r
- t = get_current_calender_time();\r
- past_time = t - TmCanvas.last_bar_time;\r
- TmCanvas.last_bar_time = t;\r
-\r
- /* decrease alive time of bar */\r
- for(i = 0; i < TCTM_MAX_CHANNELS; i++)\r
- if(!has_bitset(&TmCanvas.channel_on_flags[i]))\r
- TmCanvas.bar_alive_time[i] -= past_time;\r
-\r
/* increase alive time of NoteON bar */\r
if(status == VOICE_ON)\r
{\r
if(TmCanvas.bar_alive_time[ch] < t)\r
TmCanvas.bar_alive_time[ch] = t;\r
}\r
+}\r
+\r
+static void TmCanvasUpdateChannel(void)\r
+{\r
+ double t, past_time;\r
+ int i, v;\r
+\r
+ t = get_current_calender_time();\r
+ past_time = t - TmCanvas.last_bar_time;\r
+ if(past_time < TM_SEC_PER_BOX)\r
+ return;\r
+ TmCanvas.last_bar_time = t;\r
+\r
+ /* decrease alive time of bar */\r
+ for(i = 0; i < TCTM_MAX_CHANNELS; i++)\r
+ if(!has_bitset(&TmCanvas.channel_on_flags[i]))\r
+ TmCanvas.bar_alive_time[i] -= past_time;\r
\r
/* Update bar[] */\r
for(i = 0; i < TCTM_MAX_CHANNELS; i++)\r
SelectObject(TmCanvas.hmdc, hgdiobj_hpen);\r
SelectObject(TmCanvas.hmdc, hgdiobj_hbrush);\r
}\r
+ TmCanvasRefresh();\r
}\r
\r
static void TmCanvasFillRect(RECT *r, COLORREF c)\r
return rc;\r
}\r
\r
+void TmCanvasUpdateInterval(void)\r
+{\r
+ TmCanvasUpdateChannel();\r
+}\r
+\r
void TmCanvasRefresh(void)\r
{\r
if(!TmCanvas.hdc)\r
#include <strings.h>
#endif
#include <stdlib.h>
-
#include <png.h>
#include "timidity.h"
defined(HAVE_X11_EXTENSIONS_XSHM_H) && \
defined(HAVE_SYS_IPC_H) && \
defined(HAVE_SYS_SHM_H)
-#include <X11/extensions/XShm.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
#define XSHM_SUPPORT 1
#else
-#undef XSHM_SUPPORT 0
+#define XSHM_SUPPORT 0
#endif
#endif /* XSHM_SUPPORT */
+#if XSHM_SUPPORT
+#include <X11/extensions/XShm.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+
#define MAX_PLANES 8
#define MAX_COLORS (1<<MAX_PLANES)
#define MAX_VIRTUAL_SCREENS 65536
XImage *im;
GC gc;
int depth;
-#ifdef XSHM_SUPPORT
+#if XSHM_SUPPORT
XShmSegmentInfo shminfo;
#endif /* XSHM_SUPPORT */
} ImagePixmap;
theDepth);
imageBitmap = create_shm_image_pixmap(IMAGEBITMAPLEN * CHAR_WIDTH1,
CHAR_HEIGHT,
- 1);
+ theDepth);
#else
theRealScreen = create_image_pixmap(REAL_SCREEN_SIZE_X,
REAL_SCREEN_SIZE_Y,
str = (char *)data + 10;
len = strlen(str);
+ if(len == 0)
+ return;
+
#ifdef SRY_DEBUG
printf("%d 0x%02x %d %d %d (%d,%d)\n%s\n",
screen, mask, mode, fg, bg, tx, ty, str);
ImagePixmap *ip;
int shm_depth;
- if(depth <= 1)
- shm_depth = 8; /* Can't create SHM bitmap. Why ?? */
- else
- shm_depth = depth;
-
+ shm_depth = depth;
ip = (ImagePixmap *)safe_malloc(sizeof(ImagePixmap));
shm_error = 0;
gscreen_plane_mask = 0;
for(i = 0; i < NUMPLANE; i++)
gscreen_plane_mask |= mywin.pmask[i];
+ gscreen_plane_mask |= mywin.basepix[0];
}
for(i=0;i<NUMPXL;i++){
#define ABORT -1
ArchiveHandler arc_handler;
+static MBlockList arc_buffer;
typedef struct _ArchiveFileList
{
method = url_getc(url);
switch(method)
{
- case 8: /* deflated */
+ case 8: /* deflated */
method = ARCHIVEC_DEFLATED;
break;
default:
/* time */
url_getc(url); url_getc(url); url_getc(url); url_getc(url);
- url_getc(url); /* extra flags */
- url_getc(url); /* OS type */
+ url_getc(url); /* extra flags */
+ url_getc(url); /* OS type */
if(flags & GZIP_MULTIPARTFLAG)
{
int parse_gzip_header_bytes(char *gz, long maxparse, int *hdrsiz)
{
- URL url = url_mem_open(gz, maxparse, 0);
- int method;
-
- if(!url)
- return -1;
- method = skip_gzip_header(url);
- *hdrsiz = url_tell(url);
- url_close(url);
- return method;
+ URL url = url_mem_open(gz, maxparse, 0);
+ int method;
+
+ if(!url)
+ return -1;
+ method = skip_gzip_header(url);
+ *hdrsiz = url_tell(url);
+ url_close(url);
+ return method;
}
void (* arc_error_handler)(char *error_message) = NULL;
-
+
static void arc_cant_open(char *s)
{
if(arc_error_handler != NULL)
if(url_check_type(archive_name) == URL_dir_t)
return ARCHIVE_DIR;
- return -1; /* Not found */
+ return -1; /* Not found */
}
static ArchiveFileList *find_arc_filelist(char *basename)
ArchiveEntryNode *arc_parse_entry(URL url, int archive_type)
{
- ArchiveEntryNode *entry_first, *entry_last, *entry;
- ArchiveEntryNode *(* next_header_entry)(void);
- int gzip_method;
- URL orig;
+ ArchiveEntryNode *entry_first, *entry_last, *entry;
+ ArchiveEntryNode *(* next_header_entry)(void);
+ int gzip_method;
+ URL orig;
- orig = NULL;
+ orig = NULL;
switch(archive_type)
{
case ARCHIVE_TAR:
case ARCHIVE_MIME:
if(!IS_URL_SEEK_SAFE(url))
{
- orig = url;
+ orig = url;
if((url = url_cache_open(orig, 0)) == NULL)
return NULL;
}
else
entry_first = entry_last = entry;
while(entry_last->next)
- entry_last = entry_last->next;
+ entry_last = entry_last->next;
arc_handler.counter++;
}
url_close(url);
if(orig)
- url_close(orig);
- return entry_first; /* Note that NULL if no archive file */
+ url_close(orig);
+ return entry_first; /* Note that NULL if no archive file */
}
static ArchiveFileList *add_arc_filelist(char *basename, int archive_type)
case ARCHIVE_LZH:
case ARCHIVE_MIME:
break;
- default:
- return NULL;
+ default:
+ return NULL;
}
if((url = url_open(basename)) == NULL)
return afl;
}
-int regist_archive(char *archive_filename, int archive_type)
+static ArchiveFileList *regist_archive(char *archive_filename)
{
- if(archive_type < 0)
- archive_type = get_archive_type(archive_filename);
- if(archive_type < 0)
- return 0; /* Unknown archive */
- archive_filename = url_expand_home_dir(archive_filename);
- if(find_arc_filelist(archive_filename))
- return 0; /* Already registerd */
- if(add_arc_filelist(archive_filename, archive_type))
- {
- reuse_mblock(&arc_handler.pool);
- return 1;
- }
- return 0;
+ int archive_type;
+
+ if((archive_type = get_archive_type(archive_filename)) < 0)
+ return NULL; /* Unknown archive */
+ archive_filename = url_expand_home_dir(archive_filename);
+ if(find_arc_filelist(archive_filename))
+ return NULL; /* Already registerd */
+ return add_arc_filelist(archive_filename, archive_type);
}
static int arc_expand_newfile(StringTable *s, ArchiveFileList *afl,
char *pattern)
{
- ArchiveEntryNode *entry;
- char *p;
+ ArchiveEntryNode *entry;
+ char *p;
- for(entry = afl->entry_list; entry; entry = entry->next)
+ for(entry = afl->entry_list; entry; entry = entry->next)
{
- if(arc_case_wildmat(entry->name, pattern))
+ if(arc_case_wildmat(entry->name, pattern))
{
- p = new_segment(&arc_handler.pool, strlen(afl->archive_name) +
- strlen(entry->name) + 2);
- strcpy(p, afl->archive_name);
- strcat(p, "#");
- strcat(p, entry->name);
- if(put_string_table(s, p, strlen(p)) == NULL)
- return -1;
+ p = new_segment(&arc_buffer, strlen(afl->archive_name) +
+ strlen(entry->name) + 2);
+ strcpy(p, afl->archive_name);
+ strcat(p, "#");
+ strcat(p, entry->name);
+ if(put_string_table(s, p, strlen(p)) == NULL)
+ return -1;
}
}
- return 0;
+ return 0;
}
char **expand_archive_names(int *nfiles_in_out, char **files)
{
error_flag = 0;
init_string_table(&stab);
- pool = &arc_handler.pool;
+ pool = &arc_buffer;
}
nfiles = *nfiles_in_out;
if((afl = find_arc_filelist(base)) != NULL)
{
- if(arc_expand_newfile(&stab, afl, pattern) == -1)
- goto abort_expand;
- continue;
+ if(arc_expand_newfile(&stab, afl, pattern) == -1)
+ goto abort_expand;
+ continue;
}
arc_type = get_archive_type(base);
len1--;
while(url_gets(url, buff, sizeof(buff)))
{
- if(strcmp(buff, ".") == 0 || strcmp(buff, "..") == 0)
- continue;
+ if(strcmp(buff, ".") == 0 || strcmp(buff, "..") == 0)
+ continue;
len2 = strlen(buff);
p = (char *)new_segment(pool, len1 + len2 + 2);
if((afl = add_arc_filelist(base, arc_type)) != NULL)
{
- if(arc_expand_newfile(&stab, afl, pattern) == -1)
- goto abort_expand;
+ if(arc_expand_newfile(&stab, afl, pattern) == -1)
+ goto abort_expand;
}
}
ArchiveEntryNode *new_entry_node(char *name, int len)
{
- ArchiveEntryNode *entry;
- entry = (ArchiveEntryNode *)safe_malloc(sizeof(ArchiveEntryNode));
- memset(entry, 0, sizeof(ArchiveEntryNode));
- entry->name = (char *)safe_malloc(len + 1);
- memcpy(entry->name, name, len);
- entry->name[len] = '\0';
- return entry;
+ ArchiveEntryNode *entry;
+ entry = (ArchiveEntryNode *)safe_malloc(sizeof(ArchiveEntryNode));
+ memset(entry, 0, sizeof(ArchiveEntryNode));
+ entry->name = (char *)safe_malloc(len + 1);
+ memcpy(entry->name, name, len);
+ entry->name[len] = '\0';
+ return entry;
}
void free_entry_node(ArchiveEntryNode *entry)
{
- free(entry->name);
- if(entry->cache != NULL)
- free(entry->cache);
- free(entry);
+ free(entry->name);
+ if(entry->cache != NULL)
+ free(entry->cache);
+ free(entry);
}
long compress_buff_len;
static long arc_compress_func(char *buff, long size, void *user_val)
{
- if(compress_buff_len <= 0)
- return 0;
- if(size > compress_buff_len)
- size = compress_buff_len;
- memcpy(buff, compress_buff, size);
- compress_buff += size;
- compress_buff_len -= size;
- return size;
+ if(compress_buff_len <= 0)
+ return 0;
+ if(size > compress_buff_len)
+ size = compress_buff_len;
+ memcpy(buff, compress_buff, size);
+ compress_buff += size;
+ compress_buff_len -= size;
+ return size;
}
void *arc_compress(void *buff, long bufsiz,
int compress_level, long *compressed_size)
{
- DeflateHandler compressor;
- long allocated, offset, space, nbytes;
- char *compressed;
-
- compress_buff = (char *)buff;
- compress_buff_len = bufsiz;
- compressor = open_deflate_handler(arc_compress_func, NULL,
- compress_level);
+ DeflateHandler compressor;
+ long allocated, offset, space, nbytes;
+ char *compressed;
+
+ compress_buff = (char *)buff;
+ compress_buff_len = bufsiz;
+ compressor = open_deflate_handler(arc_compress_func, NULL,
+ compress_level);
allocated = 1024;
compressed = (char *)safe_malloc(allocated);
offset = 0;
void *arc_decompress(void *buff, long bufsiz, long *decompressed_size)
{
- InflateHandler decompressor;
- long allocated, offset, space, nbytes;
- char *decompressed;
+ InflateHandler decompressor;
+ long allocated, offset, space, nbytes;
+ char *decompressed;
- compress_buff = (char *)buff;
- compress_buff_len = bufsiz;
- decompressor = open_inflate_handler(arc_compress_func, NULL);
+ compress_buff = (char *)buff;
+ compress_buff_len = bufsiz;
+ decompressor = open_inflate_handler(arc_compress_func, NULL);
allocated = 1024;
decompressed = (char *)safe_malloc(allocated);
offset = 0;
void free_archive_files(void)
{
- ArchiveEntryNode *entry, *ecur;
- ArchiveFileList *acur;
+ ArchiveEntryNode *entry, *ecur;
+ ArchiveFileList *acur;
- while(arc_filelist)
+ while(arc_filelist)
{
- acur = arc_filelist;
- arc_filelist = arc_filelist->next;
- entry = acur->entry_list;
- while(entry)
+ acur = arc_filelist;
+ arc_filelist = arc_filelist->next;
+ entry = acur->entry_list;
+ while(entry)
{
- ecur = entry;
- entry = entry->next;
- free_entry_node(ecur);
+ ecur = entry;
+ entry = entry->next;
+ free_entry_node(ecur);
}
- free(acur->archive_name);
- free(acur);
+ free(acur->archive_name);
+ free(acur);
}
}
-
/******************************************************************************
- * url_arc
- *****************************************************************************/
+* url_arc
+*****************************************************************************/
typedef struct _URL_arc
{
char common[sizeof(struct _URL)];
URL instream;
long pos, size;
- int comptype;
- void *decoder;
+ int comptype;
+ void *decoder;
} URL_arc;
static long url_arc_read(URL url, void *buff, long n);
url = (URL_arc *)v;
if(url->size < 0)
- n = buff_size;
+ n = buff_size;
else
- {
+ {
n = url->size - url->pos;
if(n > buff_size)
- n = buff_size;
- }
+ n = buff_size;
+ }
if(n <= 0)
- return 0;
+ return 0;
n = url_read(url->instream, buff, n);
if(n <= 0)
return n;
if((p = strrchr(name, '#')) == NULL)
return NULL;
len = p - name;
- base = new_segment(&arc_handler.pool, len + 1);
+ base = new_segment(&arc_buffer, len + 1);
memcpy(base, name, len);
base[len] = '\0';
base = url_expand_home_dir(base);
+
if((afl = find_arc_filelist(base)) == NULL)
- {
- reuse_mblock(&arc_handler.pool);
+ afl = regist_archive(base);
+ if(afl == NULL)
return NULL;
- }
- reuse_mblock(&arc_handler.pool); /* free `base' */
+ reuse_mblock(&arc_buffer); /* free `base' */
name += len + 1;
for(entry = afl->entry_list; entry; entry = entry->next)
return NULL;
if(entry->cache != NULL)
- instream = url_mem_open((char *)entry->cache + entry->start,
- entry->compsize, 0);
+ instream = url_mem_open((char *)entry->cache + entry->start,
+ entry->compsize, 0);
else
- {
+ {
if((instream = url_file_open(base)) == NULL)
- return NULL;
+ return NULL;
url_seek(instream, entry->start, 0);
- }
+ }
url = (URL_arc *)alloc_url(sizeof(URL_arc));
if(url == NULL)
case ARCHIVEC_STORED: /* No compression */
case ARCHIVEC_LZHED_LH0: /* -lh0- */
case ARCHIVEC_LZHED_LZ4: /* -lz4- */
- url->comptype = ARCHIVEC_STORED;
url->decoder = NULL;
case ARCHIVEC_DEFLATED: /* deflate */
case ARCHIVEC_LZHED_LH7: /* -lh7- */
url->decoder =
(void *)open_unlzh_handler(
- archiver_read_func,
- lzh_methods[entry->comptype - ARCHIVEC_LZHED - 1],
- entry->compsize, entry->origsize, url);
+ archiver_read_func,
+ lzh_methods[entry->comptype - ARCHIVEC_LZHED - 1],
+ entry->compsize, entry->origsize, url);
if(url->decoder == NULL)
{
url_arc_close((URL)url);
switch(comptype)
{
case ARCHIVEC_STORED:
+ case ARCHIVEC_LZHED_LH0: /* -lh0- */
+ case ARCHIVEC_LZHED_LZ4: /* -lz4- */
n = archiver_read_func(buff, bufsiz, (void *)urlp);
break;
int save_errno = errno;
/* 1. close decoder
- * 2. close decode_stream
- * 3. free url
- */
+ * 2. close decode_stream
+ * 3. free url
+ */
decoder = urlp->decoder;
if(decoder != NULL)
close_explode_handler((ExplodeHandler)decoder);
break;
- case ARCHIVEC_LZHED_LH1: /* -lh1- */
- case ARCHIVEC_LZHED_LH2: /* -lh2- */
- case ARCHIVEC_LZHED_LH3: /* -lh3- */
- case ARCHIVEC_LZHED_LH4: /* -lh4- */
- case ARCHIVEC_LZHED_LH5: /* -lh5- */
- case ARCHIVEC_LZHED_LZS: /* -lzs- */
- case ARCHIVEC_LZHED_LZ5: /* -lz5- */
- case ARCHIVEC_LZHED_LHD: /* -lhd- */
- case ARCHIVEC_LZHED_LH6: /* -lh6- */
- case ARCHIVEC_LZHED_LH7: /* -lh7- */
+ case ARCHIVEC_LZHED_LH1: /* -lh1- */
+ case ARCHIVEC_LZHED_LH2: /* -lh2- */
+ case ARCHIVEC_LZHED_LH3: /* -lh3- */
+ case ARCHIVEC_LZHED_LH4: /* -lh4- */
+ case ARCHIVEC_LZHED_LH5: /* -lh5- */
+ case ARCHIVEC_LZHED_LZS: /* -lzs- */
+ case ARCHIVEC_LZHED_LZ5: /* -lz5- */
+ case ARCHIVEC_LZHED_LHD: /* -lhd- */
+ case ARCHIVEC_LZHED_LH6: /* -lh6- */
+ case ARCHIVEC_LZHED_LH7: /* -lh7- */
close_unlzh_handler((UNLZHHandler)decoder);
break;
}
if(urlp->instream != NULL)
- url_close(urlp->instream);
- free(urlp);
- errno = save_errno;
+ url_close(urlp->instream);
+ free(urlp);
+ errno = save_errno;
}
}
/*
-** Match text and p, return TRUE, FALSE, or ABORT.
-*/
+ * Match text and p, return TRUE, FALSE, or ABORT.
+ */
static int DoMatch(char *text, char *p)
{
register int last;
#ifdef OPTIMIZE_JUST_STAR
if (p[0] == '*' && p[1] == '\0')
return TRUE;
-#endif /* OPTIMIZE_JUST_STAR */
+#endif /* OPTIMIZE_JUST_STAR */
return DoMatch(text, p) == TRUE;
}
#ifdef OPTIMIZE_JUST_STAR
if (p[0] == '*' && p[1] == '\0')
return TRUE;
-#endif /* OPTIMIZE_JUST_STAR */
+#endif /* OPTIMIZE_JUST_STAR */
return DoCaseMatch(text, p) == TRUE;
}
* Interfaces
*/
-extern int regist_archive(char *archive_filename, int archive_type);
-/* Regist archive file name to use url_arc_open */
-
-extern char **expand_archive_names(int *nfiles_in_out, char **files_in_out);
+extern char **expand_archive_names(int *nfiles_in_out, char **files);
/* Regist all archive files in `files_in_out', and expand the archive */
extern URL url_arc_open(char *name);
-/* Open input stream from registerd archive */
+/* Open input stream from archive. `name' format must be "filename#entry".
+ */
extern void free_archive_files(void);
/* Call once at the last */
extern void (* arc_error_handler)(char *error_message);
-
/*
* Internal library usage only
*/
URL url; /* Input stream */
int counter;/* counter to extract the entry*/
long pos;
- MBlockList pool;
} ArchiveHandler;
extern ArchiveHandler arc_handler;
readmidi.h controls.h wrd.h ../utils/strtab.h
wrdt.o: wrdt.c ../config.h timidity.h ../utils/support.h common.h \
../libarc/url.h ../utils/mblock.h wrd.h ../utils/strtab.h \
- instrum.h playmidi.h readmidi.h
+ instrum.h playmidi.h readmidi.h ../libarc/arc.h
info-am:
info: info-am
break;
}
}
+
trace_flush();
play_mode->acntl(PM_REQ_FLUSH, NULL);
play_counter = play_offset_counter = 0;
char *program_name, current_filename[1024];
MBlockList tmpbuffer;
char *output_text_code = NULL;
+int open_file_noise_mode = OF_NORMAL;
#ifdef DEFAULT_PATH
/* The paths in this list will be tried whenever we're reading a file */
PathList *plp=pathlist;
int l;
+ open_file_noise_mode = noise_mode;
if (!name || !(*name))
{
if(noise_mode)
/* Second, expand archive files */
new_nfiles = nfiles;
+ open_file_noise_mode = OF_NORMAL;
new_files = expand_archive_names(&new_nfiles, files);
free(files[0]);
free(files);
CTLE_REFRESH,
CTLE_RESET,
CTLE_SPEANA, /* v1:double[] v2:len */
- CTLE_PAUSE /* v1:pause on/off v2:time of pause */
+ CTLE_PAUSE, /* v1:pause on/off v2:time of pause */
+ CTLE_GSLCD /* GS L.C.D. */
};
typedef struct _CtlEvent {
#include "playmidi.h"
#include "miditrace.h"
+/* It is possible count_info.bytes > written bytes. bug? */
+#define BYTES_PROCESSED_BUGFIX 1
+
#ifndef AFMT_S16_NE
#ifdef LITTLE_ENDIAN
#define AFMT_S16_NE AFMT_S16_LE
static void close_output(void);
static int output_data(char *buf, int32 nbytes);
static int acntl(int request, void *arg);
+static int output_counter, counter_offset;
/* export the playback mode */
acntl
};
-
/*************************************************************************/
/* We currently only honor the PE_MONO bit, the sample rate, and the
number of buffer fragments. We try 16-bit signed data first, and
#endif
dpm.fd = fd;
+ output_counter = counter_offset = 0;
return warnings;
}
static int output_data(char *buf, int32 nbytes)
{
int n;
+ count_info cinfo;
+
+ ioctl(dpm.fd, SNDCTL_DSP_GETOPTR, &cinfo);
+ if(output_counter < cinfo.bytes)
+ {
+ counter_offset += output_counter;
+ ioctl(dpm.fd, SNDCTL_DSP_SYNC);
+ output_counter = 0;
+ }
while(nbytes > 0)
{
}
buf += n;
nbytes -= n;
+ output_counter += n;
}
return 0;
switch(request)
{
- case PM_REQ_GETQSIZ:
- if(ioctl(dpm.fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
- return -1;
- total = info.fragstotal * info.fragsize;
- *((int *)arg) = total;
- return 0;
+ case PM_REQ_GETQSIZ:
+ if(ioctl(dpm.fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
+ return -1;
+ total = info.fragstotal * info.fragsize;
+ *((int *)arg) = total;
+ return 0;
case PM_REQ_DISCARD:
+ counter_offset = output_counter = 0;
return ioctl(dpm.fd, SNDCTL_DSP_RESET);
+ case PM_REQ_FLUSH:
+ counter_offset = output_counter = 0;
+ return ioctl(dpm.fd, SNDCTL_DSP_SYNC);
+
case PM_REQ_RATE: {
int rate;
rate = *(int *)arg;
case PM_REQ_GETSAMPLES:
if(ioctl(dpm.fd, SNDCTL_DSP_GETOPTR, &cinfo) == -1)
return -1;
- bytes = cinfo.bytes;
+ bytes = cinfo.bytes + counter_offset;
if(!(dpm.encoding & PE_MONO)) bytes >>= 1;
if(dpm.encoding & PE_16BIT) bytes >>= 1;
*((int *)arg) = bytes;
return 0;
-
- case PM_REQ_FLUSH:
- return ioctl(dpm.fd, SNDCTL_DSP_SYNC);
}
return -1;
}
EVENT_NAME(ME_TEMPO);
EVENT_NAME(ME_CHORUS_TEXT);
EVENT_NAME(ME_LYRIC);
+ EVENT_NAME(ME_GSLCD);
EVENT_NAME(ME_MARKER);
EVENT_NAME(ME_INSERT_TEXT);
EVENT_NAME(ME_TEXT);
if(intr)
return RC_QUIT;
if(play_pause_flag)
-#ifdef HAVE_USLEEP
usleep(300000);
-#else
- sleep(1);
-#endif
} while (rc != RC_NONE || play_pause_flag);
return jump_flag ? RC_JUMP : RC_NONE;
}
ctl_mode_event(CTLE_LYRIC, 1, i, 0);
break;
+ case ME_GSLCD:
+ i = ev->a | ((int)ev->b << 8);
+ ctl_mode_event(CTLE_GSLCD, 1, i, 0);
+ break;
+
case ME_MASTER_VOLUME:
master_volume_ratio = (int32)ev->a + 256 * (int32)ev->b;
adjust_master_volume();
ce.type = type;
ce.v1 = arg1;
ce.v2 = arg2;
- if(trace && ctl->trace_playing && !midi_trace.flush_flag)
+ if(trace && ctl->trace_playing)
push_midi_trace_ce(ctl->event, &ce);
- else if(ctl->event != NULL)
+ else
ctl->event(&ce);
}
ce.v2 = voice[noteID].channel;
ce.v3 = voice[noteID].note;
ce.v4 = voice[noteID].velocity;
- if(ctl->trace_playing && !midi_trace.flush_flag)
+ if(ctl->trace_playing)
push_midi_trace_ce(ctl->event, &ce);
else
ctl->event(&ce);
ce.type = CTLE_CURRENT_TIME;
ce.v1 = last_secs = secs;
ce.v2 = last_voices = voices;
- if(ctl->trace_playing && !midi_trace.flush_flag)
+ if(ctl->trace_playing)
push_midi_trace_ce(ctl->event, &ce);
- else if(ctl->event)
+ else
ctl->event(&ce);
}
static void ctl_updatetime(int32 samples)
{
long secs;
- CtlEvent ce;
-
secs = (long)(samples / (midi_time_ratio * play_mode->rate));
- ce.type = CTLE_CURRENT_TIME;
- ce.v1 = secs;
- ce.v2 = 0;
- if(ctl->event)
- {
- ctl->event(&ce);
- ctl_mode_event(CTLE_REFRESH, 0, 0, 0);
- }
+ ctl_mode_event(CTLE_CURRENT_TIME, 0, secs, 0);
+ ctl_mode_event(CTLE_REFRESH, 0, 0, 0);
}
static void ctl_prog_event(int ch)
ce.v1 = ch;
ce.v2 = channel[ch].program;
ce.v3 = (long)channel_instrum_name(ch);
- if(ctl->trace_playing && !midi_trace.flush_flag)
+ if(ctl->trace_playing)
push_midi_trace_ce(ctl->event, &ce);
else
ctl->event(&ce);
static void ctl_pause_event(int pause, int32 s)
{
- if(ctl->event)
- {
- CtlEvent ce;
- ce.type = CTLE_PAUSE;
- ce.v1 = pause;
- ce.v2 = (long)(s / (midi_time_ratio * play_mode->rate));
- ctl->event(&ce);
- }
+ long secs;
+ secs = (long)(s / (midi_time_ratio * play_mode->rate));
+ ctl_mode_event(CTLE_PAUSE, 0, pause, secs);
}
char *channel_instrum_name(int ch)
ME_TEMPO,
ME_CHORUS_TEXT,
ME_LYRIC,
+ ME_GSLCD, /* GS L.C.D. Exclusive message event */
ME_MARKER,
ME_INSERT_TEXT, /* for SC */
ME_TEXT,
a = (string_event_strtab.nstring & 0xff);
b = ((string_event_strtab.nstring >> 8) & 0xff);
- len = 7+128;
+ len = 128;
- text = (char *)new_segment(&tmpbuffer, len + 1);
+ text = (char *)new_segment(&tmpbuffer, len + 2);
- strcpy(text+1, "gslcd: ");
for( i=0; i<64; i++){
const char tbl[]= "0123456789ABCDEF";
- text[8+i*2 ]=tbl[data[i]>>4];
- text[8+i*2+1]=tbl[data[i]&0xF];
+ text[1+i*2 ]=tbl[data[i]>>4];
+ text[1+i*2+1]=tbl[data[i]&0xF];
}
text[len + 1] = '\0';
len -= 2;
save = val[len];
val[len] = '\0';
- if(readmidi_make_lcd_event(ME_INSERT_TEXT, (uint8 *)val + 7, ev))
+ if(readmidi_make_lcd_event(ME_GSLCD, (uint8 *)val + 7, ev))
{
val[len] = save;
return 1;
extension_flag = 0;
i = 0;
}
+
+ /* Chop the comment.
+ * Comment delimiter =~ /^#|\s#|#[ \t]/
+ */
if((cp = strchr(tmp + i, '#')) != NULL) {
- if(cp == tmp + i || isspace((int)cp[-1]) || isspace((int)cp[1]))
+ if(cp == tmp + i || /* beginning of line */
+ isspace((int)cp[-1]) || /* "\s#" */
+ cp[1] == ' ' || /* "#[ \t]" */
+ cp[1] == '\t')
*cp = '\0';
}
s[2] = '\n';
write(2, s, 3);
- if(sig == SIGINT && intr < 5)
+ if(sig == SIGINT && intr < 3)
{
intr++;
signal(SIGINT, sigterm_exit); /* For SysV base */
static void timidity_arc_error_handler(char *error_message)
{
- ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "%s", error_message);
+ extern int open_file_noise_mode;
+ if(open_file_noise_mode)
+ ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "%s", error_message);
}
MAIN_INTERFACE void timidity_start_initialize(void)
#include "instrum.h"
#include "playmidi.h"
#include "readmidi.h"
+#include "arc.h"
/*
* Remap WRD @COLOR(16)-@COLOR(23) to RGB plain number.
static StringTable path_list;
static StringTable default_path_list;
+static int wrd_add_path_one(char *path, int pathlen);
void wrd_init_path(void)
{
StringTableNode *p;
delete_string_table(&path_list);
for(p = default_path_list.head; p; p = p->next)
- wrd_add_path(p->string, 0);
- if(current_file_info && strchr(current_file_info->filename, '#') != NULL)
- wrd_add_path(current_file_info->filename,
- strchr(current_file_info->filename, '#') -
- current_file_info->filename + 1);
- if(current_file_info &&
- strrchr(current_file_info->filename, PATH_SEP) != NULL)
- wrd_add_path(current_file_info->filename,
- strrchr(current_file_info->filename, PATH_SEP) -
- current_file_info->filename + 1);
+ wrd_add_path_one(p->string, strlen(p->string));
+
+ if(current_file_info)
+ {
+ if(strchr(current_file_info->filename, '#') != NULL)
+ wrd_add_path_one(current_file_info->filename,
+ strchr(current_file_info->filename, '#') -
+ current_file_info->filename + 1);
+ if(strrchr(current_file_info->filename, PATH_SEP) != NULL)
+ wrd_add_path_one(current_file_info->filename,
+ strrchr(current_file_info->filename, PATH_SEP) -
+ current_file_info->filename + 1);
+ }
+}
+
+static int wrd_add_path_one(char *path, int pathlen)
+{
+ int exists;
+ StringTableNode *p;
+
+ exists = 0;
+ for(p = path_list.head; p; p = p->next)
+ if(strncmp(p->string, path, pathlen) == 0 &&
+ p->string[pathlen] == '\0')
+ {
+ exists = 1;
+ break;
+ }
+ if(exists)
+ return 0;
+ put_string_table(&path_list, path, pathlen);
+ return 1;
}
void wrd_add_path(char *path, int pathlen)
{
if(pathlen == 0)
pathlen = strlen(path);
- if(pathlen > 0)
+ if(!wrd_add_path_one(path, pathlen))
+ return;
+
+ if(current_file_info &&
+ get_archive_type(current_file_info->filename) != -1)
{
- int exists;
- StringTableNode *p;
-
- exists = 0;
- for(p = path_list.head; p; p = p->next)
- if(strncmp(p->string, path, pathlen) == 0)
- {
- exists = 1;
- break;
- }
- if(!exists)
- {
- put_string_table(&path_list, path, pathlen);
- if(current_file_info &&
- strchr(current_file_info->filename, '#') != NULL &&
- path[pathlen - 1] != '#')
- {
- MBlockList buf;
- char *arc_path;
- int baselen;
-
- init_mblock(&buf);
- baselen = strchr(current_file_info->filename, '#') -
- current_file_info->filename + 1;
- arc_path = new_segment(&buf, baselen + pathlen + 1);
- strncpy(arc_path, current_file_info->filename, baselen);
- strncpy(arc_path + baselen, path, pathlen);
- arc_path[baselen + pathlen] = '\0';
- put_string_table(&path_list, arc_path, strlen(arc_path));
- reuse_mblock(&buf);
- }
- }
+ MBlockList buf;
+ char *arc_path;
+ int baselen;
+
+ init_mblock(&buf);
+ baselen = strrchr(current_file_info->filename, '#') -
+ current_file_info->filename + 1;
+ arc_path = new_segment(&buf, baselen + pathlen + 1);
+ strncpy(arc_path, current_file_info->filename, baselen);
+ strncpy(arc_path + baselen, path, pathlen);
+ arc_path[baselen + pathlen] = '\0';
+ put_string_table(&path_list, arc_path, strlen(arc_path));
+ reuse_mblock(&buf);
}
}
{
StringTableNode *path;
struct timidity_file *tf;
+
+ if(get_archive_type(filename) != -1)
+ return open_file(filename, 0, OF_SILENT);
+
for(path = path_list.head; path; path = path->next){
if((tf = try_wrd_open_file(path->string, filename)) != NULL)
return tf;