1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
diff -ur xmms-nsf-0.0.3/src/nes/audiosys.c xmms-nsf-0.0.3.about/src/nes/audiosys.c
--- xmms-nsf-0.0.3/src/nes/audiosys.c 2001-01-06 23:17:57.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/nes/audiosys.c 2005-01-02 20:34:41.767192374 -0500
@@ -8,8 +8,11 @@
static NES_AUDIO_HANDLER *nah = 0;
static NES_VOLUME_HANDLER *nvh = 0;
-void NESAudioRender(Int16 *bufp, Uint buflen)
+Uint32 NESAudioRender(Int16 *bufp, Uint buflen)
{
+ Int16 x;
+ Uint32 count = 0;
+
while (buflen--)
{
NES_AUDIO_HANDLER *ph;
@@ -31,9 +34,17 @@
else
output = accum;
output >>= 8;
- *bufp++ = ((Int32)output) - 0x8000;
+ x = ((Int32)output) - 0x8000;
+ if (abs(x) < 96)
+ count++;
+ else
+ count = 0;
+
+ *bufp++ = x;
}
}
+
+ return count;
}
void NESVolume(Uint volume)
diff -ur xmms-nsf-0.0.3/src/nes/audiosys.h xmms-nsf-0.0.3.about/src/nes/audiosys.h
--- xmms-nsf-0.0.3/src/nes/audiosys.h 2001-01-06 23:17:56.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/nes/audiosys.h 2005-01-02 20:42:51.457112634 -0500
@@ -21,7 +21,7 @@
} NES_VOLUME_HANDLER;
-void NESAudioRender(Int16 *bufp, Uint buflen);
+Uint32 NESAudioRender(Int16 *bufp, Uint buflen);
void NESAudioHandlerInstall(NES_AUDIO_HANDLER *ph);
void NESAudioFrequencySet(Uint freq);
Uint NESAudioFrequencyGet(void);
diff -ur xmms-nsf-0.0.3/src/xmms/callbacks.c xmms-nsf-0.0.3.about/src/xmms/callbacks.c
--- xmms-nsf-0.0.3/src/xmms/callbacks.c 2000-07-23 05:06:43.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/xmms/callbacks.c 2005-01-02 20:58:29.052175495 -0500
@@ -219,7 +219,7 @@
widget = lookup_widget(GTK_WIDGET(button), "spinbutton1");
nsf_cfg.play_time = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
widget = lookup_widget(GTK_WIDGET(button), "spinbutton2");
- nsf_cfg.fadeout_time = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
+ nsf_cfg.silence_time = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL);
cfg = xmms_cfg_open_file(filename);
@@ -228,7 +228,7 @@
}
xmms_cfg_write_int(cfg, "NSF", "play_time",nsf_cfg.play_time);
- xmms_cfg_write_int(cfg, "NSF", "fadeout_time",nsf_cfg.fadeout_time);
+ xmms_cfg_write_int(cfg, "NSF", "silence_time",nsf_cfg.silence_time);
xmms_cfg_write_file(cfg, filename);
xmms_cfg_free(cfg);
g_free(filename);
diff -ur xmms-nsf-0.0.3/src/xmms/interface.c xmms-nsf-0.0.3.about/src/xmms/interface.c
--- xmms-nsf-0.0.3/src/xmms/interface.c 2000-07-23 04:41:14.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/xmms/interface.c 2005-01-02 20:55:32.754086347 -0500
@@ -106,7 +106,7 @@
gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT);
gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
- label3 = gtk_label_new ("Fadeout Time:");
+ label3 = gtk_label_new ("Silence Until Next Song:");
gtk_widget_ref (label3);
gtk_object_set_data_full (GTK_OBJECT (configure), "label3", label3,
(GtkDestroyNotify) gtk_widget_unref);
diff -ur xmms-nsf-0.0.3/src/xmms/nsf.c xmms-nsf-0.0.3.about/src/xmms/nsf.c
--- xmms-nsf-0.0.3/src/xmms/nsf.c 2001-01-07 00:15:12.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/xmms/nsf.c 2005-01-02 20:58:06.990044841 -0500
@@ -23,7 +23,8 @@
#define VERSION "0.0.3"
#define PLAYTIME 30
-#define FADEOUTTIME 5
+#define SILENCETIME 5
+#define FREQ 44100
#include "nsf.h"
@@ -328,7 +329,7 @@
widget = lookup_widget(nsf_configure_win, "spinbutton1");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), nsf_cfg.play_time);
widget = lookup_widget(nsf_configure_win, "spinbutton2");
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), nsf_cfg.fadeout_time);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), nsf_cfg.silence_time);
gtk_widget_show(nsf_configure_win);
}else{
@@ -357,7 +358,7 @@
nsf_win->dock_window_list = NULL;
nsf_cfg.play_time = PLAYTIME; /* second */
- nsf_cfg.fadeout_time = FADEOUTTIME; /* second */
+ nsf_cfg.silence_time = SILENCETIME; /* second */
nsf_cfg.player_shaded = FALSE;
nsf_cfg.easy_move = FALSE;
@@ -365,7 +366,7 @@
if ((cfg = xmms_cfg_open_file(filename)) != 0){
xmms_cfg_read_int(cfg, "NSF", "play_time", &nsf_cfg.play_time);
- xmms_cfg_read_int(cfg, "NSF", "fadeout_time", &nsf_cfg.fadeout_time);
+ xmms_cfg_read_int(cfg, "NSF", "silence_time", &nsf_cfg.silence_time);
xmms_cfg_free(cfg);
}
}
@@ -439,10 +440,11 @@
{
char data[2048 * 2];
int bytes, blk_size, rate;
+ Uint32 c = 0, count = 0;
//setting NSF
NSFSetSongNo(nsf_file->current_song);
- NESAudioFrequencySet(44100);
+ NESAudioFrequencySet(FREQ);
NESReset();
//16bit/8bit * 1channel * 512 sample = 1024byte
@@ -460,7 +462,15 @@
}
if (bytes > 0){
//read 1024byte = 512 sample * 2byte
- NESAudioRender(data, bytes/2);
+ c = NESAudioRender(data, bytes/2);
+ if (c < 512)
+ count = 0;
+ else
+ count += c;
+ if (count > FREQ*nsf_cfg.silence_time) {
+ nsf_file->eos = 1;
+ count = 0;
+ }
nsf_ip.add_vis_pcm(nsf_ip.output->written_time(), (nsf_file->bits_per_sample == 16) ? FMT_S16_LE : FMT_U8,
nsf_file->channels, bytes, data);
@@ -512,6 +522,9 @@
if (!(nsf_file->file = fopen(filename, "rb"))){
return;
}
+
+ nsf_about();
+
fseek(nsf_file->file, 0, SEEK_END);
count = ftell(nsf_file->file);
fseek(nsf_file->file, 0, SEEK_SET);
diff -ur xmms-nsf-0.0.3/src/xmms/nsf.h xmms-nsf-0.0.3.about/src/xmms/nsf.h
--- xmms-nsf-0.0.3/src/xmms/nsf.h 2000-07-23 05:00:35.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/xmms/nsf.h 2005-01-02 20:58:37.563297001 -0500
@@ -58,7 +58,7 @@
typedef struct
{
gint play_time;
- gint fadeout_time;
+ gint silence_time;
// reserve
gint resolution;
gint channels;
diff -ur xmms-nsf-0.0.3/src/xmms/nsflib.h xmms-nsf-0.0.3.about/src/xmms/nsflib.h
--- xmms-nsf-0.0.3/src/xmms/nsflib.h 2000-07-23 05:05:21.000000000 -0500
+++ xmms-nsf-0.0.3.about/src/xmms/nsflib.h 2005-01-02 20:45:55.481496508 -0500
@@ -1,10 +1,11 @@
typedef signed short Int16;
typedef unsigned int Uint;
+typedef unsigned int Uint32;
typedef unsigned char Uint8;
Uint NSFLoad(Uint8 *pData, Uint uSize);
void NSFSetSongNo(Uint uSongNo);
void NESAudioFrequencySet(Uint freq);
void NESReset(void);
-void NESAudioRender(Int16 *bufp, Uint buflen);
+Uint32 NESAudioRender(Int16 *bufp, Uint buflen);
void NESTerminate(void);
|