• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision358d315246945cdc832b9e8542881e93ed90b079 (tree)
Time2018-06-13 09:22:02
AuthorStarg <starg@user...>
CommiterStarg

Log Message

Import UnkoTim218

Change Summary

Incremental Difference

--- a/config.h
+++ b/config.h
@@ -311,6 +311,7 @@
311311 #define AU_VORBIS 1
312312 #define AU_VORBIS_DLL 1
313313 #define VORBIS_DLL_INCLUDE_VORBISENC 1 /* ver 1.3.3 */
314+//#define VORBIS_DLL_INCLUDE_VORBISFILE 1 /* ver 1.3.3 */
314315 #define AU_GOGO 1
315316 #define AU_GOGO_DLL 1
316317 #define AU_LAME 1
@@ -322,6 +323,7 @@
322323 #define AU_OPUS_DLL 1
323324 #define AU_SPEEX 1
324325 //#define AU_AO 1
326+//#define AU_ASIO 1
325327 #define AU_PORTAUDIO 1
326328 #define AU_PORTAUDIO_DLL 1
327329 #define PORTAUDIO_V19 1
@@ -411,7 +413,7 @@
411413 //#undef __W32G__ /* for Win32 GUI */
412414 #undef IA_W32GUI /* for Win32 GUI */
413415 #undef AU_VORBIS
414-#undef AU_VORBIS_DLL
416+//#undef AU_VORBIS_DLL
415417 #undef AU_GOGO
416418 #undef AU_GOGO_DLL
417419 #undef AU_LAME
@@ -433,7 +435,7 @@
433435 #undef AU_BENCHMARK
434436 #undef SMFCONV
435437 /* Define if you have the vorbis library (-lvorbis). */
436-#undef HAVE_LIBVORBIS
438+//#undef HAVE_LIBVORBIS
437439 /* Define if you have the vorbis library (-lgogo). */
438440 #undef HAVE_LIBGOGOL
439441 #endif
@@ -447,7 +449,7 @@
447449 #undef USE_TWSYN_BRIDGE
448450 /* #undef AU_NPIPE */
449451 #undef AU_VORBIS
450-#undef AU_VORBIS_DLL
452+//#undef AU_VORBIS_DLL
451453 #undef AU_GOGO
452454 #undef AU_GOGO_DLL
453455 /* #undef AU_PORTAUDIO */
@@ -484,7 +486,7 @@
484486 #undef USE_TWSYN_BRIDGE
485487 //#undef AU_WASAPI
486488 #undef AU_VORBIS
487-#undef AU_VORBIS_DLL
489+//#undef AU_VORBIS_DLL
488490 #undef AU_GOGO
489491 #undef AU_GOGO_DLL
490492 #undef AU_LAME
@@ -509,10 +511,10 @@
509511 #undef SMFCONV
510512
511513 /* Define if you have the vorbis library (-lvorbis). */
512-#undef HAVE_LIBVORBIS
514+//#undef HAVE_LIBVORBIS
513515
514516 /* Define if you have the vorbis library (-lgogo). */
515-#undef HAVE_LIBGOGOL
517+//#undef HAVE_LIBGOGOL
516518
517519 #undef __W32G__ /* for Win32 GUI */
518520 #undef SUPPORT_SOUNDSPEC
@@ -675,7 +677,7 @@
675677 #undef AU_WASAPI
676678 #undef AU_WDMKS
677679 #undef AU_VORBIS
678-#undef AU_VORBIS_DLL
680+//#undef AU_VORBIS_DLL
679681 #undef AU_GOGO
680682 #undef AU_GOGO_DLL
681683 #undef AU_LAME
--- a/interface/w32g_pref.c
+++ b/interface/w32g_pref.c
@@ -8692,9 +8692,9 @@ LRESULT WINAPI wasapiConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
86928692 cb_sel = SendDlgItemMessage(hwnd, IDC_COMBO_WASAPI_PRIORITY, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
86938693 st_temp->wasapi_priority = cb_sel;
86948694 // WASAPI Stream Category
8695- st_temp->wasapi_stream_category = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_CATEGORY);
8695+ st_temp->wasapi_stream_category = CB_GET(IDC_COMBO_WASAPI_STREAM_CATEGORY);
86968696 // WASAPI Stream Option
8697- st_temp->wasapi_stream_option = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_OPTION);
8697+ st_temp->wasapi_stream_option = CB_GET(IDC_COMBO_WASAPI_STREAM_OPTION);
86988698
86998699 EndDialog(hwnd,TRUE);
87008700 break;
--- a/interface/w32g_utl.c
+++ b/interface/w32g_utl.c
@@ -1809,7 +1809,7 @@ void ScanDirectoryFiles(char *basedir,
18091809 url_close(dir);
18101810 }
18111811
1812-#define EXPANDDIR_MAX_SIZE 100000 /* Limit of total bytes of the file names */
1812+#define EXPANDDIR_MAX_SIZE 1000000 /* Limit of total bytes of the file names */
18131813 static int expand_dir_proc(char *filename, void *v)
18141814 {
18151815 void **user_val = (void **)v;
--- a/kbtim/kbtim_dll.vcproj
+++ b/kbtim/kbtim_dll.vcproj
@@ -348,6 +348,14 @@
348348 />
349349 </FileConfiguration>
350350 </File>
351+ <File
352+ RelativePath="..\timidity\w32g_vorbis_dll.c"
353+ >
354+ </File>
355+ <File
356+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
357+ >
358+ </File>
351359 <Filter
352360 Name="timidity"
353361 >
@@ -382,6 +390,10 @@
382390 </FileConfiguration>
383391 </File>
384392 <File
393+ RelativePath="..\timidity\decode.c"
394+ >
395+ </File>
396+ <File
385397 RelativePath="..\timidity\effect.c"
386398 >
387399 <FileConfiguration
--- a/kbtim/kbtim_dll.vcxproj
+++ b/kbtim/kbtim_dll.vcxproj
@@ -313,6 +313,7 @@
313313 <ItemGroup>
314314 <ClCompile Include="..\timidity\aq.c" />
315315 <ClCompile Include="..\timidity\audio_cnv.c" />
316+ <ClCompile Include="..\timidity\decode.c" />
316317 <ClCompile Include="..\timidity\envelope.c" />
317318 <ClCompile Include="..\timidity\freq.c" />
318319 <ClCompile Include="..\timidity\int_synth.c" />
@@ -328,6 +329,8 @@
328329 <ClCompile Include="..\timidity\sndfontini.c" />
329330 <ClCompile Include="..\timidity\thread.c" />
330331 <ClCompile Include="..\timidity\voice_effect.c" />
332+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
333+ <ClCompile Include="..\timidity\w32g_vorbis_dll.c" />
331334 <ClCompile Include="kbstr.cpp" />
332335 <ClCompile Include="_timidity_.c">
333336 <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
--- a/sf_view_gui/OpenDlg.h
+++ b/sf_view_gui/OpenDlg.h
@@ -1,6 +1,8 @@
11 #include <string>
22 #include <list>
33 #include <windows.h>
4+#include <commdlg.h>
5+#include <shellapi.h>
46
57 class CMyFileDialog
68 {
--- a/sf_view_gui/sfview_main.cpp
+++ b/sf_view_gui/sfview_main.cpp
@@ -1,3 +1,4 @@
1+
12 #define _WIN32_IE 0x500
23 #define _CRT_SECURE_NO_WARNINGS
34 #pragma warning(disable:4530) // ƒAƒ“ƒƒCƒ“ƒh ƒZƒ}ƒ“ƒeƒBƒNƒX‚ª–³Œø
@@ -166,7 +167,7 @@ void ExportFile(HWND hDlg, bool bExportList)
166167
167168 if (bExportList) {
168169 fd.setDefaultExt("txt");
169- fd.setFilter("Soundfont Preset List (*.txt)\0*.txt\0\0");
170+ fd.setFilter("soundfont (*.sf2;*.sf3)\0*.sf2;*.sf3\0All files (*.*)\0*.*\0\0");
170171 } else {
171172 fd.setDefaultExt("cfg");
172173 fd.setFilter("TiMidity++ Config File (*.cfg)\0*.cfg\0\0");
@@ -298,7 +299,7 @@ LRESULT DlgMainProc_CLOSE(HWND hDlg, WPARAM wParam, LPARAM lParam)
298299
299300 LRESULT CALLBACK DlgMainProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
300301 {
301-#define SET_MYWINMSG(VN) case WM_ ## VN: return DlgMainProc_## VN ##(hDlg, wParam, lParam);
302+#define SET_MYWINMSG(VN) case WM_ ## VN: return DlgMainProc_## VN(hDlg, wParam, lParam);
302303 switch (msg) {
303304 SET_MYWINMSG(INITDIALOG);
304305 SET_MYWINMSG(DROPFILES);
--- a/tim_cui/tim_cui.vcproj
+++ b/tim_cui/tim_cui.vcproj
@@ -362,6 +362,10 @@
362362 >
363363 </File>
364364 <File
365+ RelativePath="..\timidity\decode.c"
366+ >
367+ </File>
368+ <File
365369 RelativePath="..\timidity\effect.c"
366370 >
367371 </File>
@@ -621,6 +625,10 @@
621625 RelativePath="..\timidity\w32g_vorbisenc_dll.c"
622626 >
623627 </File>
628+ <File
629+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
630+ >
631+ </File>
624632 </Filter>
625633 </Filter>
626634 <Filter
--- a/tim_cui/tim_cui.vcxproj
+++ b/tim_cui/tim_cui.vcxproj
@@ -345,6 +345,7 @@
345345 <ClCompile Include="..\timidity\benchmark_a.c" />
346346 <ClCompile Include="..\timidity\common.c" />
347347 <ClCompile Include="..\timidity\controls.c" />
348+ <ClCompile Include="..\timidity\decode.c" />
348349 <ClCompile Include="..\timidity\effect.c" />
349350 <ClCompile Include="..\timidity\envelope.c" />
350351 <ClCompile Include="..\timidity\filter.c" />
@@ -398,6 +399,7 @@
398399 <ClCompile Include="..\timidity\w32g_ogg_dll.c" />
399400 <ClCompile Include="..\timidity\w32g_opus_dll.c" />
400401 <ClCompile Include="..\timidity\w32g_vorbisenc_dll.c" />
402+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
401403 <ClCompile Include="..\timidity\w32g_vorbis_dll.c" />
402404 <ClCompile Include="..\timidity\w32_a.c" />
403405 <ClCompile Include="..\timidity\w32_gogo.c" />
--- a/timidity/au_a.c
+++ b/timidity/au_a.c
@@ -235,8 +235,6 @@ static int open_output(void)
235235 dpm.encoding = validate_encoding(dpm.encoding, include_enc, exclude_enc);
236236
237237 if(dpm.name == NULL) {
238- if (!current_file_info || !current_file_info->filename)
239- return -1;
240238 dpm.flag |= PF_AUTO_SPLIT_FILE;
241239 } else {
242240 dpm.flag &= ~PF_AUTO_SPLIT_FILE;
--- a/timidity/common.c
+++ b/timidity/common.c
@@ -593,6 +593,10 @@ char *tf_gets(char *buff, size_t n, struct timidity_file *tf)
593593
594594 size_t tf_read(void *buff, size_t size, size_t nitems, struct timidity_file *tf)
595595 {
596+ if (size == 0) {
597+ return 0;
598+ }
599+
596600 return url_nread(tf->url, buff, size * nitems) / size;
597601 }
598602
--- /dev/null
+++ b/timidity/decode.c
@@ -0,0 +1,148 @@
1+
2+#ifdef HAVE_CONFIG_H
3+#include "config.h"
4+#endif /* HAVE_CONFIG_H */
5+#ifdef __POCC__
6+#include <sys/types.h>
7+#endif //for off_t
8+#include <stdio.h>
9+#ifndef NO_STRING_H
10+#include <string.h>
11+#else
12+#include <strings.h>
13+#endif
14+#ifdef HAVE_STDLIB_H
15+#include <stdlib.h>
16+#endif /* HAVE_STDLIB_H */
17+#include <math.h>
18+#ifdef HAVE_UNISTD_H
19+#include <unistd.h>
20+#endif
21+#include "timidity.h"
22+#include "common.h"
23+#include "controls.h"
24+#include "decode.h"
25+
26+#ifdef HAVE_LIBVORBIS
27+
28+#include <vorbis/vorbisfile.h>
29+
30+extern int load_vorbis_dll(void); // w32g_vorbis_dll.c
31+
32+#ifndef VORBIS_DLL_INCLUDE_VORBISFILE
33+extern int load_vorbisfile_dll(void); // w32g_vorbisfile_dll.c
34+#endif
35+
36+static size_t oggvorbis_read_callback(void *ptr, size_t size, size_t nmemb, void *datasource)
37+{
38+ struct timidity_file *tf = (struct timidity_file *)datasource;
39+ return tf_read(ptr, size, nmemb, tf);
40+}
41+
42+static int oggvorbis_seek_callback(void *datasource, ogg_int64_t offset, int whence)
43+{
44+ struct timidity_file *tf = (struct timidity_file *)datasource;
45+ return tf_seek(tf, offset, whence);
46+}
47+
48+static long oggvorbis_tell_callback(void *datasource)
49+{
50+ struct timidity_file *tf = (struct timidity_file *)datasource;
51+ return tf_tell(tf);
52+}
53+
54+SampleDecodeResult decode_oggvorbis(struct timidity_file *tf)
55+{
56+ int result;
57+ SampleDecodeResult sdr = {0};
58+ OggVorbis_File vf;
59+ vorbis_info *info = NULL;
60+ int64 total;
61+ ptr_size_t data_length;
62+ ptr_size_t current_size;
63+
64+ if (load_vorbis_dll() != 0) {
65+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to load vorbis dll");
66+ return sdr;
67+ }
68+#ifndef VORBIS_DLL_INCLUDE_VORBISFILE
69+ if (load_vorbisfile_dll() != 0) {
70+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to load vorbisfile dll");
71+ return sdr;
72+ }
73+#endif
74+ vf.callbacks.read_func = &oggvorbis_read_callback;
75+ vf.callbacks.seek_func = &oggvorbis_seek_callback;
76+ vf.callbacks.tell_func = &oggvorbis_tell_callback;
77+ result = ov_open_callbacks(tf, &vf, 0, 0, vf.callbacks);
78+
79+ if (result != 0) {
80+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to open ogg vorbis data; ov_open_callbacks() failed");
81+ return sdr;
82+ }
83+
84+ info = ov_info(&vf, -1);
85+
86+ if (!info) {
87+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to read ogg vorbis info; ov_info() failed");
88+ goto cleanup;
89+ }
90+
91+ sdr.channels = info->channels;
92+ total = ov_pcm_total(&vf, -1);
93+
94+ if (total < 0) {
95+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to get data length; ov_pcm_total() failed");
96+ goto cleanup;
97+ }
98+
99+ data_length = info->channels * sizeof(sample_t) * total;
100+ data_length = (data_length > 0 ? data_length : 4096);
101+ current_size = 0;
102+ sdr.data = (sample_t *)safe_large_malloc(data_length);
103+
104+ while (1) {
105+ int bitstream = 0;
106+ long ret = ov_read(&vf, (char *)(sdr.data) + current_size, data_length - current_size, 0, 2, 1, &bitstream);
107+
108+ if (ret < 0) {
109+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to decode ogg vorbis data; ov_read() failed");
110+ goto cleanup;
111+ } else if (ret == 0) {
112+ sdr.data_length = (splen_t)(current_size / 2) << FRACTION_BITS;
113+ break;
114+ }
115+
116+ current_size += ret;
117+
118+ if (data_length - current_size < 512) {
119+ ptr_size_t new_data_length = data_length + data_length / 2;
120+ sdr.data = (sample_t *)safe_large_realloc(sdr.data, new_data_length);
121+ data_length = new_data_length;
122+ }
123+ }
124+
125+ memset(((char *)sdr.data) + current_size, 0, data_length - current_size);
126+ ov_clear(&vf);
127+ return sdr;
128+
129+cleanup:
130+ ov_clear(&vf);
131+
132+ if (sdr.data) {
133+ safe_free(sdr.data);
134+ sdr.data = NULL;
135+ }
136+
137+ return sdr;
138+}
139+
140+#else // HAVE_LIBVORBIS
141+
142+SampleDecodeResult decode_oggvorbis(struct timidity_file *tf)
143+{
144+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "ogg vorbis decoder support is disabled");
145+ return (SampleDecodeResult){.data = NULL, .data_type = 0};
146+}
147+
148+#endif // HAVE_LIBVORBIS
--- /dev/null
+++ b/timidity/decode.h
@@ -0,0 +1,10 @@
1+
2+#pragma once
3+
4+typedef struct SampleDecodeResult {
5+ sample_t *data;
6+ splen_t data_length;
7+ int channels;
8+} SampleDecodeResult;
9+
10+SampleDecodeResult decode_oggvorbis(struct timidity_file *tf);
--- a/timidity/instrum.h
+++ b/timidity/instrum.h
@@ -116,6 +116,7 @@ enum {
116116 #define SF_SAMPLETYPE_RIGHT 2
117117 #define SF_SAMPLETYPE_LEFT 4
118118 #define SF_SAMPLETYPE_LINKED 8
119+#define SF_SAMPLETYPE_VORBIS 0x10
119120 #define SF_SAMPLETYPE_ROM 0x8000
120121
121122 typedef struct {
--- a/timidity/optcode.h
+++ b/timidity/optcode.h
@@ -852,12 +852,14 @@ LSU : Unalignment (use loadu/storeu
852852
853853 static TIMIDITY_FORCEINLINE __m256i mm256_i32gather_i32_impl(const int *base, __m256i offset, int scale)
854854 {
855+ int i;
855856 ALIGN32 int32 buf[8];
856857 __m256i byte_offset = _mm256_mullo_epi32(offset, _mm256_set1_epi32(scale));
857858 #ifdef IX64CPU
858859 __m256i vbase = _mm256_set1_epi64x((int64)base);
859- __m256i vptr0145 = _mm256_add_epi64(vbase, _mm256_unpacklo_epi32(byte_offset, _mm256_setzero_si256()));
860- __m256i vptr2367 = _mm256_add_epi64(vbase, _mm256_unpackhi_epi32(byte_offset, _mm256_setzero_si256()));
860+ __m256i vnegative = _mm256_cmpgt_epi32(_mm256_setzero_si256(), byte_offset);
861+ __m256i vptr0145 = _mm256_add_epi64(vbase, _mm256_unpacklo_epi32(byte_offset, vnegative));
862+ __m256i vptr2367 = _mm256_add_epi64(vbase, _mm256_unpackhi_epi32(byte_offset, vnegative));
861863 ALIGN32 const int32 *ptr0145[8];
862864 ALIGN32 const int32 *ptr2367[8];
863865 _mm256_store_si256((__m256i *)ptr0145, vptr0145);
@@ -872,7 +874,6 @@ static TIMIDITY_FORCEINLINE __m256i mm256_i32gather_i32_impl(const int *base, __
872874 buf[6] = *ptr2367[2];
873875 buf[7] = *ptr2367[3];
874876 #else
875- int i;
876877 __m256i pointers = _mm256_add_epi32(_mm256_set1_epi32((int32)base), byte_offset);
877878 _mm256_store_si256((__m256i *)buf, pointers);
878879
@@ -889,14 +890,16 @@ static TIMIDITY_FORCEINLINE __m256i mm256_i32gather_i32_impl(const int *base, __
889890
890891 static TIMIDITY_FORCEINLINE void mm256_i32scatter_i32_impl(void *base, __m256i offset, __m256i val, int scale)
891892 {
893+ int i;
892894 ALIGN32 int32 buf[8];
893895 _mm256_store_si256((__m256i *)buf, val);
894896
895897 __m256i byte_offset = _mm256_mullo_epi32(offset, _mm256_set1_epi32(scale));
896898 #ifdef IX64CPU
897899 __m256i vbase = _mm256_set1_epi64x((int64)base);
898- __m256i vptr0145 = _mm256_add_epi64(vbase, _mm256_unpacklo_epi32(byte_offset, _mm256_setzero_si256()));
899- __m256i vptr2367 = _mm256_add_epi64(vbase, _mm256_unpackhi_epi32(byte_offset, _mm256_setzero_si256()));
900+ __m256i vnegative = _mm256_cmpgt_epi32(_mm256_setzero_si256(), byte_offset);
901+ __m256i vptr0145 = _mm256_add_epi64(vbase, _mm256_unpacklo_epi32(byte_offset, vnegative));
902+ __m256i vptr2367 = _mm256_add_epi64(vbase, _mm256_unpackhi_epi32(byte_offset, vnegative));
900903 ALIGN32 int32 *ptr0145[4];
901904 ALIGN32 int32 *ptr2367[4];
902905 _mm256_store_si256((__m256i *)ptr0145, vptr0145);
@@ -915,7 +918,7 @@ static TIMIDITY_FORCEINLINE void mm256_i32scatter_i32_impl(void *base, __m256i o
915918 ALIGN32 int32 *ptr[8];
916919 _mm256_store_si256((__m256i *)ptr, vptr);
917920
918- for (int i = 0; i < 8; i++) {
921+ for (i = 0; i < 8; i++) {
919922 *ptr[i] = buf[i];
920923 }
921924 #endif
@@ -932,12 +935,14 @@ static TIMIDITY_FORCEINLINE void mm256_i32scatter_i32_impl(void *base, __m256i o
932935
933936 static TIMIDITY_FORCEINLINE __m128i mm_i32gather_i32_impl(const int *base, __m128i offset, int scale)
934937 {
938+ int i;
935939 ALIGN16 int32 buf[4];
936940 __m128i byte_offset = _mm_mullo_epi32(offset, _mm_set1_epi32(scale));
937941 #ifdef IX64CPU
938942 __m128i vbase = _mm_set1_epi64x((int64)base);
939- __m128i vptr01 = _mm_add_epi64(vbase, _mm_unpacklo_epi32(byte_offset, _mm_setzero_si128()));
940- __m128i vptr23 = _mm_add_epi64(vbase, _mm_unpackhi_epi32(byte_offset, _mm_setzero_si128()));
943+ __m128i vnegative = _mm_cmpgt_epi32(_mm_setzero_si128(), byte_offset);
944+ __m128i vptr01 = _mm_add_epi64(vbase, _mm_unpacklo_epi32(byte_offset, vnegative));
945+ __m128i vptr23 = _mm_add_epi64(vbase, _mm_unpackhi_epi32(byte_offset, vnegative));
941946 ALIGN16 const int32 *ptr01[2];
942947 ALIGN16 const int32 *ptr23[2];
943948 _mm_store_si128((__m128i *)ptr01, vptr01);
@@ -948,7 +953,6 @@ static TIMIDITY_FORCEINLINE __m128i mm_i32gather_i32_impl(const int *base, __m12
948953 buf[2] = *ptr23[0];
949954 buf[3] = *ptr23[1];
950955 #else
951- int i;
952956 __m128i pointers = _mm_add_epi32(_mm_set1_epi32((int32)base), byte_offset);
953957 _mm_store_si128((__m128i *)buf, pointers);
954958
@@ -968,36 +972,32 @@ static TIMIDITY_FORCEINLINE __m128i mm_i32gather_i32_impl(const int *base, __m12
968972
969973 static TIMIDITY_FORCEINLINE void mm_i32scatter_i32_impl(void *base, __m128i offset, __m128i val, int scale)
970974 {
975+ int i;
971976 ALIGN16 int32 buf[4];
972- __m128i byte_offset;
973-
974977 _mm_store_si128((__m128i *)buf, val);
975- byte_offset = _mm_mullo_epi32(offset, _mm_set1_epi32(scale));
978+
979+ __m128i byte_offset = _mm_mullo_epi32(offset, _mm_set1_epi32(scale));
976980 #ifdef IX64CPU
977- {
978- __m128i vbase = _mm_set1_epi64x((int64)base);
979- __m128i vptr01 = _mm_add_epi64(vbase, _mm_unpacklo_epi32(byte_offset, _mm_setzero_si128()));
980- __m128i vptr23 = _mm_add_epi64(vbase, _mm_unpackhi_epi32(byte_offset, _mm_setzero_si128()));
981- ALIGN16 int32 *ptr01[2];
982- ALIGN16 int32 *ptr23[2];
983- _mm_store_si128((__m128i *)ptr01, vptr01);
984- _mm_store_si128((__m128i *)ptr23, vptr23);
985-
986- *ptr01[0] = buf[0];
987- *ptr01[1] = buf[1];
988- *ptr23[0] = buf[2];
989- *ptr23[1] = buf[3];
990- }
981+ __m128i vbase = _mm_set1_epi64x((int64)base);
982+ __m128i vnegative = _mm_cmpgt_epi32(_mm_setzero_si128(), byte_offset);
983+ __m128i vptr01 = _mm_add_epi64(vbase, _mm_unpacklo_epi32(byte_offset, vnegative));
984+ __m128i vptr23 = _mm_add_epi64(vbase, _mm_unpackhi_epi32(byte_offset, vnegative));
985+ ALIGN16 int32 *ptr01[2];
986+ ALIGN16 int32 *ptr23[2];
987+ _mm_store_si128((__m128i *)ptr01, vptr01);
988+ _mm_store_si128((__m128i *)ptr23, vptr23);
989+
990+ *ptr01[0] = buf[0];
991+ *ptr01[1] = buf[1];
992+ *ptr23[0] = buf[2];
993+ *ptr23[1] = buf[3];
991994 #else
992- {
993- __m128i vptr = _mm_add_epi32(_mm_set1_epi32((int32)base), byte_offset);
994- ALIGN16 int32 *ptr[4];
995- _mm_store_si128((__m128i *)ptr, vptr);
996-
997- *ptr[0] = buf[0];
998- *ptr[1] = buf[1];
999- *ptr[2] = buf[2];
1000- *ptr[3] = buf[3];
995+ __m128i vptr = _mm_add_epi32(_mm_set1_epi32((int32)base), byte_offset);
996+ ALIGN16 int32 *ptr[4];
997+ _mm_store_si128((__m128i *)ptr, vptr);
998+
999+ for (i = 0; i < 4; i++) {
1000+ *ptr[i] = buf[i];
10011001 }
10021002 #endif
10031003 }
--- a/timidity/sndfont.c
+++ b/timidity/sndfont.c
@@ -62,6 +62,7 @@
6262 #include "resample.h"
6363 #include "interface.h"
6464 #include "sndfontini.h"
65+#include "decode.h"
6566
6667 ///r
6768 int8 sf_attenuation_neg = 0;
@@ -824,103 +825,154 @@ static Instrument *load_from_file(SFInsts *rec, InstList *ip)
824825 }
825826 tf = sp->sfrom ? sfrom_sfrec->tf : rec->tf; ///r
826827
828+ if (rec->version >= 4) {
829+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unsupported soundfont version: %d", rec->version);
830+ } else if (rec->version == 3) {
831+ struct timidity_file *ctf = NULL;
832+ off_size_t length = sp->len / 2;
833+ off_size_t start_offset = (sp->start - rec->samplepos) / 2;
834+ char *compressed_data = (char *)safe_large_malloc(length);
835+ // sp->start is SAMPLEPOS + START * 2 but we want SAMPLEPOS + START
836+ tf_seek(tf, sp->start - start_offset, SEEK_SET);
837+ tf_read(compressed_data, length, 1, tf);
838+
839+ ctf = open_with_mem(compressed_data, length, OF_VERBOSE);
840+
841+ if (ctf) {
842+ SampleDecodeResult sdr = decode_oggvorbis(ctf);
843+ close_file(ctf);
844+ sample->data = sdr.data;
845+ sample->data_alloced = 1;
846+ sample->data_type = SAMPLE_TYPE_INT16;
847+ sample->data_length = sdr.data_length;
848+
849+ if (!(sample->modes & MODES_LOOPING)) {
850+ sample->loop_start = sdr.data_length;
851+ sample->loop_end = sdr.data_length + (1 << FRACTION_BITS);
852+ }
853+
854+ if (sample->loop_end > sample->data_length + (1 << FRACTION_BITS))
855+ sample->loop_end = sample->data_length + (1 << FRACTION_BITS);
856+ if (sample->loop_start > sample->data_length)
857+ sample->loop_start = sample->data_length;
858+ if (sample->loop_start < 0)
859+ sample->loop_start = 0;
860+ if (sample->loop_start >= sample->loop_end)
861+ {
862+ sample->loop_start = sample->data_length;
863+ sample->loop_end = sample->data_length + (1 << FRACTION_BITS);
864+ }
865+
866+ if (sdr.channels > 1) {
867+ sample->sample_type &= ~SF_SAMPLETYPE_MONO;
868+ } else {
869+ sample->sample_type |= SF_SAMPLETYPE_MONO;
870+ }
871+ } else {
872+ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "unable to read compressed sample; open_with_mem() failed");
873+ }
874+
875+ safe_free(compressed_data);
876+ } else {
877+
827878 #if defined(SF2_24BIT) && (defined(DATA_T_DOUBLE) || defined(DATA_T_FLOAT))
828879 #if 1 /* SF2_24BIT_SAMPLE_TYPE_FLOAT */
829- if(sp->lowbit > 0 ){
830- /* 24 bit */
831- splen_t cnt;
832- uint8 *lowbit;
833- uint16 *highbit;
834- float *tmp_data;
835-
836- frames = divi_2(sp->len);
837- sample->data = (sample_t*)safe_large_malloc(sizeof(float) * (frames + 128));
838- sample->data_alloced = 1;
839- sample->data_type = SAMPLE_TYPE_FLOAT;
840- highbit = (uint16 *)safe_large_malloc(sizeof(int16) * frames); // 16bit
841- lowbit = (uint8 *)safe_large_malloc(sizeof(int8) * frames); // 8bit
842- tf_seek(tf, sp->start, SEEK_SET);
843- tf_read(highbit, sp->len, 1, tf);
844- tf_seek(tf, sp->lowbit, SEEK_SET);
845- tf_read(lowbit, frames, 1, tf);
846- tmp_data = (float *)sample->data;
847- for(j = 0; j < frames; j++) {
848- // 24bit to int32full
849- int32 tmp_i = 0; // 1byte 00‚Å‚¢‚¢‚炵‚¢H
850- tmp_i |= (uint32)lowbit[j] << 8; // 2byte
851- tmp_i |= (uint32)highbit[j] << 16; // 3-4byte
880+ if(sp->lowbit > 0 ){
881+ /* 24 bit */
882+ splen_t cnt;
883+ uint8 *lowbit;
884+ uint16 *highbit;
885+ float *tmp_data;
886+
887+ frames = divi_2(sp->len);
888+ sample->data = (sample_t*)safe_large_malloc(sizeof(float) * (frames + 128));
889+ sample->data_alloced = 1;
890+ sample->data_type = SAMPLE_TYPE_FLOAT;
891+ highbit = (uint16 *)safe_large_malloc(sizeof(int16) * frames); // 16bit
892+ lowbit = (uint8 *)safe_large_malloc(sizeof(int8) * frames); // 8bit
893+ tf_seek(tf, sp->start, SEEK_SET);
894+ tf_read(highbit, sp->len, 1, tf);
895+ tf_seek(tf, sp->lowbit, SEEK_SET);
896+ tf_read(lowbit, frames, 1, tf);
897+ tmp_data = (float *)sample->data;
898+ for(j = 0; j < frames; j++) {
899+ // 24bit to int32full
900+ int32 tmp_i = 0; // 1byte 00‚Å‚¢‚¢‚炵‚¢H
901+ tmp_i |= (uint32)lowbit[j] << 8; // 2byte
902+ tmp_i |= (uint32)highbit[j] << 16; // 3-4byte
852903 #ifndef LITTLE_ENDIAN
853- XCHG_LONG(tmp_i)
904+ XCHG_LONG(tmp_i)
854905 #endif
855- tmp_data[j] = (float)tmp_i * DIV_31BIT;
856- }
857- safe_free(highbit);
858- safe_free(lowbit);
859- /* set a small blank loop at the tail for avoiding abnormal loop. */
860- memset(&tmp_data[frames], 0, sizeof(float) * 128);
861- if (antialiasing_allowed)
862- antialiasing_float((float *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
863- }else
906+ tmp_data[j] = (float)tmp_i * DIV_31BIT;
907+ }
908+ safe_free(highbit);
909+ safe_free(lowbit);
910+ /* set a small blank loop at the tail for avoiding abnormal loop. */
911+ memset(&tmp_data[frames], 0, sizeof(float) * 128);
912+ if (antialiasing_allowed)
913+ antialiasing_float((float *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
914+ }else
864915 #else /* SF2_24BIT_SAMPLE_TYPE_INT32 */
865- if(sp->lowbit > 0 ){
866- /* 24 bit */
867- splen_t cnt;
868- uint8 *lowbit;
869- uint16 *highbit;
870- uint32 *tmp_data;
871-
872- frames = divi_2(sp->len);
873- sample->data = (sample_t*)safe_large_malloc(sizeof(int32) * (frames + 128));
874- sample->data_alloced = 1;
875- sample->data_type = SAMPLE_TYPE_INT32;
876- highbit = (uint16 *)safe_large_malloc(sizeof(int16) * frames); // 16bit
877- lowbit = (uint8 *)safe_large_malloc(sizeof(int8) * frames); // 8bit
878- tf_seek(tf, sp->start, SEEK_SET);
879- tf_read(highbit, sp->len, 1, tf);
880- tf_seek(tf, sp->lowbit, SEEK_SET);
881- tf_read(lowbit, frames, 1, tf);
882- tmp_data = (uint32 *)sample->data;
883- for(j = 0; j < frames; j++) {
884- // 24bit to int32full
885- uint32 tmp_i = 0; // 1byte 00‚Å‚¢‚¢‚炵‚¢H
886- tmp_i |= (uint32)lowbit[j] << 8; // 2byte
887- tmp_i |= (uint32)highbit[j] << 16; // 3-4byte
916+ if(sp->lowbit > 0 ){
917+ /* 24 bit */
918+ splen_t cnt;
919+ uint8 *lowbit;
920+ uint16 *highbit;
921+ uint32 *tmp_data;
922+
923+ frames = divi_2(sp->len);
924+ sample->data = (sample_t*)safe_large_malloc(sizeof(int32) * (frames + 128));
925+ sample->data_alloced = 1;
926+ sample->data_type = SAMPLE_TYPE_INT32;
927+ highbit = (uint16 *)safe_large_malloc(sizeof(int16) * frames); // 16bit
928+ lowbit = (uint8 *)safe_large_malloc(sizeof(int8) * frames); // 8bit
929+ tf_seek(tf, sp->start, SEEK_SET);
930+ tf_read(highbit, sp->len, 1, tf);
931+ tf_seek(tf, sp->lowbit, SEEK_SET);
932+ tf_read(lowbit, frames, 1, tf);
933+ tmp_data = (uint32 *)sample->data;
934+ for(j = 0; j < frames; j++) {
935+ // 24bit to int32full
936+ uint32 tmp_i = 0; // 1byte 00‚Å‚¢‚¢‚炵‚¢H
937+ tmp_i |= (uint32)lowbit[j] << 8; // 2byte
938+ tmp_i |= (uint32)highbit[j] << 16; // 3-4byte
888939 #ifndef LITTLE_ENDIAN
889- XCHG_LONG(tmp_i)
940+ XCHG_LONG(tmp_i)
890941 #endif
891- tmp_data[j] = tmp_i;
892- }
893- safe_free(highbit);
894- safe_free(lowbit);
895- /* set a small blank loop at the tail for avoiding abnormal loop. */
896- // tmp_data[frames] = tmp_data[frames + 1] = tmp_data[frames + 2] = 0;
897- memset(&tmp_data[frames], 0, sizeof(int32) * 128);
898- if (antialiasing_allowed)
899- antialiasing_int32((int32 *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
900- }else
942+ tmp_data[j] = tmp_i;
943+ }
944+ safe_free(highbit);
945+ safe_free(lowbit);
946+ /* set a small blank loop at the tail for avoiding abnormal loop. */
947+ // tmp_data[frames] = tmp_data[frames + 1] = tmp_data[frames + 2] = 0;
948+ memset(&tmp_data[frames], 0, sizeof(int32) * 128);
949+ if (antialiasing_allowed)
950+ antialiasing_int32((int32 *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
951+ }else
901952 #endif /* SF2_24BIT_SAMPLE_TYPE_FLOAT */
902953 #endif /* defined(SF2_24BIT) && (defined(DATA_T_DOUBLE) || defined(DATA_T_FLOAT)) */
903- {
904- /* 16 bit */
905- frames = divi_2(sp->len);
906- sample->data = (sample_t *)safe_large_malloc(sizeof(sample_t) * (frames + 128));
907- memset(sample->data, 0, sizeof(sample_t) * (frames + 128));
908- sample->data_alloced = 1;
909- sample->data_type = SAMPLE_TYPE_INT16;
954+ {
955+ /* 16 bit */
956+ frames = divi_2(sp->len);
957+ sample->data = (sample_t *)safe_large_malloc(sizeof(sample_t) * (frames + 128));
958+ memset(sample->data, 0, sizeof(sample_t) * (frames + 128));
959+ sample->data_alloced = 1;
960+ sample->data_type = SAMPLE_TYPE_INT16;
910961
911- tf_seek(tf, sp->start, SEEK_SET);
912- tf_read(sample->data, sp->len, 1, tf);
962+ tf_seek(tf, sp->start, SEEK_SET);
963+ tf_read(sample->data, sp->len, 1, tf);
913964
914965 #ifndef LITTLE_ENDIAN
915- for (j = 0; j < frames; j++)
916- sample->data[j] = (int16)(LE_SHORT(tmp_data[j]));
966+ for (j = 0; j < frames; j++)
967+ sample->data[j] = (int16)(LE_SHORT(tmp_data[j]));
917968 #endif
918- /* set a small blank loop at the tail for avoiding abnormal loop. */
919- // sample->data[frames] = sample->data[frames + 1] = sample->data[frames + 2] = 0;
920- memset(&sample->data[frames], 0, sizeof(sample_t) * 128);
969+ /* set a small blank loop at the tail for avoiding abnormal loop. */
970+ // sample->data[frames] = sample->data[frames + 1] = sample->data[frames + 2] = 0;
971+ memset(&sample->data[frames], 0, sizeof(sample_t) * 128);
921972
922- if (antialiasing_allowed)
923- antialiasing((int16 *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
973+ if (antialiasing_allowed)
974+ antialiasing((int16 *)sample->data, sample->data_length >> FRACTION_BITS, sample->sample_rate, play_mode->rate);
975+ }
924976 }
925977 ///r
926978 /* resample it if possible */
@@ -1561,25 +1613,33 @@ static void set_sample_info(SFInfo *sf, SampleList *vp, LayerTable *tbl)
15611613 vp->len = abs(vp->len);
15621614
15631615 /* set loop position */
1564- vp->v.loop_start = sp->startloop - vp->start;
1565- vp->v.loop_end = sp->endloop - vp->start;
1616+ vp->v.loop_start = sp->startloop;
1617+ vp->v.loop_end = sp->endloop;
1618+
1619+ if (sf->version < 3) {
1620+ vp->v.loop_start -= vp->start;
1621+ vp->v.loop_end -= vp->start;
1622+ }
1623+
15661624 vp->v.loop_start += (tbl->val[SF_startloopAddrsHi] << 15) + tbl->val[SF_startloopAddrs];
15671625 vp->v.loop_end += (tbl->val[SF_endloopAddrsHi] << 15) + tbl->val[SF_endloopAddrs];
15681626
15691627 /* set data length */
15701628 vp->v.data_length = vp->len + 1;
1571-
1572- /* fix loop position */
1573- if (vp->v.loop_end > vp->len + 1)
1574- vp->v.loop_end = vp->len + 1;
1575- if (vp->v.loop_start > vp->len)
1576- vp->v.loop_start = vp->len;
1577- if (vp->v.loop_start < 0)
1578- vp->v.loop_start = 0;
1579- if (vp->v.loop_start >= vp->v.loop_end)
1580- {
1581- vp->v.loop_start = vp->len;
1582- vp->v.loop_end = vp->len + 1;
1629+
1630+ if (sf->version < 3) {
1631+ /* fix loop position */
1632+ if (vp->v.loop_end > vp->len + 1)
1633+ vp->v.loop_end = vp->len + 1;
1634+ if (vp->v.loop_start > vp->len)
1635+ vp->v.loop_start = vp->len;
1636+ if (vp->v.loop_start < 0)
1637+ vp->v.loop_start = 0;
1638+ if (vp->v.loop_start >= vp->v.loop_end)
1639+ {
1640+ vp->v.loop_start = vp->len;
1641+ vp->v.loop_end = vp->len + 1;
1642+ }
15831643 }
15841644
15851645 /* Sample rate */
--- a/timidity/timidity.h
+++ b/timidity/timidity.h
@@ -440,6 +440,7 @@
440440 #define VOICE_EFFECT
441441 #define INT_SYNTH
442442 #define NEW_LEGATO
443+//#define ENABLE_SFZ
443444
444445
445446 /*****************************************************************************\
--- a/timidity/timidity.vcproj
+++ b/timidity/timidity.vcproj
@@ -226,6 +226,10 @@
226226 >
227227 </File>
228228 <File
229+ RelativePath=".\decode.c"
230+ >
231+ </File>
232+ <File
229233 RelativePath=".\effect.c"
230234 >
231235 </File>
--- a/timidity/timidity.vcxproj
+++ b/timidity/timidity.vcxproj
@@ -261,6 +261,7 @@
261261 <ClCompile Include="audio_cnv.c" />
262262 <ClCompile Include="common.c" />
263263 <ClCompile Include="controls.c" />
264+ <ClCompile Include="decode.c" />
264265 <ClCompile Include="effect.c" />
265266 <ClCompile Include="envelope.c" />
266267 <ClCompile Include="filter.c" />
--- a/timidity/w32g_vorbis_dll.c
+++ b/timidity/w32g_vorbis_dll.c
@@ -37,6 +37,9 @@
3737 #ifdef VORBIS_DLL_INCLUDE_VORBISENC
3838 #include <vorbis/vorbisenc.h>
3939 #endif
40+#ifdef VORBIS_DLL_INCLUDE_VORBISFILE
41+#include <vorbis/vorbisfile.h>
42+#endif
4043
4144 extern int load_vorbis_dll(void);
4245 extern void free_vorbis_dll(void);
@@ -74,6 +77,16 @@ typedef int(*type_vorbis_encode_init_vbr)(vorbis_info *vi, long channels, long r
7477 typedef int(*type_vorbis_encode_ctl)(vorbis_info *vi, int number, void *arg);
7578 #endif
7679
80+#ifdef VORBIS_DLL_INCLUDE_VORBISFILE
81+typedef int (*type_ov_clear)(OggVorbis_File *vf);
82+typedef int (*type_ov_open_callbacks)(void *datasource, OggVorbis_File *vf,
83+ const char *initial, long ibytes, ov_callbacks callbacks);
84+typedef ogg_int64_t(*type_ov_pcm_total)(OggVorbis_File *vf, int i);
85+typedef vorbis_info *(*type_ov_info)(OggVorbis_File *vf, int link);
86+typedef long (*type_ov_read)(OggVorbis_File *vf, char *buffer, int length,
87+ int bigendianp, int word, int sgned, int *bitstream);
88+#endif
89+
7790 static struct vorbis_dll_ {
7891 type_vorbis_info_init vorbis_info_init;
7992 type_vorbis_info_clear vorbis_info_clear;
@@ -106,6 +119,13 @@ static struct vorbis_dll_ {
106119 type_vorbis_encode_init_vbr vorbis_encode_init_vbr;
107120 type_vorbis_encode_ctl vorbis_encode_ctl;
108121 #endif
122+#ifdef VORBIS_DLL_INCLUDE_VORBISFILE
123+ type_ov_clear ov_clear;
124+ type_ov_open_callbacks ov_open_callbacks;
125+ type_ov_pcm_total ov_pcm_total;
126+ type_ov_info ov_info;
127+ type_ov_read ov_read;
128+#endif
109129 } vorbis_dll;
110130
111131 static volatile HANDLE h_vorbis_dll = NULL;
@@ -186,6 +206,18 @@ int load_vorbis_dll(void)
186206 vorbis_dll.vorbis_encode_ctl = (type_vorbis_encode_ctl) GetProcAddress(h_vorbis_dll, "vorbis_encode_ctl");
187207 if (!vorbis_dll.vorbis_encode_ctl) { free_vorbis_dll(); return -1; }
188208 #endif
209+#ifdef VORBIS_DLL_INCLUDE_VORBISFILE
210+ vorbis_dll.ov_clear = (type_ov_clear)GetProcAddress(h_vorbis_dll, "ov_clear");
211+ if (!vorbis_dll.ov_clear) { free_vorbis_dll(); return -1; }
212+ vorbis_dll.ov_open_callbacks = (type_ov_open_callbacks)GetProcAddress(h_vorbis_dll, "ov_open_callbacks");
213+ if (!vorbis_dll.ov_open_callbacks) { free_vorbis_dll(); return -1; }
214+ vorbis_dll.ov_pcm_total = (type_ov_pcm_total)GetProcAddress(h_vorbis_dll, "ov_pcm_total");
215+ if (!vorbis_dll.ov_pcm_total) { free_vorbis_dll(); return -1; }
216+ vorbis_dll.ov_info = (type_ov_info)GetProcAddress(h_vorbis_dll, "ov_info");
217+ if (!vorbis_dll.ov_info) { free_vorbis_dll(); return -1; }
218+ vorbis_dll.ov_read = (type_ov_read)GetProcAddress(h_vorbis_dll, "ov_read");
219+ if (!vorbis_dll.ov_read) { free_vorbis_dll(); return -1; }
220+#endif
189221 return 0;
190222 }
191223
@@ -420,5 +452,56 @@ int vorbis_encode_ctl(vorbis_info *vi, int number, void *arg)
420452 }
421453 #endif
422454
455+#ifdef VORBIS_DLL_INCLUDE_VORBISFILE
456+
457+int ov_clear(OggVorbis_File *vf)
458+{
459+ if (h_vorbis_dll) {
460+ return vorbis_dll.ov_clear(vf);
461+ }
462+
463+ return -1;
464+}
465+
466+int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
467+ const char *initial, long ibytes, ov_callbacks callbacks)
468+{
469+ if (h_vorbis_dll) {
470+ return vorbis_dll.ov_open_callbacks(datasource, vf, initial, ibytes, callbacks);
471+ }
472+
473+ return -1;
474+}
475+
476+ogg_int64_t ov_pcm_total(OggVorbis_File *vf, int i)
477+{
478+ if (h_vorbis_dll) {
479+ return vorbis_dll.ov_pcm_total(vf, i);
480+ }
481+
482+ return -1;
483+}
484+
485+vorbis_info *ov_info(OggVorbis_File *vf, int link)
486+{
487+ if (h_vorbis_dll) {
488+ return vorbis_dll.ov_info(vf, link);
489+ }
490+
491+ return NULL;
492+}
493+
494+long ov_read(OggVorbis_File *vf, char *buffer, int length,
495+ int bigendianp, int word, int sgned, int *bitstream)
496+{
497+ if (h_vorbis_dll) {
498+ return vorbis_dll.ov_read(vf, buffer, length, bigendianp, word, sgned, bitstream);
499+ }
500+
501+ return -1;
502+}
503+
504+#endif
505+
423506 /***************************************************************/
424507 #endif /* AU_VORBIS_DLL */
--- /dev/null
+++ b/timidity/w32g_vorbisfile_dll.c
@@ -0,0 +1,138 @@
1+/*
2+TiMidity++ -- MIDI to WAVE converter and player
3+Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4+Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5+
6+This program is free software; you can redistribute it and/or modify
7+it under the terms of the GNU General Public License as published by
8+the Free Software Foundation; either version 2 of the License, or
9+(at your option) any later version.
10+
11+This program is distributed in the hope that it will be useful,
12+but WITHOUT ANY WARRANTY; without even the implied warranty of
13+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+GNU General Public License for more details.
15+
16+You should have received a copy of the GNU General Public License
17+along with this program; if not, write to the Free Software
18+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+*/
20+
21+/***************************************************************
22+name: vorbisfile_dll dll: vorbisfile.dll
23+***************************************************************/
24+
25+#ifdef HAVE_CONFIG_H
26+#include "config.h"
27+#endif /* HAVE_CONFIG_H */
28+
29+#include "common.h"
30+
31+#ifndef VORBIS_DLL_INCLUDE_VORBISFILE
32+
33+#ifdef AU_VORBIS_DLL
34+
35+#include <windows.h>
36+#include <vorbis/vorbisfile.h>
37+
38+extern int load_vorbisfile_dll(void);
39+extern void free_vorbisfile_dll(void);
40+
41+typedef int (*type_ov_clear)(OggVorbis_File *vf);
42+typedef int (*type_ov_open_callbacks)(void *datasource, OggVorbis_File *vf,
43+ const char *initial, long ibytes, ov_callbacks callbacks);
44+typedef ogg_int64_t(*type_ov_pcm_total)(OggVorbis_File *vf, int i);
45+typedef vorbis_info *(*type_ov_info)(OggVorbis_File *vf, int link);
46+typedef long (*type_ov_read)(OggVorbis_File *vf, char *buffer, int length,
47+ int bigendianp, int word, int sgned, int *bitstream);
48+
49+static struct vorbisfile_dll_ {
50+ type_ov_clear ov_clear;
51+ type_ov_open_callbacks ov_open_callbacks;
52+ type_ov_pcm_total ov_pcm_total;
53+ type_ov_info ov_info;
54+ type_ov_read ov_read;
55+} vorbisfile_dll;
56+
57+static volatile HANDLE h_vorbisfile_dll = NULL;
58+
59+void free_vorbisfile_dll(void)
60+{
61+ if (h_vorbisfile_dll) {
62+ FreeLibrary(h_vorbisfile_dll);
63+ h_vorbisfile_dll = NULL;
64+ }
65+}
66+
67+int load_vorbisfile_dll(void)
68+{
69+ if (!h_vorbisfile_dll) {
70+ w32_reset_dll_directory();
71+ h_vorbisfile_dll = LoadLibrary(TEXT("vorbisfile.dll"));
72+ if (!h_vorbisfile_dll) h_vorbisfile_dll = LoadLibrary(TEXT("libvorbisfile-2.dll"));
73+ if (!h_vorbisfile_dll) h_vorbisfile_dll = LoadLibrary(TEXT("libvorbisfile.dll"));
74+ if (!h_vorbisfile_dll) return -1;
75+ vorbisfile_dll.ov_clear = (type_ov_clear)GetProcAddress(h_vorbisfile_dll, "ov_clear");
76+ if (!vorbisfile_dll.ov_clear) { free_vorbisfile_dll(); return -1; }
77+ vorbisfile_dll.ov_open_callbacks = (type_ov_open_callbacks)GetProcAddress(h_vorbisfile_dll, "ov_open_callbacks");
78+ if (!vorbisfile_dll.ov_open_callbacks) { free_vorbisfile_dll(); return -1; }
79+ vorbisfile_dll.ov_pcm_total = (type_ov_pcm_total) GetProcAddress(h_vorbisfile_dll, "ov_pcm_total");
80+ if (!vorbisfile_dll.ov_pcm_total) { free_vorbisfile_dll(); return -1; }
81+ vorbisfile_dll.ov_info = (type_ov_info)GetProcAddress(h_vorbisfile_dll, "ov_info");
82+ if (!vorbisfile_dll.ov_info) { free_vorbisfile_dll(); return -1; }
83+ vorbisfile_dll.ov_read = (type_ov_read)GetProcAddress(h_vorbisfile_dll, "ov_read");
84+ if (!vorbisfile_dll.ov_read) { free_vorbisfile_dll(); return -1; }
85+ }
86+ return 0;
87+}
88+
89+int ov_clear(OggVorbis_File *vf)
90+{
91+ if (h_vorbisfile_dll) {
92+ return vorbisfile_dll.ov_clear(vf);
93+ }
94+
95+ return -1;
96+}
97+
98+int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
99+ const char *initial, long ibytes, ov_callbacks callbacks)
100+{
101+ if (h_vorbisfile_dll) {
102+ return vorbisfile_dll.ov_open_callbacks(datasource, vf, initial, ibytes, callbacks);
103+ }
104+
105+ return -1;
106+}
107+
108+ogg_int64_t ov_pcm_total(OggVorbis_File *vf, int i)
109+{
110+ if (h_vorbisfile_dll) {
111+ return vorbisfile_dll.ov_pcm_total(vf, i);
112+ }
113+
114+ return -1;
115+}
116+
117+vorbis_info *ov_info(OggVorbis_File *vf, int link)
118+{
119+ if (h_vorbisfile_dll) {
120+ return vorbisfile_dll.ov_info(vf, link);
121+ }
122+
123+ return NULL;
124+}
125+
126+long ov_read(OggVorbis_File *vf, char *buffer, int length,
127+ int bigendianp, int word, int sgned, int *bitstream)
128+{
129+ if (h_vorbisfile_dll) {
130+ return vorbisfile_dll.ov_read(vf, buffer, length, bigendianp, word, sgned, bitstream);
131+ }
132+
133+ return -1;
134+}
135+
136+/***************************************************************/
137+#endif /* AU_VORBIS_DLL */
138+#endif /* ! VORBIS_DLL_INCLUDE_VORBISFILE */
--- a/timw32g/timw32g.vcproj
+++ b/timw32g/timw32g.vcproj
@@ -348,6 +348,10 @@
348348 >
349349 </File>
350350 <File
351+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
352+ >
353+ </File>
354+ <File
351355 RelativePath="..\interface\wrdt_w32g.c"
352356 >
353357 </File>
--- a/timw32g/timw32g.vcxproj
+++ b/timw32g/timw32g.vcxproj
@@ -90,8 +90,8 @@
9090 <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(VCInstallDir)atlmfc\lib\amd64;$(VCInstallDir)lib\amd64;$(WindowsSdkDir)lib\x64;$(FrameworkSDKDir)\lib\x64;$(WindowsSdkDir)\lib\x64;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;</LibraryPath>
9191 <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(DXSDK_DIR)\ILib\x86;</LibraryPath>
9292 <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(VCInstallDir)atlmfc\lib\amd64;$(VCInstallDir)lib\amd64;$(WindowsSdkDir)lib\x64;$(FrameworkSDKDir)\lib\x64;$(WindowsSdkDir)\lib\x64;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;</LibraryPath>
93- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">timw32g_c216</TargetName>
94- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">timw32g_x64_c216</TargetName>
93+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">timw32g_c218</TargetName>
94+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">timw32g_x64_c218</TargetName>
9595 <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)_x64</TargetName>
9696 </PropertyGroup>
9797 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -139,7 +139,7 @@
139139 </ResourceCompile>
140140 <Link>
141141 <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions>
142- <AdditionalDependencies>setupapi.lib;comctl32.lib;libcmtd.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
142+ <AdditionalDependencies>setupapi.lib;comctl32.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
143143 <OutputFile>$(TargetPath)</OutputFile>
144144 <SuppressStartupBanner>true</SuppressStartupBanner>
145145 <IgnoreSpecificDefaultLibraries>msvcrtd.lib;libcd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -349,6 +349,7 @@
349349 <ClCompile Include="..\interface\w32g_soundspec.c" />
350350 <ClCompile Include="..\interface\wrdt_w32g.c" />
351351 <ClCompile Include="..\timidity\w32g_ogg_dll.c" />
352+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
352353 <ClCompile Include="..\timidity\w32_portaudio_dll.c" />
353354 <ClCompile Include="..\timidity\w32g_vorbis_dll.c" />
354355 <ClCompile Include="..\timidity\w32g_vorbisenc_dll.c" />
--- a/twsyng/twsyng.vcproj
+++ b/twsyng/twsyng.vcproj
@@ -267,6 +267,10 @@
267267 >
268268 </File>
269269 <File
270+ RelativePath="..\timidity\decode.c"
271+ >
272+ </File>
273+ <File
270274 RelativePath="..\timidity\effect.c"
271275 >
272276 </File>
@@ -535,6 +539,10 @@
535539 >
536540 </File>
537541 <File
542+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
543+ >
544+ </File>
545+ <File
538546 RelativePath="..\timidity\wasapi_a.c"
539547 >
540548 </File>
--- a/twsyng/twsyng.vcxproj
+++ b/twsyng/twsyng.vcxproj
@@ -81,8 +81,8 @@
8181 <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
8282 <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
8383 <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
84- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">twsyng_c216</TargetName>
85- <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">twsyng_x64_c216</TargetName>
84+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">twsyng_c218</TargetName>
85+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">twsyng_x64_c218</TargetName>
8686 <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;</LibraryPath>
8787 <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)_x64</TargetName>
8888 <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LibraryPath);$(VSInstallDir);$(VSInstallDir)lib\amd64;$(WindowsSdkDir)lib\x64;</LibraryPath>
@@ -310,6 +310,7 @@
310310 <ClCompile Include="..\timidity\audio_cnv.c" />
311311 <ClCompile Include="..\timidity\common.c" />
312312 <ClCompile Include="..\timidity\controls.c" />
313+ <ClCompile Include="..\timidity\decode.c" />
313314 <ClCompile Include="..\timidity\effect.c" />
314315 <ClCompile Include="..\timidity\envelope.c" />
315316 <ClCompile Include="..\timidity\filter.c" />
@@ -359,6 +360,7 @@
359360 <ClCompile Include="..\timidity\voice_effect.c" />
360361 <ClCompile Include="..\timidity\vorbis_a.c" />
361362 <ClCompile Include="..\timidity\w32g_opus_dll.c" />
363+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
362364 <ClCompile Include="..\timidity\w32_a.c" />
363365 <ClCompile Include="..\timidity\w32_gogo.c" />
364366 <ClCompile Include="..\timidity\w32_libFLAC_dll.c" />
--- a/twsynsrv/twsynsrv.vcproj
+++ b/twsynsrv/twsynsrv.vcproj
@@ -252,6 +252,10 @@
252252 >
253253 </File>
254254 <File
255+ RelativePath="..\timidity\decode.c"
256+ >
257+ </File>
258+ <File
255259 RelativePath="..\timidity\effect.c"
256260 >
257261 </File>
@@ -488,6 +492,10 @@
488492 >
489493 </File>
490494 <File
495+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
496+ >
497+ </File>
498+ <File
491499 RelativePath="..\timidity\wasapi_a.c"
492500 >
493501 </File>
--- a/twsynsrv/twsynsrv.vcxproj
+++ b/twsynsrv/twsynsrv.vcxproj
@@ -252,6 +252,7 @@
252252 <ClCompile Include="..\timidity\audio_cnv.c" />
253253 <ClCompile Include="..\timidity\common.c" />
254254 <ClCompile Include="..\timidity\controls.c" />
255+ <ClCompile Include="..\timidity\decode.c" />
255256 <ClCompile Include="..\timidity\effect.c" />
256257 <ClCompile Include="..\timidity\envelope.c" />
257258 <ClCompile Include="..\timidity\filter.c" />
@@ -298,6 +299,7 @@
298299 <ClCompile Include="..\timidity\version.c" />
299300 <ClCompile Include="..\timidity\voice_effect.c" />
300301 <ClCompile Include="..\timidity\vorbis_a.c" />
302+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
301303 <ClCompile Include="..\timidity\w32_a.c" />
302304 <ClCompile Include="..\timidity\w32_gogo.c" />
303305 <ClCompile Include="..\timidity\w32_libFLAC_dll.c" />
--- a/windrv/windrv.vcproj
+++ b/windrv/windrv.vcproj
@@ -274,6 +274,14 @@
274274 >
275275 </File>
276276 <File
277+ RelativePath="..\timidity\w32g_vorbis_dll.c"
278+ >
279+ </File>
280+ <File
281+ RelativePath="..\timidity\w32g_vorbisfile_dll.c"
282+ >
283+ </File>
284+ <File
277285 RelativePath="..\interface\winsyn_c.c"
278286 >
279287 </File>
@@ -305,6 +313,10 @@
305313 >
306314 </File>
307315 <File
316+ RelativePath="..\timidity\decode.c"
317+ >
318+ </File>
319+ <File
308320 RelativePath="..\interface\dumb_c.c"
309321 >
310322 </File>
@@ -618,11 +630,11 @@
618630 >
619631 </File>
620632 <File
621- RelativePath="..\vstwrapper.h"
633+ RelativePath="..\timidity\vstwrapper.h"
622634 >
623635 </File>
624636 <File
625- RelativePath="..\timidity\vstwrapper.h"
637+ RelativePath="..\vstwrapper.h"
626638 >
627639 </File>
628640 <File
--- a/windrv/windrv.vcxproj
+++ b/windrv/windrv.vcxproj
@@ -288,6 +288,7 @@
288288 <ClCompile Include="..\timidity\common.c" />
289289 <ClCompile Include="..\timidity\controls.c" />
290290 <ClCompile Include="..\interface\dumb_c.c" />
291+ <ClCompile Include="..\timidity\decode.c" />
291292 <ClCompile Include="..\timidity\effect.c" />
292293 <ClCompile Include="..\timidity\envelope.c" />
293294 <ClCompile Include="..\timidity\filter.c" />
@@ -330,6 +331,8 @@
330331 <ClCompile Include="..\timidity\thread.c" />
331332 <ClCompile Include="..\timidity\timidity.c" />
332333 <ClCompile Include="..\timidity\voice_effect.c" />
334+ <ClCompile Include="..\timidity\w32g_vorbisfile_dll.c" />
335+ <ClCompile Include="..\timidity\w32g_vorbis_dll.c" />
333336 <ClCompile Include="..\timidity\wasapi_a.c" />
334337 <ClCompile Include="..\timidity\wdmks_a.c" />
335338 <ClCompile Include="timiditydrv.c" />