From cd38e5e6be31e4f7c47030d10437b6b44efa034e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 7 Mar 2015 23:10:08 -0600 Subject: [PATCH] Big DUMB update Squashed commit of the following: commit f961d7764ccab2dbed8166706896b4b3750e5ab9 Author: Randy Heit Date: Sat Mar 7 23:09:24 2015 -0600 Was missing some files from the dumb_static project commit fb6b709c903687015fe775cac5ea1146dfd47051 Author: Randy Heit Date: Sat Mar 7 22:59:38 2015 -0600 Update CMakeLists.txt for new DUMB commit 8201b9aee8cc6e8d7fb7043a0e7062e26b9891b1 Author: Randy Heit Date: Sat Mar 7 22:32:44 2015 -0600 Change the default DUMB quality to cubic commit 0bd9e1858642dd03cf9633ac1fd69e0e54c67c06 Author: Randy Heit Date: Sat Mar 7 22:30:17 2015 -0600 Update mod_volramp for new DUMB volume ramping settings commit 622a67044e3a0aea560e397622b3c6138a8a8cb9 Author: Randy Heit Date: Sat Mar 7 22:14:04 2015 -0600 Add new DUMB quality levels to the menu commit b23a3862b9fba672d2c966d8eebcab7ade951498 Author: Randy Heit Date: Sat Mar 7 21:50:03 2015 -0600 Speed up resamplers by removing lots of implicit function calls commit 9b884676b9c6afbc4bbe889e7e33a10cffa0e90c Author: Randy Heit Date: Sat Mar 7 21:49:57 2015 -0600 Remove direct access to the FP aliasing mixer The original integer one is faster, and using floats gains nothing here, so don't bother offering it. commit 8f9fc8d3317f0db3480577b2c92963dc88f609d0 Author: Randy Heit Date: Sat Mar 7 20:14:34 2015 -0600 Use unsigned phase counters in the resampler - delta should always be positive commit d1228954405bbcd036de66e9bcbe443657cfc590 Author: Randy Heit Date: Fri Mar 6 23:09:14 2015 -0600 Restore DUMB's original resamplers - The all-in-one resamplers in resampler.c have more overhead than the originals, so bring them back. Specifically, the aliasing, linear, and cubic resamplers have been restored to their previous form. Also, this is the original aliasing filter and not the blip_buf one. The resampler.c resamplers are still accessible but at different quality numbers. commit 730e5d98a0c127b9177e5364752d47a82416a0e4 Author: Randy Heit Date: Fri Mar 6 22:00:06 2015 -0600 Convert phase back to integers - Having to call functions to convert to integer and chop off the non-decimal part of the phase for every sample is super heavyweight. commit a6325a54e77d2c523f3637c963a41314287b1b0f Author: Randy Heit Date: Fri Mar 6 20:16:29 2015 -0600 Remove fir_resampler files - What are these still doing here? commit 7f3ebf9b7fa9c9ba9e579b081a263f0e7f949da5 Author: Randy Heit Date: Fri Mar 6 20:01:53 2015 -0600 Try to eek out some more performance from new resamplers - Change some floats to doubles to avoid extra conversions. - Use modf() instead of fmod(), since it seems at least marginally faster. commit 87047ef20068ee394a3132f173bf12ead8aae8b2 Author: Randy Heit Date: Fri Mar 6 19:19:09 2015 -0600 Add DUMBCALLBACK to filesystem functions in music_dumb.cpp commit 36a39ead8109660e1c6054ab91799a765b1ca219 Merge: 92473a0 68d6ef8 Author: Randy Heit Date: Thu Mar 5 21:48:17 2015 -0600 Merge branch 'dumb_branch' into newdumb2 Conflicts: dumb/include/dumb.h dumb/src/core/dumbfile.c dumb/src/helpers/blip_buf.c dumb/src/helpers/fir_resampler.c dumb/src/helpers/resamp3.inc dumb/src/helpers/resample.inc dumb/src/it/itread.c dumb/src/it/itrender.c dumb/src/it/loadmod.c dumb/src/it/loadmod2.c dumb/src/it/readam.c dumb/src/it/readdsmf.c dumb/src/it/readmod.c dumb/src/it/readmod2.c dumb/src/it/readokt.c dumb/src/it/readpsm.c dumb/src/it/readptm.c dumb/src/it/readstm.c commit 92473a05517ba36c632236f08a36d4b1870e526a Author: Randy Heit Date: Thu Mar 5 15:08:15 2015 -0600 Add seek and get_size functions to mem_dfs commit 7635e05007df7415d07cc202c2f082424687a0c4 Author: Randy Heit Date: Thu Mar 5 14:17:25 2015 -0600 Restore ZDoom customizations to DUMB commit cfdb14c4bbb43410a1549e45f54be1e5872759ae Merge: fe3c5bd f900c65 Author: Randy Heit Date: Thu Mar 5 19:00:05 2015 -0600 Merge commit 'f900c65e79c089755013d84cf7f8' into newdumb2 commit fe3c5bdf270c2b1ab65cd8e96bfc16bc88025ae6 Author: Randy Heit Date: Thu Mar 5 18:59:41 2015 -0600 Remove old DUMB to make way for new DUMB commit 68d6ef8731e2499bd99790c40cf0dcd179c9903b Merge: f900c65 2424469 Author: Randy Heit Date: Thu Mar 5 14:19:19 2015 -0600 Merge remote-tracking branch 'dumb_remote/master' into dumb_branch commit f900c65e79c089755013d84cf7f856da78c0bc39 Author: Chris Moeller Date: Thu Jun 20 22:27:52 2013 -0700 Fixed C++11 compilation error on Mac OS X commit 24244696518e81dccac26d13e0acfdaeec56b79e Author: Chris Moeller Date: Tue Feb 10 00:07:32 2015 -0800 Revert default resampling quality to cubic, as it's a nice trade-off between speed and quality commit 766a20f4816f5d08275a430ed68d788aefb23e5b Author: Chris Moeller Date: Fri Jan 16 20:52:57 2015 -0800 Fixed compilation with -fPIC on x86 and x64 commit 1f2c97ef13d66e4787ea1da86a75c6ab7d3b66a7 Author: Chris Moeller Date: Mon Jan 12 02:01:36 2015 -0800 Fixed non-SIMD blep and blam handlers commit 7f3dd7ed3c97b1f0030ac24753ab248a8d8374b4 Author: Chris Moeller Date: Mon Jan 12 01:25:45 2015 -0800 Sanity fix for ARM NEON code: vmlaq always adds onto the first input parameter commit 189c55a1eb5902b09579efb79ed9a5b0f960b6c0 Author: Chris Moeller Date: Mon Jan 12 00:03:36 2015 -0800 Typo fix that I only caught by trying to build for ARM commit 85297714b9f89914a04c39c340a2433a20925f2c Author: Chris Moeller Date: Sun Jan 11 17:18:53 2015 -0800 Fixed a bug with resampler not clearing blep/blam state variables commit a39b4d41f63ed34754bcfe94e1638ab2fe9ecb71 Author: Chris Moeller Date: Sat Jan 10 22:15:47 2015 -0800 Added a way to configure the load-time panning separation of hard panned channels, now defaulting to 25% commit 80e1e1a33c3b1b64012ef24a6537176ea0cc7fd0 Author: Chris Moeller Date: Sat Jan 10 21:50:15 2015 -0800 Overhauled resampler quite a bit, and implmented a new band-limited linear interpolation mode commit 8ea3282ceaf9e2915d60310fc74fed6951e2b754 Author: Chris Moeller Date: Tue Jan 6 22:44:59 2015 -0800 Fixed STM trying to seek and read non-existing samples commit f3d6e8f9b1718b1ec1791c49150a0e140ea83911 Author: Chris Moeller Date: Sun Nov 23 00:46:57 2014 -0800 Revert to MSVC 2013 commit a2e6f8de924377007fdd014945e0ce74e44dac78 Author: Chris Moeller Date: Thu Nov 20 21:38:31 2014 -0800 Updated project file to MSVC 2015 commit 7ee625748304ef158460633439c153724171eb3e Author: Chris Moeller Date: Sun Sep 28 17:48:43 2014 -0700 Updated bit array source and enabled decoration on both bit array and resampler functions commit 97ef9342913d3ea48e8682bf80a3154631fd481d Author: Chris Moeller Date: Fri Aug 15 06:10:31 2014 -0700 Fix for MSVC 2013, which now provides its own log2 commit 2069bbc7ae0aa2b395b844f3085db5b3b989d8fc Author: Chris Moeller Date: Fri Aug 15 05:46:02 2014 -0700 Updated project for MSVC 2013 commit c7f726980b257e127cb0fc788674cc5958005588 Author: Chris Moeller Date: Wed Jul 2 12:24:31 2014 -0700 Fixed dead note dropping when volume ramping is active commit c08c5988a0f2106660dd61734d91541a0d894e49 Merge: 2c21da5 3b31096 Author: Chris Moeller Date: Wed May 21 22:53:31 2014 -0700 Merge pull request #10 from realistschuckle/master Move the block for adding the Mac OS X specific properties to after the registration of the library commit 3b310960c80638e07863de76db5bfdf828577491 Author: Curtis Schlak Date: Thu May 22 00:44:09 2014 -0500 Move the block for adding the Mac OS X specific properties to after the registration of the library. commit 2c21da52cbd096f3d7409b58b47d8cddcad6b84b Author: Chris Moeller Date: Sun May 11 17:29:13 2014 -0700 Increased precision of resampler phase variable, greatly reducing the incidence of sample rate rounding errors commit 9aa0dc277e1360b918aa62f87c92841f25f141ab Merge: 47337ba 143ac6b Author: Chris Moeller Date: Wed May 7 21:09:09 2014 -0700 Merge pull request #9 from Vagabond/adt-valgrind-uninitialized-memory Fix 2 places valgrind warns about unintialized memory being used commit 143ac6b1311c738587defa65016358fa71be0e31 Author: Andrew Thompson Date: Thu May 8 00:02:39 2014 -0400 Fix 2 places valgrind warns about unintialized memory being used commit 47337ba425c79771a522050f85d17db804619ac7 Merge: 5b36c39 57614d0 Author: Chris Moeller Date: Fri Apr 18 16:38:36 2014 -0700 Merge pull request #8 from katajakasa/ttv-cmake-header-path Change dumb.h install subdirectory in cmake script commit 57614d0c3f4e160d73676f422e1ba282cc135bbf Author: Tuomas Virtanen Date: Sat Apr 19 02:16:48 2014 +0300 Change dumb.h install subdirectory in cmake script commit 5b36c39238d02c7f1fa8df791ae54935830300ca Author: Chris Moeller Date: Fri Apr 11 16:34:13 2014 -0700 Adjusted tempo timing a bit, now rounding samples per tick down instead of up commit 7a0d05c002c7ced72ceba489fc603b10b6d72d2b Author: Chris Moeller Date: Tue Apr 8 15:15:29 2014 -0700 Updated license from the original project with clause 8 commit 8c6f27a159f53fbf7a622dfd3ac59bb1df23d206 Merge: 6cb73ee 5ed52e6 Author: Chris Moeller Date: Tue Apr 8 15:10:19 2014 -0700 Merge pull request #6 from Vagabond/adt-unix-debug Don't include the MSVC debug header if we aren't using MSVC commit 5ed52e609b8fc32e00cb46330a0c08d5f01a0ea5 Author: Andrew Thompson Date: Tue Apr 8 13:10:54 2014 -0400 Don't include the MSVC debug header if we aren't using MSVC commit 6cb73ee3430f7ba10376286a06f28eeb2ed598a2 Author: Chris Moeller Date: Fri Apr 4 21:45:39 2014 -0700 Attempt to fix issue #5 with compiling cpuid inline assembly on any platform using PIC commit 651e5235b72883f8480bb8138fad01bb168c16f4 Author: Chris Moeller Date: Fri Apr 4 20:25:43 2014 -0700 Updated sinc resampler with unscaled windowing, which fixes a lot of the previous aliasing commit 9e2c91079ddbbc3d968f17e78b734d529af2afcd Merge: 07c545a 98e7d70 Author: Chris Moeller Date: Fri Apr 4 19:46:41 2014 -0700 Merge pull request #4 from katajakasa/ttv-cmake-improvements CMake readme+improvements commit 07c545a6b7437f30c2864892a1709efcb50b521b Author: Chris Moeller Date: Fri Apr 4 17:14:38 2014 -0700 MSVC fix again commit 84ac89922d6fed2d363254965111a0c3222811f1 Author: Chris Moeller Date: Fri Apr 4 16:50:51 2014 -0700 Resampler now adds input delay and subtracts output delay according to whichever quality is selected, rather than being fixed for sinc only. This fixes blep synthesis mode defeating note on and off volume ramping. commit 98e7d70de745097165e1ea40ded2d3d7e16699b4 Author: Tuomas Virtanen Date: Fri Apr 4 16:08:13 2014 +0300 Add readme file for cmake building. This adds a simple readme file for building the cmake project. It includes the most common flags and quick build/install commands. commit 33bc39397f3bef48d5c1c688bfec929db653c9d5 Author: Tuomas Virtanen Date: Fri Apr 4 16:05:43 2014 +0300 CMake improvements and cleanups Add missing "-msse" flag, clean up old BUILD_SHARED flags (cmake has its own system for doing this) and add a couple more build targets. commit fa1413c69747f35c396fce8bbd8d2fba005bb11e Author: Chris Moeller Date: Fri Mar 28 17:50:30 2014 -0700 Changed volume ramping so normal transitions to or from zero volume are quicker commit 58556af70c7d3ad68657cbda7ff3d4d74aefb70e Author: Chris Moeller Date: Wed Mar 26 20:58:26 2014 -0700 Removed blip_buf.c from remaining projects commit 74390bd111b0496a25967cd1418e6f7ec0a4a868 Author: Chris Moeller Date: Wed Mar 26 20:51:43 2014 -0700 Implemented blep synthesis into resampler.c, and removed blip_buf.c and code which referenced the old resamplers commit cb8ab8c6f6ddef8a0938f771e3fad9d0ca6b2735 Author: Chris Moeller Date: Wed Mar 26 02:12:33 2014 -0700 Derp commit 56093a31621a65b1f9aae21fbb34cf62e7918a15 Author: Chris Moeller Date: Wed Mar 26 02:04:50 2014 -0700 Another meh fix commit 23f4dc1b6d64df60fea10eae1d6bf0a88c6d9c0c Author: Chris Moeller Date: Wed Mar 26 01:40:41 2014 -0700 Oops, I somehow seriously broke volume ramping prior to the previous release commit 3bcbb6a94a73e0d782e63055a20e7d90860a8b70 Author: Chris Moeller Date: Tue Mar 25 20:19:21 2014 -0700 Made disabling volume ramping actually work correctly commit 4fcf162e992167d875978ce829f4d8347b1297f4 Author: Chris Moeller Date: Tue Mar 25 20:04:09 2014 -0700 Forgot to re-add missing function commit dfdf86be5e69122bb1ed4aa34cb6ecc6a7158672 Author: Chris Moeller Date: Tue Mar 25 20:01:37 2014 -0700 Oops, typo commit 477011d74059eac39f530737ad73b98da24085f1 Author: Chris Moeller Date: Tue Mar 25 19:50:19 2014 -0700 Made volume ramping configurable once again, now configurable between note on/off declicking only or full ramping commit 52a88bedf98d7582e1efda99782534dab0d3f089 Author: Chris Moeller Date: Mon Mar 24 18:07:52 2014 -0700 Oops, accidentally made DUMB twice as loud as it should be commit c052e6a45599edc6401e3c3b4513d903f6917e92 Author: Chris Moeller Date: Mon Mar 24 17:24:51 2014 -0700 Fixed resampler for large increments; fixes spx-troughtheinfinite.it commit 243233d3977da6693aeb131dce03c03cd74ead75 Author: Chris Moeller Date: Mon Mar 24 17:23:44 2014 -0700 Reworked volume ramping a bit commit a15a906131e89bc8b7fb43dc0c54f704f743d7df Author: Chris Moeller Date: Sun Mar 23 20:58:27 2014 -0700 Changed sinc window to Nuttal 3 term, and added pre-fill of silence to account for half the window size minus one commit 3e3c7e15806ba01fc6a680def36ee0df4a3bc6da Author: Chris Moeller Date: Sun Mar 23 20:58:03 2014 -0700 Removed a stale file from project commit 3aaf281a82702411ba77067784afb6ba936f8a46 Author: Chris Moeller Date: Sun Mar 23 13:24:54 2014 -0700 Forgot to remove last vestiges of now unused linear and cubic code commit ee94f03e1d576e6879122dc992f01f2df0b0078c Author: Chris Moeller Date: Sun Mar 23 13:05:08 2014 -0700 Oops wrong header commit e1e2edd45fe09a616b336f4e59fcff069da6af4e Author: Chris Moeller Date: Sun Mar 23 01:30:23 2014 -0700 Oops commit 6937b61cc57d839278f6ee73bc9471eaa07c7f87 Author: Chris Moeller Date: Sun Mar 23 01:28:04 2014 -0700 Replaced built-in linear and cubic resamplers with new routines commit a8d9baafc008bc851bce7b0aef799b74b9732a76 Author: Chris Moeller Date: Sat Mar 22 16:29:27 2014 -0700 Renamed lanczos_resampler to sinc_resampler, changed to Blackman window commit 0d21e1317cb204c4975cb98f7ab3ca5685aca910 Author: Chris Moeller Date: Fri Mar 21 16:15:28 2014 -0700 Remove comments which are no longer correct commit a2f7fccb2b2cd6b504990b09f784d74b3bb9e8bd Author: Chris Moeller Date: Fri Mar 21 15:55:46 2014 -0700 Optimized SSE with optional SSE convolving loop, and doubled the kernel size commit f7e4d06555e314a0b831d8a44a802043d16df69e Author: Chris Moeller Date: Fri Mar 21 07:06:51 2014 -0700 Overhauled volume ramping and note start/end declicking, now volume ramping is mandatory commit 02b855c989a02ddf757cf87110857cf376b879e4 Author: Chris Moeller Date: Thu Mar 20 22:26:06 2014 -0700 Work around two possible issues in XM reader; Fixes dark_lighthouse.xm. commit b661a11b09185a8e8b8a2c4a5c64021cc928ef12 Author: Chris Moeller Date: Tue Mar 4 17:11:22 2014 -0800 Fixed offset effect limiting edge case due to samples being 64 points longer due to LPC processing commit 7e4d1331dee5772d6eb91073ac68f18b1bd4a55d Author: Chris Moeller Date: Fri Feb 28 17:51:32 2014 -0800 Revert last change as file was actually broken commit 70c9d7e03ed210010c88acb2024c94fc60d74cdc Merge: 3ec1cc5 b068221 Author: Chris Moeller Date: Fri Feb 28 17:06:13 2014 -0800 Merge branch 'master' of github.com:kode54/dumb commit 3ec1cc5db70c2f782b9e4b1f199bfb04ceae8718 Author: Chris Moeller Date: Fri Feb 28 17:05:33 2014 -0800 Added a workaround for pattern 255 in the order list commit b0682214bba89f1a6386ed891495a53f74bb67d9 Merge: 3a25c20 3a9b6c7 Author: Chris Moeller Date: Mon Jan 13 23:54:15 2014 -0800 Merge pull request #3 from Vagabond/adt-cmake-install-name Set the dylib install name on OSX commit 3a9b6c7cb585c6b1328a97a8befe2f979a1b009d Author: Andrew Thompson Date: Tue Jan 14 02:54:22 2014 -0500 Set the dylib install name on OSX commit 3a25c206f5610e2626926be036b1ffaa8afab5ef Author: Chris Moeller Date: Mon Dec 2 23:17:42 2013 -0800 Fixed panning and sample loops commit 16c119ad546665eef86579cefd2a6501c0e3059f Author: Chris Moeller Date: Mon Nov 25 17:05:36 2013 -0800 Fixed assertion checks in case of envelope loops on the last node commit b456e20491ea5edc1c052d21e1c105f2d2d5815b Author: Chris Moeller Date: Mon Nov 25 17:05:02 2013 -0800 Added extra safety checking to aliased resampling mode commit 55217b9408a6d8d47e9aed12276d096711d3e8f4 Merge: e5df9e9 30dc8c8 Author: Chris Moeller Date: Sun Nov 10 23:41:07 2013 -0800 Merge branch 'ttv-cmake-v2' of https://github.com/omf2097/dumb commit 30dc8c8c9ead24734d0a42994d2fd3186bf05874 Author: Tuomas Virtanen Date: Mon Nov 11 09:29:52 2013 +0200 Remove unnecessary USE_SSE option from cmake file. commit e5df9e9bec0ff82bce7930ee2dadd5a925cd8342 Author: Chris Moeller Date: Sun Nov 10 23:21:34 2013 -0800 Added more architecture type guards to _USE_SSE blocks commit 14bf151cba840ea4db29226c1bcfb07c286b1afa Author: Tuomas Virtanen Date: Sat Nov 2 21:24:06 2013 +0200 Add initial CMake script and directory commit 094cfcc27187a209a5b457b15276d618fea08658 Author: Chris Moeller Date: Sun Nov 10 22:35:24 2013 -0800 Made the inline assembly cpuid function specific to GCC/Clang like it should have been in the first place. commit 2c9ca950a32cd2de05ed8ae384ad08248793fecd Author: Chris Moeller Date: Thu Nov 7 19:36:22 2013 -0800 Pan and pitch envelopes carry regardless of NNA being note cut commit e07088e5f65186f78681116f3337a89d9db3f5ae Author: Chris Moeller Date: Thu Nov 7 19:06:43 2013 -0800 It is now possible to use both Gxx/Lxx and hx in the volume column in the same row commit ee34129043d15e9cb9f980ab73585bbec8b40314 Author: Chris Moeller Date: Thu Nov 7 18:20:52 2013 -0800 Fixed IT mixing Dxx regular volume slide with cx/dx volume column slide effect commit b85fdab6f8102a7df5925d58a4e07b98ed69dd4a Author: Chris Moeller Date: Thu Nov 7 17:52:50 2013 -0800 Simplified pan law calculation a bit commit da31373331b91be6d6dd7e83a1e6eee94b0a585a Author: Chris Moeller Date: Mon Oct 7 08:11:57 2013 -0700 Fixed Asylum Music Format panning effect commit 5945794aff46562478ff764a841e085448046125 Author: Chris Moeller Date: Fri Oct 4 13:14:52 2013 -0700 Fixed a C11 warning by adding a macro lock around blip_t declaration commit bf5dd80894f947d3eca15960ca1b329e9ccde677 Author: Chris Moeller Date: Fri Oct 4 10:16:35 2013 -0700 Copied LONG_LONG definition inside of tarray header so it doesn't need to include the main dumb header commit 8298eb20f77e77c92012ca880e479456d0d1112c Author: Chris Moeller Date: Fri Oct 4 10:15:52 2013 -0700 Made resampler and SSE filter setup functions public, in case anyone wants to call them early to prevent possible but harmless race conditions commit 23f9ebdf1a385e01b365598527c0a59458a4c99d Author: Chris Moeller Date: Fri Oct 4 10:15:00 2013 -0700 Implemented automatic detection of SSE support commit a5652e854199c29a6c06493515d20b0cb939a173 Author: Chris Moeller Date: Fri Oct 4 10:12:17 2013 -0700 Renamed init_cubic function in preparation to make it public commit af75f07ccc9813ad19ba5b9a7f488c07834f7e9c Author: Chris Moeller Date: Fri Oct 4 10:10:32 2013 -0700 Fixed compilation errors/warnings commit 46a337c17f1921640757007c67f5af3ca2a3ba19 Author: Chris Moeller Date: Fri Sep 27 19:59:47 2013 -0700 Envelopes do not carry when New Note Action is Cut commit fed6a743dd695249dde84369b09ac8a4e6facfe7 Author: Chris Moeller Date: Fri Sep 27 19:57:03 2013 -0700 Reworked declicker final volume propagation a bit commit 9fc8f92d437a8132e90d53c94e6ca019b928dd1c Author: Chris Moeller Date: Fri Sep 27 19:55:52 2013 -0700 Fixed declicker handling cases where a declicking operation lasts longer than the current block commit 5fedef969bbde33acedc5be6dad13e943e3aa98e Author: Chris Moeller Date: Fri Sep 27 19:53:31 2013 -0700 Removed start of note ramp when raising volume from zero on a running note, as normal volume ramping will already kick in commit 3a3375f808ee166c78315e1005cd82203e356b3c Author: Chris Moeller Date: Fri Sep 27 19:51:13 2013 -0700 Fixed IT envelope loop pickup when the loop start is not on the first tick commit f8dfb33eeaf570b29580736dd1d5092e49ae9ddf Author: Chris Moeller Date: Fri Sep 27 19:49:44 2013 -0700 Moved internal headers out of public dumb.h commit 75c25767bcae8a13eb08b00fd46c4922619c34b6 Author: Chris Moeller Date: Fri Sep 27 11:21:57 2013 -0700 Added documentation from the original project commit 50e839d4f51e1ff6fcbe68d39519475d7da74c4a Author: Chris Moeller Date: Mon Sep 16 15:48:04 2013 -0700 Fixed 8xx effect for MODs, which have a range of 00...FF, not 00...7F or 80 or whatever commit 4a26a05d107a1aee0cc21bf5a41344da35acc3bf Author: Chris Moeller Date: Tue Aug 27 15:26:30 2013 -0700 Fixed IT note cut and note off commands commit 7a16e6a7caf6c001064e47e5da9c19f9e2c75d43 Author: Chris Moeller Date: Mon Aug 26 22:50:32 2013 -0700 Invalid notes correctly cause note fade, and range of valid notes increased to include 120/B-9 commit 5c5fedc5f76277abc281066b26dd7463a06841b4 Author: Chris Moeller Date: Sun Aug 25 23:06:43 2013 -0700 Normalized the indentation in the Lanczos resampler, and optimized the resampler a bit commit b3596083ebba5974d1a5b9052145394eae980948 Author: Chris Moeller Date: Sun Aug 25 09:49:55 2013 -0700 IT NFx/NxF should not affect background voices commit 2fcecb0f960dc6d206a480bc882ce430054350e2 Merge: ea96b85 d244b87 Author: Chris Moeller Date: Sun Aug 25 07:55:15 2013 -0700 Merge branch 'master' of bitbucket.org:kode54/dumb commit ea96b859192e9db25968d290b19e57ef25b62a1c Author: Chris Moeller Date: Sun Aug 25 07:50:31 2013 -0700 Channel volume effect should only apply to foreground voices commit d244b8790af5c8caee2eacff1cda8380390eba93 Author: Chris Moeller Date: Fri Aug 23 16:46:43 2013 -0700 Fixed row played tracking and row timekeeping information for orders with skip commands commit d1fe0fdbd105df23a2f879b54385074a3891ce2d Author: Chris Moeller Date: Fri Aug 23 15:56:35 2013 -0700 Fixed XM arpeggio commit 1c44d72e13bbd62790f71206fb061c606ec96337 Author: Chris Moeller Date: Sat Aug 3 17:46:19 2013 -0700 Meh commit 01b9e3faabace3855a6fcd8cae6c253aeee28206 Author: Chris Moeller Date: Thu Aug 1 09:29:49 2013 -0700 - I didn't realize that sigrenderer->tick counted down from speed to 1, rather than up from 0 to speed-1, so every other format's arpeggios were backwards except for XM. Fixed. - Mask tick count to 0-31 so it can't overflow the arpeggio tables. commit 29c3c9e5c9ce8debcd419eac92d841a2e26c7483 Author: Chris Moeller Date: Sun Jul 28 18:05:04 2013 -0700 Apply delta to compressed samples regardless of creating tracker version commit 52caa06214b5b09c8e69b56fb769f6ea93c941b2 Merge: 0fc04de ee557fc Author: Chris Moeller Date: Sun Jul 28 18:02:51 2013 -0700 Merge branch 'master' of github.com:kode54/dumb commit 0fc04dec175327cc0f99c011690bafa4a3c2ccf5 Author: Chris Moeller Date: Sun Jul 28 18:01:28 2013 -0700 - Rewrote arpeggio implementation to use note offset tables - Implemented Fast Tracker II arpeggio bug (ticks count backwards from speed minus one, speeds greater than 15 result in note offsets reading from the vibrato table, which gets clamped to 2) commit ee557fc6f24807d7383ea025c99e81efed3c9ef2 Author: Chris Moeller Date: Sat Jul 27 16:30:29 2013 -0700 Meh. commit 951ce0752e9c64a792551b2868613a1b5b85f884 Author: Chris Moeller Date: Fri Jul 26 11:11:39 2013 -0700 Fixed songs with envelope loops on the last tick commit eaad8176c626959111f3c13fc82b1c4ad02a1e83 Author: Chris Moeller Date: Mon Jul 22 19:56:28 2013 -0700 Fixed envelope start and end shortcuts commit 27406abff56cb47d39c1a9e2d4f50336a882be49 Merge: 5698ac5 f2cd234 Author: Chris Moeller Date: Mon Jul 22 19:28:27 2013 -0700 Merge branch 'master' of github.com:kode54/dumb commit 5698ac532ffe1e01f7e23a476a6ea52341276b26 Author: Chris Moeller Date: Mon Jul 22 19:28:15 2013 -0700 Fixed envelope loop timing commit f2cd2349a4a2b49960f4193be7377dbdd9547a95 Author: Chris Moeller Date: Fri Jul 19 15:56:51 2013 -0700 Fixed so it only initializes envelopes when instruments are enabled commit 01f8ce4b56e460057d6cca3bfc2d58e3600300aa Author: Chris Moeller Date: Thu Jul 18 08:23:11 2013 -0700 Fixed envelope carry to only occur if the running note has not already been cut or released commit b9aea1412d1645766b9373c432ac498abed34b63 Author: Chris Moeller Date: Wed Jul 17 18:53:55 2013 -0700 Further fixes to IT envelope behavior commit a42b6bcdc28e200a751baf4414e6f4c6ebb36c71 Author: Chris Moeller Date: Wed Jul 17 18:34:09 2013 -0700 Reimplemented envelope carry to be more like other players commit 0bc29b4eb63b5758cf0d174258b6b072a3041a33 Author: Carlos Rafael Giani Date: Sun Jun 30 16:43:31 2013 +0200 various fixes to address GCC warnings commit 991ce8202643a296969d9a623e9702966a957e69 Author: Chris Moeller Date: Sat Jun 22 15:16:04 2013 -0700 Moved DUMBFILE structure to its own header file to unify the rare cases where it needs to be visible outside of dumbfile.c commit bfb8fea251124760b834c36e5eabd2aff24494b4 Author: Chris Moeller Date: Fri Jun 21 00:14:19 2013 -0700 Whoops. commit f5a1c5ec318cd7c17fb54f2ed2cb70d72cd549f6 Author: Chris Moeller Date: Thu Jun 20 22:28:11 2013 -0700 Eliminated all clang compilation warnings commit d31fb2084659b64d07eb0644d9bacfd67059d066 Author: Chris Moeller Date: Thu Jun 20 22:27:52 2013 -0700 Fixed C++11 compilation error on Mac OS X commit d2d6f48b2bdecc96a60c7e7dfab2b83bf72dc143 Author: Chris Moeller Date: Sun Jun 16 09:55:19 2013 -0700 Fixed another stupid error commit 9b377f8d7f76159d7f227c727aeae7e16fd1db7b Author: Chris Moeller Date: Sat Jun 15 19:48:23 2013 -0700 Cleaned up several warnings, including a buffer overflow in the DSMF reader commit e12facc69845ef4f16bc70f755dc7cb898cede41 Author: Chris Moeller Date: Wed Jun 12 07:19:13 2013 -0700 Disabled MSVC 2012 default of SSE2 commit 5b83c82c3cc13dd2eeec47758fde4cd61d455bd6 Author: Chris Moeller Date: Wed Jun 12 05:56:32 2013 -0700 Fixed intermittent noise with SSE resonant filters by special casing zero length render calls commit 796c801be6b1db3a800a844ab58b9a5454951ace Author: Chris Moeller Date: Wed Jun 12 04:06:19 2013 -0700 Subsong scanner always tries to play the first order now commit b5f940169c2968b54e8d48cf880f5999c5932922 Author: Chris Moeller Date: Wed Jun 12 03:45:06 2013 -0700 Re-enabled SSE support and rewrote SSE filter function commit cf2577d4bc284fb5c5b71377413a47c72a1362dc Author: Chris Moeller Date: Sun Jun 9 11:22:34 2013 -0700 Fixed timekeeping when starting a sigrenderer with a time offset commit 89724f7ac8c7b5395df41443c504f7a3c486f144 Author: Chris Moeller Date: Sun Jun 9 10:47:48 2013 -0700 Coding consistency fixes commit 68f8a3aa8fb53b98625232d99cc5bd040e67dd96 Author: Chris Moeller Date: Sun Jun 9 10:33:32 2013 -0700 Fixed timekeeping commit 3e73bae5e9ddd3a44d9b0767093d93dfd45df1fc Author: Chris Moeller Date: Sun Jun 9 10:33:16 2013 -0700 Enabled SSE compilation commit 2e0b1fae827b0cf771049e8697f0e8c98df87f96 Author: Chris Moeller Date: Sun Jun 9 02:58:16 2013 -0700 Disabled SSE as MSVC 2012 breaks it commit ca9fae207ca4505560ac9f0a3f25cd076179e5dc Author: Chris Moeller Date: Fri Jun 7 20:24:38 2013 -0700 Fixed position status reset on callback-aborted loop commit 852b2b9d01fa0f31dd004d5acc19035401faf6f3 Author: Chris Moeller Date: Fri Jun 7 20:23:41 2013 -0700 Added MSVC 2012 v110_xp platform commit a6c23d0bd4ab4a4e28fe4bbb112f4f56c68488b9 Author: Chris Moeller Date: Tue Jun 4 19:15:25 2013 -0700 Fixed Qt project file commit 381ce8ea4237a64d63ac447d1e42463edde356da Author: Chris Moeller Date: Tue Jun 4 11:00:52 2013 -0700 Fixed duplicating some timekeeping state variables commit 7c1e30edb5700a7751281cc0f8e5e3bb4934989f Author: Chris Moeller Date: Tue Jun 4 10:57:59 2013 -0700 Small fix for possible issue with time reporting for looped modules if callback ends playback commit 153721b1c9f4cde62fa17d6aef56f782b37384bf Author: Chris Moeller Date: Mon Jun 3 18:41:31 2013 -0700 - Implemented loop-accurate time position reporting into DUMB - Implemented get samples stopping short on loops commit 99111038210a07af485be94a6e85dc43faa10eff Author: Carlos Rafael Giani Date: Wed May 22 17:37:36 2013 +0200 M_PI may not be defined When building with gcc 4.7.2 and -std=c99 , M_PI is not defined commit db4dcf6c1581496e336062c866ce522544d25849 Author: Carlos Rafael Giani Date: Wed May 22 17:36:35 2013 +0200 the MEMFILE filesystem didn't have seek and get_size functions This caused crashes if read_any was used commit 4e0faec2b81698376b78c4715d633de23140cd10 Author: Carlos Rafael Giani Date: Wed May 22 17:35:47 2013 +0200 renamed "restrict" parameters to "restrict_" "restrict" is a keyword since C99 commit e65a86fc81352fbd667269f22878365606e2cf2c Author: Chris Moeller Date: Mon May 6 17:08:39 2013 -0700 Removed unnecessary optimization function commit 1fe80f166e57778b1500bb035ec9ff8d95819006 Author: Chris Moeller Date: Sat May 4 21:08:17 2013 -0700 Fixed regular surround mixing commit a869c4734a0df7a35b7616089db89cf64fcb3d80 Author: Chris Moeller Date: Sat May 4 21:07:58 2013 -0700 Optimizations and bug fixes for the Lanczos resampler commit 6edaad13465e6739f185884bd2d308e1f50d7cc9 Author: Chris Moeller Date: Thu May 2 16:04:14 2013 -0700 Fixed resonant filter handling in surround mixer commit b40d6a5877558121d876ee3c578daecf138b504c Author: Chris Moeller Date: Tue Apr 30 13:04:56 2013 -0700 Implemented 3 channel surround mixing commit 85fa2b7e833e2ec45af7ed9629c9f360e4f37730 Author: Chris Moeller Date: Mon Apr 29 18:04:41 2013 -0700 Removed unnecessary code commit 8111a1eb5bcd11f01dd4fcea067d53b00c13d8a4 Author: Chris Moeller Date: Fri Apr 26 02:13:17 2013 -0700 Whoops, that was Blackman-Harris, not Lanczos. Lanczos produces less aliasing, anyway. commit ffd168da5e639f5ef9943d2cc8c8be202a1003b0 Author: Chris Moeller Date: Fri Apr 26 01:42:23 2013 -0700 Fixed phase calculation when downsampling commit 1eef4c9f892c119f2f92f0d928efe1b7a98af934 Author: Chris Moeller Date: Fri Apr 26 00:25:04 2013 -0700 - Implemented Lanczos resampler - Fixed overhead of performing effects updates on background voices commit 8605fb3a520aafb2d43febb6c0a9acde871090e7 Author: Chris Moeller Date: Mon Apr 22 23:15:06 2013 -0700 Replaced FIR resampler's IIR low pass filter with a fixed set of cutoff stages commit 5f1d4388b1ba13ca80540f4734bbc58648468e3c Author: Chris Moeller Date: Sat Mar 16 15:03:07 2013 -0700 - Removed *16/11 scale from S3M global volume - Applied S3M master volume as mixing volume - Renderer now ignores S3M Vxx for values greater than 0x40 commit cc986aa7dad019e2e4f8fe2d42013e50a1cd79d6 Merge: 9a68144 8ba1f7e Author: Chris Moeller Date: Tue Feb 19 21:10:15 2013 -0800 Fixed shit commit 8ba1f7e7c01eef9dac7dd79cf2026ae9c3364b8d Author: Chris Moeller Date: Tue Feb 19 21:08:21 2013 -0800 Fixed panning correctly this time commit 569b49a533a53b92dceac0eb6b4aa6641f65ae5e Author: Chris Moeller Date: Tue Feb 19 21:08:02 2013 -0800 Implemented support for compressed stereo samples commit 9a68144bfcd970e257b37ccc001d58c23cbe007e Author: Chris Moeller Date: Thu Feb 14 12:21:31 2013 -0800 Changed panning rule from 3dB to 0dB to match most trackers commit c7aadf292975e96c3036fc4f2e4248a5c727fa5d Author: Chris Moeller Date: Sun Feb 10 11:45:04 2013 -0800 Fixed loop start for STK modules commit ff84ff32fe1fc82926020feedf894c4fb5c37ccd Author: Chris Moeller Date: Tue Jan 22 03:02:12 2013 -0800 Fixed serious error with MPT extension reading commit 3aee7f113c66f19e93f9e41a6e280e12dfd9a0e9 Author: Chris Moeller Date: Thu Jan 17 16:26:06 2013 -0800 Fixed envelope reading to gracefully handle nodes which are out of range commit 73da922bddede1f81fffc7e5e895cace755b378d Author: Chris Moeller Date: Wed Jan 16 22:03:01 2013 -0800 Implemented support for the obscure S9F sample reverse effect commit 0994e9948c6ca6b2d50e1e5e4ac87b8371764b7f Author: Chris Moeller Date: Mon Jan 14 20:14:48 2013 -0800 Removed unused variables commit beea1d9f5c32609b8b48859f018a4225b1ab29ab Author: Chris Moeller Date: Mon Jan 14 20:11:28 2013 -0800 More fixes for seeking support commit a79a9725a9ed45f80d0c9ecf6fc1697219937dd9 Author: Chris Moeller Date: Mon Jan 14 19:26:42 2013 -0800 Fixes for C89 limitations and some const types commit d8784727e4b117e77c9cf4ff609dace2c4d1da24 Author: Chris Moeller Date: Mon Jan 14 19:06:08 2013 -0800 Implemented full seeking in DUMBFILE and modified several readers to account for this change, which also reduces their overall memory usage commit 3267dd862062e755782f04eee5db47ef338fc5b8 Author: Chris Moeller Date: Sat Jan 12 18:34:22 2013 -0800 - Added silence padding for samples which are too short to predict padding for - Added extra comments commit d5b0ced73cd72f99816b7db788cef63b2603bbe4 Author: Chris Moeller Date: Sat Jan 12 18:33:35 2013 -0800 Eliminate clipping from the low-pass filter stage by increasing intermediate buffer type size to int commit a57194a330f1ed2b44bb681e3d2c63880628f214 Author: Chris Moeller Date: Sat Jan 12 15:59:36 2013 -0800 - Simplified low-pass filter - Eliminated accidentally applied resonance from low-pass filter - Silenced a C89 error by adding a static cast commit 6c8eeb8a7b0e72c3de865d517ec0ff4778389315 Author: Chris Moeller Date: Sat Jan 12 10:17:54 2013 -0800 Added a low-pass filter to the FIR resampler commit b440292bbb949f0aaf5dbb8fa17169833fd15c5e Author: Chris Moeller Date: Fri Jan 11 20:53:32 2013 -0800 - Fixed FIR resampling - Silenced warnings commit 0f63644adc09deb4f7aa87d156a8d2fc70418fef Author: Chris Moeller Date: Fri Jan 11 20:22:46 2013 -0800 Fixed C99isms for MSVC commit 3a1e4eeeb0e868cadc392a59c962bcd0ec57e924 Merge: e032212 abedfc2 Author: Chris Moeller Date: Fri Jan 11 19:58:47 2013 -0800 Merge branch 'master' of github.com:kode54/dumb ... oops, I started making changes without pulling the latest source first. commit e032212355ac7075c91fc9d9c48b990f02353a60 Author: Chris Moeller Date: Fri Jan 11 19:58:42 2013 -0800 Made SSE filters configurable commit abedfc226b1f070c979ac8e8d6c09fa31eee96c8 Author: Chris Moeller Date: Fri Jan 11 19:39:43 2013 -0800 Added new files to MSVC projects commit d666d3d8906a27d9475e7aea1b650da8c5d163b2 Author: Chris Moeller Date: Fri Jan 11 19:35:58 2013 -0800 Cleaned up MSVC 2010 project file commit 8cc51b9415ad34de3aa8e8f29f5e5eac96b9fae1 Author: Chris Moeller Date: Fri Jan 11 19:30:28 2013 -0800 Removed stale source control file commit 52b415ace8dee10d26984da1eabf36fc08f07f4c Author: Chris Moeller Date: Fri Jan 11 19:27:12 2013 -0800 - Implemented FIR resampler - Implemented one-time LPC extension of samples without permanent loops, to better facilitate declicking, and also to help flush the resamplers commit 2fa3b87ae99fc62a03ec26c81c81ae23f3ab7cec Author: Chris Moeller Date: Fri Jan 11 19:24:34 2013 -0800 Minor indentation change commit 4df0e8c5be294fa1fe3ea96eff8387c2505912ec Author: Chris Moeller Date: Sun Dec 30 10:59:29 2012 -0800 Fixed pattern counting, and swapped pattern counting flag commit b97e36954f873516c31c0a8c24054784f3c9d751 Author: Chris Moeller Date: Sat Dec 29 18:02:21 2012 -0800 Fixed portamento up effect when NNA channels are active commit ac46a8b6056cf12bff464407bc1582301051c1f1 Author: Chris Moeller Date: Wed Dec 26 13:22:49 2012 -0800 Fixed STM speed handling commit 425a8407fb003e1ca7d5f332cad9d7be90a6e2ee Author: Chris Moeller Date: Sun Dec 23 13:40:35 2012 -0800 Oops, forgot MSVC doesn't have snprintf commit ad8a234f3c6c9b3e7a2d590c81f297bf20375f6d Author: Chris Moeller Date: Sun Dec 23 13:32:31 2012 -0800 Buffer entire file into memory to allow for weird file offsets, and add minimal Open/MPT extension reading commit 347a1170d6d00ec2ea9db2a3667ee7c8d2ef422b Author: Chris Moeller Date: Sun Dec 23 13:31:41 2012 -0800 Fixed envelope handling commit b837698bcffa3952e5fa26e80ffc562e961002b9 Author: Chris Moeller Date: Sat Dec 22 19:15:19 2012 -0800 Fixed memory reader for formats which perform empty skips at the end of the file, like Asylum AMF commit 690b8c607fa01df486f00af03b068d11acd14d55 Author: Chris Moeller Date: Sat Dec 22 18:56:25 2012 -0800 Silenced MSVC warning, removed unused variables, and reordered some code for pre-C99 compilers commit 3ec6f425abbaf5fc6141fdff1783cd5d71005fe8 Author: Chris Moeller Date: Sat Dec 22 18:55:51 2012 -0800 Silenced MSVC warning commit b80bcdf9054a60bbba6806313327b10d14ab9517 Author: Chris Moeller Date: Sat Dec 22 18:55:32 2012 -0800 Added new 'any' reader to MSVC 2010 project commit efd9431447a6f686e8212ffc796624ed58b06531 Author: Chris Moeller Date: Sat Dec 22 18:54:44 2012 -0800 Added format tag to IT reader commit 07787fb0eb2473c7bc7e7185d37936c1b78e424b Author: Chris Moeller Date: Sat Dec 22 18:41:25 2012 -0800 Portability fixes commit a17f9925e5b2e4b5fc20108723374c142e942bbe Author: Chris Moeller Date: Sat Dec 22 18:40:43 2012 -0800 Included SSE optimized it_filter function, enabled if _USE_SSE macro is defined at compile time commit 918d6366a57d34b63dd8144790f979cd9d2656f5 Author: Chris Moeller Date: Sat Dec 22 18:39:41 2012 -0800 Implemented simple 'any' format reader which attempts to detect the format of the input file and passes it off to the correct reader. commit d013643820c4fd4d1d80011bed52a047be46c9f1 Author: Chris Moeller Date: Sat Dec 22 16:50:52 2012 -0800 Added Qt project file commit f4c6edf2923b3098e80123ae2262d01bf6fa89f6 Author: Chris Moeller Date: Sat Dec 22 16:49:34 2012 -0800 Only provide our own log2 for MSVC, since other platforms should already provide it commit 5c9c4359042555c182a4bd52ef212a162e5bbd76 Author: Chris Moeller Date: Sat Dec 22 16:49:01 2012 -0800 Removed unused variable from function declarations, a leftover from copying from the MOD reader commit 9b60a9a4784af5eb7ae2274726c7107c072eb3a6 Author: Chris Moeller Date: Sat Dec 22 16:48:30 2012 -0800 Added limits.h for LONG_MAX commit 045efbd6fc579a78e304185e480c8c15b2b932c4 Author: Chris Moeller Date: Sat Dec 15 22:54:14 2012 -0800 Fixed older pattern counting mode commit 5b53815e1f271746627bde0bfce7140109b88f14 Author: Chris Moeller Date: Sat Dec 15 22:47:19 2012 -0800 Made the new MOD pattern counting system optional commit 30b178af5674b8604306885a693c2a8aa422472f Author: Chris Moeller Date: Sun Dec 9 23:17:38 2012 -0800 Fixed ADPCM sample support commit 02190e007b4967b8a546f64a3934724817ff5c3a Author: Chris Moeller Date: Sun Dec 9 21:59:33 2012 -0800 Fixed MOD pattern count calculation in weird cases where the last sample is missing four bytes commit 756ecf2ac0a2b70639193aca55627b64dac8d8d5 Author: Chris Moeller Date: Sun Dec 9 19:53:45 2012 -0800 Added interface for inserting extra DUH signals, and fixed searching for IT sigdata when more than one signal is present commit d2575fcc80abf2f04e702adb60a6265cef0fcabb Author: Chris Moeller Date: Tue Dec 4 03:49:30 2012 -0800 - Implemented final solution for MOD pattern count calculation - Fixed possible memory leak which only would have occurred with rare MOD files - Fixed a possible memory allocation error or crash with FLT8 MOD files commit b17c5254eeac1bff7e4b613c151e0232c2cba646 Author: Chris Moeller Date: Mon Nov 26 03:49:04 2012 -0800 Remove trailing whitespace from all song, instrument, and sample names commit 32c9bb420240cac2120e7e01c2683df88d1dc1ac Author: Chris Moeller Date: Mon Nov 26 03:11:49 2012 -0800 Corrected MOD reader to only check the known number of orders when calculating the pattern count commit 9e3012a7ce5fb52383f51c99061bc45921699f63 Author: Chris Moeller Date: Thu Sep 20 05:28:25 2012 -0700 Fixed pitch slides on non-playing channels commit e84e1824fbd0b2b690bd9beb2e25fd308e661982 Author: Chris Moeller Date: Sun Sep 9 11:23:47 2012 -0700 Fixed envelopes so they only carry from the same channel commit 22e82be0a7b0a915a2669e8f4ff889a938a7bfcb Author: Chris Moeller Date: Sun Sep 9 09:26:00 2012 -0700 Reverted previous failed tone portamento fix commit 09b78300e19b5cb72d4a515c1e331800d3a6ffbd Author: Chris Moeller Date: Sun Sep 9 08:18:55 2012 -0700 Fixed IT tone portamento again commit e0917efbb9707dea88f1f4c525be7c7647bd82a4 Author: Chris Moeller Date: Sat Sep 8 19:55:47 2012 -0700 Fixed IT tone portamento so it can continue without a destination note on every row commit 15b780d08f2ee6f50a9843dc7479349f4deee5a7 Author: Chris Moeller Date: Sun Sep 2 12:56:38 2012 -0700 Fixed most effects applying to background voices commit 8d87ab8b9ec398cf3831b87dc969a28e278f3105 Author: Chris Moeller Date: Tue Aug 7 00:02:03 2012 -0700 - Fixed XM sample header size handling to always assume a size of 0x28 - Version is now 0.9.9.56 commit 7ad496ecf2fd658a51de55df0e7f0257025038cc Author: Chris Moeller Date: Sun Jul 8 12:57:56 2012 -0700 - Added sanity checking to XM reader instrument and sample header sizes - Added footer tag checking to prevent tags from reaching the module reader - Version is now 0.9.9.55 commit 5bee3e5ba3d57d1b16dda6d82c18fb417781625b Author: Chris Moeller Date: Tue Jul 3 22:24:17 2012 -0700 - Fixed XM reader for files with smaller than expected instrument or sample header sizes - Version is now 0.9.9.54 commit 0e95459562669335f7de543d063cfa57d25a8b77 Author: Chris Moeller Date: Mon Feb 27 16:04:22 2012 -0800 2012-02-24 19:11 UTC - kode54 - Fixed MOD vibrato depth - Fixed XM tremolo ramp and square waveform tracking - Version is now 0.9.9.52 commit 7fc359f6c61939618b11aa2aedf42d45220609f7 Author: Chris Moeller Date: Fri Feb 10 17:14:38 2012 -0800 Fixed BaseClasses project name capitalization to correct version control tracking, removed TFS tracking files. commit 149898118213ec5d5cf8bba057702ab984b8dfa3 Author: Chris Moeller Date: Fri Feb 10 16:53:05 2012 -0800 Added ignore lists for compiler output files commit b85ab3ba352ea05126f6b4ebcca293f223a3988f Author: Chris Moeller Date: Fri Feb 10 12:28:35 2012 -0800 All projects updated and now compile in the new git repository. commit 8c3e510483ba1fdec19017dad4a5004d694177eb Author: Chris Moeller Date: Wed Aug 31 07:53:24 2011 +0000 - Corrected old style PSM note data - Version is now 0.9.9.45 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C724 commit 317a6f3da95fddbdbff464d77ad47ffd0dbfdaff Author: Chris Moeller Date: Sun Aug 14 02:31:37 2011 +0000 Major project file maintenance git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C717 commit 71ecdc7274a7fa33af0a0dea915eb3a294b0b04a Author: Chris Moeller Date: Tue Aug 2 23:31:19 2011 +0000 - Fixed IT stereo samples - Version is now 0.9.9.43 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C713 commit 667b479457fd7c1e9aff4ea8301295c81762bdf5 Author: Chris Moeller Date: Sun Jun 5 22:49:29 2011 +0000 - Fixed IT envelope reading for node counts over 25, which are invalid - Version is now 0.9.9.41 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C684 commit 4a268f95b7d2a116e3ea53d297c1d5a29f46bf07 Author: Chris Moeller Date: Wed May 25 18:42:29 2011 +0000 - Added missing song restart position initialization to AM, AMFF, and DSM readers - Version is now 0.9.9.40 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C682 commit 07f761e918e8a621f64242dd1a631ceba03cc920 Author: Chris Moeller Date: Thu May 12 12:26:57 2011 +0000 - Fixed IT New Note Action duplicate check types for sample and instrument - Version is now 0.9.9.38 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C678 commit 7def196332594817f94138dce2942007d232d407 Author: Chris Moeller Date: Wed Mar 23 05:45:50 2011 +0000 - Corrected volume slide behavior for S3M playback, and also adjusted the slide volume level clipping range for S3M to 0-63 - Updated S3M playback to share memory between DEFIJQRS effects - Adjusted S3M reader to a lower master volume level scale - Version is now 0.9.9.36 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C668 commit f5f34570905e87f1933a0220d71d0d48c05b9b49 Author: Chris Moeller Date: Wed Feb 9 08:10:45 2011 +0000 - Added a workaround for bad sample offsets in STM files - Disabled inserting note cut commands in STM files, as there is no such command in the format - Version is now 0.9.9.35 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C614 commit d78c28566689e3fca51f1fbb7208cde8b6e190a6 Author: Chris Moeller Date: Tue Feb 8 14:11:09 2011 +0000 - Fixed STM sample reading - Version is now 0.9.9.34 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C613 commit c2cb42ff918b398ec8c305ddc6574f9f8f945ad9 Author: Chris Moeller Date: Tue Feb 8 12:03:29 2011 +0000 - Implemented support for STM 1.x format - Flagged STM files as stereo, as they should be - Version is now 0.9.9.33 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C612 commit 33cd2c469ae9872dd0710297760bfb1dfe53a56d Author: Chris Moeller Date: Wed Jan 19 15:20:02 2011 +0000 - Made Oktalyzer reader more tolerant of truncated files - Version is now 0.9.9.30 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C562 commit e169b25f34ca140da8375a7085791447a5b8e8e8 Author: Chris Moeller Date: Wed Jan 19 07:14:25 2011 +0000 - Implemented Oktalyzer format loader - Version is now 0.9.9.29 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C555 commit e34d68685d2e5e8b45f62acdaf8157872624620c Author: Chris Moeller Date: Fri Jan 14 00:10:44 2011 +0000 2011-01-13 23:11 UTC - kode54 - Implemented ASYLUM instrument base semitone offset - Fixed ASYLUM effect number translation - Version is now 0.9.9.28 2011-01-13 21:28 UTC - kode54 - Quick fix for PT2 invert loop effect - Version is now 0.9.9.27 2011-01-13 20:37 UTC - kode54 - Implemented PT2 invert loop effect - Version is now 0.9.9.26 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C545 commit c0fc19ef2e756ef25aa44ca3775b4afed3f02c9c Author: Chris Moeller Date: Tue Jan 11 18:57:59 2011 +0000 - Changed aliased resampler loop conditions a bit to fix some bugs - Removed resampler loop unrolling, as it actually made things slightly slower - Fixed a bug with songs triggering notes on the first order with instrument changes before any note commands have been triggered - Version is now 0.9.9.24 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C543 commit bf42c55a9ad494b3bcbee5dc2959f03c1938fdfb Author: Chris Moeller Date: Sun Jan 9 14:18:02 2011 +0000 Import of blip_buf and one missing header. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C540 commit 9ac6cf69758fe0db6d6e654f298cd36efdb73366 Author: Chris Moeller Date: Sun Jan 9 14:16:37 2011 +0000 - Replaced old aliased resampling mode with a 65536x oversampling sinc resampler - Version is now 0.9.9.23 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C539 commit 4c0d2d92e6cc5c607a145f9fcbc8903e39327d1f Author: Chris Moeller Date: Mon Jan 3 14:33:17 2011 +0000 Add missing files to repository, delete old 7-Zip source folder git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C534 commit a9176165a2ccc56410b2004d2f5dd40b2052453a Author: Chris Moeller Date: Mon Nov 22 01:24:37 2010 +0000 - Changed a break to row behavior in DUMB, hopefully it doesn't break anything - Version is now 0.9.9.22 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C516 commit 1a9e0d4fd889dc9d17a5ebe97825be0cb2b7a273 Author: Chris Moeller Date: Sun Oct 3 06:17:34 2010 +0000 - Added range checking for XM global volume command - Version is now 0.9.9.20 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C490 commit ca554279a235b23c7f5f6ff9ce478a7aa7250dfe Author: Chris Moeller Date: Sat Aug 21 01:00:49 2010 +0000 - Fixed channel muting when switching or restarting songs, or when seeking - Version is now 0.9.9.19 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C467 commit 6e159ab89b5df27acf8a182a1ea5bf307ba8ff95 Author: Chris Moeller Date: Fri Mar 12 00:16:35 2010 +0000 - Fixed two bugs with pattern loops causing songs to loop forever - Version is now 0.9.9.13 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C383 commit 73bec70252bbed9b127d091f6dfded8c0a31116e Author: Chris Moeller Date: Fri Feb 12 20:33:49 2010 +0000 The Great Merge of 2010 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C370 commit 7c2cc8b01ae64355772be20f7d5edd4e30bd1e08 Author: Chris Moeller Date: Mon Jan 11 09:02:22 2010 +0000 {12/17/2009 2:12:36 AM}Reverted sinc interpolation until I feel like fixing it git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C365 commit eff0f2541daf739f21bb0662345915f4fa60354f Author: Chris Moeller Date: Mon Jan 11 09:02:22 2010 +0000 {12/17/2009 2:02:04 AM}Failed sinc interpolation for future review git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C364 commit 92fea5b475e37c39b28b88ab28b0dfbd8c899adf Author: Chris Moeller Date: Mon Jan 11 09:02:16 2010 +0000 {10/23/2009 9:27:50 PM}2009-10-24 05:13 UTC - kode54 - Restored old sample info tag reading method and made the new style optional - Version is now 0.9.9.8 2009-10-18 04:52 UTC - kode54 - Changed sigdata flags for AMF reader - Version is now 0.9.9.7 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C352 commit 52da4eb628a4a0f96495b42b75aac6b3a76d101a Author: Chris Moeller Date: Mon Jan 11 09:02:16 2010 +0000 {10/17/2009 6:03:36 AM}- Fixed a stupid bug in the AMF reader - Version is now 0.9.9.6 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C351 commit db718382dfb187fbdaa16a9dd4904c073fb8004d Author: Chris Moeller Date: Mon Jan 11 09:02:15 2010 +0000 {10/12/2009 11:53:02 AM~10/12/2009 11:53:04 AM}- Implemented DSMI AMF reader - Changed MO3 unpacker to use unmo3.dll - Version is now 0.9.9.5 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C348 commit 19527c25846226fe8d5479aaefc5bee0f3274d1a Author: Chris Moeller Date: Mon Jan 11 09:02:14 2010 +0000 {9/30/2009 4:11:06 AM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C347 commit d02aa3a3a3ab05acf6908411f8ecfcb46bf06f73 Author: Chris Moeller Date: Mon Jan 11 09:01:37 2010 +0000 {5/3/2009 5:29:28 PM}Underflow fix. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C262 commit da229930ce0f698c7443ae693e593d582748822f Author: Chris Moeller Date: Mon Jan 11 09:01:37 2010 +0000 {4/18/2009 4:30:02 PM}- Fixed another bug in xm_note_off with potential unknown files. - Version is now 0.9.8.5 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C259 commit df55c420128a38d58016ef9517707c37b15e67fc Author: Chris Moeller Date: Mon Jan 11 09:01:17 2010 +0000 {1/7/2009 4:53:48 PM}Removed inherited property sheet definitions. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C214 commit 1f89a5627cfc0c48aa13a1d6bcb060847119206b Author: Chris Moeller Date: Mon Jan 11 09:01:06 2010 +0000 {10/4/2008 3:54:34 PM}Fixed xm_note_off for when instrument number is out of range. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C201 commit 1f2e7f8d46858490d0bd6a5e4855a4c168a8a31f Author: Chris Moeller Date: Mon Jan 11 09:01:05 2010 +0000 {5/28/2008 5:29:34 PM}Fixed renderer for tempos greater than 255 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C198 commit 242c96c172f5203f595a4ba24f9649c2c975846f Author: Chris Moeller Date: Mon Jan 11 09:01:04 2010 +0000 {5/1/2008 3:06:24 PM~5/1/2008 3:07:24 PM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C196 commit 83a79f2c29b2601d78087aaa8e8363157e0b4ecb Author: Chris Moeller Date: Mon Jan 11 09:01:02 2010 +0000 {4/28/2008 3:21:58 PM~4/28/2008 3:22:14 PM}Converted projects for Visual Studio 2008. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C193 commit a78d4c613bc37d175db2fa90fc82f4b43e0ea470 Author: Chris Moeller Date: Mon Jan 11 09:00:59 2010 +0000 {1/27/2008 5:51:00 PM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C192 commit f230355b7f90105f13ca56343c4d2e2c1763d68f Author: Chris Moeller Date: Mon Jan 11 09:00:56 2010 +0000 {7/24/2007 3:48:08 PM}2007-01-26 22:50 UTC - kode54 - Moved IT S70-2 effects alongside the rest of S7x so they all trigger after paired notes. - Integrated note on/cut ramping with volume transition ramping to reduce setup/cleanup overhead of calling render_playing and the resampler functions for single samples. - Note on/cut ramping scaled from 7 sample logarithmic and 256 sample linear to .75ms and 5ms respectively, both linear. - Integrated the pattern looping changes from DUMB 0.9.3, since a few files seemed to be broken. The XM-only features still needed to be flagged for XM so they won't break MOD. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C181 commit 684f4672fe54d3e82a6912a8896cf812ca0acbdb Author: Chris Moeller Date: Mon Jan 11 09:00:42 2010 +0000 {1/24/2007 5:58:58 AM}Reduced the warning level of the Release target to 3 and enabled project database debugging info, for when the relevant measures are enabled in foo_dumb. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C166 commit 79c6f2cb09edeebcebd3e8e6422caf38720df82a Author: Chris Moeller Date: Mon Jan 11 09:00:42 2010 +0000 {1/24/2007 5:57:52 AM}2007-01-24 08:34 UTC - kode54 - Implemented 669 running effects correctly. 2007-01-22 18:54 UTC - kode54 - Implemented 669 running effects, nasty stuff. 2007-01-21 14:21 UTC - kode54 - Fixed a bug in IT renderer / get_true_pan that caused it to crash on IT files with instruments enabled upon hitting an invalid instrument change. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C165 commit 885cabebbfc78ad7a3e4c4ecf80b1b6045faa139 Author: Chris Moeller Date: Mon Jan 11 09:00:42 2010 +0000 {1/24/2007 5:56:54 AM}Corrected effects parsing and added global flag for the renderer. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C164 commit 41014790720378a31106ea18e27bcb2d45fcc2a5 Author: Chris Moeller Date: Mon Jan 11 09:00:42 2010 +0000 {1/24/2007 5:55:02 AM}2007-01-21 17:43 UTC - kode54 - XM reader now ignores sample header length, as Sk@le Tracker fills this with nonsense. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C163 commit a87eac09ccd72ca7257d6102835e8b94bfac6583 Author: Chris Moeller Date: Mon Jan 11 09:00:42 2010 +0000 {1/24/2007 5:54:32 AM}Removed unused variables. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C162 commit fa3a8d1cafd0db06dc748af6755355f101978ad4 Author: Chris Moeller Date: Mon Jan 11 09:00:41 2010 +0000 {1/24/2007 5:52:26 AM}2007-01-23 17:42 UTC - kode54 - Fixed IT reader decompression to support compression+delta on files created with 2.15 or newer. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C161 commit 8b1e1b01ceea3d5b7cb5fa2a781a883ccfbe44af Author: Chris Moeller Date: Mon Jan 11 09:00:26 2010 +0000 {11/29/2006 6:01:06 AM}2006-10-12 06:28 UTC - kode54 - STM reader checks for more values after the song name, reports the correct order list size, and ignores samples which are shorter than four bytes or have a default volume of zero. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C137 commit cfb81dff3e9a09bd943bec1a814f35c41432c356 Author: Chris Moeller Date: Mon Jan 11 09:00:26 2010 +0000 {11/29/2006 6:00:28 AM}2006-11-01 00:50 UTC - kode54 - IT renderer now cuts existing notes when it reaches a note where the instrument references an invalid sample. (jumping under trees.it) 2006-10-14 08:33 UTC - kode54 - IT renderer pattern loop processor now resets the rows played to clear table per channel regardless of whether order changed since last loop start was initiated. This is correct, since two pattern loop starts in a row means that a loop will never jump to the first loop point. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C136 commit 4f9a59e413f0cf404b136a7a1696968ecddd8372 Author: Chris Moeller Date: Mon Jan 11 09:00:25 2010 +0000 {11/29/2006 5:59:20 AM}2006-11-01 00:50 UTC - kode54 - Resamplers now return immediately if the fixed point delta is zero. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C135 commit 3be9ce486cf67827f18346b54d83478d487abd40 Author: Chris Moeller Date: Mon Jan 11 09:00:22 2010 +0000 {10/6/2006 9:42:18 PM~10/6/2006 9:42:20 PM}2006-10-07 05:24 UTC - kode54 - Simplified volume ramping update code, reducing the size of the resampler code considerably. - Bumped the volume ramping precision to 24 bits of fraction precision, which is needed by Sweetsin.xm. - Moved sample rate reporting to dynamic info as requested by Peter, since it's not a property of the files themselves, but user configurable. - Version is now 0.9.8.1 2006-10-07 03:42 UTC - kode54 - Changed DSMF sample loader to ignore unknown flags instead of blowing an error. 2006-09-25 17:39 UTC - kode54 - Added hack to MOD loader for when sample start is specified in bytes instead of words. 2006-09-19 15:05 UTC - kode54 - Shuffled finetune calculation into the correct position, immediately applied as delta is calculated from note. - Promoted IT_SAMPLE finetune property to signed short as char is insufficient for full semitone range. (+/- 256) - Changed resampler to use full 64-bit comparison for todo variable range checking which should hopefully eliminate any further problems with pitch slides which go out of range. - Version is now 0.9.8 git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C123 commit 719dbbe38317512e9aabb2654953e9ba226caaf6 Author: Chris Moeller Date: Mon Jan 11 09:00:09 2010 +0000 {6/16/2006 12:00:56 AM}- Changed Amiga clock rate and divisor constant - Added finetune property to IT_SAMPLE git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C110 commit 7b35d20e52156ddf5eb73015f43f6787f520bcf5 Author: Chris Moeller Date: Mon Jan 11 09:00:09 2010 +0000 {6/13/2006 4:52:42 AM}Removed a line of unneeded code. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C108 commit 691d717ba6d2bee9c477e971f157f57bf051ed8b Author: Chris Moeller Date: Mon Jan 11 09:00:08 2010 +0000 {6/13/2006 4:52:18 AM}2006-06-10 18:10 UTC - kode54 - Fixed volume ramping. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C107 commit bbee7ab76b3e04fa2ae1cff8a23f9a61e214c6bf Author: Chris Moeller Date: Mon Jan 11 09:00:08 2010 +0000 {6/9/2006 9:34:08 AM~6/9/2006 9:34:10 AM}Ported changes over from DUMB 0.9.3. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C106 commit 5ed3b0ec86820172d2cff9a19529e60a9c39a93a Author: Chris Moeller Date: Mon Jan 11 09:00:03 2010 +0000 {6/8/2006 7:36:56 AM}2006-06-03 02:13 UTC - kode54 - Implemented ASYLUM Music Format support. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C102 commit cf89f65a58886db9c0c274a7032a50e61911ace8 Author: Chris Moeller Date: Mon Jan 11 09:00:03 2010 +0000 {6/8/2006 7:36:18 AM}2006-06-02 21:20 UTC - kode54 - IT renderer now supports pattern jump and break to row on the same row. (coffee-blues 3.mod) 2006-06-02 20:25 UTC - kode54 - Empty pattern scanner now returns the correct value for completely empty pattern structures, and also checks for lists of empty rows. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C101 commit 14e15b8bfdf9d09e0a884d899641af5ad09de82d Author: Chris Moeller Date: Mon Jan 11 09:00:02 2010 +0000 {5/31/2006 8:37:04 PM}2006-05-31 23:15 UTC - kode54 - Implemented STM support. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C96 commit 82f65ee68c0d49d7419769992da22131ac6d48ec Author: Chris Moeller Date: Mon Jan 11 09:00:01 2010 +0000 {5/31/2006 8:36:40 PM}2006-05-30 00:04 UTC - kode54 - XM reader now truncates instrument envelope lengths to 12, and performs some basic envelope loop checking, similar to Open ModPlug Tracker. (revive_nimnone.xm) git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C95 commit 1dbeaf67c98af889a5a71fec6ad1e14e470461ac Author: Chris Moeller Date: Mon Jan 11 09:00:01 2010 +0000 {5/31/2006 8:36:12 PM}2006-05-30 03:57 UTC - kode54 - IT reader works around a broken file that has several of the instruments offset by two bytes from their indicated file offsets. Since the hack only checks for offset by two null bytes, it also assumes that the two bytes it can't read from the end are also zero. (bz_ult9.it) - IT reader treats null instrument/sample/pattern offsets as empty items. (flight2.it, sherri.it) git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C94 commit 2b2f154894d691a18ede7740a2c319d90b47a14d Author: Chris Moeller Date: Mon Jan 11 09:00:01 2010 +0000 {5/31/2006 8:35:22 PM}2006-06-01 00:47 UTC - kode54 - STM reader reads effects properly now. 2006-05-31 23:15 UTC - kode54 - Implemented STM support. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C93 commit 9d44f7d96637019c3d9ff0f2186a7886fac466b5 Author: Chris Moeller Date: Mon Jan 11 09:00:01 2010 +0000 {5/31/2006 8:34:58 PM}2006-05-31 23:15 UTC - kode54 - Implemented STM support. git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C92 commit d8680ee4bdafc15a97bab686bb61597289fedec1 Author: Chris Moeller Date: Mon Jan 11 09:00:00 2010 +0000 {5/27/2006 1:41:32 PM}2006-05-27 22:40 UTC - kode54 - S3M reader defaults to maximum (128) global volume when the header value is either zero or greater than 64. (darkness2.s3m) git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C88 commit 4e1db2adb05e53c50fe38102676889c22a4f2e66 Author: Chris Moeller Date: Mon Jan 11 08:59:57 2010 +0000 {5/26/2006 10:58:10 PM~5/26/2006 10:58:12 PM}2006-05-22 21:44 UTC - kode54 - XM reader now supports up to 256 instruments, even though FT2 only supports up to 128. ModPlug Tracker again. 2006-05-22 18:43 UTC - kode54 - S3M reader was using the incorrect index into component for sample packing when reading sample data. Was using n, should have been m. 2006-05-22 17:26 UTC - kode54 - IT renderer may have a bug with its time_lost / loop handling. Switchover from sustain loop would compound time_lost onto itself for every note-off. I'm not sure if this crap is even doing the right thing, especially in the case of a sample with a sustain loop, but no main loop. Working around for now by zeroing time_lost after note-off. (hall8.it) - S3M reader ignores effects outside of 1-25 range so nothing can hit internal effects which are XM or PTM only. (N4.S3M) - IT reader now supports ModPlug Tracker extensions for up to 4000 samples and mapping them with instruments. (hallowe.it.it) - XM reader now supports instrument vibrato 4, random. Yet another ModPlug extension. (hcw-st.xm) 2006-05-21 02:11 UTC - kode54 - S3M reader correctly reads all 24 bits of the sample memory segment offset, fixing at least one file with >1MB of sample data (d-t-x_x.s3m) - XM reader stops reading instruments when it has at least one valid instrument and encounters an error, fixing at least one file with too high instrument count in the header (drx-chri.xm) - IT reader ignores instrument header signatures, since there seem to be files with bad signatures on unused/filler instruments (dsouls.it) - MOD reader can now be restricted to handling 31 sample files with legal/known signatures only, so frontend can fall back on restricted MOD loading for files with incorrect extensions (dreamer_0g.s3m) 2006-05-20 xx:xx UTC - kode54 - Modified silence skipping to hack around some "S L O W" effects crap and a misused break to row effect git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C84 commit 3527875388468d5343c7958d4781f250d4c333d6 Author: Chris Moeller Date: Mon Jan 11 08:59:17 2010 +0000 {11/28/2005 4:51:00 AM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C54 commit 95afd4ca875c3f3983de167afcc7deda682a8c8d Author: Chris Moeller Date: Mon Jan 11 08:59:11 2010 +0000 {11/20/2005 7:14:42 PM~11/20/2005 7:14:44 PM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C50 commit dae50fa2a1a66a8658827483bdc8a7aae48e019b Author: Chris Moeller Date: Mon Jan 11 08:59:05 2010 +0000 {11/6/2005 9:04:04 PM}Added generic RIFF module handler and AM/AMFF format readers git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C46 commit 8b2fadaf5a88171d9d94782c9a28e45f4ed10c92 Author: Chris Moeller Date: Mon Jan 11 08:59:03 2010 +0000 {10/30/2005 1:56:28 AM~10/30/2005 1:56:40 AM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C43 commit 9db1273c6431216946c2c30e71e2c90859635744 Author: Chris Moeller Date: Mon Jan 11 08:58:43 2010 +0000 {10/13/2005 2:19:30 AM~10/13/2005 2:22:22 AM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C22 commit b844f7ce65c15ee70426640de1802ba97d409dec Author: Chris Moeller Date: Mon Jan 11 08:58:42 2010 +0000 {10/13/2005 1:58:16 AM}Arpeggio fix for FastTracker 2 bug git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C21 commit ef97e29d06fdf5c3b9584eeacee58fd0914a0007 Author: Chris Moeller Date: Mon Jan 11 08:58:42 2010 +0000 {10/12/2005 5:04:42 PM}Emit format version info git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C20 commit f9fef91057834185b03a4cf8418bdf859b72b092 Author: Chris Moeller Date: Mon Jan 11 08:58:42 2010 +0000 {10/12/2005 4:52:14 PM}XM format v1.02 and v1.03 support git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C19 commit 9acd29b47bd6aaae698e958bc1f4906ead27e2cb Author: Chris Moeller Date: Mon Jan 11 08:58:41 2010 +0000 {10/11/2005 4:36:06 PM}Partial XM format v1.02 implementation ( incomplete ) git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C15 commit 00b26550e65da3350f684ebc19be57050a2cca1a Author: Chris Moeller Date: Mon Jan 11 08:58:41 2010 +0000 {10/11/2005 4:16:34 PM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C14 commit 61d10a21c142cb717bc25f03d5772b3cb4e09529 Author: Chris Moeller Date: Mon Jan 11 08:58:33 2010 +0000 {10/11/2005 3:57:38 PM~10/11/2005 3:58:38 PM} git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C13 --- dumb/CMakeLists.txt | 162 +- dumb/ChangeLog | 2555 -------------- dumb/cmake/CMakeLists.txt | 118 + dumb/cmake/readme.txt | 30 + dumb/docs/deprec.txt | 281 -- dumb/docs/duhspecs.txt | 296 -- dumb/docs/dumb.txt | 1699 ---------- dumb/docs/dumbfull.txt | 1717 ---------- dumb/docs/faq.txt | 264 -- dumb/docs/fnptr.txt | 113 - dumb/docs/howto.txt | 845 ----- dumb/docs/modplug.txt | 137 - dumb/docs/ptr.txt | 129 - dumb/docs/tutorial.txt | 94 - dumb/examples/dumb.ini | 44 - dumb/examples/dumb2wav.c | 481 --- dumb/examples/dumbout.c | 404 --- dumb/examples/dumbplay.c | 238 -- dumb/examples/playduh.c | 169 - dumb/include/dumb.h | 92 +- dumb/include/internal/aldumb.h | 27 + dumb/include/internal/barray.h | 21 + dumb/include/internal/blip_buf.h | 77 - dumb/include/internal/dumbfile.h | 13 + dumb/include/internal/it.h | 43 +- dumb/include/internal/lpc.h | 30 + dumb/include/internal/resampler.h | 58 + dumb/include/internal/riff.h | 7 +- dumb/include/internal/stack_alloc.h | 113 + dumb/include/internal/tarray.h | 31 + dumb/licence.txt | 141 +- dumb/prj/.gitignore | 3 + dumb/prj/dumb/dumb.pro | 130 + dumb/readme.txt | 962 +++--- dumb/release.txt | 1029 +++--- dumb/src/core/dumbfile.c | 35 +- dumb/src/core/rendsig.c | 10 +- dumb/src/helpers/barray.c | 30 + dumb/src/helpers/blip_buf.c | 354 -- dumb/src/helpers/lpc.c | 320 ++ dumb/src/helpers/memfile.c | 35 +- dumb/src/helpers/resamp2.inc | 41 +- dumb/src/helpers/resamp3.inc | 187 +- dumb/src/helpers/resample.c | 129 +- dumb/src/helpers/resample.inc | 219 +- dumb/src/helpers/resampler.c | 1512 +++++++++ dumb/src/helpers/riff.c | 45 +- dumb/src/helpers/stdfile.c | 79 +- dumb/src/helpers/tarray.c | 175 + dumb/src/it/filter.cpp | 570 ++-- dumb/src/it/itmisc.c | 2 + dumb/src/it/itread.c | 238 +- dumb/src/it/itrender.c | 1636 ++++----- dumb/src/it/loadamf.c | 42 + dumb/src/it/loadamf2.c | 34 + dumb/src/it/loadany.c | 38 + dumb/src/it/loadany2.c | 29 + dumb/src/it/loadmod.c | 4 +- dumb/src/it/loadmod2.c | 4 +- dumb/src/it/read669.c | 23 +- dumb/src/it/read6692.c | 29 + dumb/src/it/readam.c | 372 ++- dumb/src/it/readamf.c | 557 ++++ dumb/src/it/readamf2.c | 29 + dumb/src/it/readany.c | 132 + dumb/src/it/readany2.c | 29 + dumb/src/it/readasy.c | 24 +- dumb/src/it/readdsmf.c | 143 +- dumb/src/it/readmod.c | 337 +- dumb/src/it/readmod2.c | 4 +- dumb/src/it/readmtm.c | 24 +- dumb/src/it/readokt.c | 20 +- dumb/src/it/readoldpsm.c | 98 +- dumb/src/it/readpsm.c | 58 +- dumb/src/it/readptm.c | 35 +- dumb/src/it/readriff.c | 38 +- dumb/src/it/reads3m.c | 137 +- dumb/src/it/readstm.c | 110 +- dumb/src/it/readxm.c | 128 +- dumb/src/sigtypes/combine.c | 243 -- dumb/src/sigtypes/sample.c | 340 -- dumb/src/sigtypes/sequence.c | 592 ---- dumb/src/sigtypes/sterpan.c | 206 -- dumb/src/tools/it/load_it.cpp | 824 ----- dumb/src/tools/it/modulus.h | 193 -- dumb/src/tools/it/typedef.hpp | 3 - dumb/todo.txt | 141 - dumb/vc6/dumb/.gitignore | 3 + dumb/vc6/dumb/dumb.vcproj | 2007 +++++++++++ dumb/vc6/dumb/dumb.vcxproj | 218 ++ dumb/vc6/dumb/dumb.vcxproj.filters | 332 ++ dumb/vc6/dumb_static/dumb_static.vcproj | 4077 ++++++++++++----------- src/sound/music_dumb.cpp | 161 +- wadsrc/static/menudef.txt | 17 +- 94 files changed, 11855 insertions(+), 18150 deletions(-) delete mode 100644 dumb/ChangeLog create mode 100644 dumb/cmake/CMakeLists.txt create mode 100644 dumb/cmake/readme.txt delete mode 100644 dumb/docs/deprec.txt delete mode 100644 dumb/docs/duhspecs.txt delete mode 100644 dumb/docs/dumb.txt delete mode 100644 dumb/docs/dumbfull.txt delete mode 100644 dumb/docs/faq.txt delete mode 100644 dumb/docs/fnptr.txt delete mode 100644 dumb/docs/howto.txt delete mode 100644 dumb/docs/modplug.txt delete mode 100644 dumb/docs/ptr.txt delete mode 100644 dumb/docs/tutorial.txt delete mode 100644 dumb/examples/dumb.ini delete mode 100644 dumb/examples/dumb2wav.c delete mode 100644 dumb/examples/dumbout.c delete mode 100644 dumb/examples/dumbplay.c delete mode 100644 dumb/examples/playduh.c create mode 100644 dumb/include/internal/aldumb.h delete mode 100644 dumb/include/internal/blip_buf.h create mode 100644 dumb/include/internal/dumbfile.h create mode 100644 dumb/include/internal/lpc.h create mode 100644 dumb/include/internal/resampler.h create mode 100644 dumb/include/internal/stack_alloc.h create mode 100644 dumb/include/internal/tarray.h create mode 100644 dumb/prj/.gitignore create mode 100644 dumb/prj/dumb/dumb.pro delete mode 100644 dumb/src/helpers/blip_buf.c create mode 100644 dumb/src/helpers/lpc.c create mode 100644 dumb/src/helpers/resampler.c create mode 100644 dumb/src/helpers/tarray.c create mode 100644 dumb/src/it/loadamf.c create mode 100644 dumb/src/it/loadamf2.c create mode 100644 dumb/src/it/loadany.c create mode 100644 dumb/src/it/loadany2.c create mode 100644 dumb/src/it/readamf.c create mode 100644 dumb/src/it/readamf2.c create mode 100644 dumb/src/it/readany.c create mode 100644 dumb/src/it/readany2.c delete mode 100644 dumb/src/sigtypes/combine.c delete mode 100644 dumb/src/sigtypes/sample.c delete mode 100644 dumb/src/sigtypes/sequence.c delete mode 100644 dumb/src/sigtypes/sterpan.c delete mode 100644 dumb/src/tools/it/load_it.cpp delete mode 100644 dumb/src/tools/it/modulus.h delete mode 100644 dumb/src/tools/it/typedef.hpp delete mode 100644 dumb/todo.txt create mode 100644 dumb/vc6/dumb/.gitignore create mode 100644 dumb/vc6/dumb/dumb.vcproj create mode 100644 dumb/vc6/dumb/dumb.vcxproj create mode 100644 dumb/vc6/dumb/dumb.vcxproj.filters diff --git a/dumb/CMakeLists.txt b/dumb/CMakeLists.txt index 9c1a69a79f..c1e0b6df2f 100644 --- a/dumb/CMakeLists.txt +++ b/dumb/CMakeLists.txt @@ -5,13 +5,6 @@ make_release_only() include( CheckFunctionExists ) include( CheckCXXCompilerFlag ) -# DUMB is much slower in a Debug build than a Release build, so we force a Release -# build here, since we're not maintaining DUMB, only using it. -# Comment out the below line to allow Debug builds. -if( NOT CMAKE_BUILD_TYPE MATCHES "Release" ) - set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -endif( NOT CMAKE_BUILD_TYPE MATCHES "Release" ) - set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DDEBUGMODE=1" ) if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE ) @@ -26,82 +19,93 @@ endif( NOT ITOA_EXISTS ) include_directories( include ) add_library( dumb - src/core/atexit.c - src/core/duhlen.c - src/core/duhtag.c - src/core/dumbfile.c - src/core/loadduh.c - src/core/makeduh.c - src/core/rawsig.c - src/core/readduh.c - src/core/register.c - src/core/rendduh.c - src/core/rendsig.c src/core/unload.c - src/helpers/barray.c - src/helpers/blip_buf.c - src/helpers/clickrem.c - src/helpers/memfile.c - src/helpers/resample.c - src/helpers/riff.c - src/helpers/sampbuf.c - src/helpers/silence.c + src/core/rendsig.c + src/core/rendduh.c + src/core/register.c + src/core/readduh.c + src/core/rawsig.c + src/core/makeduh.c + src/core/loadduh.c + src/core/dumbfile.c + src/core/duhtag.c + src/core/duhlen.c + src/core/atexit.c src/helpers/stdfile.c + src/helpers/silence.c + src/helpers/sampbuf.c + src/helpers/riff.c + src/helpers/resample.c + src/helpers/memfile.c + src/helpers/clickrem.c + src/helpers/barray.c + src/helpers/tarray.c src/it/filter.cpp - src/it/itload.c - src/it/itload2.c - src/it/itmisc.c - src/it/itorder.c - src/it/itread.c - src/it/itread2.c - src/it/itrender.c - src/it/itunload.c - src/it/load669.c - src/it/load6692.c - src/it/loadasy.c - src/it/loadasy2.c - src/it/loadmod.c - src/it/loadmod2.c - src/it/loadmtm.c - src/it/loadmtm2.c - src/it/loadokt.c - src/it/loadokt2.c - src/it/loadoldpsm.c - src/it/loadoldpsm2.c - src/it/loadpsm.c - src/it/loadpsm2.c - src/it/loadptm.c - src/it/loadptm2.c - src/it/loadriff.c - src/it/loadriff2.c - src/it/loads3m.c - src/it/loads3m2.c - src/it/loadstm.c - src/it/loadstm2.c - src/it/loadxm.c - src/it/loadxm2.c - src/it/ptmeffect.c - src/it/read669.c - src/it/read6692.c - src/it/readam.c - src/it/readasy.c - src/it/readdsmf.c - src/it/readmod.c - src/it/readmod2.c - src/it/readmtm.c - src/it/readokt.c - src/it/readokt2.c - src/it/readoldpsm.c - src/it/readpsm.c - src/it/readptm.c - src/it/readriff.c - src/it/reads3m.c - src/it/reads3m2.c - src/it/readstm.c - src/it/readstm2.c - src/it/readxm.c + src/it/xmeffect.c src/it/readxm2.c - src/it/xmeffect.c ) + src/it/readxm.c + src/it/readstm2.c + src/it/readstm.c + src/it/reads3m2.c + src/it/reads3m.c + src/it/readriff.c + src/it/readptm.c + src/it/readpsm.c + src/it/readoldpsm.c + src/it/readokt2.c + src/it/readokt.c + src/it/readmtm.c + src/it/readmod2.c + src/it/readmod.c + src/it/readdsmf.c + src/it/readasy.c + src/it/readamf2.c + src/it/readamf.c + src/it/readam.c + src/it/read6692.c + src/it/read669.c + src/it/ptmeffect.c + src/it/loadxm2.c + src/it/loadxm.c + src/it/loadstm2.c + src/it/loadstm.c + src/it/loads3m2.c + src/it/loads3m.c + src/it/loadriff2.c + src/it/loadriff.c + src/it/loadptm2.c + src/it/loadptm.c + src/it/loadpsm2.c + src/it/loadpsm.c + src/it/loadoldpsm2.c + src/it/loadoldpsm.c + src/it/loadokt2.c + src/it/loadokt.c + src/it/loadmtm2.c + src/it/loadmtm.c + src/it/loadmod2.c + src/it/loadmod.c + src/it/loadasy2.c + src/it/loadasy.c + src/it/loadamf2.c + src/it/loadamf.c + src/it/load6692.c + src/it/load669.c + src/it/itunload.c + src/it/itrender.c + src/it/itread2.c + src/it/itread.c + src/it/itorder.c + src/it/itmisc.c + src/it/itload2.c + src/it/itload.c + src/it/readany.c + src/it/loadany2.c + src/it/loadany.c + src/it/readany2.c + src/helpers/resampler.c + src/helpers/lpc.c +) target_link_libraries( dumb ) if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) diff --git a/dumb/ChangeLog b/dumb/ChangeLog deleted file mode 100644 index d8481e98a0..0000000000 --- a/dumb/ChangeLog +++ /dev/null @@ -1,2555 +0,0 @@ -======================= foo_dumb part ================================= - -2007-01-26 23:42 UTC - kode54 -- Added CPUID specialization for it_filter() so I can release it. - -2007-01-26 22:50 UTC - kode54 -- Moved IT S70-2 effects alongside the rest of S7x so they all trigger after - paired notes. -- Integrated note on/cut ramping with volume transition ramping to reduce - setup/cleanup overhead of calling render_playing and the resampler functions - for single samples. -- Note on/cut ramping scaled from 7 sample logarithmic and 256 sample linear to - .75ms and 5ms respectively, both linear. -- Integrated the pattern looping changes from DUMB 0.9.3, since a few files - seemed to be broken. The XM-only features still needed to be flagged for XM - so they won't break MOD. -- Implemented SSE replacement for it_filter() which is actually twice as fast. - -2007-01-24 09:37 UTC - kode54 -- Version is now 0.9.8.3 - -2007-01-24 08:34 UTC - kode54 -- Implemented 669 running effects correctly. - -2007-01-23 17:42 UTC - kode54 -- Fixed IT reader decompression to support compression+delta on files created - with 2.15 or newer. - -2007-01-22 18:54 UTC - kode54 -- Implemented 669 running effects, nasty stuff. - -2007-01-22 16:40 UTC - kode54 -- Fixed MOD loading step in case any files fall through another loader first. - (if asked twice.mod) - -2007-01-21 19:47 UTC - kode54 -- Implemented crappy fixed end of sample volume ramping. - -2007-01-21 17:43 UTC - kode54 -- XM reader now ignores sample header length, as Sk@le Tracker fills this with - nonsense. - -2007-01-21 14:21 UTC - kode54 -- Fixed a bug in IT renderer / get_true_pan that caused it to crash on IT files - with instruments enabled upon hitting an invalid instrument change. - -2006-12-26 06:41 UTC - kode54 -- Fixed sample rate reporting for when extra dynamic info is turned off. - -2006-11-01 00:50 UTC - kode54 -- Resamplers now return immediately if the fixed point delta is zero. -- IT renderer now cuts existing notes when it reaches a note where the instrument - references an invalid sample. (jumping under trees.it) -- Version is now 0.9.8.2 - -2006-10-14 08:33 UTC - kode54 -- IT renderer pattern loop processor now resets the rows played to clear table - per channel regardless of whether order changed since last loop start was - initiated. This is correct, since two pattern loop starts in a row means that - a loop will never jump to the first loop point. - -2006-10-12 06:28 UTC - kode54 -- STM reader checks for more values after the song name, reports the correct - order list size, and ignores samples which are shorter than four bytes or - have a default volume of zero. - -2006-10-08 03:51 UTC - kode54 -- Added CP437 graphics to text conversion functions. - -2006-10-07 05:24 UTC - kode54 -- Simplified volume ramping update code, reducing the size of the resampler code - considerably. -- Bumped the volume ramping precision to 24 bits of fraction precision, which is - needed by Sweetsin.xm. -- Moved sample rate reporting to dynamic info as requested by Peter, since it's - not a property of the files themselves, but user configurable. -- Version is now 0.9.8.1 - -2006-10-07 03:42 UTC - kode54 -- Changed DSMF sample loader to ignore unknown flags instead of blowing an error. - -2006-09-25 17:39 UTC - kode54 -- Added hack to MOD loader for when sample start is specified in bytes instead of - words. - -2006-09-19 15:05 UTC - kode54 -- Shuffled finetune calculation into the correct position, immediately applied - as delta is calculated from note. -- Promoted IT_SAMPLE finetune property to signed short as char is insufficient - for full semitone range. (+/- 256) -- Changed resampler to use full 64-bit comparison for todo variable range checking - which should hopefully eliminate any further problems with pitch slides which go - out of range. -- Version is now 0.9.8 - -2006-06-16 19:10 UTC - kode54 -- Fixed MOD loader FLT8 handler so it halves the order list after it's allocated - and loaded. -- Unified renderer and loop restarting for playback and seeking, and made seeking - abortable. - -2006-06-16 09:12 UTC - kode54 -- Fixed PSM subsong info reporting. - -2006-06-15 21:23 UTC - kode54 -- Added finetune property to IT_SAMPLE, modified ASY, MOD, MTM, old PSM, and XM - to use it instead of adjusting the C5 speed, so that finetune effect overrides - rather than compounding sample finetune. - -2006-06-10 18:10 UTC - kode54 -- Fixed volume ramping. - -2006-06-09 16:48 UTC - kode54 -- Ported most of DUMB 0.9.3 over, except for the conflicting pattern loop change - -2006-06-03 02:13 UTC - kode54 -- Implemented ASYLUM Music Format support. - -2006-06-02 22:06 UTC - kode54 -- Fixed finite looping for speed 0 and global volume 0 triggers. -- Reset loop count when seeking backwards. - -2006-06-02 21:20 UTC - kode54 -- IT renderer now supports pattern jump and break to row on the same row. - (coffee-blues 3.mod) -- Version is now 0.9.7.5 - -2006-06-02 20:25 UTC - kode54 -- Empty pattern scanner now returns the correct value for completely empty - pattern structures, and also checks for lists of empty rows. - -2006-06-01 00:47 UTC - kode54 -- STM reader reads effects properly now. - -2006-05-31 23:15 UTC - kode54 -- Implemented STM support. -- Version is now 0.9.7.4 - -2006-05-31 20:12 UTC - kode54 -- Finished implementing working fading support. - -2006-05-31 19:09 UTC - kode54 -- Implemented fading support. - -2006-05-31 18:31 UTC - kode54 -- Removed context dialog from resources. - -2006-05-30 03:57 UTC - kode54 -- IT reader works around a broken file that has several of the instruments - offset by two bytes from their indicated file offsets. Since the hack - only checks for offset by two null bytes, it also assumes that the two - bytes it can't read from the end are also zero. (bz_ult9.it) -- IT reader treats null instrument/sample/pattern offsets as empty items. - (flight2.it, sherri.it) - -2006-05-30 00:04 UTC - kode54 -- XM reader now truncates instrument envelope lengths to 12, and performs - some basic envelope loop checking, similar to Open ModPlug Tracker. - (revive_nimnone.xm) - -2006-05-27 22:40 UTC - kode54 -- S3M reader defaults to maximum (128) global volume when the header value is - either zero or greater than 64. (darkness2.s3m) - -2006-05-23 00:06 UTC - kode54 -- Changed module format load order priority to check all signatures before - attempting MOD now, and then only 15 sample module for MOD/MDZ. This should - hopefully cut back on problems with N formats renamed to MOD. -- Version is now 0.9.7.4 - -2006-05-22 21:44 UTC - kode54 -- XM reader now supports up to 256 instruments, even though FT2 only - supports up to 128. ModPlug Tracker again. (no_utndgs2.xm) -- g_open_module now supports other files misnamed as .MOD (hilse.mod .it) - -2006-05-22 18:43 UTC - kode54 -- XM reader now ignores when instrument header contains a sample header size - of 0, when it should be 0x28. (neptune_*.xm) -- S3M reader was using the incorrect index into component for sample packing - when reading sample data. Was using n, should have been m. - -2006-05-22 17:26 UTC - kode54 -- IT renderer may have a bug with its time_lost / loop handling. Switchover - from sustain loop would compound time_lost onto itself for every note-off. - I'm not sure if this crap is even doing the right thing, especially in the - case of a sample with a sustain loop, but no main loop. Working around for - now by zeroing time_lost after note-off. (hall8.it) -- S3M reader ignores effects outside of 1-25 range so nothing can hit - internal effects which are XM or PTM only. (N4.S3M) -- IT reader now supports ModPlug Tracker extensions for up to 4000 samples - and mapping them with instruments. (hallowe.it.it) -- XM reader now supports instrument vibrato 4, random. Yet another ModPlug - extension. (hcw-st.xm) - -2006-05-21 02:11 UTC - kode54 -- S3M reader correctly reads all 24 bits of the sample memory segment - offset, fixing at least one file with >1MB of sample data (d-t-x_x.s3m) -- XM reader stops reading instruments when it has at least one valid - instrument and encounters an error, fixing at least one file with - too high instrument count in the header (drx-chri.xm) -- IT reader ignores instrument header signatures, since there seem to - be files with bad signatures on unused/filler instruments (dsouls.it) -- MOD reader can now be restricted to handling 31 sample files with - legal/known signatures only, so frontend can fall back on restricted - MOD loading for files with incorrect extensions (dreamer_0g.s3m) -- Version is now 0.9.7.2 - -2006-05-20 xx:xx UTC - kode54 -- Modified silence skipping to hack around some "S L O W" effects crap - and a misused break to row effect - -2006-03-27 07:51 UTC - kode54 -- Changed RIFF AMFF loader to ignore one unknown sample flag and - be a little more flexible with the INST chunk handler -- Version is now 0.9.7.1 - -2005-11-07 05:00 UTC - kode54 -- Added generic RIFF module handler and AM/AMFF format readers -- Added J2B unpacker -- Version is now 0.9.7 - -2005-10-13 09:02 UTC - kode54 -- Implemented XM format v1.02 and v1.03 support -- Arpeggio fix for FastTracker 2 bug, I think - -2005-06-04 00:59 UTC - kode54 -- Implemented ADPCM4 in S3M reader -- Moved ADPCM4 unpacking code to its own function in itread.c, declared in internal/it.h -- Version is now 0.9.6.3 - -2005-06-01 00:23 UTC - kode54 -- Added safety check to MOD ADPCM4 unpacking code, in case of odd lengths -- Implemented ADPCM4 in XM reader -- Implemented ADPCM4 in IT reader -- Version is now 0.9.6.2 - -2005-05-29 16:49 UTC - kode54 -- Implemented support for modplug packed samples in MOD reader (meh) -- Version is now 0.9.6.1 - -2005-05-20 06:08 UTC - kode54 -- UMX handler now ignores file type (SpaceMarines.umx, Starseek.umx report "s3m" but contain IT) -- UMX stops at the first matching resource (Kran32.umx, contains two Music entries for the same block of data) -- Version is now 0.9.6 - -2005-01-27 21:02 UTC - kode54 -- Quick bug fix for Repeat One, seek() should be clearing eof flag -- Version is now 0.9.5.8 - -2005-01-17 16:25 UTC - kode54 -- XM pattern loader is now more lenient with truncated pattern data -- Version is now 0.9.5.7 - -2005-01-12 20:19 UTC - kode54 -- Added .mod/.mdz check to track indexer in case of MOD with "PSM " in song name :) -- Version is now 0.9.5.6 - -2005-01-12 19:11 UTC - kode54 -- Fixed a bug in 669 loader -- Moved .mod/.mdz loading ahead of header checks, in case of song titles which trick one of the loader conditions - -2004-10-29 02:47 UTC - kode54 -- Touched up .mod sample truncation handling again -- Version is now 0.9.5.5 - -2004-10-21 06:02 UTC - kode54 -- Fixed a division by zero case in dumb_resample, which resulted from a sample with zero C5 speed -- Version is now 0.9.5.4 - -2004-10-18 04:50 UTC - kode54 -- Corrected 669 tempo and speed handling, although the tone portamento still seems to be a bit off -- Reenabled down ramping, always using 1/512s logarithmic decay -- Version is now 0.9.5.3 - -2004-10-17 06:25 UTC - kode54 -- Disabled the down ramping code, as the old click remover seems to behave better in more places - -2004-10-17 00:26 UTC - kode54 -- Added file remaining hack to skip remaining but unused patterns in Iguana's demo MODs -- Modified MOD buffered reader and sample data loader to avoid unnecessary dumbfile calls when size of operation is zero -- Version is now 0.9.5.2 - -2004-10-16 23:22 UTC - kode54 -- Changed sample truncation behavior in MOD and 669 to be consistent -- Added support for a couple of obscure MOD signatures used by some PC demo, just to support their delta samples natively -- Version is now 0.9.5.1 - -2004-10-16 19:44 UTC - kode54 -- 669 loader is lenient with truncated sample data -- MTM reader is lenient with track numbers which are out of range -- Version is now 0.9.5 - -2004-10-16 18:50 UTC - kode54 -- Overhauled volume ramping to an acceptable state -- Tweaked XM amiga vibrato a bit, should be more correct now - -2004-10-14 21:58 UTC - kode54 -- Set sample offset has memory even in MOD -- Version is now 0.9.4 - -2004-10-12 06:14 UTC - kode54 -- Tweaked around with volume ramping crap some more. Still a mess, still nowhere near perfect. Bleh. -- Added per-sample resampling quality limits -- Added auto chip sample detection - -2004-10-10 07:23 UTC - kode54 -- Implemented volume change ramping as well... Holy shit, what a fucking mess. - -2004-10-09 23:50 UTC - kode54 -- Implemented volume ramping -- XM channel volume/envelopes/panning should not be reset when instrument change is paired with note-off - -2004-10-06 22:08 UTC - kode54 -- Fixed volume swing -- Fixed logarithmic vibrato so it only activates on XM w/ Amiga frequency table -- Version is now 0.9.3.6 - -2004-10-06 06:21 UTC - kode54 -- Added NSMS signature for 4ch 31s module -- Changed MOD sample change behavior again, in a way that doesn't break Intro-Music.mod -- Version is now 0.9.3.5 - -2004-10-06 01:23 UTC - kode54 -- Sample offset is no longer reapplied during pattern breaks -- Version is now 0.9.3.4 - -2004-10-05 23:57 UTC - kode54 -- MOD/XM pattern break effect >63 breaks to row 0 - -2004-10-05 23:34 UTC - kode54 -- Implemented FastTracker 2 logarithmic vibrato -- Implemented FastTracker 2 ramp up/down and square wave forms... Maybe it would be faster if I calculated that crap - instead of using tables. - -2004-10-05 19:38 UTC - kode54 -- Implemented instrument random volume and panning variation, but maybe the offset should be a member of IT_CHANNEL - instead of IT_PLAYING... - -2004-10-05 19:03 UTC - kode54 -- Panbrello position persists for the life of the voice, depth is the same, but is reset to zero - if channel panning is changed - -2004-10-05 18:49 UTC - kode54 -- Fixed pitch-pan with negative separation level -- Changed instrument envelope control - -2004-10-04 14:25 UTC - kode54 -- Damn, glissando control was broken, couldn't turn it off -- Wow, hole in the MTM comment reader. It's still ugly, though. -- Version is now 0.9.3.3 - -2004-10-04 13:27 UTC - kode54 -- Undid last NNA changes, the real problem was with NNA control effects carrying when they shouldn't -- Version is now 0.9.3.2 - -2004-10-04 11:09 UTC - kode54 -- Fixed a possible bug with finetune, which should not be applied twice -- Implemented glissando -- Implemented PTM note slides, what a bitch, and just for two files! -- Version is now 0.9.3.1 - -2004-10-04 05:36 UTC - kode54 -- Old PSM support -- MTM support -- MOD/XM S8x effect support, if it's supposed to be there -- Changed several readers to use stack buffers for dynamic strings, instead of malloc -- Fixed reading IT info from UMX archives. Whoops. -- Initialized counter variable properly in get_tracks() function. Whoops again. -- Removed length probe from dumb_read_it(). Jeez, what a slowdown even when not mixing and resampling... -- Version is now 0.9.3 - -2004-10-02 17:09 UTC - kode54 -- Added dynamic speed, tempo, channels, and channels_max info -- Version is now 0.9.2.14 - -2004-10-02 16:49 UTC - kode54 -- Added hack around XM speed zero to set its row played bit, for crap which scans it later outside of renderer... - -2004-10-02 16:15 UTC - kode54 -- Increased global volume silence check to 12 seconds -- Forced restart position to match start order, for a few annoying files, so they stop. Gee. - -2004-10-02 15:04 UTC - kode54 -- Meh, extended some NNA behavior so channel volume settings affect NNA voices correctly -- This appears to be the limit of channel effects on NNA voices, I hope - -2004-10-02 14:28 UTC - kode54 -- Added pattern delay/loop checking to pattern silence checker -- Silent pattern trimmer now trims only patterns which also contain delays/loops -- Trimmer also produces a single-row empty pattern instead of a 0-row pattern, which would hang -- Amended XM effect translation to support mod parameter, currently only affects Fxx speed effect - -2004-10-01 16:20 UTC - kode54 -- Added dynamic info junk -- Version is now 0.9.2.13 - -2004-10-01 15:50 UTC - kode54 -- Fixed played bit setting on completing a pattern loop -- Removed insane level of loop bit checking because combined with the above breaks Jos-Dr4k.xm -- Fixed S3M sample length/loop fields for stereo/16-bit samples in files created by IMAGO Orpheus - -2004-10-01 12:38 UTC - kode54 -- Extended subsong scanner to check every row in each order - -2004-09-30 14:39 UTC - kode54 -- Removed most checkpoint list building for a speedup -- Added note off to silence allowance list -- Version is now 0.9.2.12.2 - -2004-09-29 18:10 UTC - kode54 -- Removed ID3v1 from tag checks -- Blarg, bug fix in track_indexer for PSMs with APE tags, VC is retarded -- Version is now 0.9.2.12.1 - -2004-09-27 11:36 UTC - kode54 -- Added configuration for subsong scanning -- Added finite looping options, will trigger either on global volume, speed zero, or just plain looping -- Fixed note portamento in the same row as note off -- Changed S3M reader to truncate loops that end past the length of the sample instead of disabling the loop -- Changed S3M reader to eliminate duplicate patterns which reference the same file offset -- Version is now 0.9.2.12 - -2004-09-27 08:21 UTC - kode54 -- Extended PSM reader to support multiple subsongs -- Added a playable orders scanner -- Changed context menu system to indicate initial pattern or subsong depending on format - -2004-09-22 22:13 UTC - kode54 -- CRAP! My quick signature check broke PSM support -- Added extension check to MOD reader so no unknown types hit it -- Version is now 0.9.2.11.1 - -2004-09-22 01:41 UTC - kode54 -- Changed S3M loader to ignore samples with zero length before checking for signature -- Added top-level signature checks for all formats other than MOD so invalid files don't become 15s MOD -- Version is now 0.9.2.11 - -2004-09-21 21:44 UTC - kode54 -- Fixed MOD 8xx effect scale - -2004-09-21 18:16 UTC - kode54 -- Holy fucking shit, PSM support! -- Fixed instrument w/o note so it always resets - -2004-09-21 00:55 UTC - kode54 -- Initialize sample variables to zero for MOD/XM files with retrigger commands before any actual note data -- Changed global volume cutoff to try the callback every 5 seconds of global silence -- Changed resampler to assume todo values less than zero are actually integer overflow, which works fine for - portamento to really low pitch levels. It should never be negative anyway. -- Version is now 0.9.2.10.1 - -2004-09-19 15:31 UTC - kode54 -- S3M reader now disposes of effects unsupported by Scream Tracker 3. Some people are just too l33t to - use the effects column only for effects. -- Swapped PTM portamento effect directions. Whoever wrote PTMFORM.DOC must have been on drugs or something. -- Corrected MOD/S3M (PTM?) behavior when the sample is changed on a playing channel without a new note -- Version is now 0.9.2.10 - -2004-09-18 01:10 UTC - kode54 -- Corrected speed change command so it only calls speed zero callback on XM files and not MOD files -- Version is now 0.9.2.9 - -2004-09-17 23:43 UTC - kode54 -- Corrected finetune effect, allowed for future finetune tweaking - -2004-09-17 20:57 UTC - kode54 -- Fixed panbrello, now it really is correct -- Implemented finetune effect -- Fixed 669 effect 3, I think - -2004-09-17 18:29 UTC - kode54 -- Fixed song message handler in ReadDUH - -2004-09-17 17:41 UTC - kode54 -- Spoony 669 support - -2004-09-17 10:45 UTC - kode54 -- Implemented IT panbrello effect, hopefully - -2004-09-17 09:18 UTC - kode54 -- Implemented S3M Xxx panning bug for surround modes -- Added OKT extension, since it is handled by the MOD reader - -2004-09-16 11:54 UTC - kode54 -- Fixed S3M panning command. Others probably need proper translation as well. -- Version is now 0.9.2.8.2 - -2004-09-16 11:34 UTC - kode54 -- Lovely, had to fix loop checking behavior when parsing through an empty pattern with no event list -- Fixed seek() to invoke open2() properly, whoops. - -2004-09-16 09:46 UTC - kode54 -- CRIKEY! Broke pattern loops on formats other than XM! Fixed now. -- Version is now 0.9.2.8.1 - -2004-09-16 06:26 UTC - kode54 -- Changed pattern trimmer to report when there's nothing left after trimming -- BLAH! Fixed another reference to the global quality level in resample.inc -- Version is now 0.9.2.8 - -2004-09-16 04:52 UTC - kode54 -- Really fixed stupid smart loop checking this time - -2004-09-16 02:39 UTC - kode54 -- Fixed some static veriable crap in IT compressed sample loaders -- Consolidated sigrenderer creation and configuration -- Previous loop checking could potentially leak memory -- Now compiled with ICL 8 for a decent speed boost - -2004-09-15 20:46 UTC - kode54 -- Added optional silence trimming - -2004-09-15 20:41 UTC - kode54 -- The loop checking is now more ludicrous, to fix some annoying modules -- Added a zero global volume callback for other annoying modules - -2004-09-14 04:57 UTC - kode54 -- Added change starting order context menu item -- Version is now 0.9.2.7 - -2004-09-14 01:56 UTC - kode54 -- Fixed 16-bit samples clipping when resampling is set to aliasing -- Version is now 0.9.2.6 - -2004-09-13 23:17 UTC - kode54 -- Fixed PTM note cut command (which behaves like XM) - -2004-09-13 22:14 UTC - kode54 -- Fixed loop end point for PTM files - -2004-09-13 19:53 UTC - kode54 -- Fixed sample offset effect for PTM files - -2004-09-13 15:30 UTC - kode54 -- Fixed an envelope carry related crash by changing the it_retrigger_note portion to handle it in a safer way -- Version is now 0.9.2.5 - -2004-09-13 15:10 UTC - kode54 -- Almost complete PTM support - -2004-09-13 09:26 UTC - kode54 -- Fixed retriggering when sample finished playing within the retrigger interval, restricted to XM for now -- Version is now 0.9.2.4 - -2004-09-13 07:36 UTC - kode54 -- Quick bugfix to envelope carry, shouldn't be messing with instruments table if not in IT instruments mode - -2004-09-13 05:03 UTC - kode54 -- Added support for envelope carry. I hope it's correct. -- Version is now 0.9.2.3 - -2004-09-12 02:51 UTC - kode54 -- Added DUH FORMAT tag for all readers except for IT, and TRACKERVERSION for S3M - -2004-09-12 02:27 UTC - kode54 -- Fixed MOD channel count, wasn't being set properly in readmod.c - -2004-09-12 02:16 UTC - kode54 -- Fixed translation of XM panning slide effect after reversing IT panning slide - -2004-09-11 23:35 UTC - kode54 -- Implemented S3M mono/stereo control, but maybe I should also add a flag and disable panning -- Implemented IT vibrato/tremolo waveform control - -2004-09-10 13:37 UTC - kode54 -- Fixed resetting from surround to centered on panning slide/shift -- Clipped IT panning shift effect -- Version is now 0.9.2.2 - -2004-09-10 09:15 UTC - kode54 -- Implemented IT S7x effect for NNA commands and per-note envelope toggles -- Implemented IT NNA duplicate note checks -- Corrected direction of panning slide effect -- Version is now 0.9.2.1 - -2004-09-10 03:57 UTC - kode54 -- Fixed pattern break replaying with a bit array -- Fixed F0x-test.xm, sort of - -2004-09-09 18:49 UTC - kode54 -- Centralized info gathering for mod/s3m/xm - -2004-09-08 00:57 UTC - kode54 -- Fixed sample quality settings, and resetting settings/callbacks on backwards seeking - -2004-09-06 16:23 UTC - kode54 -- Changed default rate to 44100Hz, the "standard" default. Hell with AC'97 - -2004-09-06 13:11 UTC - kode54 -- Transferred foo_mod codebase over and modified to use DUMB -- Modified DUMB slightly to allow for the as-yet unused start order functionality -- What a coincidence, the original latest version number was so similar to DUMB's -- Version is now 0.9.2 - -========================= dumb part =================================== - -2003-11-08 11:20 aegis - - * src/Makefile.am: fix automake build - -2003-09-06 22:41 entheh - - * include/dumb.h, include/internal/it.h, make/Makefile.inc, - src/helpers/resample.c, src/helpers/resample.inc, src/it/itread.c, - src/it/itrender.c, src/it/readmod.c, src/it/reads3m.c, - src/it/readxm.c: 8-bit and 16-bit source resamplers created (dest - is always 32-bit with 24-bit range). Cubic way faster too - look-up - table idea stolen from ModPlugXMMS ;) - -2003-09-06 11:11 entheh - - * src/core/rendsig.c: I did this ages ago. - -2003-07-19 03:00 entheh - - * Makefile.ready, release.txt, include/dumb.h, make/Makefile.inc, - src/core/register.c, src/it/itrender.c, src/sigtypes/sample.c: - Stuff. - -2003-07-01 10:12 entheh - - * include/dumb.h: Support for another compiler suite. - -2003-06-19 21:24 entheh - - * src/helpers/resample.c: Crash bug fixed. - -2003-06-19 20:49 entheh - - * src/it/: itrender.c, reads3m.c: Now we honour IT's pan separation - control. - -2003-06-19 17:31 entheh - - * release.txt, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c: Fixed warnings - in the file loaders, and made an IT playback fix. - -2003-06-15 19:09 aegis - - * vc6/: dumbout/dumbout.dsp, dumbplay/dumbplay.dsp, - playduh/playduh.dsp: adding project files I missed - -2003-06-15 19:08 aegis - - * release.txt: updating release.txt - -2003-06-15 18:40 aegis - - * configure.in, include/Makefile.am, include/internal/Makefile.am, - vc6/dumb.dsw, vc6/dumb2wav/dumb2wav.dsp: include the - include/internal directory in distributions, and build allegro - examples in VC6 build - -2003-06-15 18:36 aegis - - * examples/dumb2wav.c: add a -l option to specify number of loops - -2003-06-12 17:34 aegis - - * vc6/dumb_static/dumb_static.dsp: build dumbd_static.lib instead - of dumb_staticd.lib - -2003-06-12 03:19 aegis - - * vc6/: dumb.dsw, aldumb/aldumb.dsp, dumb/dumb.dsp, - dumb2wav/dumb2wav.dsp, dumb_static/dumb_static.dsp: adding projects - for dumb_static (compiled with /MT) and dumb2wav - -2003-06-12 03:16 aegis - - * examples/dumb2wav.c: all .wav files are little-endian so get rid - of the bigendian option - -2003-06-12 02:30 aegis - - * make/Makefile.am: forgot to add this file... - -2003-06-12 02:14 aegis - - * obj/mingw/release/tmpfile.txt, obj/msvc/debug/tmpfile.txt, - obj/msvc/release/tmpfile.txt, obj/unix/debug/tmpfile.txt, - obj/unix/release/tmpfile.txt, src/Makefile.am, - src/core/Makefile.am, src/helpers/Makefile.am, src/it/Makefile.am, - src/it/itread.c, src/it/readmod.c, src/it/reads3m.c, - src/it/readxm.c: automake build: include a bunch of extra - files in 'make dist' build examples so they actually run - copy Makefile.ready to Makefile in the default distribution - - Makefile.ready: support for SGI cc create output - directories in build rather than including them in CVS move - some compile flags to the beginning of the compile line - - Add dumb2wav example SGI LONG_LONG support Fix some issues with the - const tag arrays in itread.c and such - - : - ------------------------------------------------------------------- - --- - -2003-06-12 02:13 aegis - - * Makefile.am, Makefile.ready, configure.in, docs/Makefile.am, - examples/Makefile.am, examples/dumb2wav.c, include/dumb.h, - lib/djgpp/tmpfile.txt, lib/mingw/tmpfile.txt, lib/msvc/tmpfile.txt, - lib/unix/tmpfile.txt, make/Makefile.inc, - obj/djgpp/debug/tmpfile.txt, obj/djgpp/release/tmpfile.txt, - obj/mingw/debug/tmpfile.txt: automake build: include a - bunch of extra files in 'make dist' build examples so they - actually run copy Makefile.ready to Makefile in the default - distribution - - Makefile.ready: support for SGI cc create output - directories in build rather than including them in CVS move - some compile flags to the beginning of the compile line - - Add dumb2wav example SGI LONG_LONG support Fix some issues with the - const tag arrays in itread.c and such - -2003-06-11 06:29 entheh - - * include/dumb.h: Should compile with OpenWatcom now. I've yet to - look at the project files and decide whether to add them though :) - -2003-06-10 14:10 aegis - - * configure.in: oops, forgot configure.in when committing the - automake build - -2003-06-07 07:14 entheh - - * Makefile.ready: Small fix to compiling flags for icc. - -2003-06-06 12:26 entheh - - * include/internal/it.h, src/it/itrender.c: XM Key Off effect now - works the way it should (I hope). - -2003-06-05 06:19 aegis - - * Makefile.ready: fix Makefile.ready so it refers to itself when - recursively invoking make - -2003-06-04 02:16 aegis - - * vc6/: dumb.dsp, dumb.dsw, aldumb/aldumb.dsp, dumb/dumb.dsp: - finishing VC6 build system - -2003-05-29 20:55 aegis - - * release.txt: updating release.txt - -2003-05-29 20:55 aegis - - * examples/Makefile.am: install examples - -2003-05-29 20:37 aegis - - * Makefile, Makefile.am, Makefile.ready, bootstrap, - docs/Makefile.am, examples/Makefile.am, include/Makefile.am, - src/Makefile.am, src/core/Makefile.am, src/helpers/Makefile.am, - src/it/Makefile.am: initial pass of automake build - -2003-05-28 11:56 aegis - - * vc6/: dumb.dsp, dumb.dsw: updating VC6 project: the sigtypes - stuff doesn't compile yet though - -2003-05-17 09:33 entheh - - * Makefile, release.txt, include/dumb.h, src/it/itrender.c: Bugfix: - Gxx didn't store effect value when no note was (previously) - playing. Also added support for the Intel C compiler for Linux. - -2003-04-27 11:49 entheh - - * make/config.sh: Small fix. Thanks to Sam Hocevar from Debian for - pointing this out. - -2003-04-25 09:23 entheh - - * release.txt, include/internal/it.h, src/it/itrender.c, - src/it/xmeffect.c: XM Kxx effect should work better now. - -2003-04-24 15:26 entheh - - * docs/faq.txt, include/dumb.h, include/internal/it.h, - src/it/itmisc.c, src/it/itread.c, src/it/itunload.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c: DUMB now loads - song message and other author data, and these can be retrieved. - -2003-04-23 00:14 entheh - - * release.txt, docs/deprec.txt: Misc commits - - ------------------------------------------------------------------- - --- - -2003-04-18 03:00 entheh - - * include/dumb.h, include/internal/it.h, src/it/itread.c, - src/it/itrender.c, winamp/in_duh.c: New envelope code. I don't - trust it fully yet, but it seems to work. - -2003-04-17 16:54 entheh - - * Makefile, release.txt, include/dumb.h, include/internal/dumb.h, - include/internal/it.h, src/core/duhtag.c, src/core/makeduh.c, - src/core/unload.c, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c, - winamp/in_duh.c: Added a tagging system; using it for the song - title. Yay! - -2003-04-15 00:13 entheh - - * include/internal/it.h, src/it/itrender.c, src/it/readxm.c, - src/it/xmeffect.c: Panning slides! Finally \o/ - -2003-04-12 01:01 entheh - - * Makefile, include/aldumb.h, src/allegro/alplay.c: Added - al_duh_get_volume(). Not documented yet. - -2003-04-12 00:12 entheh - - * Makefile, todo.txt, src/it/readxm.c: XM files: map_sample[] was - uninitialised for instruments with no samples - led to strange - noises occasionally. - -2003-04-04 08:04 entheh - - * winamp/in_duh.c: Winamp plug-in improved a bit. - -2003-04-03 16:26 entheh - - * make/config.bat: Huge bugfix! - -2003-04-03 12:07 entheh - - * Makefile: Bug fixed. Example programs will now be installed. - -2003-04-03 07:02 entheh - - * vc6/dumb.dsp: Added the VC6 project file to CVS. - -2003-04-03 07:01 entheh - - * readme.txt: Bah. - -2003-04-02 04:55 entheh - - * Makefile, readme.txt, release.txt: The makefile now works for the - Mac. - -2003-04-02 04:00 entheh - - * release.txt: OK, this time it really is ready for release ... - -2003-04-02 03:56 entheh - - * Makefile, licence.txt, readme.txt, release.txt, todo.txt, - docs/deprec.txt, docs/dumb.txt, docs/faq.txt, docs/howto.txt, - docs/modplug.txt, examples/dumb.ini, examples/dumbout.c, - include/dumb.h, include/internal/it.h, src/core/rendsig.c, - src/helpers/resample.c, src/it/itrender.c: Ready for release! - -2003-03-30 12:05 entheh - - * Makefile, release.txt, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c: No longer - installing the example programs when on Windows. - -2003-03-30 09:01 entheh - - * Makefile, make/djgpp.inc, make/mingw.inc, make/unix.inc: Fix for - BeOS - -2003-03-30 08:22 entheh - - * Makefile, Makefile.dj, Makefile.inc, Makefile.mgw, Makefile.uni, - config.bat, config.sh, readme.txt, make/Makefile.inc, - make/config.bat, make/config.sh, make/djgpp.inc, make/dumbask.c, - make/makefile.dj, make/makefile.lst, make/makefile.mgw, - make/makefile.uni, make/makefile.vc, make/mingw.inc, make/unix.inc, - src/misc/dumbask.c, src/misc/runner.c: Makefiles restructured a - bit. Should now support BeOS and Mac too :) - -2003-03-29 19:45 entheh - - * Makefile, Makefile.dj, Makefile.inc, Makefile.mgw, Makefile.uni, - config.bat, config.sh, fix.bat, fix.sh, makeall.bat, makeall.sh, - makecore.bat, makecore.sh, release.txt, examples/dumbout.c, - include/dumb.h, include/internal/it.h, src/it/itrender.c, - src/misc/dumbask.c, src/misc/gccver.c: New makefile system! No - provision for MSVC yet ... - -2003-03-28 06:06 entheh - - * make/makefile.mgw: -funroll-loops removed from makefiles. - -2003-03-28 05:29 entheh - - * src/helpers/resample.c: Some optimisation. Still needs work! - -2003-03-27 04:13 entheh - - * src/it/itrender.c: Pacified valgrind. - -2003-03-19 08:42 entheh - - * examples/dumb.ini, include/dumb.h, src/helpers/clickrem.c, - src/helpers/resample.c: Blah, stuff. - -2003-03-16 01:13 entheh - - * licence.txt, readme.txt, release.txt, docs/deprec.txt, - docs/duhspecs.txt, docs/dumb.txt, docs/dumbfull.txt, docs/faq.txt, - docs/fnptr.txt, docs/howto.txt, docs/modplug.txt, docs/ptr.txt, - docs/tutorial.txt, examples/dumbout.c, examples/dumbplay.c, - examples/playduh.c, include/aldumb.h, include/dumb.h, - include/internal/aldumb.h, include/internal/dumb.h, - include/internal/it.h, src/allegro/alplay.c, src/allegro/datduh.c, - src/allegro/datit.c, src/allegro/datmod.c, src/allegro/dats3m.c, - src/allegro/datunld.c, src/allegro/datxm.c, src/allegro/packfile.c, - src/core/atexit.c, src/core/duhlen.c, src/core/dumbfile.c, - src/core/loadduh.c, src/core/makeduh.c, src/core/rawsig.c, - src/core/readduh.c, src/core/register.c, src/core/rendduh.c, - src/core/rendsig.c, src/core/unload.c, src/helpers/clickrem.c, - src/helpers/memfile.c, src/helpers/resample.c, - src/helpers/sampbuf.c, src/helpers/silence.c, - src/helpers/stdfile.c, src/it/itload.c, src/it/itmisc.c, - src/it/itorder.c, src/it/itread.c, src/it/itrender.c, - src/it/itunload.c, src/it/loadmod.c, src/it/loads3m.c, - src/it/loadxm.c, src/it/readmod.c, src/it/reads3m.c, - src/it/readxm.c, src/it/xmeffect.c, src/sigtypes/combine.c, - src/sigtypes/sample.c, src/sigtypes/sequence.c, - src/sigtypes/sterpan.c, tools/cit.c, winamp/in2.h, winamp/in_duh.c, - winamp/in_duh.h, winamp/out.h: SHAZZAM! DUMB now has a decent name. - :D - -2003-03-16 00:36 entheh - - * src/helpers/clickrem.c: Added a #warning to an evil piece of code - -2003-03-15 21:03 entheh - - * src/helpers/clickrem.c: Click remover now copes with the huge - values. - -2003-03-15 19:53 entheh - - * src/: core/rendduh.c, it/itread.c, it/readmod.c, it/reads3m.c, - it/readxm.c: 24-bit mixing YAAAAAAAY :D Click remover overflows - - will fix that later. - -2003-03-15 19:16 entheh - - * examples/dumbout.c, src/helpers/resample.c: MULSC macro created - and tweaked for speed AND precision! Yaaaaay ^~ Thanks for the help - Bob :) - -2003-03-11 18:41 entheh - - * src/it/itrender.c: Reinstating the vibrato I disabled while - playing with valgrind (oops). - -2003-03-11 00:02 entheh - - * src/helpers/resample.c: Resamplers didn't quite Do The Right - Thing for click removal. Fixed. - -2003-03-10 22:49 entheh - - * readme.txt, docs/deprec.txt, docs/faq.txt, docs/howto.txt, - examples/dumbout.c, include/dumb.h, include/internal/it.h, - src/core/makeduh.c, src/core/register.c, src/core/rendduh.c, - src/core/rendsig.c, src/helpers/clickrem.c, src/helpers/resample.c, - src/it/itread.c, src/it/itrender.c, src/it/itrender.old.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c: Resamplers - reworked, finally! More to do, but it's bug-free and usable. :) - -2003-02-14 01:25 entheh - - * readme.txt, docs/howto.txt, src/helpers/clickrem.c, - src/it/itrender.c: Removed an old #warning (and did some other - stuff it seems). - -2003-01-26 19:16 entheh - - * release.txt, docs/dumb.txt, include/dumb.h, src/it/itrender.c: - dumb_it_sr_get_channel_state() now provides a more precise pan - value. - -2003-01-24 19:13 entheh - - * docs/dumb.txt, include/dumb.h, src/it/itrender.c: - dumb_it_get_state() now returns more precise information on - filters. - -2003-01-21 06:40 entheh - - * release.txt, docs/dumb.txt, examples/dumbplay.c, - include/aldumb.h, src/allegro/alplay.c, src/allegro/packfile.c: - Stuff... dumbfile_from_packfile() added, if nothing else. - -2003-01-15 19:43 entheh - - * src/it/readmod.c: Committing what appears to be an MSVC warning - pacifier. - -2003-01-03 15:28 entheh - - * include/internal/it.h, make/makefile.mgw, src/core/dumbfile.c, - src/it/itrender.c, src/it/readmod.c, src/it/xmeffect.c: Muted - channels supported, more accurate envelopes, several bugs fixed - -2003-01-03 15:03 entheh - - * release.txt, docs/dumb.txt, examples/dumb.ini: Muted channels, - and lots of bugs fixed - -2002-12-24 06:41 entheh - - * include/dumb.h, src/core/dumbfile.c, src/it/itrender.c: Fixed - some bugs. - -2002-12-20 21:51 entheh - - * src/it/readxm.c: Fixed the bug I thought I fixed just now. - -2002-12-20 21:45 entheh - - * examples/dumb.ini, make/makefile.mgw, make/makefile.vc, - src/allegro/alplay.c, src/it/readxm.c: Fixed a bug. - -2002-12-20 21:07 joe_programmer - - * src/it/itrender.c: MSVC6 does'nt support C99 - fixed variable - declarations - -2002-12-20 01:49 entheh - - * make/makefile.dj, make/makefile.mgw, src/it/itrender.c: Filter - instability fixed. - -2002-12-19 05:35 entheh - - * readme.txt, release.txt, docs/deprec.txt, docs/dumb.txt, - docs/howto.txt, docs/modplug.txt, examples/dumb.ini, - include/dumb.h, include/internal/it.h, src/it/itmisc.c, - src/it/itread.c, src/it/itrender.c, src/it/xmeffect.c, - winamp/in_duh.c: Err... stuff - -2002-12-18 17:15 entheh - - * docs/faq.txt: New stuff in FAQ. - -2002-12-18 17:06 entheh - - * licence.txt, readme.txt, release.txt, docs/deprec.txt, - docs/dumb.txt, docs/faq.txt, docs/fnptr.txt, docs/howto.txt, - docs/modplug.txt, docs/ptr.txt, examples/dumbplay.c, - include/dumb.h, include/internal/it.h, make/makefile.lst, - src/core/rendduh.c, src/helpers/memfile.c, src/helpers/sampbuf.c, - src/it/itmisc.c, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/readxm.c, src/it/xmeffect.c: XM and MOD - support improved, and lots of docs written. - -2002-12-17 00:23 entheh - - * release.txt, examples/dumbplay.c, examples/playit.c, - examples/playmod.c, examples/plays3m.c, examples/playxm.c, - include/aldumb.h, include/dumb.h, make/makefile.lst, - make/makefile.vc, src/allegro/datmod.c, src/core/loadduh.c, - src/it/itrender.c, src/it/readxm.c, src/misc/gccver.c: Lots o' - little changes. Notably the examples have been combined. - -2002-12-16 22:13 entheh - - * include/dumb.h, make/makefile.dj, make/makefile.mgw, - make/makefile.uni, make/makefile.vc, src/misc/gccver.c: Improved - the makefiles and... stuff. GCC 2.x should be happy now. - -2002-12-13 23:25 entheh - - * src/it/itrender.c: Filtered samples now have click removal - applied. Yay \o/ - -2002-12-12 00:17 entheh - - * examples/dumb.ini, include/dumb.h, include/internal/it.h, - make/makefile.lst, src/helpers/clickrem.c, src/helpers/resample.c, - src/it/itrender.c: Click removal! Incomplete though; not applied to - filtered samples... - -2002-12-09 17:25 entheh - - * src/it/readxm.c: #warning removed. MSVC might just be happy now. - -2002-12-09 17:23 entheh - - * src/it/itrender.c: Fixed some MSVC warnings, probably. - -2002-12-07 18:04 entheh - - * src/core/rendduh.c: Readding file that got removed because I - thought I was going to rename it >_< - -2002-12-07 17:48 entheh - - * examples/playit.c, include/aldumb.h, include/dumb.h, - src/allegro/alplay.c, src/core/rendduh.c, src/core/rendsig.c: - Deprecated some stuff, and added some stuff. \o/ - -2002-12-01 09:08 entheh - - * src/it/itrender.c, winamp/in_duh.c: Bugfix in tremor (Ixx) - handling. - -2002-11-26 06:39 entheh - - * include/internal/it.h, src/it/itrender.c, src/it/readxm.c: Wow, - who'd have thought an XM file could contain that many samples! - -2002-11-26 00:20 entheh - - * examples/playduh.c, examples/playit.c, examples/playmod.c, - examples/plays3m.c, examples/playxm.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c, - src/it/xmeffect.c: Quite a few bugfixes. - -2002-11-22 06:46 entheh - - * examples/playit.c, include/dumb.h, include/internal/it.h, - src/it/itmisc.c, src/it/itorder.c, src/it/itread.c, - src/it/itrender.c, src/it/itunload.c, src/it/readmod.c, - src/it/reads3m.c, src/it/readxm.c, winamp/config.rc, - winamp/in_duh.c: Uh... stuff :o - -2002-11-18 21:35 entheh - - * docs/: faq.txt, howto.txt: Addition to the docs. - -2002-11-18 05:46 entheh - - * src/it/itread.c: Bleh. - -2002-11-18 05:42 entheh - - * src/it/itread.c: Added a "duplicate check" to the IT loader... - not the kind you're thinking of though :) - -2002-11-18 04:32 entheh - - * examples/playit.c, include/aldumb.h, include/dumb.h, - src/allegro/alplay.c, src/core/rendduh.c, src/core/rendsig.c, - src/it/itrender.c: Extra API functions - -2002-11-16 23:17 entheh - - * src/it/itrender.c: mmm, pie... - -2002-11-16 23:04 entheh - - * release.txt, examples/dumb.ini, include/internal/it.h, - make/makefile.dj, make/makefile.lst, make/makefile.mgw, - make/makefile.uni, src/core/rendduh.c, src/core/rendsig.c, - src/helpers/memfile.c, src/it/itread.c, src/it/itrender.c, - src/it/itunload.c, src/it/readmod.c, src/it/reads3m.c, - src/it/readxm.c: - FILTERS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -2002-11-01 17:02 entheh - - * include/internal/it.h, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c: DUMB now freezes (correctly I - hope) on speed=0 in XM and MOD files. - -2002-10-29 09:39 entheh - - * include/internal/it.h, src/core/rawsig.c, src/it/itrender.c, - src/it/readxm.c: Sample vibrato :D - -2002-10-26 07:43 entheh - - * src/core/rendsig.c: Some more safety; it shouldn't crash on low - memory or invalid start order now. - -2002-10-26 07:25 entheh - - * examples/playit.c, include/dumb.h, src/it/itrender.c: Fixed - another bug :P - -2002-10-26 07:12 entheh - - * examples/playit.c, src/it/itrender.c: Fixed bug. - -2002-10-26 06:56 entheh - - * todo.txt, include/aldumb.h, include/dumb.h, - include/internal/it.h, make/makefile.lst, src/allegro/alplay.c, - src/core/rawsig.c, src/core/rendduh.c, src/core/rendsig.c, - src/it/itmisc.c, src/it/itrender.c, studio/include/dumbdesk.h, - studio/include/guiproc.h, studio/include/guitop.h, - studio/src/dumbdesk.c, studio/src/guitop.c, studio/src/main.c: - Added some rough & ready start-at-order functionality at short - order (no pun intended :) - -2002-10-20 05:42 entheh - - * studio/: font0.bmp, font1.bmp, font2.bmp: Added binary files for - DUMB Studio - -2002-10-16 07:04 entheh - - * examples/: dumb.ini, playit.c: Neatened the examples up a bit. - -2002-10-16 06:52 entheh - - * fix.bat, readme.txt, release.txt, docs/dumb.txt, - docs/dumbfull.txt, docs/faq.txt, docs/fnptr.txt, docs/howto.txt, - include/aldumb.h, include/dumb.h, lib/mingw/tmpfile.txt, - lib/mingw32/tmpfile.txt, make/makefile.mgw, - obj/mingw/debug/tmpfile.txt, obj/mingw/release/tmpfile.txt, - obj/mingw32/debug/tmpfile.txt, obj/mingw32/release/tmpfile.txt, - src/allegro/alplay.c, src/it/itrender.c, src/it/readmod.c, - src/it/reads3m.c, src/it/readxm.c: Lotsa changes... notably mingw32 - changed to mingw, and should be ready for release today. - -2002-10-05 01:55 jcugniere - - * src/it/: reads3m.c, readxm.c: Prevented that silly test.pcm from - taking ALL the space on my c: drive ;) - -2002-09-27 04:55 entheh - - * docs/fnptr.txt: Function pointer explanation fleshed out with the - whys and wherefores. - -2002-09-26 13:03 entheh - - * src/it/: itrender.c, readxm.c: XM envelopes fixed - -2002-09-26 06:31 entheh - - * include/internal/it.h, src/it/itrender.c: Improvements to the IT - and XM support, tone portamento handling in particular. WARNING: - code restructured slightly; bugs possibly introduced in IT support. - If your IT file plays wrong yadda yadda yadda. - -2002-09-25 04:29 entheh - - * include/dumb.h, include/internal/dumb.h, include/internal/it.h, - src/core/makeduh.c, src/core/readduh.c, src/core/register.c, - src/core/rendduh.c, src/core/rendsig.c, src/core/unload.c, - src/it/itorder.c, src/it/itread.c, src/it/itrender.c, - src/it/itunload.c, src/it/readmod.c, src/it/reads3m.c, - src/it/readxm.c: Change in terminology - -2002-09-24 14:14 entheh - - * src/it/: itrender.c, readxm.c: :o - -2002-09-24 04:50 entheh - - * todo.txt, docs/dumb.txt, include/aldumb.h, src/allegro/alplay.c: - Small addition to API; added info and proposal to todo.txt. - -2002-09-23 03:31 jcugniere - - * examples/dumb.ini, include/internal/it.h, make/makefile.lst, - src/it/itorder.c, src/it/itread.c, src/it/itrender.c, - src/it/readmod.c, src/it/reads3m.c, src/it/readxm.c: Made non - existant patterns be considered as containing 64 empty rows. - -2002-09-22 05:49 entheh - - * src/it/readxm.c: Now we correctly handle the weird case of - envelope on but n_nodes = 0 for XM files. - -2002-09-20 08:07 entheh - - * src/it/readmod.c: Panning fixed; error checking cleaned up to - some extent. - -2002-09-20 02:29 entheh - - * src/it/: loadmod.c, loadxm.c, readmod.c: Don't Convert Numbers To - BCD On Loading. To Do So Would Be DUMB. :P - -2002-09-19 01:08 jcugniere - - * src/core/rendduh.c: fixed compilation problems related to - CHAR_BITS and FAST_MID - -2002-09-18 09:31 entheh - - * readme.txt, release.txt, todo.txt, docs/dumb.txt, - examples/playmod.c, include/aldumb.h, include/dumb.h, - include/internal/it.h, make/makefile.lst, src/allegro/datmod.c, - src/it/loadmod.c, src/it/readmod.c, src/it/readxm.c, - src/it/xmeffect.c: First signs of .mod support :D - -2002-09-11 19:42 joe_programmer - - * make/makefile.vc: Fix for MSVC install target - -2002-09-08 22:46 entheh - - * src/it/itrender.c, winamp/in_duh.c: Seeking fixed; Winamp plug-in - improved in theory, but it crashes sometimes :x - -2002-09-08 10:50 entheh - - * src/it/itrender.c: Seeking should now be quick :) - -2002-09-08 09:20 entheh - - * src/it/itrender.c: Bug fixed. Odd that it only affected one IT - file. That's uninitialised variables for ya :) - -2002-09-08 08:26 entheh - - * examples/playit.c, include/internal/it.h, src/it/itread.c, - src/it/itrender.c, src/it/itunload.c, src/it/reads3m.c, - src/it/readxm.c: Length of songs now being calculated. Shame it - gets it wrong ;) - -2002-09-08 07:46 joe_programmer - - * src/core/rendduh.c: Optimized the convertors - -2002-09-08 04:09 entheh - - * include/internal/it.h, src/it/itrender.c: _dumb_it_dup_sampinfo() - coded - first step towards length calculation and fast seeking - -2002-09-06 10:31 entheh - - * studio/makedat: Datafile makefile updated. - -2002-09-06 09:59 entheh - - * studio/: dumbdesk.c, dumbdesk.h, dumbgui.c, dumbgui.h, - dumbmenu.c, guiproc.c, guiproc.h, guitop.c, guitop.h, main.c, - main.h, options.c, options.h, subclip.c, subclip.h, - include/dumbdesk.h, include/dumbgui.h, include/dumbmenu.h, - include/guiproc.h, include/guitop.h, include/main.h, - include/options.h, include/subclip.h, src/dumbdesk.c, - src/dumbgui.c, src/dumbmenu.c, src/guiproc.c, src/guitop.c, - src/main.c, src/options.c, src/subclip.c: Moved studio stuff into - subdirs - -2002-09-05 14:55 entheh - - * studio/: dumbdesk.c, dumbmenu.c, guiproc.h: Hmm - -2002-09-05 13:06 entheh - - * studio/dumbmenu.c: The menu module compiles. It isn't used at all - though. - -2002-09-05 12:58 entheh - - * studio/dumbmenu.c: Menu module committed; no testing done yet. - -2002-09-05 08:03 entheh - - * studio/: datafile.h, makedat: Created a makefile for building the - datafile. (Binary files left out of repository.) - -2002-09-04 20:53 entheh - - * studio/: datafile.h, dumbdesk.c, dumbdesk.h, dumbgui.c, - dumbgui.h, guiproc.c, guiproc.h, guitop.c, guitop.h, main.c, - main.h, options.c, options.h, subclip.c, subclip.h: DUMB Studio - added. Little more than a freaky GUI test so far... - -2002-09-04 16:49 entheh - - * docs/dumb.txt, examples/dumb.ini, examples/playduh.c, - examples/playit.c, examples/plays3m.c, examples/playxm.c, - include/internal/it.h, make/makefile.uni: Various changes :o - -2002-08-26 02:37 entheh - - * makeall.sh, makecore.sh: I thought I already fixed this :) - -2002-08-16 04:49 entheh - - * examples/playit.c: Yay 2... - -2002-08-16 04:21 entheh - - * examples/playit.c, make/makefile.uni: Yay... - -2002-08-12 02:20 entheh - - * readme.txt, release.txt, docs/ptr.txt, examples/dumb.ini, - make/makefile.dj, make/makefile.mgw, make/makefile.vc: A few typos - corrected. Not much else. Actually I'm not sure. - -2002-08-10 17:44 entheh - - * readme.txt, release.txt, docs/faq.txt, docs/fnptr.txt, - docs/ptr.txt: Last commit before 0.8.1 release... - -2002-08-10 16:03 entheh - - * docs/dumb.txt, examples/dumb.ini, include/dumb.h, - make/makefile.dj, make/makefile.mgw, make/makefile.uni, - make/makefile.vc, src/it/readxm.c: Another bug fixed; should be - ready for a release soon... - -2002-08-06 12:57 entheh - - * docs/howto.txt, examples/dumb.ini, make/makefile.lst, - src/allegro/datit.c, src/allegro/dats3m.c, src/allegro/datxm.c, - src/it/readxm.c: dumb_register_dat_xm() added (!) Also fixed a - Freudian slip in the docs, and added dumb_resampling_quality to - howto.txt. - -2002-07-30 07:02 entheh - - * docs/: dumb.txt, howto.txt: Position about null pointers - clarified in the docs - -2002-07-29 19:02 entheh - - * src/it/reads3m.c: S3M support made more robust; now handles some - buggy files. - -2002-07-29 08:28 entheh - - * make/: makefile.dj, makefile.mgw, makefile.uni: Makefiles - updated. - -2002-07-29 07:57 entheh - - * src/it/itrender.c: XM bug relating to invalid instruments fixed. - -2002-07-28 17:40 entheh - - * docs/faq.txt, make/makefile.dj, make/makefile.vc, - src/it/readxm.c, winamp/gui.c, winamp/in_duh.c, winamp/in_duh.h: - Winamp plug-in up to date, and plays IT/XM/S3M ;D - -2002-07-10 09:17 jcugniere - - * include/internal/it.h, src/it/itrender.c, src/it/readxm.c: fixed - a bug involving XM's fine volume slide down - -2002-06-16 17:59 entheh - - * release.txt, src/it/readxm.c: Can now load XM files with stereo - samples - -2002-06-16 02:35 entheh - - * release.txt, make/makefile.dj, make/makefile.mgw, - make/makefile.vc: 'make veryclean' fixed in DOS/Windows makefiles. - -2002-06-15 17:56 entheh - - * readme.txt: Another change... - -2002-06-15 17:49 entheh - - * licence.txt, release.txt, docs/faq.txt, docs/howto.txt: More - changes to the docs. - -2002-06-15 17:12 entheh - - * fix.bat, fix.sh, readme.txt, docs/howto.txt: A few corrections to - the docs; fix scripts slightly improved. - -2002-06-14 15:13 entheh - - * fix.bat, fix.sh, make/makefile.vc: Fix to the MSVC makefile - -2002-06-14 12:33 entheh - - * readme.txt, release.txt, docs/dumb.txt, docs/faq.txt, - docs/howto.txt, examples/dumb.ini, examples/playit.c, - examples/plays3m.c, examples/playxm.c, include/aldumb.h, - make/makefile.dj, make/makefile.mgw, make/makefile.uni, - make/makefile.vc: Last commit before release - everything's working - :) - -2002-06-14 09:02 entheh - - * makeall.sh, makecore.sh: Damn, it failed. Oh well, files added - back in. - -2002-06-14 08:58 entheh - - * makeall.sh, makecore.sh: Make 'em executable, Phase 1 - -2002-06-14 08:37 entheh - - * makeall.sh, makecore.sh, readme.txt: Unix stuff should be ready. - Might still change to provide BeOS support though... - -2002-06-14 08:18 entheh - - * readme.txt, docs/faq.txt: Getting there... - -2002-06-14 06:45 entheh - - * release.txt, make/makefile.uni: Updated Unix/BeOS makefile, - thanks to networm (he's going in the credits soon :) - -2002-06-14 06:10 entheh - - * makeall.bat, makecore.bat, release.txt, docs/faq.txt, - include/dumb.h, make/makefile.dj, make/makefile.lst, - make/makefile.mgw, make/makefile.uni, make/makefile.vc, - src/it/itread.c, src/it/itrender.c, src/it/readxm.c: Endianness - fixed, and work on the docs and makefiles preparing for release... - -2002-06-14 03:48 jcugniere - - * src/it/itrender.c: Oops! fixed 2 stupid warnings... - -2002-06-13 12:34 jcugniere - - * src/it/: itrender.c, readxm.c: more stuff on XM volpan - -2002-06-12 13:35 entheh - - * include/internal/it.h, src/core/rendduh.c, src/it/itrender.c: - Added xm_volslide field for better handling of XM volume slides. - -2002-06-12 12:54 jcugniere - - * src/it/: itrender.c, readxm.c: Trying to handle the XM volume - column more accurately. - -2002-05-30 13:36 entheh - - * include/internal/dumb.h, src/it/itrender.c: Improvement to the XM - support. - -2002-05-07 10:49 jcugniere - - * src/it/itrender.c: one liner to get volume properly initialized - with XM files - -2002-05-06 17:52 entheh - - * src/it/itrender.c: Some uninitialised fields fixed for XM files. - -2002-05-06 11:37 jcugniere - - * src/it/: itrender.c, readxm.c: Fixed premature fadeout - -2002-05-05 13:10 entheh - - * include/internal/it.h, src/it/itrender.c, src/it/readxm.c: More - stuff - -2002-05-05 11:47 entheh - - * src/it/: itrender.c, itrender.old.c: Stuff - -2002-05-04 13:46 jcugniere - - * src/it/readxm.c: Removed some fixes from readxm.c, made obsolete - by ben's changes in itrender.c - -2002-04-21 09:54 entheh - - * todo.txt, src/it/itrender.c, src/it/readxm.c, - src/sigtypes/sequence.c: Restructuring of the XM playing core. I've - done more harm than good... ostensibly ^_^ (look it up :P) - -2002-04-07 03:17 jcugniere - - * include/internal/it.h, src/it/itrender.c, src/it/reads3m.c, - src/it/readxm.c: Fixed a stupid bug in the XM effects conversion. - Minor fixes to get more S3Ms to load. - -2002-03-26 10:30 jcugniere - - * include/internal/it.h: Added a new IT_WAS_AN_XM signal flag, and - restart_position for XM compat. - -2002-03-26 10:27 jcugniere - - * src/it/readxm.c: All effects are now supported (provided - itrender.c implements them ;). But volume effects are still - incorrect. - -2002-03-26 10:26 jcugniere - - * src/it/reads3m.c: Added restart_position for XM compatibility. - -2002-03-26 10:25 jcugniere - - * src/it/itrender.c: Modified the behavior of a few things when - IT_WAS_AN_XM is set. Hopefully I haven't broken anything for IT - files ;) - -2002-03-26 10:23 jcugniere - - * src/it/itread.c: Added restart_position for XM compatibility - -2002-03-24 08:38 jcugniere - - * src/it/readxm.c: Bug fixes. - -2002-03-21 11:44 jcugniere - - * src/it/readxm.c: Some improvments on readxm.c. - -2002-03-14 12:50 jcugniere - - * examples/playxm.c, src/it/loadxm.c, src/it/readxm.c: Added an XM - loader (still needs work). - -2002-03-14 12:46 jcugniere - - * include/dumb.h, make/makefile.lst: Added an XM loader (still - needs work). - -2002-03-10 12:40 joe_programmer - - * make/makefile.vc: Fixed Allegro incompatibility - -2002-03-03 10:21 joe_programmer - - * src/it/itrender.c: Fixed some warnings - -2002-03-02 16:17 entheh - - * include/dumb.h: MSVC compile fixed - -2002-03-02 13:31 entheh - - * licence.txt, makeall.bat, makecore.bat, readme.txt, release.txt, - include/dumb.h, src/core/dumbfile.c: Hmm, possibly the last commit - before release????????? - -2002-03-02 12:23 entheh - - * makeall.bat, makecore.bat: Fixed batch files. - -2002-03-02 12:17 entheh - - * makeall.bat, makecore.bat: Added makeall.bat and makecore.bat, as - promised in readme.txt. - -2002-03-02 12:10 entheh - - * readme.txt: readme.txt done. - -2002-03-02 10:57 entheh - - * make/: makefile.dj, makefile.mgw, makefile.uni, makefile.vc: - Makefiles updated to allow for building without Allegro. Not tested - except DJGPP. - -2002-03-02 10:14 entheh - - * readme.txt, docs/dumb.txt, include/dumb.h: Some constants added - and documented. First signs of content in the readme. - -2002-03-02 08:42 entheh - - * lib/djgpp/tmpfile.txt, lib/mingw32/tmpfile.txt, - lib/msvc/tmpfile.txt, lib/unix/tmpfile.txt, - obj/djgpp/debug/tmpfile.txt, obj/djgpp/release/tmpfile.txt, - obj/mingw32/debug/tmpfile.txt, obj/mingw32/release/tmpfile.txt, - obj/msvc/debug/tmpfile.txt, obj/msvc/release/tmpfile.txt, - obj/unix/debug/tmpfile.txt, obj/unix/release/tmpfile.txt: - tmpfile.txt message changed, and some more added. - -2002-03-01 21:35 entheh - - * include/dumb.h, make/makefile.lst: Detached default sigtype - stuff, since that's not to be released. - -2002-03-01 21:29 entheh - - * readme.txt, docs/dumb.txt, docs/dumbfull.txt, docs/howto.txt, - docs/ptr.txt, include/aldumb.h, include/dumb.h, - src/allegro/datduh.c, src/allegro/datit.c, src/allegro/dats3m.c, - src/it/itread.c, src/it/itrender.c, src/it/itunload.c: Lots of - stuff, mostly work on docs. A few things neatened up. - -2002-02-22 21:09 entheh - - * src/helpers/resample.c: High-quality resamplers are now more - accurate, thanks to a LONG_LONG trick that gcc optimises quite - nicely for us. - -2002-02-22 19:55 entheh - - * src/helpers/resample.c: New comments at the top of resample.c, - and a compiler error fixed. - -2002-02-22 19:25 entheh - - * docs/dumb.txt, docs/tutorial.txt, src/it/itread.c, - src/it/itrender.c, src/it/reads3m.c: Dunno what I did, but I'd - better commit it :) - -2002-02-22 14:42 joe_programmer - - * src/helpers/resample.c: Volume scaling changed from float to int - (hope it works...) - -2002-02-17 03:41 entheh - - * include/dumb.h, src/helpers/resample.c, src/it/itread.c, - src/it/itrender.c, src/it/reads3m.c: A few unresolved issues seen - to. - -2002-02-16 20:06 tjaden - - * make/makefile.uni: Updated the Unix makefile (from the Mingw32 - makefile) - -2002-02-16 15:10 entheh - - * todo.txt: Stuff added to todo.txt - -2002-02-16 13:46 entheh - - * include/dumb.h, make/makefile.lst, src/helpers/resample.c, - src/helpers/silence.c, src/it/itread.c, src/it/itrender.c, - src/it/reads3m.c, src/sigtypes/sample.c: Lots of work on S3M - support. Fundamental change; always mix into buffer, never write. - Standard sigtypes probably aren't all reprogrammed correctly, but - they'll be stripped from the first release. Speaking of which... - not too long to wait now, I hope :) - -2002-02-06 17:28 entheh - - * src/: allegro/datit.c, allegro/datunld.c, core/unload.c, - helpers/resample.c, it/itload.c, it/itread.c, it/itrender.c, - it/itunload.c, it/reads3m.c: S3M support improved upon, but it's - not right yet. - -2002-02-06 16:43 entheh - - * make/: makefile.dj, makefile.lst: Makefiles updated slightly. - -2002-02-01 23:53 entheh - - * examples/plays3m.c, include/dumb.h, make/makefile.lst, - src/it/itload.c, src/it/itread.c, src/it/loads3m.c, - src/it/reads3m.c: Hahaha S3M sounds GREAT! Utterly out of tune, but - GREAT! LOL, gotta show this to Louis :) - -2002-02-01 10:07 entheh - - * include/internal/it.h: D'oh! - -2002-01-31 14:49 entheh - - * docs/dumb.txt, include/dumb.h, make/makefile.lst, src/it/it.c, - src/it/itload.c, src/it/itread.c, src/it/itrender.c, - src/it/itunload.c: IT modularised, and dumb_it_max_to_mix - formalised. S3M soon! - -2002-01-30 17:51 entheh - - * src/it/it.c: Amiga slides now programmed properly. - -2002-01-17 15:48 joe_programmer - - * src/it/it.c: Bug fixes by entheh - -2002-01-11 13:21 entheh - - * winamp/: in_duh.c, in_duh.h, winamp.dsp: Paranoima got the Winamp - plug-in up and running. Tx :) - -2002-01-11 12:01 entheh - - * src/it/it.c, winamp/in_duh.c: Winamp plug-in updated to match new - API. - -2002-01-11 10:58 entheh - - * examples/playit.c, src/it/it.c: Hmm, how to apply pan and pitch - envelopes in instruments that don't exist... I AM SO DUMB oh and - windowes sux bcasu it lets yuo get awawy with nullptrs in dos!@~ - -2002-01-11 02:09 entheh - - * src/it/it.c: Pattern loop done. - -2002-01-08 16:57 entheh - - * examples/playit.c, src/helpers/resample.c, src/it/it.c: IT loader - was faulty in more ways than one! Fixed now. Only seven effects to - go! - -2002-01-07 17:05 entheh - - * docs/dumb.txt, include/dumb.h, src/it/it.c: Pitch and panning - envelopes done, and a bug or two fixed. - -2002-01-06 17:17 entheh - - * src/it/it.c: Note delay done. zasx.it should play perfectly now - :) - -2002-01-06 00:27 entheh - - * src/it/it.c: Optimisations and 'damage limitation' in IT - playback; NEEDS TESTING. - -2002-01-02 02:39 entheh - - * examples/playit.c, src/it/it.c: Added vibrato :) Also made the IT - loading code more robust, as it failed on one of my files. Testers - welcome :) - -2002-01-01 15:59 entheh - - * docs/dumb.txt, src/allegro/alplay.c: Fixed a stupid bug in - alplay.c. Did something to dumb.txt, apparently... - -2001-12-31 20:44 entheh - - * docs/dumb.txt: Extra info added to docs. - -2001-12-31 20:40 entheh - - * docs/dumb.txt, examples/playduh.c, examples/playit.c, - include/aldumb.h, include/dumb.h, src/allegro/alplay.c, - src/core/rendduh.c: Additions to the renderer and Allegro player - APIs; docs updated. - -2001-12-30 17:31 entheh - - * docs/dumb.txt: Modified docs to describe new dumb_[at]exit() - system. - -2001-12-30 16:25 entheh - - * examples/playduh.c, examples/playit.c, include/dumb.h, - include/internal/dumb.h, make/makefile.lst, src/core/atexit.c, - src/core/main.c, src/core/readduh.c, src/core/register.c: - dumb_init() no longer exists. dumb_exit() just calls functions - registered by dumb_atexit(). Now to do the docs... - -2001-12-27 16:44 entheh - - * docs/dumb.txt, docs/tutorial.txt, examples/playduh.c, - examples/playit.c, include/dumb.h, src/core/main.c, - src/core/register.c, src/core/rendduh.c, src/core/rendsig.c, - src/helpers/resample.c, src/it/it.c, src/sigtypes/combine.c, - src/sigtypes/sample.c, src/sigtypes/sequence.c, - src/sigtypes/sterpan.c: *** CHANGES TO THE API *** docs might not - be fully updated. Added tutorial.txt. - -2001-12-27 11:33 entheh - - * docs/dumb.txt, include/dumb.h, src/it/it.c, - src/sigtypes/sequence.c: Fixed DJGPP compilation - -2001-12-26 22:16 joe_programmer - - * make/: makefile.dj, makefile.mgw, makefile.vc: More bugs fixed in - the makefiles Also fixed up the DJGPP makefile - -2001-12-26 22:09 joe_programmer - - * include/dumb.h, make/makefile.mgw, make/makefile.vc, - src/helpers/stdfile.c, src/it/it.c, src/sigtypes/sample.c, - src/sigtypes/sequence.c: Fixed warnings and errors in MSVC compile. - Finished MSVC makefile. Fixed Mingw makefile - -2001-12-26 21:33 joe_programmer - - * include/dumb.h, make/makefile.lst, make/makefile.mgw, - src/it/it.c, src/sigtypes/sequence.c: Fixed Mingw32 makefile Added - some temp files so CVS doesn't lose the directory tree - -2001-12-26 16:51 joe_programmer - - * lib/djgpp/tmpfile.txt, lib/mingw32/tmpfile.txt, - lib/msvc/tmpfile.txt, obj/djgpp/debug/tmpfile.txt, - obj/djgpp/release/tmpfile.txt, obj/msvc/debug/tmpfile.txt, - obj/msvc/release/tmpfile.txt: Added some temp files so CVS does'nt - lose the directory tree - -2001-12-26 09:40 entheh - - * docs/fnptr.txt: fnptr.txt added. - -2001-12-26 09:26 entheh - - * docs/dumb.txt, include/dumb.h, src/core/makeduh.c, - src/core/unload.c: A lot of work on the docs, but not finished. - Fixed some bugs in make_duh(). - -2001-12-22 17:28 entheh - - * docs/dumb.txt, examples/playit.c, include/aldumb.h, - include/dumb.h, src/allegro/packfile.c, src/core/dumbfile.c, - src/core/file.c, src/helpers/stdfile.c: Provided a stdio file input - module, amongst other things. - -2001-12-20 05:25 entheh - - * include/aldumb.h, include/internal/aldumb.h, - src/allegro/datduh.c, src/allegro/datit.c, src/allegro/datunld.c, - src/allegro/packfile.c, src/it/it.c: register_dat_it() fixed. - -2001-12-19 12:12 entheh - - * src/sigtypes/: combine.c, sample.c, sequence.c, sterpan.c: - Removed dumb_errno references from signal types. Dunno how I missed - them :o - -2001-12-17 08:57 entheh - - * include/dumb.h, src/helpers/resample.c, src/it/it.c: IT files can - now be started from somewhere in the middle, and silent samples' - positions are advanced. New do_silent_resample() function for this - purpose. - -2001-12-16 17:45 entheh - - * include/internal/aldumb.h, src/allegro/datduh.c, - src/allegro/packfile.c: Finished what I started ;) - -2001-12-16 17:18 entheh - - * todo.txt, examples/playit.c, include/aldumb.h, include/dumb.h, - include/dumb/file.h, include/internal/allegro/file.h, - src/allegro/file.c, src/allegro/packfile.c, src/core/file.c, - src/core/loadduh.c, src/core/main.c, src/core/readduh.c, - src/it/it.c: More changes - now the port (e.g. Allegro) must - actively register its file handlers. As for the IT support, note - retrig is now done. - -2001-12-16 06:11 entheh - - * src/it/it.c: Some more IT effects... makefiles still out of date - though - -2001-12-14 13:32 entheh - - * include/dumb.h, src/it/it.c: Did Amiga frequency slides =) - -2001-12-12 19:24 entheh - - * todo.txt, examples/playduh.c, examples/playit.c, - include/aldumb.h, include/dintern.h, include/dumb.h, - include/minalleg.h, include/dumb/file.h, include/internal/dumb.h, - include/internal/allegro/file.h, src/combine.c, src/datduh.c, - src/getsig.c, src/it.c, src/llload.c, src/load.c, src/main.c, - src/play.c, src/register.c, src/render.c, src/resample.c, - src/sample.c, src/sequence.c, src/sterpan.c, src/unload.c, - src/allegro/alplay.c, src/allegro/datduh.c, src/allegro/file.c, - src/core/duhlen.c, src/core/loadduh.c, src/core/main.c, - src/core/makeduh.c, src/core/readduh.c, src/core/register.c, - src/core/rendduh.c, src/core/rendsig.c, src/core/unload.c, - src/helpers/resample.c, src/it/it.c, src/sigtypes/combine.c, - src/sigtypes/sample.c, src/sigtypes/sequence.c, - src/sigtypes/sterpan.c: NEW DIRECTORY STRUCTURE. Please do a new - checkout, but WARNING: NO MAKEFILES. However, DUMB is now (almost) - separable from Allegro. - -2001-12-08 17:09 entheh - - * src/it.c: Neatened up a bit... possible a bug-fix or two that I - don't remember doing... - -2001-12-07 21:38 tjaden - - * make/makefile.uni: Use rm for make clean under Unices - -2001-12-07 21:37 tjaden - - * fix.sh: New fix.sh script - -2001-12-07 21:33 entheh - - * make/: makefile.lnx, makefile.uni: File renamed - -2001-12-07 19:54 entheh - - * examples/unload.c, src/unload.c: Damn, that was DUMB. unload.c - was in the wrong place :o - -2001-12-07 19:39 entheh - - * src/it.c: Fixed a bug affecting IT files that don't use - instruments. Most noticeable in that tone portamento didn't work. - -2001-12-07 13:56 entheh - - * todo.txt, examples/unload.c, make/makefile.lst, src/combine.c, - src/getsig.c, src/it.c, src/llload.c, src/render.c, src/resample.c, - src/sample.c, src/sequence.c, src/sterpan.c: unload_duh() in - separate file; checked usage of free() and other stuff. - -2001-12-07 09:55 entheh - - * todo.txt: Added to todo.txt - -2001-12-06 21:00 entheh - - * todo.txt: Amendment to todo.txt. - -2001-12-06 20:12 entheh - - * docs/dumb.txt: dumb.txt added. - -2001-12-06 19:08 entheh - - * examples/playduh.c, examples/playit.c, make/makefile.lst, - src/main.c, winamp/in_duh.c: playit.c added. register_sigtype_*() - calls finally moved out of install_dumb(). That means you have to - call them yourself! See docs/dumb.txt. - -2001-12-06 18:24 entheh - - * todo.txt, make/makefile.lst, src/it.c: More bugs fixed; DUMB more - faithful to IT. Added to todo.txt. - -2001-12-06 13:54 entheh - - * todo.txt, src/it.c: More IT stuff done/fixed/whatever. We have - official permission to use sample decompression algorithms, but see - todo.txt. - -2001-12-05 12:55 entheh - - * src/: it.c, resample.c: Revamped IT support has caught up with - cit.c. It even reproduces a bug in IT itself - the lengthy - experimentation payed off :) Also implemented a system to limit the - number of samples mixed simultaneously. - -2001-12-05 06:33 entheh - - * src/: it.c, resample.c: More work on the IT support. Some IT - files actually sound nice now :) - -2001-12-04 19:13 entheh - - * src/: sample.c, sequence.c: Unused parameter warnings fixed. I - now use -W as well as -Wall ;) - -2001-12-04 18:59 entheh - - * include/dumb.h, src/it.c, src/llload.c, src/load.c: IT support - revamped. Now you load IT files directly. Not finished though. A - few other minor changes. - -2001-10-27 08:26 joe_programmer - - * src/render.c, src/resample.c, tools/citbugs.txt: Entheh's new - resampling code - -2001-10-25 16:50 joe_programmer - - * src/resample.c: entheh started a workaround for incorrect - multiplication generation code by C compilers. 36 bits were in fact - needed when only 32 were provided. The low-pass (linear average) - filter is not yet completed. - -2001-10-21 15:40 joe_programmer - - * todo.txt: Added some stuff - -2001-10-20 12:19 joe_programmer - - * tools/citbugs.txt: Updated buglist - -2001-09-30 18:11 joe_programmer - - * todo.txt: Updated todo - -2001-09-30 18:06 joe_programmer - - * src/sample.c: Fixes to the loader. Samples are now properly - loaded, which akes the int code as good as the float code - -2001-09-30 17:00 joe_programmer - - * todo.txt: Added todo.txt - -2001-09-30 10:43 joe_programmer - - * include/dumb.h, src/combine.c, src/getsig.c, src/render.c, - src/resample.c, src/sample.c, src/sequence.c, src/sterpan.c, - winamp/config.rc, winamp/winamp.dsp: Converted all the floating - point code to integer math. 30% speed boost! Sounds like crap - though. I'll fix that later. - -2001-09-26 19:37 joe_programmer - - * winamp/: config.rc, gui.c, resource.h: Fixes to the plug-in's UI - -2001-09-25 19:23 joe_programmer - - * src/resample.c, winamp/config.rc: Minor changes to the UI - -2001-09-25 18:37 joe_programmer - - * src/resample.c: Sped up the low pass filters - -2001-09-25 17:25 joe_programmer - - * src/resample.c, winamp/config.rc, winamp/gui.c, - winamp/resource.h: Sped up the quadratic and cubic resamplers - -2001-09-25 16:54 joe_programmer - - * src/resample.c: Added quadratic resampler - -2001-09-23 08:19 joe_programmer - - * src/resample.c, winamp/config.rc, winamp/winamp.dsp: Slight - changes ot the plug-in presentation - -2001-09-22 11:36 joe_programmer - - * include/minalleg.h, src/resample.c, winamp/config.rc, - winamp/gui.c, winamp/gui.h, winamp/in_duh.c, winamp/resource.h, - winamp/winamp.dsp: Plug-in supports threading priority, new plug-in - setup option, small speed-up in the cubic resampler - -2001-09-17 20:02 joe_programmer - - * src/resample.c, winamp/config.rc, winamp/gui.c, winamp/in_duh.c, - winamp/resource.h, winamp/winamp.dsp: Minor speed tweaks. - -2001-09-16 18:49 joe_programmer - - * tools/cit.c: Fixed yet another null dereferencing bug - -2001-09-16 12:13 joe_programmer - - * winamp/: config.rc, gui.c, gui.h, in_duh.c, resource.h: Lots of - fixes ot the plugin - -2001-09-16 08:52 joe_programmer - - * tools/cit.c: Fixed yet another null dereferencing bug - -2001-09-16 08:49 joe_programmer - - * winamp/gui.c: Fixes to the plug-in - -2001-09-16 08:36 joe_programmer - - * winamp/in_duh.c: Fixes to the plug-in - -2001-09-16 08:32 joe_programmer - - * winamp/: config.rc, gui.c, gui.h, in_duh.c, in_duh.h, resource.h, - winamp.dsp: The plug-in works and is almost done now. Config screen - added, seeking also added - -2001-09-15 18:10 joe_programmer - - * winamp/in_duh.h: Forgot to commit a file - -2001-09-15 18:08 joe_programmer - - * winamp/in_duh.c: More fixes to the plug-in - -2001-09-15 15:47 joe_programmer - - * tools/cit.c, winamp/in_duh.c, winamp/winamp.dsp: Winamp update: - Vis should work - -2001-09-15 14:38 joe_programmer - - * include/minalleg.h, make/makefile.vc, src/main.c, tools/cit.c, - winamp/in2.h, winamp/in_duh.c, winamp/out.h, winamp/winamp.dsp: - Winamp plug-in works! (well, kinda) - -2001-09-15 13:29 joe_programmer - - * make/makefile.lst, make/makefile.mgw, make/makefile.vc, - tools/cit.c: Updated makefiles, added drag&drop support to cit - -2001-09-15 11:48 joe_programmer - - * examples/playduh.c, include/dumb.h, winamp/in_duh.c, - winamp/winamp.dsp: More Winamp changes. Plug-in is almost ready - -2001-09-15 09:25 joe_programmer - - * include/minalleg.h, src/combine.c, src/getsig.c, src/llload.c, - src/load.c, src/main.c, src/play.c, src/register.c, src/render.c, - src/resample.c, src/sample.c, src/sequence.c, src/sterpan.c, - winamp/in2.h, winamp/in_duh.c, winamp/minalleg.c, winamp/out.h, - winamp/winamp.dsp, winamp/winamp.dsw: Winamp plug-in commit - not - finished yet - -2001-09-10 02:14 entheh - - * docs/duhspecs.txt, tools/cit.c: Note Fade and New Note Actions - now supported. Argh! I never want to program that again. :P - -2001-09-09 14:25 entheh - - * include/dumb.h, src/render.c: 8-bit bug fixed, but the code - hasn't been tested yet. - -2001-09-09 13:07 entheh - - * include/dumb.h, src/play.c, src/render.c: Rendering and audio - stream playing are now separated into levels. The rendering level - is available in dumb.h. I've removed Bob's changes, so I hope it - won't set him back too much :) - -2001-09-08 20:23 joe_programmer - - * src/play.c: Slight change to make winamp plugin easier to write - :) - -2001-09-07 23:38 entheh - - * include/dintern.h, src/llload.c, tools/cit.c: The length of a DUH - file is now stored, in preparation for Winamp and/or looping - support. - -2001-09-05 19:16 entheh - - * tools/cit.c: Panning bug fixed. Forgot default sample panning! - D'oh! :) - -2001-09-05 17:37 entheh - - * tools/cit.c: Volume envelopes working properly now, and stereo - panning bug fixed. - -2001-09-05 11:10 entheh - - * src/play.c, tools/cit.c: Volume envelopes... bleargh, zasx.duh - sounds pretty good now :) - -2001-09-04 21:12 entheh - - * make/: makefile.dj, makefile.lst: Makefile update (untested) - -2001-09-04 19:46 entheh - - * tools/cit.c: Portamento in the volume column is done, and - handling of 'Compatible Gxx' is in place. - -2001-09-04 12:56 entheh - - * tools/cit.c: Pitch/Pan Separation is done. - -2001-09-03 09:24 entheh - - * include/dumb.h, src/combine.c, src/main.c, src/sterpan.c, - tools/cit.c: Stereo sound now works, finally! Not all stereo stuff - is implemented though, and it'll suffer from the same bug as the - volume (see the citbugs.txt file). - -2001-09-02 19:34 entheh - - * examples/playduh.c, include/dumb.h, src/combine.c, src/getsig.c, - src/main.c, src/play.c, src/sample.c, src/sequence.c: COMB signal - implemented. This will allow two mono signals to be combined into a - stereo one. SPAN (panning), and modifications to cit.c, still to do - before any stereo sound will be heard. - -2001-08-24 19:01 entheh - - * include/dumb.h, src/getsig.c, src/play.c, src/resample.c, - src/sample.c, src/sequence.c: Support for multiple channels has - been added. Adding stereo sound support should be a breeze now, but - that'll have to wait for another day. - -2001-08-24 14:17 entheh - - * include/dumb.h, tools/cit.c, tools/citbugs.txt: Dunno what this - commit is, but it seems it should've been done a long time ago :) - -2001-08-17 18:25 entheh - - * docs/duhspecs.txt, src/sequence.c, tools/cit.c: A new compression - system is in use for the sequences. WARNING: OLDER DUH FILES WILL - CAUSE A CRASH. This is the price you pay for using a version of - DUMB prior to the first release :) - -2001-08-17 12:25 joe_programmer - - * docs/duhspecs.txt: Proposal for new smaller format - -2001-08-17 01:49 entheh - - * docs/duhspecs.txt: The DUH file format specification is now - documented :) - -2001-08-16 15:13 joe_programmer - - * tools/cit.c: Fixed a NULL dereferencing bug - -2001-08-16 14:38 entheh - - * tools/cit.c: Bug fixed (multisample instruments work) and more - flow control effects done - -2001-08-16 03:33 entheh - - * src/resample.c, tools/cit.c, tools/citbugs.txt: Wahoo, resampling - fixed! Also did something to cit.c and added citbugs.txt. - -2001-08-15 22:15 joe_programmer - - * src/resample.c: Fixed compilation warning - -2001-08-15 18:50 entheh - - * include/dumb.h, src/sample.c, src/sequence.c, tools/cit.c: - Various stuff... cit.c improved, the sequence signal can now be - started halfway through... - -2001-08-14 23:32 entheh - - * tools/cit.c: Yay, volume slides! :-) - -2001-08-14 16:06 entheh - - * tools/cit.c: Some of the effects work! Yay! :-) - -2001-08-14 04:32 entheh - - * tools/cit.c: cit.c has been revamped somewhat. It's a hell of a - lot uglier, and has lost some features. However, it is supposedly - more faithful to the IT standard. Thank goodness the IT converter - is not to be the central attraction :-) - -2001-08-13 12:36 entheh - - * tools/cit.c: cit.c now loads everything in the IT file. It has - been adapted to support everything described in the ittech.txt file - that comes with Impulse Tracker 2.14. However, the conversion is - still as awful as ever :-) - -2001-08-11 22:40 entheh - - * tools/cit.c: Some of the "Damn, I need more information"-style - comments in cit.c have been replaced with information on what the - stuff really is :D - -2001-08-10 21:30 entheh - - * examples/playduh.c: allegro_exit()/allegro_message() bug - partially fixed in playduh.c. Still problems in case of usage(), - and failure on allegro_init(). - -2001-08-10 20:07 entheh - - * include/dumb.h, src/getsig.c, src/sequence.c: Removed the - MAX_SAMPLES limitation. STREAM_SIZE can be increased now. - -2001-08-10 19:31 entheh - - * examples/playduh.c, include/dumb.h, src/play.c: A few - enhancements to the playback interface. - -2001-08-10 10:13 joe_programmer - - * make/makefile.lst: Added new files - -2001-08-10 08:48 entheh - - * include/dumb.h, src/play.c, src/resample.c, src/sample.c, - src/sequence.c, tools/cit.c: Looped samples :-) - -2001-08-09 11:15 entheh - - * src/resample.c: Bug fixed! Resampling works - -2001-08-09 10:35 entheh - - * include/dumb.h, src/play.c, src/resample.c, src/sample.c, - tools/cit.c: RESAMPLE_PICKUP stuff added, but there's a bug. Trying - to fix it... Various other minor changes - -2001-08-06 18:06 entheh - - * include/dumb.h, src/resample.c, src/sample.c, tools/cit.c: - Resampling code is in a separate file, and extensive comments have - been written for it. cit.c has very limited volume support now. - -2001-08-05 10:18 entheh - - * tools/cit.c: A check in cit.c has gone from ASSERT to if :-) - -2001-08-03 23:23 joe_programmer - - * tools/cit.c: Fix to the it->duh converter - -2001-08-03 23:12 entheh - - * tools/cit.c: Bugfix, another bug has surfaced :/ - -2001-08-03 22:39 entheh - - * examples/playduh.c, include/dintern.h, include/dumb.h, - src/datduh.c, src/getsig.c, src/llload.c, src/load.c, src/main.c, - src/play.c, src/register.c, src/sample.c, src/sequence.c, - tools/cit.c: CIT (IT Compiler) working, just about. Tut tut, such a - name, so suggestive of monopolistic intentions... But anyway, the - new ASCII art and credits are at the top of every file! - -2001-08-03 11:46 entheh - - * tools/cit.c: cit.c added. Currently unchanged from Bob's IT - loader, except that the header files have been hard-included, and - it now compiles as C rather than C++. Oh, and check out the new - ASCII art :-) - -2001-08-02 17:49 entheh - - * src/sample.c: Changes to the sample signal so that no special - case is required at the end of a sample when resampling. - -2001-08-02 14:33 joe_programmer - - * src/tools/it/: load_it.cpp, modulus.h, typedef.hpp: Added code to - load ITs from old IT player. needs a rewrite to work with dumb - -2001-08-01 19:33 entheh - - * include/dumb.h, src/getsig.c, src/play.c, src/sample.c, - src/sequence.c: New sequencing format done. - -2001-08-01 15:13 entheh - - * include/dintern.h, include/dumb.h, src/getsig.c, src/play.c, - src/register.c, src/sample.c, src/sequence.c: First signs of signal - parameters - -2001-07-28 14:40 entheh - - * include/dintern.h, include/dumb.h, src/getsig.c, src/main.c, - src/play.c, src/sample.c, src/sequence.c: Some restructuring... - -2001-07-28 11:27 entheh - - * src/: play.c, sample.c: Resampling fixed - -2001-07-28 11:16 joe_programmer - - * src/sample.c: Fixes to the lowpass filter - -2001-07-28 10:54 joe_programmer - - * src/sample.c: Attempt at fixing the low-pass filter - -2001-07-28 09:53 entheh - - * examples/playduh.c, src/play.c, src/sample.c: Huh? uh, I don't - remember what I did. - -2001-07-28 09:44 joe_programmer - - * src/sample.c: Fixes to the low-pass filter - -2001-07-28 09:33 joe_programmer - - * src/sample.c: Added a dithering filter - -2001-07-28 09:08 joe_programmer - - * src/sample.c: Cubic interpolation, and some form of high-pass - filter? - -2001-07-27 17:38 joe_programmer - - * examples/playduh.c: Made the player work in the background - -2001-07-27 13:39 joe_programmer - - * src/sample.c: Fixes to the lowpass filter - -2001-07-27 12:40 joe_programmer - - * examples/playduh.c, src/sample.c: Hopefully fixed the crackiling - problem in the linear filter. - -2001-07-27 12:33 joe_programmer - - * src/sample.c: Fixed the downsampling - -2001-07-27 12:21 joe_programmer - - * src/sample.c: Bug fixed int he resampler - -2001-07-27 12:21 joe_programmer - - * examples/playduh.c, make/makefile.vc, src/sample.c: Added linear - resampler and explerimental lowpass filter. Also fixed teh VC - makefile - -2001-07-25 08:33 entheh - - * examples/playduh.c, include/dumb.h, src/getsig.c, src/play.c, - src/sample.c, src/sequence.c: Yay, for the first time it actually - plays MUSIC!!! :D - -2001-07-23 12:24 joe_programmer - - * fix.bat, make/makefile.dj, make/makefile.lnx, make/makefile.lst, - make/makefile.mgw, make/makefile.vc: Fixes to the build scripts - -2001-07-23 11:28 joe_programmer - - * fix.bat, make/makefile.dj, make/makefile.lnx, make/makefile.lst, - make/makefile.mgw, make/makefile.vc, src/misc/runner.c: Added - makefile system - -2001-07-23 10:11 entheh - - * examples/playduh.c, include/dumb.h, src/getsig.c, src/llload.c, - src/main.c, src/play.c, src/register.c, src/sample.c, - src/sequence.c: [no log message] - -2001-07-21 08:04 entheh - - * include/: dintern.h, dumb.h.ex: dumb.h.ex added, containing DUMB - struct stuff which will not be used for now. Don't wanna lose - stuff though :-) dintern.h is now updated with the new signal - processing functions. The package compiles. - -2001-07-21 06:43 entheh - - * include/dintern.h, include/dumb.h, src/register.c: - Signal-handling functions are improved. - -2001-07-20 15:03 joe_programmer - - * src/Shortcut to src.lnk: Removed file added by error - -2001-07-20 14:57 joe_programmer - - * licence.txt, include/dintern.h, include/dumb.h, src/Shortcut to - src.lnk, src/datduh.c, src/llload.c, src/load.c, src/main.c, - src/register.c: Initial revision - -2001-07-20 14:57 joe_programmer - - * licence.txt, include/dintern.h, include/dumb.h, src/Shortcut to - src.lnk, src/datduh.c, src/llload.c, src/load.c, src/main.c, - src/register.c: Initial checkin - diff --git a/dumb/cmake/CMakeLists.txt b/dumb/cmake/CMakeLists.txt new file mode 100644 index 0000000000..4fbedcecaa --- /dev/null +++ b/dumb/cmake/CMakeLists.txt @@ -0,0 +1,118 @@ +cmake_minimum_required(VERSION 2.6) +project(libdumb C) + +set(CMAKE_C_FLAGS "-Wall -DDUMB_DECLARE_DEPRECATED -D_USE_SSE -msse -Wno-unused-variable -Wno-unused-but-set-variable") +set(CMAKE_C_FLAGS_DEBUG "-ggdb -DDEBUGMODE=1 -D_DEBUG") +set(CMAKE_C_FLAGS_RELEASE "-ffast-math -O2 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-ffast-math -g -O2 -DNDEBUG") +set(CMAKE_C_FLAGS_MINSIZEREL "-ffast-math -Os -DNDEBUG") + +link_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(../include/) + +SET(SOURCES + ../src/core/unload.c + ../src/core/rendsig.c + ../src/core/rendduh.c + ../src/core/register.c + ../src/core/readduh.c + ../src/core/rawsig.c + ../src/core/makeduh.c + ../src/core/loadduh.c + ../src/core/dumbfile.c + ../src/core/duhtag.c + ../src/core/duhlen.c + ../src/core/atexit.c + ../src/helpers/stdfile.c + ../src/helpers/silence.c + ../src/helpers/sampbuf.c + ../src/helpers/riff.c + ../src/helpers/resample.c + ../src/helpers/memfile.c + ../src/helpers/clickrem.c + ../src/helpers/barray.c + ../src/helpers/tarray.c + ../src/it/xmeffect.c + ../src/it/readxm2.c + ../src/it/readxm.c + ../src/it/readstm2.c + ../src/it/readstm.c + ../src/it/reads3m2.c + ../src/it/reads3m.c + ../src/it/readriff.c + ../src/it/readptm.c + ../src/it/readpsm.c + ../src/it/readoldpsm.c + ../src/it/readokt2.c + ../src/it/readokt.c + ../src/it/readmtm.c + ../src/it/readmod2.c + ../src/it/readmod.c + ../src/it/readdsmf.c + ../src/it/readasy.c + ../src/it/readamf2.c + ../src/it/readamf.c + ../src/it/readam.c + ../src/it/read6692.c + ../src/it/read669.c + ../src/it/ptmeffect.c + ../src/it/loadxm2.c + ../src/it/loadxm.c + ../src/it/loadstm2.c + ../src/it/loadstm.c + ../src/it/loads3m2.c + ../src/it/loads3m.c + ../src/it/loadriff2.c + ../src/it/loadriff.c + ../src/it/loadptm2.c + ../src/it/loadptm.c + ../src/it/loadpsm2.c + ../src/it/loadpsm.c + ../src/it/loadoldpsm2.c + ../src/it/loadoldpsm.c + ../src/it/loadokt2.c + ../src/it/loadokt.c + ../src/it/loadmtm2.c + ../src/it/loadmtm.c + ../src/it/loadmod2.c + ../src/it/loadmod.c + ../src/it/loadasy2.c + ../src/it/loadasy.c + ../src/it/loadamf2.c + ../src/it/loadamf.c + ../src/it/load6692.c + ../src/it/load669.c + ../src/it/itunload.c + ../src/it/itrender.c + ../src/it/itread2.c + ../src/it/itread.c + ../src/it/itorder.c + ../src/it/itmisc.c + ../src/it/itload2.c + ../src/it/itload.c + ../src/it/readany.c + ../src/it/loadany2.c + ../src/it/loadany.c + ../src/it/readany2.c + ../src/helpers/resampler.c + ../src/helpers/lpc.c +) + +set(INSTALL_HEADERS + ../include/dumb.h +) + +add_library(dumb ${SOURCES}) +set_target_properties(dumb PROPERTIES DEBUG_POSTFIX d) + +# Make sure the dylib install name path is set on OSX so you can include dumb in app bundles +IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(dumb PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + +INSTALL(FILES ${INSTALL_HEADERS} DESTINATION include/) +INSTALL(TARGETS dumb + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/dumb/cmake/readme.txt b/dumb/cmake/readme.txt new file mode 100644 index 0000000000..32897c797a --- /dev/null +++ b/dumb/cmake/readme.txt @@ -0,0 +1,30 @@ +Howto build libdumb with cmake +============================== + +A quick example +--------------- + +In libdumb cmake directory (dumb/cmake/), run: +``` +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS:BOOL=ON .. +make +make install +``` + +Steps +----- + +1. Create a new temporary build directory and cd into it +2. Run libdumb cmake file with cmake (eg. `cmake -DCMAKE_INSTALL_PREFIX=/install/dir -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE=Release path/to/dumb/cmake/dir`). +3. Run make (eg. just `make` or `mingw32-make` or something). +4. If needed, run make install. + +Flags +----- + +* CMAKE_INSTALL_PREFIX sets the installation path prefix +* CMAKE_BUILD_TYPE sets the build type (eg. Release, Debug, RelWithDebInfo, MinSizeRel). Debug libraries will be named libdumbd, release libraries libdumb. +* BUILD_SHARED_LIBS selects whether cmake should build dynamic or static library (On=shared, OFF=static) +* You may also need to tell cmake what kind of makefiles to create with the "-G" flag. Eg. for MSYS one would say something like `cmake -G "MSYS Makefiles" .`. diff --git a/dumb/docs/deprec.txt b/dumb/docs/deprec.txt deleted file mode 100644 index 6ab7b60af4..0000000000 --- a/dumb/docs/deprec.txt +++ /dev/null @@ -1,281 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * deprec.txt - Deprecated functions, why they / / \ \ - * were deprecated, and what to do | < / \_ - * instead. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -********************************************** -*** How the functions have been deprecated *** -********************************************** - - - GCC 3.1 and later provide a very useful attribute. The following: - - __attribute__((__deprecated__)) - - when written alongside a function prototype, variable declaration or type - definition, will result in a warning from GCC if any such part of the API - is used. The warning will even tell you where the declaration is, and I - have inserted comments by all the deprecated declarations, telling you - what to do. - - Unfortunately, GCC 2.x and 3.0.x and MSVC do not have any means to - deprecate things. The approach I have taken with these compilers is to - avoid prototyping the deprecated parts of the API. This means you will get - warnings and errors, and they won't be very helpful. If your program - compiles, you may get strange crashes when you run it, since the compiler - needs the declarations in order to make sure function calls are carried - out correctly. - - If you would like the deprecated parts of the API to be declared, you can - compile with the -DDUMB_DECLARE_DEPRECATED switch for GCC, or the - -D"DUMB_DECLARE_DEPRECATED" switch for MSVC. This will be accepted by - GCC 3.x but is unnecessary. Use this switch with other people's projects - if necessary, but please make the effort to update your own projects to - use the new API, as the deprecated parts may be removed in the future. - - The rest of this file explains why some parts of the API were deprecated, - and how to adapt your code. - - -************************************** -*** What happened to DUH_RENDERER? *** -************************************** - - - The DUH_RENDERER struct was designed for rendering audio to an end-user - format - 8-bit or 16-bit, signed or unsigned, with stereo samples - interleaved. In order for it to do this, it was built on top of the - hitherto undocumented DUH_SIGRENDERER struct, which rendered audio in - DUMB's internal 32-bit signed format with channels (left/right) stored - separately. The DUH_RENDERER struct contained a pointer to a - DUH_SIGRENDERER struct, along with some other data like the position and - number of channels. - - There were then some developments in the API. The DUH_SIGRENDERER struct - also stored the position and the number of channels, so I decided to write - functions for returning these. Suddenly there was no need to store them in - the DUH_RENDERER struct. Before long, the DUH_RENDERER struct contained - nothing but a pointer to a DUH_SIGRENDERER. - - I decided it would be a good idea to unify the structs. After all, there - really is no difference between the data stored in each, and it would be - easy to make duh_render(DUH_RENDERER *dr, ...) and - duh_render_signal(DUH_SIGRENDERER *sr, ...) work on the same type of - struct. (Note that duh_render_signal() is now deprecated too; see the next - section.) It took some deliberation, but I decided I didn't want functions - to be #defined (it prevents you from using these names for member - functions in C++ classes), and that meant they had to be defined - somewhere. Defining redundant functions is a source of bloat, inefficiency - and general inelegance. After weighing things up, I decided it was better - to deprecate the redundant functions and have people begin to use the more - efficient versions, and eventually the redundant functions will be able to - be removed. - - So why did I choose to keep the more complicated name, DUH_SIGRENDERER? - The reason has to do with what DUMB will become in the future. Signals are - an inherent part of the DUH struct and how .duh files will be constructed. - It will be possible to have multiple signals in a single DUH struct, and - you will be able to choose which one you want to play (this is the 'sig' - parameter passed to duh_start_sigrenderer()). But don't hold your breath; - we still have a long way to go before .duh files will start to appear... - - -typedef DUH_SIGRENDERER DUH_RENDERER; - - Wherever you are using DUH_RENDERER in your program, simply replace it - with DUH_SIGRENDERER. An automated (case-sensitive!) search and replace - operation should get this done. - - -DUH_RENDERER *duh_start_renderer(DUH *duh, int n_channels, long pos); - - Use duh_start_sigrenderer() instead. It takes an extra parameter, 'sig', - which comes after 'duh' and before 'n_channels'; pass 0 for this. So an - example would be, replace: - - sr = duh_start_renderer(duh, 2, 0); - - with: - - sr = duh_start_sigrenderer(duh, 0, 2, 0); - - -int duh_renderer_get_n_channels(DUH_RENDERER *dr); -long duh_renderer_get_position(DUH_RENDERER *dr); -void duh_end_renderer(DUH_RENDERER *dr); - - These are easy enough to fix; all you have to do is replace 'renderer' - with 'sigrenderer'. So the new functions are: - - int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer); - long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer); - void duh_end_sigrenderer(DUH_SIGRENDERER *sigrenderer); - - -Note that duh_render() has NOT been deprecated. It now uses DUH_SIGRENDERER -instead of DUH_RENDERER, but its functionality is unchanged. You do not have -to change calls to this function in any way. - - -DUH_RENDERER *duh_renderer_encapsulate_sigrenderer(DUH_SIGRENDERER *sr); -DUH_SIGRENDERER *duh_renderer_get_sigrenderer(DUH_RENDERER *dr); -DUH_SIGRENDERER *duh_renderer_decompose_to_sigrenderer(DUH_RENDERER *dr); - - These functions did not exist in the last release of DUMB, so you are - probably not using them, but they are included here for completeness. All - you have to do here is unwrap the function, since the structs have been - unified. So, for instance, replace: - - duh_renderer_encapsulate_sigrenderer(my_sigrenderer) - - with: - - my_sigrenderer - - Simple! - - -AL_DUH_PLAYER *al_duh_encapsulate_renderer(DUH_RENDERER *dr, - float volume, long bufsize, int freq); -DUH_RENDERER *al_duh_get_renderer(AL_DUH_PLAYER *dp); -DUH_RENDERER *al_duh_decompose_to_renderer(AL_DUH_PLAYER *dp); - - Again, these functions were not in the last release, so you probably - aren't using them. Nevertheless, the fix is simple as always: simply - replace 'renderer' with 'sigrenderer'. So the new functions are: - - AL_DUH_PLAYER *al_duh_encapsulate_sigrenderer(DUH_SIGRENDERER *sr, - float volume, long bufsize, int freq); - DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp); - DUH_SIGRENDERER *al_duh_decompose_to_sigrenderer(AL_DUH_PLAYER *dp); - - -********************* -*** Miscellaneous *** -********************* - - -long duh_render_signal(DUH_SIGRENDERER *sigrenderer, - float volume, float delta, - long size, sample_t **samples); - - This function used to return samples in DUMB's internal format. This - format consisted of 32-bit integers whose 'normal range' was -0x8000 to - 0x7FFF (any samples outside this range would have to be clipped when sent - to the sound card). - - DUMB's internal format has changed. DUMB still uses 32-bit integers, but - now the normal range is -0x800000 to 0x7FFFFF. The lowest eight bits are - discarded at the final stage by duh_render() when you ask for 16-bit - output. A new function, duh_sigrenderer_get_samples(), will return samples - in DUMB's new internal format. It takes exactly the same parameters, so - all you have to do to the call itself is change the name; however, you - will most likely have to change your code to account for the new - normalised range. - - duh_render_signal() will still be able to give you the samples in DUMB's - old internal format, but it is inefficient. You should change your code as - soon as possible. - - -typedef void (*DUH_SIGRENDERER_CALLBACK)(void *data, sample_t **samples, - int n_channels, long length); - -void duh_sigrenderer_set_callback(DUH_SIGRENDERER *sigrenderer, - DUH_SIGRENDERER_CALLBACK callback, void *data); - - This callback was intended to allow you to analyse the output. It was by - no means intended to let you modify the output. For this reason, the names - have been changed to DUH_SIGRENDERER_ANALYSER_CALLBACK and - duh_sigrenderer_set_analyser_callback, and the 'samples' parameter to your - callback should now be specified as follows: - - const sample_t *const *samples - - The first 'const' indicates that you must not modify the samples. The - second indicates that you must not modify the pointers to each channel. - - There is a second reason why this change was necessary, and it is the one - described further up for duh_render_signal()'s entry: the format in which - the samples themselves are stored has changed. They are 256 times as - large, with a normal range from -0x800000 to 0x7FFFFF. You will most - likely need to change your code to account for this. - - If you try to call the old function, it will print a message to stderr - directing you to this file, and it will not install the callback. You - shouldn't be able to get this far without a compiler warning (or, if you - don't have GCC 3.1 or later, some compiler errors). - - If you wanted to use this callback to apply a DSP effect, don't worry; - there is a better way of doing this. It is undocumented, so contact me - and I shall try to help. Contact details are at the bottom of this file. - - For reference, here are the new definitions: - - typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data, - const sample_t *const *samples, int n_channels, long length); - - void duh_sigrenderer_set_analyser_callback(DUH_SIGRENDERER *sigrenderer, - DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data); - - -int dumb_resampling_quality; - - This variable has changed meaning. It used to hold a value from 0 to 4, - whose meaning was as follows: - - 0 - aliasing - 1,2 - linear interpolation - 3 - quadratic interpolation - 4 - cubic interpolation - - 0,1 - always use a straightforward interpolation algorithm - 2,3,4 - when decimating (increasing the pitch), use a linear average - algorithm designed to reduce frequencies that would otherwise - reflect off the Nyquist - - Now the variable only holds values from 0 to 2, and these values have - preprocessor constants associated with them. The somewhat inappropriate - quadratic interpolation has been removed. The linear average algorithm has - also been removed, and may or may not come back; there are probably more - efficient ways of achieving the same effect, which I shall be - investigating in the future. - - This change will have hardly any noticeable effect on existing programs. - Levels 2, 3 and 4 used considerably more processor time because of the - linear average algorithm. Likewise, Level 2 in the new scheme (cubic) uses - considerably more processor time than Levels 1 and 0, and Levels 3 and 4 - will behave identically to Level 2. - - -****************** -*** Conclusion *** -****************** - - -"I conclude that... DUMB is the bestest music player in the world because... -Complete this sentence in fifteen words or fewer... D'OH!" - -The preceding conclusion formerly appeared in dumb.txt, and is deprecated -because it's lame. - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/duhspecs.txt b/dumb/docs/duhspecs.txt deleted file mode 100644 index 43b3d39c15..0000000000 --- a/dumb/docs/duhspecs.txt +++ /dev/null @@ -1,296 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * duhspecs.txt - DUH File Specifications. / / \ \ - * | < / \_ - * Written by entheh, one of the few programmers | \/ /\ / - * in existance who can spell correctly. \_ / > / - * | \ / / - * | ' / - * \__/ - */ - -Technical Details -================= - -WARNING: until this warning disappears, the DUH file format could change at -any moment. This should not be of great concern, since DUH files are not -designed to be edited directly, but will always be generated from some other -format. However, it is our intention that this warning be removed before the -first release. - -This document is written chiefly in the context of writing a DUH file, since -the library already contains the necessary functionality to read and play a -DUH file. - -DUH files are currently saved using Allegro's file compression routines. See -Allegro's documentation and source code for details on this system. If you -wish to port DUMB away from Allegro and wish to preserve the file compression -capabilities, you will have to borrow the packfile source code from Allegro. - -If you are happy to do away with file compression, please store the following -four-byte signature before the rest of the file: "slh." Alternatively, write -your DUH file writer with Allegro, and open the file with F_WRITE_NOPACK. -This will enable versions of the library using Allegro's file compression -routines to load the file. If you are reading a DUH file and you detect the -signature "slh!", then the file is compressed (and is not necessarily a DUH -file). - -All numbers are little-endian unless specified otherwise. Allegro's -pack_iget*() and pack_iput*() functions can be used to read and write data in -this format. However, the four-byte signatures can be encoded into long ints -with AL_ID() and read and written with pack_m*(). - - -Overall Structure -================= - -Size Type Value Example C code to save to PACKFILE *f - - 4 ID "DUH!" pack_mputl(AL_ID('D','U','H','!'), f); - 4 Int Number of signals pack_iputl(n_signals, f); - -For each signal { for (i = 0; i < n_signals; i++) { - 4 ID Signal type pack_mputl(AL_ID('S','E','Q','U'), f); - * - Signal data write_sequence(f); -} } - -* The size of the data for any signal must either be constant or somehow - encoded in the data themselves. The library contains functions to read - various standard signal types, including "SAMP" and "SEQU" (sample and - sequence respectively), and the formats for these types are laid out - further down. If you wish to create your own signals, you must provide your - own loading function for the signal. This will be described in more detail - in a separate file. - -In order to play a DUH file, we simply play the first signal. Signals can -construct their sound from the samples of other signals, and they in turn can -use other signals. Thus a recursive structure is built up. Recursive cycles -are not permitted. - - -Signal: SAMP (Sample) -===================== - -Size Type Value Example C code to save to PACKFILE *f - - 4 Int Size pack_iputl(size, f); - 1 Bits Flags pack_putc(flags, f); - 1 ID Compression type pack_putc(compress, f); /* NOT IMPLEMENTED YET */ - -The flags are stored in a bit-field. Bit 0 indicates whether 16-bit samples -(set) or 8-bit samples (clear) are stored in the file. In both cases, the -samples are signed. NOTE: this bit might be replaced with a system allowing -for various sample compression algorithms, or altered so there are different -signal types for the purpose. - -If Bit 1 is set, the sample is a looping sample, and loops indefinitely. In -this case the loop start point will be saved. The loop end point is not -saved, and is assumed to be the end of the sample. (When creating DUH files -from other formats which allow for the loop end to be earlier, you should -truncate the sample.) - -If Bit 1 is not set, then Bit 2 may be set to indicate that the sample is -looping but only loops a finite number of times before continuing to play -normally. In this mode, both loop points (start and end) are saved in the -file. The number of times to loop will be specified on an instance-by- -instance basis using signal parameter #0, which should be set immediately -(before any samples are rendered) if it is to be set at all. It defaults to 0 -(so the sample just plays through normally). In fact this parameter's value -is added to the loop count, but this is immaterial since there is no reason -to specify it more than once. - -If Bit 1 is set, you should make sure Bit 2 is clear to allow for the -possibility of future expansion. - -If Bit 3 is set, a ping-pong loop is used. When the sample reaches the loop -end point, it starts to play backwards until it reaches the loop start point, -at which time it will resume forward playback. When using a finite loop, -every change of direction counts as one iteration. That means an odd loop -count will cause the sample to proceed backwards when the looping ends. - -If neither Bit 1 nor Bit 2 is set, then neither loop point will be saved. In -this case, you should also make sure Bit 3 is clear for the same reason as -above. - -You may find the following definitions useful: - -#define SAMPFLAG_16BIT 1 -#define SAMPFLAG_LOOP 2 -#define SAMPFLAG_XLOOP 4 -#define SAMPFLAG_PINGPONG 8 - -#define SAMPPARAM_N_LOOPS 0 - -Size Type Value Example C code to save to PACKFILE *f - - 4 Int Loop start pack_iputl(loop_start, f); - 4 Int Loop end pack_iputl(loop_end, f); - -For a 16-bit sample: if (flags & SAMPFLAG_16BIT) - for (n = 0; n < size; n++) - x*2 Int Sample data pack_iputw(sample[n], f); -For an 8-bit sample: else - for (n = 0; n < size; n++) - x*1 Int Sample data pack_putc(sample[n], f); - -/* -Compression type is 0 for uncompressed PCM. -*/ - - -Signal: SEQU (Sequence) -======================= - -Size Type Value Example C code to save to PACKFILE *f - - 4 Int Size size = pack_igetl(f); - x - Sequencing data pack_fwrite(data, size, f); - -The sequence signal provides a medium in which other signals can be played at -specific times for specific lengths. You can control the pitch, volume and -other parameters for a signal, and these can change during the signal. - -A sequence consists of a series of commands. Each command is preceded by a -time, which measures how long to wait before executing this command. A time -of zero indicates that this command is simultaneous with the previous. A time -of -1 indicates the end of the sequence. Note that signals do not stop -playing when the end is reached. - -All times are measured in units such that 65536 corresponds to one second. -The timing in DUMB is accurate to the nearest sample, and cannot be offset in -the way it can with much mixing software, so you can rely on timing to -achieve certain effects. Resampling should be accurate enough to satisfy the -most acute musician's ear, but juggling pitches at this level of accuracy -requires knowledge of temperaments such as many musicians do not have. The -vast majority of people are satisfied with the even temperament. More on this -later. - -Size Type Value Example C code to save to PACKFILE *f - - 4 Int Time pack_iputl(time, f); - 1 ID Command pack_putc(SEQUENCE_START_SIGNAL, f); - -/******************************** - Proposed change: - Time is a short, encoded in 2 bytes. - The value of 'time' is actually an unsigned offset from the time of the - previous command. 0 means at the same time as the last command. - If the time in between this signal and the previous one is larger than - 65534 ticks, then the value 65535 is written, followed by 4 more bytes (uint) - indicating the time offset. -**********************************/ - -Here are definitions for the various commands: - -#define SEQUENCE_START_SIGNAL 0 -#define SEQUENCE_SET_VOLUME 1 -#define SEQUENCE_SET_PITCH 2 -#define SEQUENCE_SET_PARAMETER 3 -#define SEQUENCE_STOP_SIGNAL 4 - -Below are the details of what to write after each command code. The various -fields are explained afterwards. - -Size Type Value Example C code to save to PACKFILE *f - -SEQUENCE_START_SIGNAL: - 1 ID Reference pack_putc(ref, f); - 4 Int Signal pack_iputl(signal, f); /* --> Can we drop this to 2 bytes? (65536 signals) */ - 4 Int Starting position pack_iputl(pos, f); - 2 Int Volume pack_iputw(volume, f); - 2 Int Pitch pack_iputw(pitch, f); - -SEQUENCE_SET_VOLUME: - 1 ID Reference pack_putc(ref, f); - 2 Int Volume pack_iputw(volume, f); - -SEQUENCE_SET_PITCH: - 1 ID Reference pack_putc(ref, f); - 2 Int Pitch pack_iputw(pitch, f); - -SEQUENCE_SET_PARAMETER: - 1 ID Reference pack_putc(ref, f); - 1 ID Parameter ID pack_putc(id, f); - 4 Int Value pack_iputl(value, f); - -SEQUENCE_STOP_SIGNAL: - 1 ID Reference pack_putc(ref, f); - -When you initiate a signal, you must choose a reference number. If you want -to modify the signal's volume, pitch or parameters, or stop the signal later, -you must use this reference number to do so. Need more than 256 reference -numbers? Use two sequences, and get your brain seen to. - -If you initiate a new signal with the same reference number, the reference -will belong to the new signal. The old signal becomes anonymous, and will -either continue to play indefinitely or stop of its own accord. Even if the -new signal stops, the old one remains anonymous. DUMB will safely ignore -operations on reference numbers not used by any signal, or which were used by -a signal which has now stopped. - -Of course all signals will stop if the sequence itself is stopped. - -To initiate a signal, you must index the signal. The index is 0-based, so to -initiate the fifth signal in the file you must specify 4. Out-of-range values -will be handled safely, as will the case where a signal tries to generate -itself directly or indirectly from its own samples (a recursive cycle). - -When you initiate a signal, you can specify a starting position. This will be -passed directly to the appropriate signal's start_samples function, so for a -SAMP (sample) signal it represents the sample on which to start, after any -loops have been expanded (so you can start on the backwards-playing part of -a ping-pong loop for example by careful choice of the starting position). - -Volume is probably the simplest parameter. It is on a linear scale ranging -from 0 to 65535. Note that most music sounds more dramatic if the volume -rises and falls exponentially or on a greater curve. Linear fades are more -suitable for fading in and out, and do not sound dramatic in the least. - -Pitch is specified on what is perceived as a linear scale. It is in fact -logarithmic, but you will not need to worry about this for most purposes. -Pitch 0 represents that the sample will be played at 65536 Hz. (This is not -strictly true, and will be explained further later.) In the likely case that -your sample is not recorded at 65536 Hz, you will first need to calculate the -central pitch. Use the following formula: - -pitch_centre = 12 * 256 * log(sampling_frequency / 65536.0) / log(2); - -If your programming language does not have a log function, look for ln, or -any function that calculates the logarithm (to any base) of the number you -give it. If you are lucky enough to find a logarithm to base 2, you can omit -the final division since the divisor evaluates to 1. - -Once you have calculated pitch_centre, you can use it to play the sample at -the frequency at which it was recorded. Each time you add or subtract 256, -the sample will increase or decrease respectively in pitch by one semitone in -the even temperament. (The even temperament was noted further up as being -suitable for most musical applications.) One octave is represented by an -interval of 12 * 256. - -If you wish to use another temperament, you can calculate the appropriate -intervals in pitch as follows: - -pitch_interval = 12 * 256 * log(ratio) / log(2); - -where, for example, ratio = 1.5 for a perfect fifth. An octave is, of course, -still represented by 12 * 256. - -The SEQUENCE_SET_PARAMETER command needs little explanation. Quite simply, -the parameter ID and value you specify are passed on to the set_parameter -function of the signal to which this reference belongs. Exactly what this -does depends on the signal in question. - -Remember, a sequence is a signal in itself. Like all signals, it is subject -to changes in pitch. Increasing the pitch of a sequence will also speed it -up. This capability is used to allow DUH files to be rendered at different -sampling frequencies, and it is also available for use by the musician. This -means that samples are only played at 65536 Hz if the pitch of the sequence -itself has not been adjusted. diff --git a/dumb/docs/dumb.txt b/dumb/docs/dumb.txt deleted file mode 100644 index 4f6cc69b80..0000000000 --- a/dumb/docs/dumb.txt +++ /dev/null @@ -1,1699 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * dumb.txt - DUMB library reference. / / \ \ - * | < / \_ - * See readme.txt for general information on | \/ /\ / - * DUMB and how to set it up. \_ / > / - * | \ / / - * If you are new to DUMB, see howto.txt. | ' / - * \__/ - */ - - -*********************************** -*** Include Files and Libraries *** -*********************************** - - -dumb.h - - Include this if you only want the core DUMB library functions. You will - be able to load music files and render them into memory buffers at your - own pace. The core library is completely portable, and as such does not - access hardware; you must relay the sound data to the sound card yourself. - A stdio file input module is available, but you must actively register it - if you wish to use it (see dumb_register_stdfiles()); if you do not - register it, it will not be linked into your executable. You must register - it, or a DUMBFILE module of your own, in order to load stand-alone music - files. - - Optimised: -ldumb or /link dumb.lib - Debugging: -ldumbd or /link dumbd.lib - - -aldumb.h - - Include this if you wish to use DUMB with Allegro. This will provide you - with functions to play DUHs back through Allegro's audio streams and embed - music files in Allegro datafiles. A file input module using Allegro's - packfiles is provided; you have a choice between this and the stdio - module (or provide one of your own). You will be able to load datafiles - containing music files no matter which file input module you register, or - even if you register no file input module. However, you must register a - file input module in order to load stand-alone files. - - Optimised: -laldmb -ldumb -lalleg or /link aldmb.lib alleg.lib dumb.lib - Debugging: -laldmd -ldumbd -lalld or /link aldmd.lib alld.lib dumbd.lib - - aldmb or aldmd must be linked in first, so the symbols can be resolved - when linking in the other two libraries. - - -*************************** -*** Version Information *** -*************************** - - -#define DUMB_MAJOR_VERSION -#define DUMB_MINOR_VERSION -#define DUMB_REVISION_VERSION - - Numeric constants representing this version of DUMB. If this were version - 1.0, DUMB_MAJOR_VERSION would be 1 and DUMB_MINOR_VERSION would be 0. - DUMB_REVISION_VERSION will be 0 on any significant releases, and will be - incremented as releases with bugfixes and minor features are made. - - Typical usage: - - #if DUMB_MAJOR_VERSION < 1 - #error This add-on requires DUMB v1.0 or higher. Please upgrade. - #endif - - -#define DUMB_VERSION - - A numeric constant which appears in the format MMmmrr when displayed in - decimal (M for major, m for minor, r for revision). This is most useful - for comparing version numbers; it has little other practical use. - - Typical usage: - - #if DUMB_VERSION < 801 - #error This game requires DUMB v0.8.1 or higher. Please upgrade. - #endif - - #if DUMB_VERSION < 10002 - #error This game requires DUMB v1.0.2 or higher. Please upgrade. - #endif - - -#define DUMB_VERSION_STR - - String constant representing this version of DUMB. If this were Version - 1.0, DUMB_VERSION_STR would be "1.0". DUMB_REVISION_VERSION will only - appear on the end if it is nonzero; then DUMB_VERSION_STR might be - "1.0.1". - - -#define DUMB_NAME - - A string identifying DUMB and its version. If this were Version 1.0, - DUMB_NAME might be "DUMB v1.0". This constant is suitable for use in your - Credits screen if you wish to acknowledge the use of DUMB there. - - -#define DUMB_YEAR -#define DUMB_MONTH -#define DUMB_DAY - - Numeric constants representing the year, month and day of this release of - DUMB. All four digits are included in the year. Please note that - DUMB_MONTH and DUMB_DAY were inadvertently swapped in the v0.8 release. - - -#define DUMB_YEAR_STR4 -#define DUMB_YEAR_STR2 -#define DUMB_MONTH_STR2 -#define DUMB_MONTH_STR1 -#define DUMB_DAY_STR2 -#define DUMB_DAY_STR1 - - String constants representing the year, month and day of this release of - DUMB. DUMB_MONTH_STR2 and DUMB_DAY_STR2 include a leading zero if the - month or day respectively are less than ten; the STR1 variations do not. - DUMB_YEAR_STR2 contains only the two rightmost digits of the year, while - DUMB_YEAR_STR4 contains all four. I recommend using DUMB_YEAR_STR4, - especially so soon after the turn of the century (indeed the millennium). - However, it is a matter of personal preference which you use. - - Please note that the month and day were inadvertently swapped in the v0.8 - release. - - -#define DUMB_DATE - - A numeric constant that appears in the form yyyymmdd when displayed in - decimal. This is most useful for comparing release dates; it has little - other practical use. - - WARNING: The month and day were inadvertently swapped in the v0.8 release. - Please do not compare this constant against any date in 2002. In - any case, DUMB_VERSION is probably more useful for this purpose. - - -#define DUMB_DATE_STR - - The date as a string. The format is "d.m.yyyy", with dots used as - separators, the day written first, four digits for the year, and no - leading zeros on the day or month. This is my preferred format. If you - don't like it, you can construct your own format using the other - constants. For example, "mm/dd/yy" could be constructed as follows: - - DUMB_MONTH_STR2 "/" DUMB_DAY_STR2 "/" DUMB_YEAR_STR2 - - Please note that the month and day were inadvertently swapped in the v0.8 - release. - - -************************* -*** Basic Sample Type *** -************************* - - -typedef int sample_t; - - DUMB works internally with 32-bit integer samples, with a 'normal range' - from -0x800000 to 0x7FFFFF (as of DUMB v0.9.2; previously they ranged from - -0x8000 to 0x7FFF). Any samples that exceed this range will eventually be - clipped, and could cause integer overflow in extreme cases. - - -*********************************** -*** Library Clean-up Management *** -*********************************** - - -int dumb_atexit(void (*proc)(void)); - - Registers a function to be called at the end of your program. You can - register multiple functions to be called, and the one you register last - will be called first. If you try to register the same function twice, the - second attempt will have no effect. - - See fnptr.txt for help with function pointers. - - You must call dumb_exit() before exiting your program for this to work - properly. The library itself registers functions with dumb_atexit(), so it - is important to call dumb_exit() even if you do not use dumb_atexit() - yourself. - - This function will return zero on success. It will return zero when - trying to install the same function twice. If it fails through lack of - memory, it will return nonzero. Generally you can ignore the return code; - in the worst case some memory will not be freed at the end. If it is - crucial that your function be called (e.g. to shut down some hardware or - save critical data), then you should call your function manually at the - end of the program instead of registering it here - or use the stdlib - function atexit(), guaranteed under ANSI C to succeed for at least 32 - functions. - - -void dumb_exit(void); - - You should call this before exiting your program if you have used any part - of DUMB in the program. Some parts of DUMB will allocate memory, and this - function will free it all up. - - More specifically, this function will call any functions that have been - registered with dumb_atexit(). If a part of DUMB needs shutting down, the - shutdown procedure will have been registered in this way. - - dumb_exit() will, of course, also call any functions you registered with - dumb_atexit() yourself. - - After a call to dumb_exit(), the list of functions is erased. If you are - not ready to exit your program, you can start using DUMB anew as if your - program had just started. (Note that not everything will be reset in - practice - dumb_resampling_quality will retain whatever you set it to, for - example, though you should not assume it will.) - - If you only need to call dumb_exit() once at the end of the program, you - can use the following to register dumb_exit() with stdlib.h atexit(): - - #include - - atexit(&dumb_exit); - - Then dumb_exit() will be called for you when your program exits. This is - the recommended method, since it will ensure clean-up even if your program - aborts. You should only call dumb_exit() manually if you need to shut DUMB - down prematurely, or if atexit() is unavailable for one reason or another. - - -***************************** -*** Sequential File Input *** -***************************** - - - DUMB provides a strictly sequential file input system which uses the - DUMBFILE struct. "Strictly sequential" means you cannot seek backwards. - However, the system will keep track of how many bytes you have read, - enabling you to seek forwards. DUMBFILEs provide a convenient error - detection system, so you do not have to check the return value from every - function call in the way you do with the ANSI C functions. - - Note that DUMBFILEs cannot be used for output, nor can they be used - portably for text files. - - If an error occurs when reading data from a DUMBFILE, the DUMBFILE will - become inoperative. All subsequent activities on the DUMBFILE will return - error codes without attempting to read from the file. The position in the - file will also be forgotten. You can find out if this has happened at any - stage with the dumbfile_error() function. You are still required to close - the DUMBFILE, and the return value from dumbfile_close() will tell you if - an error has occurred. - - This system allows you to input large chunks of your file, neither - checking every return value nor wasting time accessing a file that has - already experienced an error. However, before you allocate an amount of - memory or read in a quantity of data depending on previous input from the - file, you should always check that such input was valid. In particular you - should avoid passing zero or negative numbers to malloc(), and avoid - passing negative numbers to dumbfile_skip() and dumbfile_getnc(). - - DUMBFILEs can be hooked. In other words, you can specify your own - functions to do the work of reading from a file. While DUMB contains two - modules for this purpose, it does not set them up for you automatically. - In most cases you must register one of these modules yourself, or provide - your own module. See register_dumbfile_system(), dumb_register_stdfiles() - and dumb_register_packfiles(). - - -void register_dumbfile_system(DUMBFILE_SYSTEM *dfs); - - Use this function to register a set of functions for use by the DUMBFILEs - (a DUMBFILE system). The DUMBFILE_SYSTEM struct contains the following - fields: - - void *(*open)(const char *filename); - int (*skip)(void *f, long n); - int (*getc)(void *f); - long (*getnc)(char *ptr, long n, void *f); - void (*close)(void *f); - - See fnptr.txt for help with function pointers such as these. - - Your 'open' function should open the file specified and return a pointer - to a struct representing the open file. This pointer will be passed to - your other functions as 'f'. Your 'close' function should close the file - and free all memory pointed to by 'f'. Note that the 'close' operation - should never be able to fail; if you are calling a function with a return - value, you can generally ignore it. - - Your 'getc' function should read one byte from the file and return its - value in the range 0 to 255. If an error occurs, you should return -1. Do - not worry about remembering that an error has occurred; DUMB will do that - for you. - - 'skip' is for skipping parts of the file, and should skip n bytes, - returning 0 on success or any other number on failure. 'getnc' should read - n bytes from the file, store them at 'ptr', and return the number of bytes - read (n on success, fewer on failure). However, these two functions are - optional, and you should only provide them if the operations can be done - more efficiently than with repeated calls to your 'getc' function. If this - is not the case, specify NULL for 'skip', 'getnc' or both, and DUMB will - use your 'getc' function to do the work. - - Once you have written all your functions, you need to create a - DUMBFILE_SYSTEM struct to hold them, and pass its pointer to - register_dumbfile_system(). - - The DUMBFILE_SYSTEM struct must be permanent. In other words, it must be - either global or static, and you should not modify it later. DUMB will not - make its own copy. - - You will most likely create your own struct to represent the open file, - but do not be tempted to specify that struct in the function prototypes - and pacify the compiler warnings by casting your function pointers. There - exist computer systems where a (void *) pointer and a (MY_STRUCT *) - pointer are represented differently in memory, and a cast of such a - pointer causes a tangible conversion to take place. If you cast the - function pointers, the computer cannot know when such a conversion is - necessary. Instead, use the following structure: - - int myskip(void *f, long n) - { - FILE *file = f; - /* Do some stuff with 'file' */ - return something; - } - - If you need examples, have a look at the two existing DUMBFILE systems in - dumb/src/core/stdfile.c and dumb/src/allegro/packfile.c. - - -DUMBFILE *dumbfile_open(const char *filename); - - Open the specified file for input. You must pass the DUMBFILE pointer - whenever you wish to operate on this file. When you have finished with the - file, you must pass it to dumbfile_close(). - - Before you use this function, make sure you have registered a DUMBFILE - system. See register_dumbfile_system(), dumb_register_stdfiles() and - dumb_register_packfiles(). - - You must check the return value from this function. If it is NULL, the - file could not be opened, and you must not pass the DUMBFILE to any other - function. The debugging library will abort if you get this wrong; the - optimised library will act weird. - - -DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs); - - This function is provided for more specialised use. You should create a - DUMBFILE_SYSTEM specially for the purpose. Its 'open' field is irrelevant; - for neatness, set it to NULL, unless you are using this DUMBFILE_SYSTEM - with register_dumbfile_system() as well. - - When you have called this function, the DUMBFILE struct it returned can be - used as normal. The specified DUMBFILE_SYSTEM will be used for all input, - with 'file' passed to your 'skip', 'getc' and 'getnc' functions as 'f'. - This can be used, for example, to read from an already open file. - - Note that the position will always be initialised to 0 for this DUMBFILE. - This means for example that offsets in the file do not need adjusting when - embedding data in a larger file. - - There are two ways to use this function. If you want 'file' to persist - after using a DUMBFILE returned by this function, you should make sure the - 'close' field in the DUMBFILE is set to NULL. When the DUMBFILE is closed, - 'file' will be left alone, and you can and should deal with it yourself - when the DUMBFILE has been closed. - - Alternatively, you can provide a 'close' function to get rid of 'file' for - you when the DUMBFILE is closed. If you do this, you should not otherwise - use 'file' after a call to this function. - - If dumbfile_open_ex() has to return NULL, owing to lack of memory, then - your 'close' function will be called if provided. In other words, if you - have provided a 'close' function, then you no longer need to worry about - 'file' whether this function succeeds or not. - - See dumb/src/helpers/stdfile.c and dumb/src/allegro/packfile.c for - examples of how to use this function. Neither provides a 'close' function, - so I hope my explanation here will suffice. If not, please feel free to - contact me so I can make the explanation clearer and help you do what you - want to do. Contact details are at the end of this file. - - -long dumbfile_pos(DUMBFILE *f); - - Returns the number of bytes read from the DUMBFILE (or skipped) since it - was opened, or -1 if an error has occurred while reading. - - -int dumbfile_skip(DUMBFILE *f, long n); - - Skips n bytes of the specified DUMBFILE. Returns zero on success. - - -int dumbfile_getc(DUMBFILE *f); - - Reads one byte from the DUMBFILE and returns it in unsigned format (from 0 - to 255). If an error occurs, or occurred before, this function returns -1. - - -int dumbfile_igetw(DUMBFILE *f); - - Reads two bytes from the DUMBFILE and combines them into a word ranging - from 0 to 65535. The first byte read is the least significant byte, as - with Intel processors. This function returns -1 on error. - - -int dumbfile_mgetw(DUMBFILE *f); - - Reads two bytes from the DUMBFILE and combines them into a word ranging - from 0 to 65535. The first byte read is the most significant byte, as - with the Apple Macintosh. This function returns -1 on error. - - -long dumbfile_igetl(DUMBFILE *f); - - Reads four bytes from the DUMBFILE and combines them into a long integer - ranging from -2147483648 to 2147483647. The first byte read is the least - significant byte, as with Intel processors. This function returns -1 on - error, but -1 is also a valid return value. After a call to this function, - you can use dumbfile_error() to find out if an error occurred. - - -long dumbfile_mgetl(DUMBFILE *f); - - Reads four bytes from the DUMBFILE and combines them into a long integer - ranging from -2147483648 to 2147483647. The first byte read is the most - significant byte, as with the Apple Macintosh. This function returns -1 on - error, but -1 is also a valid return value. After a call to this function, - you can use dumbfile_error() to find out if an error occurred. - - -unsigned long dumbfile_cgetul(DUMBFILE *f); - - Reads an unsigned (nonnegative) integer from the DUMBFILE. The integer is - stored in a condensed format where smaller numbers use less space: - - 0 to 127 1 byte - 128 to 16383 2 bytes - 16384 to 2097151 3 bytes - 2097152 to 268435455 4 bytes - 268435456 to 4294967295 5 bytes - - This format is the same as that used for the times between notes in MIDI - files. - - If an error occurs, this function returns (unsigned long)(-1), but that - may be a valid return value. After a call to this function, you can use - dumbfile_error() to find out if an error occurred. - - -signed long dumbfile_cgetsl(DUMBFILE *f); - - Reads a signed integer from the DUMBFILE. The integer is stored in a - condensed format where numbers closer to zero use less space: - - -64 to 63 1 byte - -8192 to 8191 2 bytes - -1048576 to 1048575 3 bytes - -134217728 to 134217727 4 bytes - -2147483648 to 2147483647 5 bytes - - If an error occurs, this function returns -1, but -1 is also a valid - return value. After a call to this function, you can use dumbfile_error() - to find out if an error occurred. - - -long dumbfile_getnc(char *ptr, long n, DUMBFILE *f); - - Reads n bytes from the DUMBFILE and stores them at 'ptr'. Note that the - pointer is to a series of chars. You may also use this function to read in - a series of signed chars or unsigned chars (which are both officially - distinct types from char), but do not use this to read ints, structs or - any other data type from the file. Integers must be read one at a time - using dumbfile_igetl(), dumbfile_cgetul(), etc. To load a struct in, you - must read each field separately using an appropriate function for each - one. For complicated data types, you can simplify this process by writing - a function for each struct. - - dumbfile_getnc() returns the number of bytes successfully read, which will - be less than n if an error occurs, and may be as low as zero. If - dumbfile_getnc() returns -1, that means an error occurred on this DUMBFILE - earlier, before this function was called. - - -int dumbfile_error(DUMBFILE *f); - - This function returns -1 if an error has occurred with the specified - DUMBFILE, or 0 if all is well. - - -int dumbfile_close(DUMBFILE *f); - - This function closes the DUMBFILE, after which the pointer will be - invalid. dumbfile_close() returns the value that dumbfile_error() would - have returned, which is -1 if an error occurred while reading or 0 - otherwise. Regardless of the return value, the file will always be closed - properly. - - -******************************* -*** stdio File Input Module *** -******************************* - - -void dumb_register_stdfiles(void); - - This function registers the stdio file input module for use by DUMBFILEs. - FILE structs and their corresponding functions, as defined by the ANSI C - header stdio.h, will be used internally for all DUMBFILE input (unless - opened with dumbfile_open_ex()). - - This must be called before dumbfile_open() is used, or else an alternative - system must be registered (see register_dumbfile_system() and - dumb_register_packfiles()). - - -DUMBFILE *dumbfile_open_stdfile(FILE *p); - - If you have a stdio FILE struct representing an open file, you can call - this if you wish to read from it using a DUMBFILE. This is useful when you - need to pass a DUMBFILE struct to a library function, to read an embedded - music file for example. When you close the DUMBFILE, you can continue - using the FILE struct to read what follows the embedded data. - - -******************************** -*** Memory File Input Module *** -******************************** - - -DUMBFILE *dumbfile_open_memory(const char *data, long size); - - This function is useful if you have an image of a music file in memory. - You might have such an image if you use dat2s to encode a datafile - directly into the executable. Pass a pointer to the start of the memory, - and the size of the image to make sure DUMB doesn't overrun the buffer. - The resulting DUMBFILE will feed the contents of the image to you. - - Note that the pointer is of type 'char *'. Files are series of chars, and - interpreting them directly as anything else isn't portable. - - -********************** -*** DUH Management *** -********************** - - -void unload_duh(DUH *duh); - - Removes a DUH from memory. You must call this for all DUHs you load, - making sure they're not playing at the time. - - -long duh_get_length(DUH *duh); - - Returns the length of a DUH; 65536 represents one second. This value is - calculated when the DUH is created, and this function simply lifts it from - the struct. It may not truly correspond to the time for which the DUH will - generate sound. For module files, it will represent the point at which the - module first loops (or, in the case of some XM and MOD files, freezes). - Any add-ons to DUMB will provide their own code for calculating this. - - The algorithm for calculating the length of a module file can be fooled, - but only by very deliberate methods. In the early days, when modules could - only be played by their editors and had to be exported to .wav or similar - in order to be used elsewhere, musicians would sometimes make the player - think it was looping when it wasn't in order to prevent their music from - being exported properly. If the length of a module seems a lot less than - it should be, the module is probably protected in this way. - - Getting around this protection reliably would be extremely difficult, but - after considering it for a while I decided it would be better not to. The - musician has a right to protect his or her music in this way, and I have - no interest in actively breaking that protection. - - (On the other hand, some musicians were just showing off!) - - -*********************************** -*** IT, XM, S3M and MOD Support *** -*********************************** - - -int dumb_it_max_to_mix; - - Specifies the maximum number of samples DUMB will mix at any one time. The - default number is 64. Regardless of this value, all samples will continue - to be processed up to an internal maximum of 256 (roughly speaking; in - fact it will process one sample for each channel plus up to 192 extra - samples that are continuing to play owing to Impulse Tracker's New Note - Actions), and samples that have been cut will sound again as soon as the - congestion clears. Samples are given priority according to their final - volume after all factors affecting the volume of a sample have been - considered. - - If you play two or more modules at once, this value represents the - maximum number of samples for each one. You will have to reduce it further - if your computer cannot keep up. - - Despite the name, this variable controls XM, S3M and MOD files as well as - IT files. - - -DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh); - - This function attempts to retrieve the DUMB_IT_SIGDATA struct from a DUH. - This struct will exist for any IT, XM, S3M or MOD file, and you can use it - to obtain or override module-specific information. If 'duh' is NULL, or if - the DUH you pass contains something other than a music module, then this - function will return NULL (which can safely be passed to any other - function). - - -DUMB_IT_SIGRENDERER *duh_get_it_sigrenderer(DUH_SIGRENDERER *sigrenderer); - - This function attempts to retrieve the DUMB_IT_SIGRENDERER struct from a - DUH_SIGRENDERER. This struct will exist for any currently playing IT, XM, - S3M or MOD file, and you can use it to obtain or override information - specific to module playback. If 'sigrenderer' is NULL, or if the - DUH_SIGRENDERER you pass is rendering something other than a music module, - then this function will return NULL (which can safely be passed to any - other function). - - -DUH_SIGRENDERER *dumb_it_start_at_order - (DUH *duh, int n_channels, int startorder); - - This function, given a DUH containing an IT, XM, S3M or MOD file, will - start playing it at the specified order. If the DUH does not contain a - module, this function will fail and return NULL. - - Note that starting at an arbitrary order may result in missing notes or - other playback oddities. It should be used primarily for modules that - contain multiple songs that start on different orders. If you wish just to - start some music in the middle, consider using duh_start_sigrenderer() or - al_start_duh() with the pos parameter set appropriately. - - -void dumb_it_set_loop_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data), void *data); - - Installs a callback which will be called every time the module loops. You - can pass any data pointer you like, and it will be passed to the callback - for you. DUMB considers a file to loop when it reaches the end, or when a - 'Jump to order' effect (Bxx in both IT/S3M and XM/MOD) jumps to the same - order or a preceding order. This can result in the loop callback being - called when the module isn't really looping, but this only happens if the - module has a very deliberate design. See duh_get_length() for further - musings on this subject. - - If your callback returns nonzero, the music will stop abruptly. Samples - will be cut, and the main program will be notified that the - DUH_SIGRENDERER has ended. - - Alternatively, if you pass the DUMB_IT_SIGRENDERER for 'data', or - otherwise arrange for it to be available to the callback, then you can - call: - - dumb_it_sr_set_speed(sigrenderer, 0); - - from inside the callback, and this will cause the music to freeze but - samples will be able to continue playing. The xm_speed_zero callback will - NOT be called in this case (see below for information on this callback). - Note also that setting the speed in this way will work equally for IT and - S3M files, even though a 'speed zero' effect can only exist in XM and MOD - files. Beware when using this method; samples might not fade at all! - - A helper callback, dumb_it_callback_terminate(), is provided; installing - this will cause the music to terminate when it tries to loop for the first - time. - - Pass NULL to remove the callback function; the module will then loop as - normal. - - -void dumb_it_set_xm_speed_zero_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data), void *data); - - Installs a callback which is in many ways similar to the loop callback - (see dumb_it_set_loop_callback()). This callback will be called whenever - an F00 effect is encountered in a MOD or XM file, setting the speed to - zero. If the callback returns nonzero, the music will terminate. If not, - any currently playing samples will continue to play. You can pass any data - pointer you like to this function, and it will be passed to your callback - for you. - - The helper callback, dumb_it_callback_terminate(), will also work here; - installing it will cause the music to terminate as soon as an F00 effect - is encountered. - - Pass NULL to remove the callback function. - - -void dumb_it_set_midi_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data, int channel, unsigned char byte), - void *data); - - Installs a callback function which will be called whenever MIDI data are - generated by an IT file. (No other module formats are capable of - generating MIDI data, so your callback will never be called.) - - Zxx macros will generate MIDI data. These are most often used to set the - parameters for IT's low-pass resonant filters, and DUMB will handle these - messages by itself by default. See Impulse Tracker's documentation for - the MIDI messages that control filters. However, Zxx macros can be used - to send any kind of MIDI data. - - If you wish to interpret MIDI messages yourself, you can use this - callback. Note that the only MIDI messages generated by DUMB at present - are from Zxx macros; there are no messages for note start, stop, or - anything else. - - If you return 1 from this callback, DUMB will subsequently ignore the byte - of MIDI data. You can use this to prevent Zxx macros from controlling the - filters, useful if they were intended to do something else. Note that this - is NOT an effective way to disable filters, since instruments can have - filter envelopes and initial filter parameters. DUMB provides no means to - disable filters, as any IT file that uses them will sound wrong without - them. If you want lower processor consumption, use a different piece of - music. - - A helper callback, dumb_it_callback_midi_block(), is provided for blocking - all MIDI messages and making Zxx macros do nothing. - - Pass NULL to remove the callback. - - -int dumb_it_callback_terminate(void *data); - - This is a helper callback that can be installed with both - dumb_it_set_loop_callback() and dumb_it_set_xm_speed_zero_callback(). In - each case it will cause the music to terminate abruptly. - - -int dumb_it_callback_midi_block(void *data, int channel, unsigned char byte); - - This helper callback, for use with dumb_it_set_midi_callback(), will - absorb all MIDI messages, returning 1 to prevent DUMB from interpreting - them itself. - - -DUH *dumb_load_it(const char *filename); - - Loads the specified Impulse Tracker file, encapsulating it in a DUH - struct. Once the file is loaded, it can be treated exactly the same as any - other DUH in memory. If this fails it will return NULL, but you can safely - pass this NULL value to DUMB's other functions, so you do not need to - check the return value explicitly. - - -DUH *dumb_read_it(DUMBFILE *f); - - Reads an Impulse Tracker file from an already open DUMBFILE. This leaves - the DUMBFILE open, but the DUMBFILE may not be positioned at the end of - the IT data. If you are embedding an IT in another file, you are advised - to store the size of the IT file and make up for it at the end using - dumbfile_pos(). - - Otherwise, this function is identical to dumb_load_it(). - - WARNING: The behaviour of this function is undefined if you pass a - DUMBFILE from which data have already been read; it is likely not - to work. This oversight will be fixed in future releases. - - -DUH *dumb_load_xm(const char *filename); - - Loads the specified Fast Tracker II file, encapsulating it in a DUH - struct. Once the file is loaded, it can be treated exactly the same as any - other DUH in memory. If this fails it will return NULL, but you can safely - pass this NULL value to DUMB's other functions, so you do not need to - check the return value explicitly. - - -DUH *dumb_read_xm(DUMBFILE *f); - - Reads a Fast Tracker II file from an already open DUMBFILE. This leaves - the DUMBFILE open, but the DUMBFILE may not be positioned at the end of - the XM data. If you are embedding an XM in another file, you are advised - to store the size of the XM file and make up for it at the end using - dumbfile_pos(). - - Otherwise, this function is identical to dumb_load_xm(). - - WARNING: The behaviour of this function is undefined if you pass a - DUMBFILE from which data have already been read; it is likely not - to work. This oversight will be fixed in future releases. - - -DUH *dumb_load_s3m(const char *filename); - - Loads the specified Scream Tracker 3 file, encapsulating it in a DUH - struct. Once the file is loaded, it can be treated exactly the same as any - other DUH in memory. If this fails it will return NULL, but you can safely - pass this NULL value to DUMB's other functions, so you do not need to - check the return value explicitly. - - -DUH *dumb_read_s3m(DUMBFILE *f); - - Reads a Scream Tracker 3 file from an already open DUMBFILE. This leaves - the DUMBFILE open, but the DUMBFILE may not be positioned at the end of - the S3M data. If you are embedding an S3M in another file, you are advised - to store the size of the S3M file and make up for it at the end using - dumbfile_pos(). - - Otherwise, this function is identical to dumb_load_s3m(). - - WARNING: The behaviour of this function is undefined if you pass a - DUMBFILE from which data have already been read; it is likely not - to work. This oversight will be fixed in future releases. - - -DUH *dumb_load_mod(const char *filename); - - Loads the specified Amiga module file, encapsulating it in a DUH struct. - Once the file is loaded, it can be treated exactly the same as any other - DUH in memory. If this fails it will return NULL, but you can safely pass - this NULL value to DUMB's other functions, so you do not need to check the - return value explicitly. - - -DUH *dumb_read_mod(DUMBFILE *f); - - Reads an Amiga module file from an already open DUMBFILE. This leaves the - DUMBFILE open, but the DUMBFILE may not be positioned at the end of the - MOD data. If you are embedding a MOD in another file, you are advised to - store the size of the MOD file and make up for it at the end using - dumbfile_pos(). - - Otherwise, this function is identical to dumb_load_mod(). - - WARNING: The behaviour of this function is undefined if you pass a - DUMBFILE from which data have already been read; it is likely not - to work. This oversight will be fixed in future releases. - - -int dumb_it_sd_get_n_orders(DUMB_IT_SIGDATA *sd); - - This function returns the number of orders in the module. - - -int dumb_it_sd_get_initial_global_volume(DUMB_IT_SIGDATA *sd); -void dumb_it_sd_set_initial_global_volume(DUMB_IT_SIGDATA *sd, int gv); - - These functions obtain and set the initial global volume for the module. - This value ranges from 0 to 128 inclusive. The module can set the global - volume itself during playback, so your change may not last throughout the - playback. - - -int dumb_it_sd_get_mixing_volume(DUMB_IT_SIGDATA *sd); -void dumb_it_sd_set_mixing_volume(DUMB_IT_SIGDATA *sd, int mv); - - These functions obtain and set the mixing volume for the module. This - value ranges from 0 to 128 inclusive, and does not change during playback. - IT files have the mixing volume stored in them; for other formats it is - set to 48 on loading. - - -int dumb_it_sd_get_initial_speed(DUMB_IT_SIGDATA *sd); -void dumb_it_sd_set_initial_speed(DUMB_IT_SIGDATA *sd, int speed); -int dumb_it_sd_get_initial_tempo(DUMB_IT_SIGDATA *sd); -void dumb_it_sd_set_initial_tempo(DUMB_IT_SIGDATA *sd, int tempo); - - These functions obtain and set the initial speed and tempo for the module. - During module playback, everything happens on a tick. If a beat is 24 - ticks, then the tempo is measured in beats per second. The speed is then - the number of ticks per row. With a speed of 6, a beat is then four rows. - - Modules can set these values during playback, so your change may not last - throughout the playback. MOD files have to set the speed and tempo on the - first row if they want anything other than the default 6/125, so your - change may not be noticed at all! - - -int dumb_it_sd_get_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel); -void dumb_it_sd_set_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel, - int volume); - - These functions obtain and set the initial volume for the specified - channel. The channel parameter is 0-based (contrary to the display in most - trackers so be careful), and can range from 0 to DUMB_IT_N_CHANNELS - 1, - i.e. from 0 to 63. - - Modules can set their channel volumes during playback, so your changes may - not last throughout the playback. - - -int dumb_it_sr_get_current_order(DUMB_IT_SIGRENDERER *sr); -int dumb_it_sr_get_current_row(DUMB_IT_SIGRENDERER *sr); - - These functions return the current order and row of playback. Both are - 0-based. If the DUMB_IT_SIGRENDERER is invalid, or has been terminated - by a callback (see dumb_it_set_loop_callback() and - dumb_it_set_xm_speed_zero_callback()), these functions will both return - -1. - - -int dumb_it_sr_get_global_volume(DUMB_IT_SIGRENDERER *sr); -void dumb_it_sr_set_global_volume(DUMB_IT_SIGRENDERER *sr, int gv); - - These functions obtain and set the current global volume for the module. - This value ranges from 0 to 128 inclusive. The module can set the global - volume itself during playback, so your change may not last. - - -int dumb_it_sr_get_tempo(DUMB_IT_SIGRENDERER *sr); -void dumb_it_sr_set_tempo(DUMB_IT_SIGRENDERER *sr, int tempo); -int dumb_it_sr_get_speed(DUMB_IT_SIGRENDERER *sr); -void dumb_it_sr_set_speed(DUMB_IT_SIGRENDERER *sr, int speed); - - These functions obtain and set the current speed and tempo of the module. - See the dumb_it_sd_*() equivalents of these functions for details on what - the speed and tempo mean. - - Modules can set these values during playback, so your change may not last. - - -int dumb_it_sr_get_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel); -void dumb_it_sr_set_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel, - int volume); - - These functions obtain and set the current volume for the specified - channel. The channel parameter is 0-based (contrary to the display in most - trackers so be careful), and can range from 0 to DUMB_IT_N_CHANNELS - 1, - i.e. from 0 to 63. - - Modules can set their channel volumes during playback, so your changes may - not last. - - -void dumb_it_sr_get_channel_state(DUMB_IT_SIGRENDERER *sr, int channel, - DUMB_IT_CHANNEL_STATE *state); - - Returns the current playback state of the given channel. If you pass a - channel in the range 0 to DUMB_IT_N_CHANNELS-1 (0 to 63), you will get the - state of the most recently played note on that physical channel, if it is - still playing. For MOD, S3M and XM files, that's all there is to it. - - IT files can have more than one note playing on a single channel, courtesy - of New Note Actions. This function also lets you query all the notes that - have been forced into the background and are still playing. For this, set - 'channel' to a value from DUMB_IT_N_CHANNELS to DUMB_IT_TOTAL_CHANNELS-1. - DUMB_IT_TOTAL_CHANNELS is defined as follows: - - #define DUMB_IT_TOTAL_CHANNELS \ - (DUMB_IT_N_CHANNELS + DUMB_IT_N_NNA_CHANNELS) - - Querying these background channels for MOD, S3M and XM files will not do - any harm; the function will report that these channels are inactive. For - all files, be sure not to query any channel numbers greater than or equal - to DUMB_IT_TOTAL_CHANNELS. - - You must provide a pointer to a preallocated DUMB_IT_CHANNEL_STATE struct. - The easiest way to do this is as follows: - - DUMB_IT_CHANNEL_STATE state; - dumb_it_sr_get_channel_state(sr, channel, &state); - - or: - - DUMB_IT_CHANNEL_STATE state[IT_TOTAL_CHANNELS]; - dumb_it_sr_get_channel_state(sr, channel, &state[channel]); - - This struct contains the following fields: - - int channel; - int sample; - int freq; - float volume; - unsigned char pan; - signed char subpan; - unsigned char filter_cutoff; - unsigned char filter_subcutoff; - unsigned char filter_resonance; - - The first field to check is 'sample'; if this is 0, then the channel is - inactive and the other fields are undefined. Otherwise, it is the index of - the currently playing sample, and is 1-based. - - The channel number is returned, 0-based. This will be the same as the - channel number you passed, unless you are querying a background channel in - which case it will represent the channel the note originated on. - - The freq field is the current playback frequency, taking into account all - phenomena such as slides, vibrato and arpeggio. - - The volume field ranges from 0.0f to 1.0f. In practical terms, it will - rarely reach 1.0f; if it does, the module is probably clipping a lot. This - takes mixing volume into account, along with all the other volume - phenomena in the IT file. The only one it doesn't take into account is the - one you pass to duh_render() or duh_sigrenderer_get_samples(), or the one - you passed to al_start_duh() (these are in fact the same thing). - - The pan field ranges from 0 to 64 for a normally panned sample, but will - be 100 if the sample is playing using IT's surround mode where the right- - hand channel is inverted. If you want a more accurate pan reading, use one - of the following to get one: - - int scaled_pan = ((int)state.pan << 8) + state.subpan; - float float_pan = state.pan + state.subpan / 256.0f; - - The first will give a scaled value ranging (strictly) from 0 to 64*256. - The second will give a floating-point value whose scale corresponds to - that of the pan field. These results will only be valid if surround mode - is off, so you should check that pan <= 64 before using the above - expressions. At the time of writing, pitch-pan separation and panning - envelopes take advantage of the extra accuracy offered by subpan. - - Note that subpan is signed. This means applications that only look at the - pan field will get an unbiased reading. - - The filter cut-off and resonance both range from 0 to 127. If the cut-off - is 127 and the resonance is 0, then no filters are applied. These - parameters only ever change from the default values for IT files. - - While IT allows you to set 127 different filter cut-off levels in the - patterns and as a default value per instrument, it also allows you to - create a filter envelope, which will result in an actual cut-off somewhere - between 0 and the first-mentioned value. By the time this has been - calculated, the actual cut-off may lie in between two levels on the - original scale. If this is the case, filter_subcutoff will be nonzero and - you can combine it with filter_cutoff. Typically you will want to use one - of the following: - - int scaled_cutoff = ((int)state.filter_cutoff << 8) + - state.filter_subcutoff; - - float float_cutoff = state.filter_cutoff + - state.filter_subcutoff / 256.0f; - - The first will give you a scaled value whose maximum is 127*256. The - second will give you a floating-point value whose scale corresponds to the - scale used by filter_cutoff. These match the expressions given further up - for pan and subpan, but in this case, filter_subcutoff is unsigned. - - Note that filter_subcutoff will always be zero if filter_cutoff is 127, so - you need not check it if you simply wish to determine whether filters are - being applied. - - -******************************* -*** DUH Rendering Functions *** -******************************* - - - Use these functions to generate samples from a DUH. First you call - duh_start_sigrenderer() with the DUH, the number of channels you want and - the position at which you want to start. Then you use duh_render() or - duh_sigrenderer_get_samples() to generate the samples. You can call these - functions as many times as you like, and they will generate as many or as - few samples as you require. When you have finished, call - duh_end_sigrenderer(). - - -DUH_SIGRENDERER *duh_start_sigrenderer - (DUH *duh, int sig, int n_channels, long pos); - - Starts a DUH_SIGRENDERER off. This is the struct you can use to get - samples from a DUH. This function does not generate any samples; you must - pass the struct to duh_render() or duh_sigrenderer_get_samples() for that. - When you have finished with it, you must pass it to duh_end_sigrenderer(). - You can use as many DUH_SIGRENDERER structs as you like at the same time. - - Set sig to 0 for now. Currently, n_channels can only be 1 or 2, for - monaural and stereo sound respectively. The debugging library will cause - your program to abort if you pass anything else. Future versions will be - enhanced to support more channels as soon as someone needs them. - - When specifying the position, 0 represents the start of the DUH, and 65536 - represents one second. Unlike most other music systems, DUMB will always - make sure every note is there right from the start (assuming you aren't - using any broken add-ons). In other words, you can start a DUH at a point - halfway through a long note, and you will still hear the long note. - - -void duh_sigrenderer_set_analyser_callback(DUH_SIGRENDERER *sigrenderer, - DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data); - - Installs a callback function which will be called every time the given - sigrenderer is used to generate some samples. This can be used to create - an oscilloscope or spectrum analyser. DUH_SIGRENDERER_ANALYSER_CALLBACK is - defined as follows: - - typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data, - const sample_t *const *samples, int n_channels, long length); - - If the above confuses you, see fnptr.txt. As for the 'samples' parameter, - the first 'const' says that the samples are read-only; the second says - that each channel's sample pointer is also read-only. If you don't - understand this, don't worry about it. - - Beware: your callback function may occasionally be called with - samples == NULL. This means the main program has decided to skip through - the music without generating any data (see duh_sigrenderer_get_samples()). - You should handle this case elegantly, typically by returning immediately, - but you may wish to make a note of the fact that the music is being - skipped, for whatever reason. - - Beware again: if the main program ever calls duh_sigrenderer_get_samples() - on a buffer that isn't all silence, this callback function will be passed - the existing buffer after mixing, and thus it will include the original - data. This will not be an issue if you stick to duh_render(), which always - starts with a buffer filled with silence. - - The samples array is two-dimensional. Refer to it as follows: - - samples[channel_number][sample_position] - - where 0 <= channel_number < n_channels, - and 0 <= sample_position < length. - - In addition you can pass any 'data' pointer you like to - duh_sigrenderer_set_analyser_callback(), and this pointer will be relayed - to your callback function each time. - - To remove the callback function, pass NULL to - duh_sigrenderer_set_analyser_callback(). - - -int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer); - - Tells you how many channels a DUH_SIGRENDERER is set up to generate, or 0 - if it is invalid (perhaps owing to lack of memory). This will be 1 for - monaural sound or 2 for stereo, in this release. - - -long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer); - - Tells you what position a DUH_SIGRENDERER is up to, or -1 if it is invalid - (perhaps owing to lack of memory). As usual, 65536 is one second. - - -long duh_sigrenderer_get_samples(DUH_SIGRENDERER *sigrenderer, - float volume, float delta, - long size, sample_t **samples); - - Generates some samples in DUMB's internal 32-bit format (see sample_t; see - also duh_render()). The samples buffer is a two-dimensional array, and can - be allocated with create_sample_buffer(); see - duh_sigrenderer_set_analyser_callback() for details. - duh_sigrenderer_get_samples() mixes sample data with what's already in the - buffer, so you have to call dumb_silence() first. - - The volume is a float. 1.0f is the pseudo-maximum. If you pass 1.0f, any - properly designed DUH will play nice and loud, but will not clip. You can - pass a greater volume if you like, but be prepared for the possibility of - distortion due to integer overflow. Of course you can pass smaller values - to play the DUH more quietly, and this will also resolve clipping issues - in badly designed DUHs. - - Use delta to control the speed of the output signal. If you pass 1.0f, the - resultant signal will be suitable for a 65536-Hz sampling rate (which - isn't a commonly used rate). The most common sampling rates are 11025 Hz, - 22050 Hz, 44100 Hz and 48000 Hz. You can work out the required delta value - as follows: - - delta = 65536.0f / sampling_rate; - - If you then increase this value, the DUH will speed up and increase in - pitch. If you decrease it, the DUH will slow down and decrease in pitch. - - This function will attempt to render 'size' samples. In most cases it will - succeed. However, if the end of the DUH is reached, it may render fewer. - The number of samples rendered will be returned. Therefore, if the return - value is less than the value of 'size' passed, you know the DUH has - finished. It is safe to continue calling duh_sigrenderer_get_samples() if - you wish, and it will continually return 0. - - If the DUH_SIGRENDERER is a null pointer, this function will generate - precisely 0 samples. If you pass NULL for 'samples', the function will - behave exactly the same as if you provided a sample buffer, except the - samples won't be stored anywhere and the function will execute very - quickly. This can be used to skip ahead in the audio. - - -long duh_render(DUH_SIGRENDERER *sigrenderer, - int bits, int unsign, - float volume, float delta, - long size, void *sptr); - - Generates some samples and converts them to an 8-bit or 16-bit format (see - also duh_sigrenderer_get_samples()). Pass the DUH_SIGRENDERER as returned - by duh_start_sigrenderer(). Pass the number of bits, which should be 8 or - 16. If unsign is nonzero, the samples will be unsigned (centred on 0x80 or - 0x8000 for 8 bits and 16 bits respectively). If unsign is zero, the - samples will be signed. - - Allegro's audio streams always take unsigned samples. 8-bit .wav files - always take unsigned samples. 16-bit .wav files always take signed - samples. - - The volume and delta parameters work the same as for - duh_sigrenderer_get_samples(). - - This function will attempt to render 'size' samples. In most cases it will - succeed. However, if the end of the DUH is reached, it may render fewer. - The number of samples rendered will be returned. Therefore, if the return - value is less than the value of 'size' passed, you know the DUH has - finished. It is safe to continue calling duh_render() if you wish, and it - will continually return 0. However, if you wish to do this, you will - probably have to fill the rest of the buffer with silence, which is 0 for - signed, 0x80 for 8-bit unsigned or 0x8000 for 16-bit unsigned. - - The samples will be placed at sptr. Use an array of chars for 8 bits or an - array of shorts for 16 bits. Stereo samples will be interleaved, left - first. Your array should contain at least (size * n_channels) elements of - the appropriate bit resolution. - - From an aesthetic standpoint if nothing else, it is wise to use the C - qualifiers 'signed' or 'unsigned' depending on whether the samples are - signed or unsigned. This is also convenient if you wish to process the - samples further yourself. - - If the DUH_SIGRENDERER is a null pointer, this function will generate - precisely 0 samples. Unlike with duh_sigrenderer_get_samples(), you must - specify a sample buffer. - - -void duh_end_sigrenderer(DUH_SIGRENDERER *dr); - - Terminates a DUH_SIGRENDERER. Be sure to call this when you've finished - with one. You can safely pass a null pointer. - - -******************************** -*** Allegro Packfile Support *** -******************************** - - -void dumb_register_packfiles(void); - - This function registers the Allegro PACKFILE input module for use by - DUMBFILEs. PACKFILE structs and their corresponding functions, as defined - by Allegro's header file allegro.h, will be used internally for all - DUMBFILE input (unless opened with dumbfile_open_ex()). - - This must be called before dumbfile_open() is used, or else an alternative - system must be registered (see register_dumbfile_system() and - dumb_register_stdfiles()). Note that you don't have to call this function - in order to load datafiles that contain music. - - -DUMBFILE *dumbfile_open_packfile(PACKFILE *p); - - If you have an Allegro PACKFILE struct representing an open file, you can - call this if you wish to read from it using a DUMBFILE. This is useful - when you need to pass a DUMBFILE struct to a library function, to read an - embedded music file for example. When you close the DUMBFILE, you can - continue using the PACKFILE struct to read what follows the embedded data. - - -DUMBFILE *dumbfile_from_packfile(PACKFILE *p); - - This function is the same as dumbfile_open_packfile(), except it will - check if p is NULL, and arrange for pack_fclose() to be called on the - PACKFILE when you close the DUMBFILE. It can be seen as a function for - converting a PACKFILE to a DUMBFILE, but it will only work for a PACKFILE - you obtained with pack_fopen(), not pack_fopen_chunk(). If this function - fails, which may happen if memory is short, then the PACKFILE will be - closed immediately, so you need not worry about potential memory leaks or - files being left open when this happens. - - The following is typical usage, and will open the compressed file foo.bin: - - DUMBFILE *f = dumbfile_from_packfile(pack_fopen("foo.bin", - F_READ_PACKED)); - - This differs from calling dumb_register_packfiles() and dumbfile_open() in - that the latter will only read uncompressed files (and is thus a method - suitable for reading music modules). - - -*********************************************** -*** Allegro Datafile Registration Functions *** -*********************************************** - - -void dumb_register_dat_it(long type); - - If you wish to embed an IT file in an Allegro datafile, it is recommended - that you use "IT " for the type. The grabber will have a box for the type - when you insert a new object. The grabber will treat the IT file as binary - data, which means the datafile will contain an exact copy of the IT file - on disk. - - You must then call dumb_register_dat_it(DUMB_DAT_IT) in your program - before you load the datafile. Once you've done this, you'll be able to - access the DUH using the usual datafile[n].dat notation. You do not need - to call unload_duh() on this DUH; unload_datafile() will do that for you. - - If you are using a different type for whatever reason, you can use - Allegro's DAT_ID() macro for encoding it and passing it to this function. - For example: - - dumb_register_dat_it(DAT_ID('B','L','A','H')); - - Assuming you used the recommended type, the following example iterates - through all the ITs in disan.dat: - - DATAFILE *dat; - int n; - - dumb_register_dat_it(); - dat = load_datafile("disan.dat"); - - for (n = 0; dat[n].type != DAT_END; n++) { - if (dat[n].type == DUMB_DAT_IT) { - DUH *duh = dat[n].dat; - /* Insert code here to play 'duh' or whatever you want to do. */ - } - } - - unload_datafile(dat); - - -void dumb_register_dat_xm(long type); - - Inserting an XM file in an Allegro datafile is the same as inserting an IT - file, except that the recommended type is "XM ", the registration - function is dumb_register_dat_xm(), and the macro DUMB_DAT_XM is provided - for the type. The intuitive process of substituting XM for IT in the above - method will work. - - -void dumb_register_dat_s3m(long type); - - Inserting an S3M file in an Allegro datafile is the same as inserting an - IT file, except that the recommended type is "S3M ", the registration - function is dumb_register_dat_s3m(), and the macro DUMB_DAT_S3M is - provided for the type. The intuitive process of substituting S3M for IT in - the above method will work. - - -void dumb_register_dat_mod(long type); - - Inserting a MOD file in an Allegro datafile is the same as inserting an IT - file, except that the recommended type is "MOD ", the registration - function is dumb_register_dat_mod(), and the macro DUMB_DAT_MOD is - provided for the type. The intuitive process of substituting MOD for IT in - the above method will work. - - -**************************************** -*** Sample Buffer Allocation Helpers *** -**************************************** - - - Many parts of DUMB require sample buffers allocated in a special way. A - pointer to one looks like this: - - sample_t **samples; - - and it can be indexed as follows: - - samples[channel_number][sample_position] - - where 0 <= channel_number < n_channels - and 0 <= sample_position < length. - - The following helpers will allocate and deallocate such buffers for you. - They will not initialise them, and DUMB always writes into these buffers - by adding to what's already there, so you will generally have to call - dumb_silence() too. - - -sample_t **create_sample_buffer(int n_channels, long length); - - This will allocate a sample buffer to hold the specified number of samples - for the specified number of channels. Don't forget to check the return - value! - - You will generally have to initialise the buffer by calling - dumb_silence(); the channels will be stored consecutively in memory, so - the following technique is officially supported: - - dumb_silence(samples[0], n_channels * length); - - See dumb_silence() for general information on what this function does. - - -void destroy_sample_buffer(sample_t **samples); - - This function does the obvious: it frees up a sample buffer when you've - finished with it. It is safe to pass a null pointer to this function. - - -************************ -*** Silencing Helper *** -************************ - - -void dumb_silence(sample_t *samples, long length); - - This function simply stores 'length' samples' worth of silence in the - array. It is typically used straight after allocating a sample buffer with - create_sample_buffer(). - - -************************** -*** Resampling Helpers *** -************************** - - - Please forgive the odd section name; it has to do with DUMB's internal - structure and the fact that the resampling algorithm is there not just for - use in rendering module files but for use anywhere that a waveform needs - resampling. Unfortunately DUMB's resampling algorithm is not ready to be - documented and used yet. However, one thing can be documented, and that's - the global variable controlling the resampling quality. - - (Ironically, even this variable has changed! See deprec.txt for - information on what it used to do.) - - -int dumb_resampling_quality; - - Allows you to control the quality of all resampling that takes place. This - may be set to any DUMB_RQ_* constant (except DUMB_RQ_N_LEVELS). Higher - values will sound better, but lower values will use up less processor - time. You may compare any two DUMB_RQ_* constants or values using the - integer inequalities <, <=, > and >=; higher numbers represent higher- - quality algorithms. - - #define DUMB_RQ_ALIASING - - | --___ 'Aliasing' has very noticeable and usually unwanted - |__--- __ overtones. It will occasionally produce acceptable - | ___-- results for noisy (impure) samples (or for cheap - speakers!), but usually you will want to pay for - the extra processor time, which isn't much, and go for linear - interpolation. - - #define DUMB_RQ_LINEAR - - | __ Linear interpolation is a pretty good algorithm in most - | / \ /\ cases. When resampling down a few octaves, however, you - |/ \/ \__ may begin to notice unwanted high frequencies. You can - reduce these by switching to cubic interpolation, but it - will cost you some processor time. - - #define DUMB_RQ_CUBIC - - Cubic interpolation looks like a smooth curve to the eye, and will - produce good results in most cases. At present this is the highest - quality offered by DUMB, and also the default. While this may seem - extravagant, GCC 3.x and an AthlonXP handle it quite well - and the - general trend is for processors to get better! - - #define DUMB_RQ_N_LEVELS - - This represents the number of resampling quality levels DUMB provides. - Values of dumb_resampling_quality from 0 to DUMB_RQ_N_LEVELS - 1 are - valid. You can use this constant if you wish to offer the resampling - quality as an option for the user. - - -************************************* -*** Allegro DUH Playing Functions *** -************************************* - - - The functions in this section allow you to play back a DUH through - Allegro's sound system. You must call Allegro's install_sound() function - before you use them. - - -AL_DUH_PLAYER *al_start_duh(DUH *duh, int n_channels, long pos, - float volume, long bufsize, int freq); - - Starts playing the specified DUH. - - An AL_DUH_PLAYER represents one instance of the DUH playing. If you wish, - you can have two or more AL_DUH_PLAYERs going at the same time, for the - same DUH or for different ones. Each uses one of Allegro's audio streams - and hence one voice. The voice will be given priority 255 initially, so a - build-up of sound effects will not cause your music streams to cut off (as - long as you don't give all your sound effects priority 255!). You can - change the priority of a stream with al_duh_set_priority(). See Allegro's - documentation for more information on how voice priorities work. - - At present, n_channels can either be 1 or 2 for monaural or stereo - respectively. If you use the debugging library, your program will abort if - other values are passed; otherwise weird things will happen. - - The DUH will start playing from position 'pos'. 0 represents the start of - the DUH, and 65536 represents one second. Unlike other music systems, DUMB - will always make sure every note is there right from the start. In other - words, you can start a DUH at a point halfway through a long note, and you - will still hear the long note. - - The volume is a float. 1.0f is the pseudo-maximum. If you pass 1.0f, any - properly designed DUH file will play nice and loud, but will not clip. You - can pass a greater volume if you like, but be prepared for clipping to - occur. Of course you can pass smaller values to play the DUH more quietly, - and this will also resolve clipping issues in badly designed DUH files. - - You will need to pass the AL_DUH_PLAYER to other functions when you need - to stop or pause the DUH, change its volume, or otherwise modify the way - it is playing. You will also need to pass it to al_poll_duh() at regular - intervals; if the sound is choppy, try calling al_poll_duh() more often. - - 'bufsize' is the number of samples that will be rendered at once. 1024 is - a suitable value for most purposes. The greater this is, the less often - you will have to call al_poll_duh() - but when al_poll_duh() decides to - fill the buffer, it will take longer doing so. If your game exhibits - regular brief freezes, try reducing the buffer size. If the sound is - choppy, however, you may have to increase it. - - 'freq' specifies the sampling frequency at which the DUH should be - rendered. At present there is no (official and portable) way of knowing - the frequency at which Allegro is mixing - but if you do know that - frequency, passing it here will give the highest quality sound. If you - reduce it, the DUH will sound less crisp but use less processor time. - - When you have finished, you must pass the AL_DUH_PLAYER to al_stop_duh() - to free up memory. Do not destroy the DUH beforehand. - - There is no real need to check the return value from this function. The - other functions can be called safely with null pointers, so if there is a - problem, your music will simply not play. - - -void al_stop_duh(AL_DUH_PLAYER *dp); - - This will stop an AL_DUH_PLAYER. You must call this when you have finished - with it, before destroying the DUH. The pointer will no longer be valid on - return from this function. - - -void al_pause_duh(AL_DUH_PLAYER *dp); - - This will pause an AL_DUH_PLAYER. Use al_resume_duh() when you want it to - continue. You can safely call al_poll_duh() while the music is paused, and - it will do nothing. - - -void al_resume_duh(AL_DUH_PLAYER *dp); - - Causes a paused AL_DUH_PLAYER to resume playing (see al_pause_duh()). - - -void al_duh_set_priority(AL_DUH_PLAYER *dp, int priority); - - This will set the priority of the audio stream underlying an - AL_DUH_PLAYER. The priority is an integer ranging from 0 to 255. When - too many samples play at the same time, those with lower priorities will - be cut. 128 is the usual default with Allegro, but DUMB overrides the - default for all AL_DUH_PLAYER structs: they will be set up initially with - priority 255, so your music won't be cut (unless you play too many other - streams or samples with priority 255). See Allegro's documentation for - more information on priorities. - - -void al_duh_set_volume(AL_DUH_PLAYER *dp, float volume); - - This will set the volume of an AL_DUH_PLAYER. See al_start_duh() for - details on the volume parameter. - - -int al_poll_duh(AL_DUH_PLAYER *dp); - - An AL_DUH_PLAYER is not interrupt-driven. That means it will not play by - itself. You must keep it alive from your main program. Call this function - at regular intervals. If the sound crackles, try calling it more often. - (There is nothing you can do if Windows decides to play with the hard - disk; that will make your sound crackle no matter what you do.) - - Normally this function will return zero. However, if it returns nonzero, - that means the AL_DUH_PLAYER will not generate any more sound. Indeed the - underlying audio stream and DUH_SIGRENDERER have been destroyed. When this - happens, you can call al_stop_duh() whenever you wish - but you do not - have to. Note that this function will wait two buffers' worth of samples - before taking this action, allowing Allegro to mix the trailing sound - before the audio stream is destroyed. This is an attempt to make sure your - music does not get cut off prematurely, and it should work when using - Allegro's mixer (the only option on DOS, the default on Linux as far as I - know, but not the default on Windows). That said, if you immediately call - Allegro's remove_sound() or exit your program, the music may get cut off. - If you are using another mixer and experience problems, let me know (but I - don't guarantee to be able to come up with an elegant solution, i.e. it - might not get fixed). - - In case you were wondering, it is not safe on all platforms to call - al_poll_duh() from an interrupt context (that means an Allegro timer - handler). Not only is no part of DUMB locked in memory, but many parts of - DUMB allocate and free their memory on a call-by-call basis! Remember that - any disk access that occurs in interrupt context is likely to crash the - machine; this is explained more fully in howto.txt. This limitation only - applies to DOS at present, and is due to the fact that the DOS file access - functions are not re-entrant. - - Multitasking systems are generally safe. If you are sure you don't want to - target DOS, you can call al_poll_duh() from inside a timer handler, but I - recommend including a construction like the following! - - #ifdef ALLEGRO_DOS - #error calling al_poll_duh() from a timer handler will not work in DOS! - #endif - - Furthermore, if you call al_poll_duh() from inside a timer handler, you - must use a semaphore or other threading mechanism to make sure it is not - executing when you call al_stop_duh(). If you don't know what a semaphore - is, for Heaven's sake follow my advice and call al_poll_duh() from your - main loop! - - -long al_duh_get_position(AL_DUH_PLAYER *dp); - - Tells you what position an AL_DUH_PLAYER is up to, or -1 if it is invalid - (perhaps owing to lack of memory). As usual, 65536 is one second. Note - that this is a whole number, whereas a fractional part is stored - internally; the sample will not be continuous if you terminate the - AL_DUH_PLAYER and then reinitiate it with the same position. Furthermore, - note that Allegro will not have mixed in all the sound up to this point; - if you wait for this to reach a certain position and then terminate the - AL_DUH_PLAYER, the sound will cut off too early. Please contact me if you - need to get around this. - - -AL_DUH_PLAYER *al_duh_encapsulate_sigrenderer - (DUH_SIGRENDERER *sigrenderer, float volume, long bufsize, int freq); - - If you have a DUH_SIGRENDERER, and would like to start playing music from - it through an Allegro audio stream, use this function. Beware that it may - return NULL, in which case you will have to call duh_end_sigrenderer() - yourself instead of relying on the encapsulating AL_DUH_PLAYER to do it - for you. - - -DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp); - - This returns the DUH_SIGRENDERER contained in an AL_DUH_PLAYER, useful for - controlling playback, installing callbacks, etc. - - -DUH_SIGRENDERER *al_duh_decompose_to_sigrenderer(AL_DUH_PLAYER *dp); - - This destroys an AL_DUH_PLAYER, but preserves the DUH_SIGRENDERER it - contains, and returns it to you. You can then continue rendering samples - from the DUH_SIGRENDERER and do whatever you like with them. - - -********************* -*** Thread Safety *** -********************* - - -The following points should pretty much sum up the essence of DUMB's thread -safety. If I haven't covered the one thing you'd like to do, please don't -hesitate to ask about it. - -DOs: - -- You may load and use multiple DUHs in separate threads. - -- You may change dumb_resampling_quality and dumb_it_max_to_mix while another - thread is generating samples. - -DON'Ts: - -- You may not generate samples from the same DUH in multiple threads, even if - you are using separate DUH_RENDERERs (separate AL_DUH_PLAYERS). - - -****************** -*** Conclusion *** -****************** - - -"DUMB is the bestest music player in the world because ..." - -Complete this sentence in fifteen words or fewer and receive a free copy of -DUMB! (Your Internet Service Provider may issue charges for your connection, -required for download of the Product. Your electricity supplier may issue -charges for the electricity consumed in writing the Product to a Permanent -Storage Device. You may have been charged for a Permanent Storage Device on -which to store the Product.) - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/dumbfull.txt b/dumb/docs/dumbfull.txt deleted file mode 100644 index 6a8e192c31..0000000000 --- a/dumb/docs/dumbfull.txt +++ /dev/null @@ -1,1717 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * dumb.txt - DUMB library reference. / / \ \ - * | < / \_ - * See readme.txt for general information on | \/ /\ / - * DUMB and how to set it up. \_ / > / - * | \ / / - * If you are new to DUMB, see howto.txt. | ' / - * \__/ - */ - - -*********************************** -*** Include Files and Libraries *** -*********************************** - - -dumb.h - - Include this if you only want the core DUMB library functions. You will - be able to load music files and render them into memory buffers at your - own pace. The core library is completely portable, and as such does not - access hardware; you must relay the sound data to the sound card yourself. - A stdio file input module is available, but you must actively register it - if you wish to use it (see dumb_register_stdfiles()); if you do not - register it, it will not be linked into your executable. You must register - it in order to load stand-alone music files. - - Optimised: libdumb.a (-ldumb) - Debugging: libdumbd.a (-ldumbd) - - -aldumb.h - - Include this if you wish to use DUMB with Allegro. This will provide you - with functions to play DUHs back through Allegro's audio streams and embed - music files in Allegro datafiles. A file input module using Allegro's - packfiles is provided; you have a choice between this and the stdio - module. You will be able to load datafiles containing music files no - matter which file input module you register, or even if you register no - file input module. However, you must register a file input module in order - to load stand-alone files. - - Optimised: -laldmb -lalleg -ldumb - Debugging: -laldmd -lalld -ldumbd - - libaldmb.a or libaldmd.a must be linked in first, so the symbols can be - resolved when linking in the other two libraries. - - -*********************************** -*** Library Clean-up Management *** -*********************************** - - -int dumb_atexit(void (*proc)(void)); - - Registers a function to be called at the end of your program. You can - register multiple functions to be called, and the one you register last - will be called first. If you try to register the same function twice, the - second attempt will have no effect. - - See fnptr.txt for help with function pointers. - - You must call dumb_exit() before exiting your program for this to work - properly. The library itself registers functions with dumb_atexit(), so it - is important to call dumb_exit() even if you do not use dumb_atexit() - yourself. - - This function will return zero on success. It will return zero when - trying to install the same function twice. If it fails through lack of - memory, it will return nonzero. Generally you can ignore the return code; - in the worst case some memory will not be freed at the end. If it is - crucial that your function be called (e.g. to shut down some hardware or - save critical data), then you should call your function manually at the - end of the program instead of registering it here - or use the stdlib - function atexit(), guaranteed under ANSI C to succeed for at least 32 - functions. - - -void dumb_exit(void); - - You should call this before exiting your program if you have used any part - of DUMB in the program. Some parts of DUMB will allocate memory, and this - function will free it all up. - - More specifically, this function will call any functions that have been - registered with dumb_atexit(). If a part of DUMB needs shutting down, the - shutdown procedure will have been registered in this way. - - dumb_exit() will, of course, also call any functions you registered with - dumb_atexit() yourself. - - After a call to dumb_exit(), the list of functions is erased. If you are - not ready to exit your program, you can start using DUMB anew as if your - program had just started. (Note that not everything will be reset in - practice - dumb_resampling_quality will retain whatever you set it to, for - example, though you should not assume it will.) - - If you only need to call dumb_exit() once at the end of the program, you - can use the following to register dumb_exit() with stdlib.h atexit(): - - #include - - atexit(&dumb_exit); - - Then dumb_exit() will be called for you when your program exits. This is - the recommended method, since it will ensure clean-up even if your program - aborts. You should only call dumb_exit() manually if you need to shut DUMB - down prematurely, or if atexit() is unavailable for one reason or another. - - -***************************** -*** Sequential File Input *** -***************************** - - - DUMB provides a strictly sequential file input system which uses the - DUMBFILE struct. "Strictly sequential" means you cannot seek backwards. - However, the system will keep track of how many bytes you have read, - enabling you to seek forwards. DUMBFILEs provide a convenient error - detection system, so you do not have to check the return value from every - function call in the way you do with the ANSI C functions. - - Note that DUMBFILEs cannot be used for output, nor can they be used - portably for text files. - - If an error occurs when reading data from a DUMBFILE, the DUMBFILE will - become inoperative. All subsequent activities on the DUMBFILE will return - error codes without attempting to read from the file. The position in the - file will also be forgotten. You can find out if this has happened at any - stage with the dumbfile_error() function. You are still required to close - the DUMBFILE, and the return value from dumbfile_close() will tell you if - an error has occurred. - - This system allows you to input large chunks of your file, neither - checking every return value nor wasting time accessing a file that has - already experienced an error. However, before you allocate an amount of - memory or read in a quantity of data depending on previous input from the - file, you should always check that such input was valid. In particular you - should passing zero or negative numbers to malloc() or dumbfile_getnc(). - - DUMBFILEs can be hooked. In other words, you can specify your own - functions to do the work of reading from a file. While DUMB contains two - modules for this purpose, it does not set them up for you automatically. - In most cases you must register one of these modules yourself, or provide - your own module. See register_dumbfile_system(), dumb_register_stdfiles() - and dumb_register_packfiles(). - - -void register_dumbfile_system(DUMBFILE_SYSTEM *dfs); - - Use this function to register a set of functions for use by the DUMBFILEs - (a DUMBFILE system). The DUMBFILE_SYSTEM struct contains the following - fields: - - void *(*open)(const char *filename); - int (*skip)(void *f, long n); - int (*getc)(void *f); - long (*getnc)(char *ptr, long n, void *f); - void (*close)(void *f); - - See fnptr.txt for help with function pointers such as these. - - Your 'open' function should open the file specified and return a pointer - to a struct representing the open file. This pointer will be passed to - your other functions as 'f'. Your 'close' function should close the file - and free all memory pointed to by 'f'. Note that the 'close' operation - should never be able to fail; if you are calling a function with a return - value, you can generally ignore it. - - Your 'getc' function should read one byte from the file and return its - value in the range 0 to 255. If an error occurs, you should return -1. Do - not worry about remembering that an error has occurred; DUMB will do that - for you. - - 'skip' is for skipping parts of the file, and should skip n bytes, - returning 0 on success or any other number on failure. 'getnc' should read - n bytes from the file, store them at 'ptr', and return the number of bytes - read (n on success, fewer on failure). However, these two functions are - optional, and you should only provide them if the operations can be done - more efficiently than with repeated calls to your 'getc' function. If this - is not the case, specify NULL for 'skip', 'getnc' or both, and DUMB will - use your 'getc' function to do the work. - - Once you have written all your functions, you need to create a - DUMBFILE_SYSTEM struct to hold them, and pass its pointer to - register_dumbfile_system(). - - The DUMBFILE_SYSTEM struct must be permanent. In other words, it must be - either global or static, and you should not modify it later. DUMB will not - make its own copy. - - You will most likely create your own struct to represent the open file, - but do not be tempted to specify that struct in the function prototypes - and pacify the compiler warnings by casting your function pointers. There - exist computer systems where a (void *) pointer and a (MY_STRUCT *) - pointer are represented differently in memory, and a cast of such a - pointer causes a tangible conversion to take place. If you cast the - function pointers, the computer cannot know when such a conversion is - necessary. Instead, use the following structure: - - int myskip(void *f, long n) - { - FILE *file = f; - /* Do some stuff with 'file' */ - return something; - } - - If you need examples, have a look at the two existing DUMBFILE systems in - dumb/src/core/stdfile.c and dumb/src/allegro/packfile.c. - - -DUMBFILE *dumbfile_open(const char *filename); - - Open the specified file for input. You must pass the DUMBFILE pointer - whenever you wish to operate on this file. When you have finished with the - file, you must pass it to dumbfile_close(). - - Before you use this function, make sure you have registered a DUMBFILE - system. See register_dumbfile_system(), dumb_register_stdfiles() and - dumb_register_packfiles(). - - -DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs); - - This function is provided for more specialised use. You should create a - DUMBFILE_SYSTEM specially for the purpose. Its 'open' field is irrelevant; - for neatness, set it to NULL, unless you are using this DUMBFILE_SYSTEM - with register_dumbfile_system() as well. - - When you have called this function, the DUMBFILE struct it returned can be - used as normal. The specified DUMBFILE_SYSTEM will be used for all input, - with 'file' passed to your 'skip', 'getc' and 'getnc' functions as 'f'. - This can be used, for example, to read from an already open file. - - Note that the position will always be initialised to 0 for this DUMBFILE. - This means for example that offsets in the file do not need adjusting when - embedding data in a larger file. - - There are two ways to use this function. If you want 'file' to persist - after using a DUMBFILE returned by this function, you should make sure the - 'close' field in the DUMBFILE is set to NULL. When the DUMBFILE is closed, - 'file' will be left alone, and you can and should deal with it yourself - when the DUMBFILE has been closed. - - Alternatively, you can provide a 'close' function to get rid of 'file' for - you when the DUMBFILE is closed. If you do this, you should not otherwise - use 'file' after a call to this function. - - If dumbfile_open_ex() has to return NULL, owing to lack of memory, then - your 'close' function will be called if provided. In other words, if you - have provided a 'close' function, then you no longer need to worry about - 'file' whether this function succeeds or not. - - See dumb/src/helpers/stdfile.c and dumb/src/allegro/packfile.c for - examples of how to use this function. Neither provides a 'close' function, - so I hope my explanation here will suffice. If not, please feel free to - contact me so I can make the explanation clearer and help you do what you - want to do. Contact details are at the end of this file. - - -long dumbfile_pos(DUMBFILE *f); - - Returns the number of bytes read from the DUMBFILE (or skipped) since it - was opened, or -1 if an error has occurred while reading. - - -int dumbfile_skip(DUMBFILE *f, long n); - - Skips n bytes of the specified DUMBFILE. Returns zero on success. - - -int dumbfile_getc(DUMBFILE *f); - - Reads one byte from the DUMBFILE and returns it in unsigned format (from 0 - to 255). If an error occurs, or occurred before, this function returns -1. - - -int dumbfile_igetw(DUMBFILE *f); - - Reads two bytes from the DUMBFILE and combines them into a word ranging - from 0 to 65535. The first byte read is the least significant byte, as - with Intel processors. This function returns -1 on error. - - -int dumbfile_mgetw(DUMBFILE *f); - - Reads two bytes from the DUMBFILE and combines them into a word ranging - from 0 to 65535. The first byte read is the most significant byte, as - with the Apple Macintosh. This function returns -1 on error. - - -long dumbfile_igetl(DUMBFILE *f); - - Reads four bytes from the DUMBFILE and combines them into a long integer - ranging from -2147483648 to 2147483647. The first byte read is the least - significant byte, as with Intel processors. This function returns -1 on - error, but -1 is also a valid return value. After a call to this function, - you can use dumbfile_error() to find out if an error occurred. - - -long dumbfile_mgetl(DUMBFILE *f); - - Reads four bytes from the DUMBFILE and combines them into a long integer - ranging from -2147483648 to 2147483647. The first byte read is the most - significant byte, as with the Apple Macintosh. This function returns -1 on - error, but -1 is also a valid return value. After a call to this function, - you can use dumbfile_error() to find out if an error occurred. - - -unsigned long dumbfile_cgetul(DUMBFILE *f); - - Reads an unsigned (nonnegative) integer from the DUMBFILE. The integer is - stored in a condensed format where smaller numbers use less space: - - 0 to 127 1 byte - 128 to 16383 2 bytes - 16384 to 2097151 3 bytes - 2097152 to 268435455 4 bytes - 268435456 to 4294967295 5 bytes - - This format is the same as that used for the times between notes in MIDI - files. - - If an error occurs, this function returns (unsigned long)(-1), but that - may be a valid return value. After a call to this function, you can use - dumbfile_error() to find out if an error occurred. - - -signed long dumbfile_cgetsl(DUMBFILE *f); - - Reads a signed integer from the DUMBFILE. The integer is stored in a - condensed format where numbers closer to zero use less space: - - -64 to 63 1 byte - -8192 to 8191 2 bytes - -1048576 to 1048575 3 bytes - -134217728 to 134217727 4 bytes - -2147483648 to 2147483647 5 bytes - - If an error occurs, this function returns -1, but -1 is also a valid - return value. After a call to this function, you can use dumbfile_error() - to find out if an error occurred. - - -long dumbfile_getnc(char *ptr, long n, DUMBFILE *f); - - Reads n bytes from the DUMBFILE and stores them at 'ptr'. Note that the - pointer is to a series of chars. You may also use this function to read in - a series of signed chars or unsigned chars (which are both officially - distinct types from char), but do not use this to read ints, structs or - any other data type from the file. Integers must be read one at a time - using dumbfile_igetl(), dumbfile_cgetul(), etc. To load a struct in, you - must read each field separately using an appropriate function for each - one. For complicated datatypes, you can simplify this process by writing a - function for each struct. - - -int dumbfile_error(DUMBFILE *f); - - This function returns -1 if an error has occurred with the specified - DUMBFILE, or 0 if all is well. - - -int dumbfile_close(DUMBFILE *f); - - This function closes the DUMBFILE, after which the pointer will be - invalid. dumbfile_close() returns the value that dumbfile_error() would - have returned, which is -1 if an error occurred while reading or 0 - otherwise. Regardless of the return value, the file will always be closed - properly. - - -******************************* -*** stdio File Input Module *** -******************************* - - -void dumb_register_stdfiles(void); - - This function registers the stdio file input module for use by DUMBFILEs. - FILE structs and their corresponding functions, as defined by the ANSI C - header stdio.h, will be used internally for all DUMBFILE input (unless - opened with dumbfile_open_ex()). - - This must be called before dumbfile_open() is used, or else an alternative - system must be registered (see register_dumbfile_system() and - dumb_register_packfiles()). - - -DUMBFILE *dumbfile_open_stdfile(FILE *p); - - If you have a stdio FILE struct representing an open file, you can call - this if you wish to read from it using a DUMBFILE. This is useful when you - need to pass a DUMBFILE struct to a library function, to read an embedded - music file for example. When you close the DUMBFILE, you can continue - using the FILE struct to read what follows the embedded data. - - -******************************** -*** Signal Type Registration *** -******************************** - - - - - - - NOTE: SINCE THIS IS NOT TO BE THE INTRODUCTION TO DUMB, SHOULD THE - FOLLOWING INFORMATION BE MOVED TO ANOTHER FILE? - - - - - - - If you are lazy, then don't bother to read this section. Simply follow - these steps: - - 1. Call all the dumb_register_sigtype_*() functions. You must do this - after dumb_init(), but before you try to call load_duh(). If you try - to load any DUH files beforehand, the library will fail to load - them. - - 2. Run your program, and make sure the DUH file was successfully loaded - and played. - - 3. Comment out the first dumb_register_sigtype_*() function call. - - 3.1. If the DUH file is still loaded and played, remove this function - call. - 3.2. If the DUH file was not loaded and played, uncomment and keep this - function call. - - 4. Repeat Step 3 for the other function calls. - - Alternatively, the musician might have told you which of the functions you - need to call. - - If you are the epitome of laziness, stop after Step 1. However, if you do - this, your executable may contain unnecessary code. - - If, on the other hand, you are interested in how all this works, then read - on. - - A DUH file comprises a number of 'signals'. A signal may be thought of as - a 'black box'; commands go in, sound comes out. A signal may in turn call - upon other signals to generate sound, and then do something with this - sound to generate its own output. - - For example, here are the contents of a simple DUH file: - Signal #0 SEQU - Signal #1 SAMP - Signal #2 SAMP - Signal #3 SAMP - - 'SEQU' and 'SAMP' are the signal types. 'SAMP' designates a sample, so - Signals #1, #2 and #3 are simple recordings. For instance, Signal #1 could - be a bass drum, Signal #2 a snare drum and Signal #3 a high hat. When - invoked, these signals simply output their respective percussion sounds. - - 'SEQU' designates a sequence. Signal #0 will therefore generate its sound - by taking the output waveforms from the other signals and mixing them in - at appropriate times. For example: - - 0.00 Signal #1 - - 0.50 Signal #2 - - 1.00 Signal #1 - 1.25 Signal #3 - 1.50 Signal #2 Signal #3 - 1.75 Signal #3 - 2.00 Signal #1 - 2.25 Signal #3 - 2.50 Signal #2 Signal #3 - 2.75 Signal #3 - 3.00 Signal #1 - - 3.50 Signal #2 Signal #3 - - The numbers down the left are times. Those with a good sense of rhythm - will be able to see that this represents a rather lame, highly cheesy pop - beat. Experienced gurus will also realise how painfully slow the beat is, - given that the times are in seconds. But enough of that. - - A DUH is played by taking the output from Signal #0 and sending it through - to the sound card via an Allegro audio stream. If you do not know what an - audio stream is, suffice it to say that you must call Allegro's - install_sound() function, and an audio stream uses one voice (hence one - voice per DUH file). If you still don't know what I'm on about, read up on - Allegro's digital sound system and then come back here. Alternatively, - read porting.txt for details on how to use DUMB without Allegro. - - In reality, DUH files are likely to be much more complicated than the - above example. Sequences may call upon other 'sub-sequences' to generate - their sound, so the above beat might be used repeatedly by a - 'super-sequence' to generate a more complex (but still lame) piece of - music. - - The DUH player library is split into two main parts - the core and the - basic signal types. The core is very simple. It does not know what 'SAMP' - or 'SEQU' mean. In fact it is not familiar with any signal type. It only - contains generic code for dealing with signals and generating output. By - itself, it cannot load or play any DUH file. - - In addition to the core, the player library comprises a few basic signal - types, including 'SAMP' and 'SEQU'. In order to use a signal type, you - must 'register' this signal type by calling its corresponding - dumb_register_sigtype_*() function. These functions are listed below, - along with descriptions of the signals. - - If you do not register a signal type, the code for that signal type will - not be linked into your executable file. That means DUMB will not become - bloated with age; new features will not add to the size of your executable - unless you use them. Dynamically linked libraries will still increase in - size. - - If you try to load a DUH file that uses a signal type you haven't - registered, the library will not crash. It will simply fail to load the - DUH file. In fact, an unrecognised or corrupt signal will prevent the - library from reading the rest of the file - but remember, DUH files are - always (intended to be) generated from other formats, so you will never - lose any data this way. - - If you are unsure which signal types a DUH uses, get in contact with the - author of the DUH file, or register them all and remove them one by one to - find out which are required (as described in the steps for lazy people at - the start of this section). - - The great advantage of DUMB over other music systems is that it enables - you to create your own signals. Filters, synthesisers and compression - algorithms can all be set up this way. Programming and audio experience - are useful, but the editor provides a way to create your own signals even - if you don't know C. More information is available in the on-line help in - the editor. - - If you are interested in the gory details of how a signal works, or if you - wish to brave creating your own without the help of the editor, then see - the section entitled Signal Design. - - -void dumb_register_sigtype_sample(void); - - Registers the sample signal type ('SAMP'). This signal deals with samples, - or recordings, in the DUH file. All samples are monaural; a combining - signal can be used to combine two of these into a stereo sample. The DUMB - library will cater for more than two channels to a certain extent, but it - is currently limited by Allegro's audio streams. - - -void dumb_register_sigtype_combining(void); - - Registers the combining signal type ('COMB'). This signal takes a set of - monaural signals and combines them into one signal with multiple channels. - Stereo samples can be set up this way. - - -void dumb_register_sigtype_stereopan(void); - - Registers the stereo pan signal type ('SPAN'). This signal takes a - monaural sample and sources it at the stereo position you specify, - provided the DUH is played in stereo (or, more precisely, provided stereo - output is requested of the signal). - - -void dumb_register_sigtype_sequence(void); - - Registers the sequence signal type ('SEQU'). This signal sequences the - sound from other signals. It is what turns a random collection of - recordings of single notes into a complete piece of music. - - -********************** -*** DUH Management *** -********************** - - -DUH *load_duh(const char *filename); - - Loads a .duh file. Before you call this, make sure you have registered all - the necessary signal types (see 'Signal Registration'). The DUH is - returned to you; you will need to pass it to various functions. When you - have finished with it, call unload_duh() to remove it from memory. - - There is no special need to check that this function succeeds. All other - functions can safely be called with a null pointer, which means your music - will simply not play if it could not be loaded. - - -DUH *read_duh(DUMBFILE *f); - - Reads a DUH from an already open file, and leaves the file open so you can - read subsequent data from the file if you wish. Otherwise this function is - identical to load_duh(). - - -void unload_duh(DUH *duh); - - Removes a DUH from memory. You must call this for all DUHs you load, - making sure they're not playing at the time. - - -long duh_get_length(DUH *duh); - - Returns the length of a DUH; 65536 represents one second. This value is - simply lifted from the DUH struct, so it may not truly correspond to the - time for which the DUH will generate sound. However, if the musician is - any good - or if the code that calculated this value is written properly - - you can assume it represents the point at which the DUH first loops, or - else it allows time for any final flourish to be appreciated. It is used - by the Winamp plug-in to decide when to stop. - - -******************************* -*** Impulse Tracker Support *** -******************************* - - -int dumb_it_max_to_mix; - - Specifies the maximum number of samples DUMB will mix at any one time. - The default number is 64. Regardless of this value, all samples will - continue to be processed up to an internal maximum of 128 (slightly - simplified), and cut samples will sound again as soon as the congestion - clears. Samples are prioritised by final volume, after all factors - affecting the volume of a sample have been considered. - - If you play two or more IT files at once, this value represents the - maximum number of samples for each one. You will have to reduce it further - if your computer cannot keep up. - - -DUH *dumb_load_it(const char *filename); - - Loads the specified Impulse Tracker file, encapsulating it in a DUH - struct. No signal types need be registered for this to work. The length - will be set to the point at which the music first loops (see - duh_get_length()). - - Once the file is loaded, it can be treated exactly the same as any other - DUH in memory. - - -DUH *dumb_read_it(DUMBFILE *f); - - Reads an Impulse Tracker file from an already open DUMBFILE. This leaves - the DUMBFILE open, but the DUMBFILE may not be positioned at the end of - the IT data. If you are embedding an IT in another file, you are advised - to store the size of the IT file and make up for it at the end using - dumbfile_pos(). - - Otherwise, this function is identical to dumb_load_it(). - - -******************************* -*** DUH Rendering Functions *** -******************************* - - - Use these functions to generate samples from a DUH. First you call - duh_start_renderer() with the DUH, the number of channels you want and the - position at which you want to start. Then you use duh_render() to generate - the samples. You can call duh_render() as many times as you like, and it - will generate as many or as few samples as you require. When you have - finished, call duh_end_renderer(). - - -DUH_RENDERER *duh_start_renderer(DUH *duh, int n_channels, long pos); - - Starts a DUH_RENDERER off. This is the struct you can use to get samples - from a DUH. This function does not generate any samples; you must pass the - struct to duh_render() for that. When you have finished with it, you must - pass it to duh_end_renderer(). You can use as many DUH_RENDERER structs as - you like at the same time. - - Currently, n_channels can only be 1 or 2, for monaural and stereo sound - respectively. The debugging library will cause your program to abort if - you pass anything else. Future versions will be enhanced to support more - channels as soon as someone needs them. - - When specifying the position, 0 represents the start of the DUH, and 65536 - represents one second. Unlike most other music systems, DUMB will always - make sure every note is there right from the start (provided any custom - signal types are properly designed). In other words, you can start a DUH - at a point halfway through a long note, and you will still hear the long - note. - - -long duh_render( - DUH_RENDERER *dr, - int bits, int unsign, - float volume, float delta, - long size, void *sptr -); - - Generates some samples. Pass the DUH_RENDERER as returned by - duh_start_renderer(). Pass the number of bits, which should be 8 or 16. If - unsign is nonzero, the samples will be unsigned (centred on 0x80 or 0x8000 - for 8 bits and 16 bits respectively). If unsign is zero, the samples will - be signed. - - Allegro's audio streams always take unsigned samples. 8-bit .wav files - always take unsigned samples. 16-bit .wav files always take signed - samples. - - The volume is a float. 1.0f is the pseudo-maximum. If you pass 1.0f, any - properly designed DUH will play nice and loud, but will not clip. You can - pass a greater volume if you like, but be prepared for clipping to occur. - Of course you can pass smaller values to play the DUH more quietly, and - this will also resolve clipping issues in badly designed DUHs. - - Use delta to control the speed of the output signal. If you pass 1.0f, the - resultant signal will be suitable for a 65536-Hz sampling rate (which - isn't a commonly used rate). The most common sampling rates are 11025 Hz, - 22050 Hz, 44100 Hz and 48000 Hz. You can work out the required delta value - as follows: - - delta = 65536.0f / sampling_rate; - - If you then increase this value, the DUH will speed up and increase in - pitch. If you decrease it, the DUH will slow down and decrease in pitch. - - This function will attempt to render 'size' samples. In most cases it will - succeed. However, if the end of the DUH is reached, it may render fewer. - The number of samples rendered will be returned. Therefore, if the return - value is less than the value of 'size' passed, you know the DUH has - finished. It is safe to continue calling duh_render() if you wish, and it - will continually return 0. However, if you wish to do this, you will - probably have to fill the rest of the buffer with silence, which is 0 for - signed, 0x80 for 8-bit unsigned or 0x8000 for 16-bit unsigned. - - The samples will be placed at sptr. Use an array of chars for 8 bits or an - array of shorts for 16 bits. Stereo samples will be interleaved, left - first. Your array should contain at least (size * n_channels) elements of - the appropriate bit resolution. - - From an aesthetic standpoint if nothing else, it is wise to use the C - qualifiers 'signed' or 'unsigned' depending on whether the samples are - signed or unsigned. This is also convenient if you wish to process the - samples further yourself. - - -long duh_renderer_get_position(DUH_RENDERER *dr); - - Tells you what position a DUH_RENDERER is up to, or -1 if it is invalid - (perhaps owing to lack of memory). As usual, 65536 is one second. Note - that this is a whole number, whereas a fractional part is stored - internally; the sample will not be continuous if you terminate the - DUH_RENDERER and then reinitiate it with the same position. - - -void duh_end_renderer(DUH_RENDERER *dr); - - Terminates a DUH_RENDERER. Be sure to call this when you've finished with - one. - - -*********************************** -*** Signal Design Helper Values *** -*********************************** - - -DUMB_SEMITONE_BASE - - When a 'delta' value is required, you can use DUMB_SEMITONE_BASE to - control the pitch. Use pow(DUMB_SEMITONE_BASE, n) to transpose up by n - semitones. To transpose down, use negative n. - - -DUMB_QUARTERTONE_BASE - - When a 'delta' value is required, you can use DUMB_QUARTERTONE_BASE to - control the pitch. Use pow(DUMB_QUARTERTONE_BASE, n) to transpose up by n - quartertones. To transpose down, use negative n. - - -DUMB_PITCH_BASE - - When a 'delta' value is required, you can use DUMB_PITCH_BASE to control - the pitch accurately. Use pow(DUMB_PITCH_BASE, n) to transpose up by n - units, where 256 units represent one semitone. This scale is used for the - 'pitch' in a sequence (SEQU). - - -************************************ -*** Signal Design Function Types *** -************************************ - - - In order to design your own signal type, you will have to write six - functions to be linked into your program. They are described below. - - See fnptr.txt for help with function pointer types such as these. - - -typedef void *(*DUH_LOAD_SIGNAL)(DUH *duh, DUMBFILE *file); - - Write a function conforming to this type which loads or creates all the - data required by your signal. You may use this, for instance, to load a - sample. You will be reading directly from the DUH file, so make sure you - read exactly the quantity of data stored in the file for this signal. You - should allocate memory (multiple blocks if you like), and return a pointer - referencing all these data. Your data will be stored, and provided - whenever this signal is handled. Be careful about using global data, since - your load_signal function will be called more than once for different - signals of the same type (e.g. for signals which are both samples but are - different samples). - - On failure you should return NULL. Please take the possibility of failed - memory allocation seriously, especially when loading large quantities of - data. You should make sure all allocated memory is freed before you return - with failure. See the standard signal types for examples of how to do this - elegantly using your unload_signal function. On failure, you need not - worry about reading the right quantity of data from the file. - - Do not close the file under any circumstances. - - Often you will write this function before you have written any code to - write a DUH file using this signal. If this is the case, don't worry; you - can write this function free-style, and then the function itself will - serve as a file format reference when you come to create the file. - - Note that a null return value will always be interpreted as failure. If - this type of signal does not need to load any data, you should not provide - a load_signal function at all. The absence of this function will convey - the intended message to the library. - - -typedef void *(*DUH_START_SAMPLES)( - DUH *duh, - void *signal, - int n_channels, - long pos -); - - Write a function conforming to this type. Every time your signal is - required to produce some output, this will be called first. The 'signal' - parameter is the same one you returned from your load_signal function. The - 'n_channels' parameter specifies how many channels you will need to render - sound in. In general you should support one or two, although sometimes - only one is necessary, depending on how your signal is used. If you can - write generic code to support more channels, then do so. Store the number - of channels for use later, unless you're only permitting one value. - - If your signal does not support more than two channels, you are - responsible for making sure it is never invoked with more than two; - likewise if your signal only supports one, then make sure it is never - invoked with more than one. In general you only need to make sure the DUH - file is never rendered with too many channels (see duh_start_renderer() - and al_start_duh()). It may be prudent to use Allegro's ASSERT() macro to - catch bugs of this kind. - - The 'pos' parameter specifies where to start, 65536 being one second into - the signal. Even if you do not intend to start in the middle of the signal - yourself, you should support this as it will be used when a DUH is not - played from the beginning. - - This function should make the necessary preparations in order to render a - string of samples. All your preparations should be stored in allocated - memory, to which you return a pointer; this allows several instances of - the same signal to play at the same time. You will not be given the 'duh' - and 'signal' parameters again, so you must store them if you need them in - the render_samples or free_samples functions. - - Once again, on the rare occasions on which you do not need such data (e.g. - a white noise signal), you should not provide a start_samples function. A - null return code is interpreted as failure, and your music will be lacking - notes (which is better than crashing on undetected memory allocation - failure). - - -typedef void (*DUH_SET_PARAMETER)( - void *sampinfo, - unsigned char id, long value -); - - Some signals can take parameters. For example, a stereo pan signal allows - you to specify the position at which to source the sample, and you might - want to choose the cut-off frequency for a low-pass filter. Such - parameters are set on an instance-by-instance basis, not globally. - Therefore, if you have any parameters, you should place default values for - them in the data you initialise in start_samples. Then you should write a - function conforming to this type, and have it change the parameters when - the correct IDs are passed (see below). - - Each of your parameters should be identified by a single byte, which will - be passed in the 'id' parameter. When one of your parameters is correctly - identified by id, you should change the parameter's value in the data you - returned from your start_samples function. These data are available via - the 'sampinfo' parameter. If you do not recognise the ID passed, you may - wish to log the situation using Allegro's TRACE() macro (which will - compile away to nothing unless you define DEBUGMODE), since it signifies a - fault in the DUH file. - - Take some care in deciding what should be a parameter and what should be - arranged through the use of separate signals (of the same type). For - example, if you are doing a low-pass filter, you will need a source signal - on which to apply the filter; this signal's index should be loaded by the - load_signal function, so you will create separate filter signals for the - separate source signals. However, the cut-off frequency for the filter is - more suitably stored in a parameter. Here are some guidelines: - - Continuous values, or discrete quantities, can be stored in parameters. - Examples: filter cut-off, echo time, stereo pan position. - - Discrete indices or references should be loaded by load_signal. - Examples: references to other signals. - - Another way of looking at it is as follows: - - If a value could be changed halfway through playing the signal, then - consider storing it in a parameter. - - If a value needs to be known by the start_samples function and cannot - change later, then consider loading it in the load_signal function. - - If your signal has no parameters, do not provide a set_parameters - function. Attempts to change parameters for this signal will not cause a - crash, but will cause the operation to be logged using Allegro's TRACE() - macro if the debugging library is used to play the DUH. - - -typedef long (*DUH_RENDER_SAMPLES)( - void *sampinfo, - float volume, float delta, - long size, sample_t **samples -); - - Write a function conforming to this type. It should render a series of - samples into the array of buffers provided (see below). You are passed - 'sampinfo' as returned by start_samples. The 'samples' parameter points to - an array of buffers, one for each channel. You can get a pointer to the - buffer for channel #n with: - - sample_t *buffer = samples[n]; - - As you can see, samples are of type sample_t, which is typedeffed as a - signed int (32 bits). Your waveform should be centred on 0 and should peak - at no more than +/- 32768, or +/- 0x8000, given a volume of 1.0f. If your - waveform goes higher, it will be clipped later on (you do not need to test - for this yourself). Please do not read any special meaning into the volume - parameter; it is simply a factor to be multiplied into each sample. If you - wish to adjust the tone, use a parameter (see DUH_SET_PARAMETER). - - In this function, you should render 'size' samples into the buffer for - each channel. Return the number of samples actually rendered, which will - be fewer than 'size' if you run out of samples (e.g. if you reach the end - of a non-looping sample). Never stop short unless the signal ends, and do - not overrun under any circumstances. Update the 'sampinfo' data so that - the samples generated by the next call to render_samples will continue - seamlessly from the samples generated this time. - - The delta parameter governs the speed at which your signal will play back. - Higher values of delta should cause the speed and pitch to increase, as - with duh_render(). In general, if delta is 1.0f then your waveform should - be suitable for playback at a sampling rate of 65536 Hz. If you wish to - bend this rule, then be careful - usually it is wiser to adjust your - thinking in other parts. - - For example, consider a sample recorded at 44100 Hz, stored in a sample - signal. If a delta of 1.0f is passed to this signal's render function, the - output will be exactly the same as the original sample - a signal at - 44100 Hz. So it breaks the rule. - - Ah, but it doesn't. Instead, it is wiser to consider the sample stored in - the DUH file as being sampled at 65536 Hz. Once we consider this, it is - clear that the output is suitable for playback at 65536 Hz, so we do not - break the rule. Now it is a simple matter of adjusting all the pitches in - the sequence to compensate for this. See duhtech.txt for details on how to - do this when you are writing the DUH file. - - Note that the position that was passed to the start_samples function is - 65536 for one second into the signal as played with delta 1.0f. So, with a - sample signal, this position is interpreted as the index of the sample on - which to start. If delta is 2.0, only half a second of the resultant - output will have been skipped. - - Once again, please do not read any special meaning into the delta - parameter. The effect of doubling delta should be virtually the same as - the effect of not doubling delta but resampling the output. If you wish to - adjust the tone for different pitches, use a parameter. - - This function is compulsory. Silent signals only increase processor and - memory usage, and we are not Microsoft-Intel evangelists. - - -typedef void (*DUH_END_SAMPLES)(void *sampinfo); - - Write a function conforming to this type. It will be called when a signal - stops playing. The parameter points to the data you returned from the - start_samples function, and here you should simply free the memory up. - - This function should be provided, always if, and only if, start_samples is - present. The debugging library will check you get this right. - - -typedef void (*DUH_UNLOAD_SIGNAL)(void *signal); - - Write a function conforming to this type. It will be called when the DUH - is removed from memory. It should free all memory allocated by your - load_signal function. The parameter is the same pointer that you returned - from load_signal. - - If you only ever use this signal type with make_duh(), and not with - dumb_register_sigtype(), then the following does not apply. - - If load_signal is present, unload_signal should also be present; if you - did not provide a load_signal function, then you should not provide an - unload_signal function either. The debugging library will check you get - this right. - - -********************************** -*** Signal Design Registration *** -********************************** - - -void dumb_register_sigtype(DUH_SIGTYPE_DESC *desc); - - When you have written all the functions that represent your signal, you - will need to register them with the library before it will be able to load - your DUH file. Use this function. The DUH_SIGTYPE_DESC struct contains the - following fields: - - long type; - DUH_LOAD_SIGNAL load_signal; - DUH_START_SAMPLES start_samples; - DUH_SET_PARAMETER set_parameter; - DUH_RENDER_SAMPLES render_samples; - DUH_END_SAMPLES end_samples; - DUH_UNLOAD_SIGNAL unload_signal; - - You need to create a DUH_SIGTYPE_DESC struct and pass its pointer to - dumb_register_sigtype(). The struct must be in permanent memory. In other - words, it must be either global or static, and you should not modify it - later. DUMB will not make its own copy. - - 'type' should be a four-character string encoded with DUMB_ID(), for - example DUMB_ID('M','E','O','W'). By convention it should be upper case, - and padded with spaces if you do not use all four characters. However, you - do not have to stick to this. - - If you are not providing a function, specify NULL for the corresponding - function pointer. - - -********************************** -*** Signal Rendering Functions *** -********************************** - - - When you are designing your own signals, you will often want to retrieve - samples from another signal in the DUH. This signal's index ('sig') should - be loaded by your load_samples function. You can use the following - functions to obtain the samples. - - -DUH_SIGNAL_SAMPINFO *duh_signal_start_samples( - DUH *duh, int sig, int n_channels, long pos -); - - Specifies where you want to start rendering. This function returns a - DUH_SIGNAL_SAMPINFO struct, which you need to pass to the other functions. - You can use as many DUH_SIGNAL_SAMPINFOs at once as you like. - - Pass the DUH and the index of the signal whose samples you want to obtain - ('sig'). Specify how many channels you want, and where you want to start - rendering (65536 represents one second). - - There is no special need to check that this function succeeds. The other - functions are safe to call with null pointers. However, checking the - return value can make your code more efficient. - - Be sure to call duh_signal_end_samples() when you've finished. - - -void duh_signal_set_parameter( - DUH_SIGNAL_SAMPINFO *signal_sampinfo, - unsigned char id, long value -); - - Sets a parameter for the signal whose samples are being rendered by - signal_sampinfo. - - - - - Calls the set_parameter function for the instance started by - duh_signal_start_samples of the signal whose details you passed to that - function. Exactly what this does depends on the signal in question. - - - - - - THIS IS NOT VERY HELPFUL. REFER TO A FILE? - - - - - - - - -long duh_signal_render_samples( - DUH_SIGNAL_SAMPINFO *signal_sampinfo, - float volume, float delta, - long size, sample_t **samples -); - - Renders 'size' samples of the signal for which signal_sampinfo was set up. - See duh_render() and DUH_RENDER_SAMPLES for details on the 'volume' and - 'delta' parameters. This function will return the number of samples - generated, which will be fewer than 'size' if the signal ends. - - Sometimes you can pass the array of sample buffers which was passed to - your function, and process the data in place. Other times you will have to - set up the array of sample buffer pointers yourself, making sure each - buffer can hold 'size' samples. Below is some code to do that. Note that - we prefix some variable names with sub-, so they don't clash with the - parameters to the function that would typically contain this code. - - sample_t **subsamples; - int n; - long subsize; - - subsamples = malloc(n_channels * sizeof(*subsamples)); - - if (!subsamples) - return 0; - - subsamples[0] = malloc(size * n_channels * sizeof(*subsamples[0])); - - if (!subsamples[0]) { - free(subsamples); - return 0; - } - - for (n = 1; n < n_channels; n++) - subsamples[n] = subsamples[n-1] + size; - - subsize = signal_render_samples( - subsampinfo, - volume, delta, - size, subsamples - ); - - /* Process the samples here. */ - - free(subsamples[0]); - free(subsamples); - - return subsize; - - -void duh_signal_end_samples(DUH_SIGNAL_SAMPINFO *signal_sampinfo); - - Call this when you have finished with a DUH_SIGNAL_SAMPINFO struct. It - will free all memory used by the struct. - - -************************** -*** Resampling Helpers *** -************************** - - - The DUH player library provides a versatile resampling system. The sample - signal type uses it, and it is available for use in any of your signals. - - Be warned that the resampler may overrun the memory you specify by up to - DUMB_EXTRA_SAMPLES samples, so you must allocate these samples and set - them to appropriate values when you load your signal. Generally, if you - are going to loop, set them to reflect the samples at the loop start - point; if you are not going to loop, set them to zero. - - DUMB_EXTRA_SAMPLES is defined as follows: - - #define DUMB_EXTRA_SAMPLES 3 - - -extern int resampling_quality; - - Allows you to control the quality of all resampling that takes place. This - may be set to any value from 0 to 4. Higher values will sound better, but - lower values will use up less processor time. - - | --___ - 0 - Aliasing |__--- __ - | ___-- - - | __ - 1 - Linear resampling | / \ /\ - |/ \/ \__ - - 2 - Linear resampling / linear average - - 3 - Quadratic / linear average - - 4 - Cubic / linear average - - Level 0 has very noticeable unwanted overtones. It will occasionally - produce satisfactory results for noisy signals, but usually you will - want to pay for the extra processor time (which isn't much) and go - for Level 1. - - Levels 1 and 2 are already pretty good. When resampling down a few - octaves, however, you will begin to notice unwanted high frequencies. - These can be eliminated by switching to Levels 3 or 4. - - When Level 2 or higher are selected, a linear average function is used for - speeding the wave up. Instead of skipping samples, all samples in the - interval will be averaged. The interval is also smoothed at the edges. - This will be especially beneficial when increasing the pitch by several - octaves. - - Levels 3 and 4 are both smooth curves to the eye. They both give - extremely good performance, but you may sometimes notice the difference - when reducing the pitch of a sample by several octaves, where Level 3 - may exhibit unwanted high frequencies. - - - - - - - - - NOTE: WHAT IS THE DEFAULT? (2 at the moment, but might change. Config?) - - - - - - - - - - - - - -long dumb_resample( - sample_t *src, long *_src_pos, int *_src_subpos, - long src_start, long src_end, - sample_t *dst, long dst_size, - float delta, int *_dir, - DUMB_RESAMPLE_PICKUP pickup, void *pickup_data -); - - This is the resampling function. It takes an array of source samples and - fills as much of the destination array as it can for you. Its operation is - quite complicated, so pay attention. - - All the parameters prefixed with an underline (_) are pointers to the - fields they describe. This means the function can modify the variables you - pass, but you have to prefix the variable with an ampersand (&) when - passing it. If you get warnings about ints being converted to pointers - without casts, you have most likely forgotten an ampersand somewhere. - - 'src' points to the source sample data. It should point to the beginning - of the sample, even if you are starting your resampling from somewhere in - the middle. Do not break this rule unless you know what you're doing. - - '_src_pos' and '_src_subpos' together represent the current position in - the sample. When you first call the function, they represent the starting - position. Once the function has done its work, they will represent the - point at which the resampling stopped. '_src_pos' is measured in samples. - '_src_subpos' represents how far between samples we are, and ranges from - 0 to 65535 - so if _src_subpos is 65535, we are very nearly on to the next - sample. - - Once _src_pos and _src_subpos have been modified by this function, you can - pass them to the function again and the resampling will continue - seamlessly. This is important, as you will hardly ever get to render all - your samples in one go. Typically you will make one call to this function - from within your render_samples function. - - This function does not need to know the size of the source buffer as such. - Instead, it knows src_start and src_end, which are start and end points. - The end point actually points to the first sample not to use, following - the usual start-inclusive end-exclusive convention. In general, the - resampling will stop when src_pos tries to pass one of these. - - WARNING: dumb_resample() may read up to DUMB_EXTRA_SAMPLES samples beyond - src_end. Make sure the memory belongs to you. - - The _dir parameter should be either 1 or -1, and tells this function - whether to go forwards or backwards respectively through the source sample - buffer. If _dir is 0, nothing will happen - resampling has stopped - permanently. Any other values of _dir will have unpredictable results, and - the debugging library will abort if you try to use them. - - If _dir is 1, then _src_pos will only be tested against src_end. - If _dir is -1, then _src_pos will only be tested against src_start. - - That means you can set src_start and src_end to your loop points, and - start playing from the beginning of the sample. The resampling will - proceed unimpeded while _src_pos is outside the loop section, provided it - is advancing towards the loop section. The sample signal makes extensive - use of this capability. - - The output waveform will be rendered into the buffer pointed to by dst. - Up to dst_size samples will be generated. Fewer will be generated if the - resampling stops permanently. The number generated will be returned. You - can find out if resampling ended by testing the value of your direction - variable (pointed to by _dir); if it is 0, then resampling stopped - permanently. - - If you pass NULL for dst, no samples will be generated. However, _src_pos, - _src_subpos and _dir will be updated as normal. The pick-up function will - be called as necessary; you should pass the usual 'src' parameter so it - can be passed to your pick-up function. (See below for information on - pick-up functions.) The function returns the number of samples that would - have been generated, had dst pointed somewhere. The operation of - do_resample() when dst is NULL is exactly the same as that when dst points - somewhere. However, do_resample() is much faster in this case; you should - use it when volume is 0, or when you are culling quieter samples to gain - execution speed. - - If delta is 1.0f, the destination is the same speed as the source. Greater - values cause the sample to speed up, and lesser values cause the sample to - slow down. delta should always be positive. - - We have covered most of the parameters. There are only two left - pickup - and pickup_data. The simplest usage is to set these both to NULL. Then, if - resampling stops, it stops permanently. Use this if your sample will not - loop. - - Alternatively, you may wish to write a pick-up function. Your pick-up - function will take control whenever _src_pos tries to pass the start or - end points. You can use it for looping, or for a multitude of other tasks. - The typedef is as follows: - - typedef int (*DUMB_RESAMPLE_PICKUP)( - sample_t *src, long *_src_pos, int *_src_subpos, - long *_src_start, long *_src_end, - int dir, - void *data - ); - - You are passed the source buffer, in case you want to fill it with new - samples. You have the _src_pos, _src_subpos, _src_start and _src_end - pointers, should you need to change the values to which they point. You - also have dir, but note that it is not a pointer. Instead, you should - return the new direction, or 0 to stop the resampling permanently. - - The data parameter is a copy of pickup_data as passed to dumb_resample(). - This is typically used to give you access to your 'sampinfo' parameter, - passed to your render_samples function. - - BEWARE: you must refer to and change src_pos, src_subpos, src_start and - src_end through the parameters passed. Do not mistakenly use their - equivalents in your struct instead. The equivalents in your struct - will eventually be updated, but they will not be accurate during - the pick-up function. - - On entry to this function, src_pos and src_subpos will have overrun by a - small amount. When changing them, you should preserve this overrun. The - following examples will do this for you: - - If you are executing a simple loop, subtract (or add) the difference - between the loop points from (or to) src_pos. Do not simply set src_pos - to the other loop point. - - *_src_pos -= *_src_end - *_src_start; - - If you are executing a ping-pong loop, you need to reflect the pointer - off the loop boundary. To reflect off the loop end point: - - *_src_pos = (*_src_end << 1) - 1 - *_src_pos; - *_src_subpos ^= 65535; - dir = -1; - - To reflect off the loop start point: - - *_src_pos = (*_src_start << 1) - 1 - *_src_pos; - *_src_subpos ^= 65535; - dir = 1; - - In each case, don't forget to return the new direction correctly! - - An ideal example of a pick-up function can be found in src/sample.c. - - Of course there is more that can be done with a pick-up function. Enjoy - experimenting! - - -************************ -*** DUH Construction *** -************************ - - -DUH *make_duh( - long length, - int n_signals, - DUH_SIGTYPE_DESC *desc[], - void *signal[] -); - - Constructs a DUH from its component parts. Use this function if you are - writing a function to load a music file format other than .duh. Indeed, - this function is used internally to load IT files. - - Before you call this function, you must do some preparation. Your DUH will - contain a fixed number of signals; pass this number as n_signals. Each - signal will have a DUH_SIGTYPE_DESC struct, and you pass an array of - pointers to these. The DUH_SIGTYPE_DESC struct contains the following - fields: - - long type; - DUH_LOAD_SIGNAL load_signal; - DUH_START_SAMPLES start_samples; - DUH_SET_PARAMETER set_parameter; - DUH_RENDER_SAMPLES render_samples; - DUH_END_SAMPLES end_samples; - DUH_UNLOAD_SIGNAL unload_signal; - - The structs must be in permanent memory, i.e. either global or static, and - not modified later; however, the array of pointers can be destroyed as - soon as the function returns. - - The values of 'type' and 'load_signal' are irrelevant; set them to 0 and - NULL respectively, unless you are using the DUH_SIGTYPE_DESC struct - elsewhere. - - Because 'load_signal' is never used, you must provide an array of pointers - to the data that 'load_signal' would otherwise have returned. This will - be passed to the other functions as 'signal'. Once again, the array of - pointers can be destroyed as soon as the function returns. As for the - pointers themselves: - - If an 'unload_signal' function is provided, then that will be used to - deallocate the pointer when you finally destroy the DUH. If the function - is not provided, then you are responsible for deallocating any memory - referenced by that pointer yourself. This applies individually to each - signal. - - If this function fails and returns NULL, then any 'unload_signal' - functions you provided will have been called. You do not have any extra - work to do if it fails. - - -******************************** -*** Allegro Packfile Support *** -******************************** - - -void dumb_register_packfiles(void); - - This function registers the Allegro PACKFILE input module for use by - DUMBFILEs. PACKFILE structs and their corresponding functions, as defined - by Allegro's header file allegro.h, will be used internally for all - DUMBFILE input (unless opened with dumbfile_open_ex()). - - This must be called before dumbfile_open() is used, or else an alternative - system must be registered (see register_dumbfile_system() and - dumb_register_stdfiles()). - - -DUMBFILE *dumbfile_open_packfile(PACKFILE *p); - - If you have an Allegro PACKFILE struct representing an open file, you can - call this if you wish to read from it using a DUMBFILE. This is useful - when you need to pass a DUMBFILE struct to a library function, to read an - embedded music file for example. When you close the DUMBFILE, you can - continue using the PACKFILE struct to read what follows the embedded data. - - -*********************************************** -*** Allegro Datafile Registration Functions *** -*********************************************** - - -void register_dat_duh(void); - - If you wish to put a DUH file in an Allegro datafile, you must use "DUH " - for the type. The grabber will have a box for the type when you insert a - new object. The grabber will treat the DUH file as binary data, which - means the datafile will contain an exact copy of the DUH file on disk. - - - - - - TODO: make it possible to choose the type... - - - - - - You must then call register_dat_duh() in your program before you load the - datafile. Once you've done this, you'll be able to access the DUH using - the usual datafile[n].dat notation. You do not need to call unload_duh() - on this DUH; unload_datafile() will do that for you. - - If you need to check the type of the object for whatever reason, you can - use DAT_DUH, defined as follows: - - #define DAT_DUH DAT_ID('D','U','H',' ') - - The following example iterates through all the DUHs in disan.dat: - - DATAFILE *dat; - int n; - - register_dat_duh(); - dat = load_datafile("disan.dat"); - - for (n = 0; dat[n].type != DAT_END; n++) { - if (dat[n].type == DAT_DUH) { - DUH *duh = dat[n].dat; - /* Insert code here to play 'duh' or whatever you want to do. */ - } - } - - unload_datafile(dat); - - -void register_dat_it(void); - - Inserting an IT file in an Allegro datafile is the same as inserting a DUH - file, except the type has to be "IT ", the registration function is - register_dat_it(), and the following definition is available for use - instead of DAT_DUH: - - #define DAT_IT DAT_ID('I','T',' ',' ') - - Once the datafile is loaded, the 'dat' field indeed points to a DUH - struct. There are no differences other than those listed above. - - -************************************* -*** Allegro DUH Playing Functions *** -************************************* - - - The functions in this section allow you to play back a DUH through - Allegro's sound system. You must call Allegro's install_sound() function - before you use them. - - -AL_DUH_PLAYER *al_start_duh( - DUH *duh, int n_channels, long pos, float volume, long bufsize, int freq -); - - Starts playing the specified DUH. - - An AL_DUH_PLAYER represents one instance of the DUH playing. If you wish, - you can have two or more AL_DUH_PLAYERs going at the same time, for the - same DUH or for different ones. Each uses one of Allegro's audio streams - and hence one voice. - - At present, n_channels can either be 1 or 2 for monaural or stereo - respectively. If you use the debugging library, your program will abort if - other values are passed; otherwise weird things will happen. - - The DUH will start playing from position 'pos'. 0 represents the start of - the DUH, and 65536 represents one second. Unlike other music systems, DUMB - will always make sure every note is there right from the start, provided - any custom signal types are designed properly. In other words, you can - start a DUH at a point halfway through a long note, and you will still - hear the long note. - - The volume is a float. 1.0f is the pseudo-maximum. If you pass 1.0f, any - properly designed DUH file will play nice and loud, but will not clip. You - can pass a greater volume if you like, but be prepared for clipping to - occur. Of course you can pass smaller values to play the DUH more quietly, - and this will also resolve clipping issues in badly designed DUH files. - - You will need to pass the AL_DUH_PLAYER to other functions when you need - to stop or pause the DUH, change its volume, or otherwise modify the way - it is playing. You will also need to pass it to al_poll_duh() at regular - intervals; if the sound is choppy, try calling al_poll_duh() more often. - - 'bufsize' is the number of samples that will be rendered at once. 1024 is - a suitable value for most purposes. - - - - - - NOTE: IS THAT TRUE ON ALL SYSTEMS? - - - - - - The greater this is, the less often you will have to call al_poll_duh() - - but when al_poll_duh() decides to fill the buffer, it will take longer - doing so. If your game exhibits regular brief freezes, try reducing the - buffer size. If the sound is choppy, however, you may have to increase it. - - 'freq' specifies the sampling frequency at which the DUH should be - rendered. At present there is no (official and portable) way of knowing - the frequency at which Allegro is mixing - but if you do know that - frequency, passing it here will give the highest quality sound. If you - reduce it, the DUH will sound less crisp but use less processor time. - - When you have finished, you must pass the AL_DUH_PLAYER to al_stop_duh() - to free up memory. Do not destroy the DUH beforehand. - - There is no real need to check the return value from this function. The - other functions can be called safely with null pointers, so if there is a - problem, your music will simply not play. - - -void al_stop_duh(AL_DUH_PLAYER *dp); - - This will stop an AL_DUH_PLAYER. You must call this when you have finished - with it, before destroying the DUH. The pointer will no longer be valid on - return from this function. - - -void al_pause_duh(AL_DUH_PLAYER *dp); - - This will pause an AL_DUH_PLAYER. Use al_resume_duh() when you want it to - continue. - - -void al_resume_duh(AL_DUH_PLAYER *dp); - - Causes a paused AL_DUH_PLAYER to resume playing (see al_pause_duh()). - - -void al_duh_set_volume(AL_DUH_PLAYER *dp, float volume); - - This will set the volume of an AL_DUH_PLAYER. See al_start_duh() for - details on the volume parameter. - - -int al_poll_duh(AL_DUH_PLAYER *dp); - - An AL_DUH_PLAYER is not interrupt-driven. That means it will not play by - itself. You must keep it alive from your main program. Call this function - at regular intervals. If the sound crackles, try calling it more often. - (There is nothing you can do if Windows decides to play with the hard - disk; that will make your sound crackle no matter what you do.) - - Normally this function will return zero. However, if it returns nonzero, - that means the AL_DUH_PLAYER will not generate any more sound. Indeed the - underlying audio stream and DUH_RENDERER have been destroyed. When this - happens, you can call al_stop_duh() whenever you wish - but you do not - have to. Note that this function will wait two buffers' worth of samples - before taking this action, allowing Allegro to mix the trailing sound - before the audio stream is destroyed. In other words, your music will not - be cut off prematurely. - - In case you were wondering, it is definitely not safe to call - al_poll_duh() from an interrupt context. Not only is no part of DUMB - locked in memory, but many signals and many core library functions - allocate and free their memory on a call-by-call basis! Remember that any - disk access that occurs in interrupt context is likely to crash the - machine. (This limitation only applies to DOS at present, and is due to - the fact that the DOS file access functions are not re-entrant. - Multitasking systems are generally safe. However, even if you do not think - you are targeting DOS, it is worth considering that calling this function - regularly from your main loop is likely to be much more efficient than - relying on task switching to do it for you.) - - -long al_duh_get_position(AL_DUH_PLAYER *dp); - - Tells you what position an AL_DUH_PLAYER is up to, or -1 if it is invalid - (perhaps owing to lack of memory). As usual, 65536 is one second. Note - that this is a whole number, whereas a fractional part is stored - internally; the sample will not be continuous if you terminate the - AL_DUH_PLAYER and then reinitiate it with the same position. Furthermore, - note that Allegro will not have mixed in all the sound up to this point; - if you wait for this to reach a certain position and then terminate the - AL_DUH_PLAYER, the sound will cut off too early. - - - - - - - - - NOTE: HOW TO GET AROUND THIS? - - - - - - - - -DUH_RENDERER *al_duh_get_renderer(AL_DUH_PLAYER *dp); - - This function returns to you the DUH_RENDERER underlying the specified - AL_DUH_PLAYER. It has no practical use in this release, but it - TODO: Write this. Also see if it should go in howto.txt. - - -****************** -*** Conclusion *** -****************** - - -I conclude that... DUMB is the bestest music player in the world because... -Complete this sentence in fifteen words or fewer... D'OH! - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/faq.txt b/dumb/docs/faq.txt deleted file mode 100644 index 63913f76b0..0000000000 --- a/dumb/docs/faq.txt +++ /dev/null @@ -1,264 +0,0 @@ -TO DO: add question regarding set_close_button_callback vs set_window_close_hook -TO DO: add question regarding mixing of DJGPP and MinGW object files - -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * faq.txt - Frequently Asked Questions. / / \ \ - * | < / \_ - * This file covers some of the common problems | \/ /\ / - * and misconceptions people have with DUMB. If \_ / > / - * your problem is not covered here, please | \ / / - * contact me. I'll do my best to help - but | ' / - * don't be offended if I just direct you to the \__/ - * manual! - */ - - -***************************************************************************** -* I get a lot of strange warnings and errors when I compile my projects * -* with this release of DUMB. They work with older versions! What happened? * -***************************************************************************** - - Some parts of DUMB's API have been deprecated. See docs/deprec.txt for - full details, including an explanation as to why your compiler warnings - and errors are so unfriendly, and information on how to fix each warning - or error. - - -***************************************************************************** -* When I try to compile DUMB with Allegro, it complains that it cannot find * -* 'internal/alconfig.h'! What's wrong? * -***************************************************************************** - - In Allegro 4.0.1, and quite likely some other versions of Allegro, the - msvcmake batch file does not install Allegro properly. I believe this was - fixed in Allegro 4.0.2, but don't take my word for it. Some include files - are neglected, including alconfig.h. The fix is quite easy; you need to - copy all of Allegro's include files to your compiler's directory. The - following should do this for you (alter it accordingly depending on where - MSVC and Allegro are installed): - - cd\progra~1\msvc\include - xcopy/s \allegro\include\*.* - - You can safely tell it to overwrite all files. - - -***************************************************************************** -* When I build a project that uses DUMB, I get an error that it doesn't * -* find -laldmbd! What's wrong? * -***************************************************************************** - - See the notes for DUMB v0.8 in release.txt; the existence of libaldmbd.a - in DUMB v0.7 was due to a mistake in the makefiles. It should be - libaldmd.a, in order to maintain DOS compatibility. All subsequent - releases get it right, but you will have to change your project files to - allow for the change. If this is someone else's project, please let them - know that it needs changing. - - -***************************************************************************** -* When I build a project that uses DUMB, I get some linker errors about * -* _free, _malloc, etc. already being defined in LIBC.lib! What's wrong? * -***************************************************************************** - - MSVC offers three different implementations of the standard libraries. - When you link statically with a library, you have to use the same - implementation that the library uses. You need the multithreaded DLL - implementation, which you can select by passing /MD when you compile (not - when you link). See howto.txt for details. - - -***************************************************************************** -* I created an IT file with Impulse Tracker, but DUMB won't play it! Why? * -***************************************************************************** - - You probably created some patterns but didn't give any information on the - order in which they should be played. Impulse Tracker will also fail to - play your music if you press F5. Press F11 and you will have an - opportunity to create an order list, required for playback. - - -***************************************************************************** -* I created an IT file with ModPlug Tracker and I have it fading out at the * -* end. Why won't it loop when I play it with DUMB? * -***************************************************************************** - - It loops at zero volume. This is what Impulse Tracker itself does. Fix the - IT file by setting the global volume explicitly (Vxx in the effects - column), either at the start, or right at the end before looping. Also see - the next two questions. - - -***************************************************************************** -* My module plays too loud and distorts badly with DUMB! What can I do? * -***************************************************************************** - - This problem is most often caused by ModPlug Tracker, which has a complete - lack of regard for the playback volume of the original tracker. See the - next question for DUMB's official position with regard to ModPlug Tracker. - If you wrote your module with ModPlug Tracker, please try loading it with - the original tracker and see if it distorts there too. If it does, reduce - the volume. If not, then it's a problem with DUMB; please let me know. - - If for whatever reason you cannot modify the module file itself, you can - make it sound better by reducing the volume passed to al_start_duh(). - - -***************************************************************************** -* I created a music module with ModPlug Tracker, and DUMB doesn't play it * -* right! * -***************************************************************************** - - DUMB cannot and will not support ModPlug Tracker. Please see - docs/modplug.txt for details. The original trackers, which DUMB is - designed to mimic as closely as possible, are listed in readme.txt. - If you find DUMB plays your module differently from the original tracker, - then please contact me. - - -***************************************************************************** -* My program crashes as soon as I try to load anything with DUMB! * -***************************************************************************** - - Please take my advice and use the debugging build of DUMB, not the - optimised build. Then you'll probably find it aborts instead of crashing. - In this case you probably forgot to register a DUMBFILE system; this is - necessary for loading stand-alone files, though not for loading Allegro - datafiles with embedded music. Follow the instructions in docs/howto.txt - carefully and you shouldn't have this problem. - - If DUMB crashes with a specific music module, please let me know. - - -***************************************************************************** -* I want to use the stdio file access functions to load stand-alone music * -* files, but I also want to load datafiles containing music files. The docs * -* say I shouldn't call both dumb_register_stdfiles() and * -* dumb_register_packfiles(). What shall I do? * -***************************************************************************** - - When you register a DUMBFILE system, it only applies to files opened with - dumbfile_open(), i.e. separate files. When a file is embedded in a - datafile, dumbfile_open_ex() is used to read it, enabling it to use - PACKFILEs regardless of which DUMBFILE system is registered. In short, you - do not need to call dumb_register_packfiles() in order to load datafiles - with embedded music. See the section on "Sequential File Input" in - docs/dumb.txt if you're interested in how all this works. - - -***************************************************************************** -* I want to read a specific object in a datafile using Allegro's * -* "demo.dat#MY_MUSIC" syntax. Why won't it work? * -***************************************************************************** - - Did you call dumb_register_packfiles(), or did you call - dumb_register_stdfiles()? It will only work if you use the former. - - -***************************************************************************** -* My program runs, but no music plays! What am I doing wrong? * -***************************************************************************** - - There are a number of possible causes for this. The most likely reason is - that you aren't calling al_poll_duh(); see docs/howto.txt for further - information. - - Other possible causes are as follows: - - - The speakers are turned down (duh) - - The volume of some system mixer is turned down - - Another program is using the sound card (not a problem for most modern - systems) - - You didn't initialise Allegro's sound system; see install_sound() in - Allegro's docs - - Allegro's drivers don't work on your system and chosen platform - - In order to narrow down the cause, consider the following: - - - Do you get any other sound from your program? - - Do other Allegro+DUMB programs generate sound? - - Do other Allegro programs generate sound? - - Do other non-Allegro programs generate sound? - - Does your program fail only on a specific platform (e.g. DOS but not - Windows)? - - This problem is highly system-specific; please try hard to solve it by - yourself before contacting me. However, if you think this problem could - affect other people, please let me know what the problem is and how you - fixed it, if you did. Be as specific as possible. - - -***************************************************************************** -* The music stutters! What can I do? * -***************************************************************************** - - If you have an older computer, it may not be able to cope with the load. - Try reducing quality options; look up dumb_resampling_quality and - dumb_it_max_to_mix in docs/dumb.txt, and consider changing the frequency - you pass to al_start_duh(). - - Stuttering may not be caused by excessive load. To find out, try - increasing the buffer size passed to al_start_duh(). Beware of making it - too big though; older systems will freeze periodically if it's too big, - because they render larger chunks less frequently. The timing of callbacks - will also be less accurate, if you are using those. - - If you're using the 'dumbplay' example, you can control these parameters - by editing dumb.ini. - - -***************************************************************************** -* Why does DUMB use so much processor time compared with other players? * -***************************************************************************** - - This should be less so in this release than in previous releases; the - resampling and filtering algorithms have been optimised. - - By default, DUMB uses the most expensive resampling quality option. I've - found on an AthlonXP 1800+ and on a Pentium 233 that it typically uses - about twice as much processor time as the least expensive option. - - Try setting dumb_resampling_quality to DUMB_RQ_ALIASING or DUMB_RQ_LINEAR. - See dumb.txt for more information. If you're using the example programs, - you can control this variable by editing dumb.ini. - - DUMB uses 32-bit ints for mixing. Some players use 16-bit ints, and are - therefore marginally faster (not much!) and lower quality. So you can't - expect DUMB to beat these players. Furthermore, DUMB is currently written - entirely in C. GCC does an impressive job on the C code, but that's not to - say some custom-written assembly language couldn't beat it ... - - -***************************************************************************** -* Why does DUMB generate so much background noise? * -***************************************************************************** - - You're probably using the DOS build on a system with bad Sound Blaster - compatibility (most Windows XP systems fall in this category). This would - mean DUMB could only access an 8-bit driver. The Windows build will almost - certainly give better results. Your DOS binary will still give good - results on systems with better compatibility (like my Windows 98 system). - - -***************************************************************************** -* I e-mailed you and you replied with "RTFM"! What does that mean? * -***************************************************************************** - - Read The Manual. If it's a specific problem, I'll probably be kind and - tell you where to look in the manual. However, if I get the impression you - haven't even looked for a solution in the manual, expect no mercy ... - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/fnptr.txt b/dumb/docs/fnptr.txt deleted file mode 100644 index 9a0d87b67a..0000000000 --- a/dumb/docs/fnptr.txt +++ /dev/null @@ -1,113 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * fnptr.txt - Function pointer explanation. / / \ \ - * | < / \_ - * | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -C allows you to create and use function pointers. A function pointer is a -variable that points to a function, and you can use it to call that function. -Why is this useful? - -Function pointers can be passed as parameters. As an example, here's a -function from Allegro: - - void create_light_table(COLOR_MAP *table, const PALETTE pal, int r, g, b, - void (*callback)(int pos)); - -Don't worry about the syntax just yet, but the last parameter, 'callback', is -a pointer to a function that takes an int parameter. create_light_table() can -take some time to complete its work, and you may want to display a progress -indicator. So you write a function to draw the progress indicator, and then, -for 'callback', you specify a pointer to your function. This will enable -create_light_table() to call your function at intervals during its -processing. (If you don't want to use the callback, you can pass NULL, but -this only works because create_light_table() checks actively for NULL. You -can't always specify NULL when you want nothing to happen.) - -There are many other uses. In addition to using function pointers as -parameters, Allegro has some global function pointers you can set to point to -your functions. Function pointers can also be used in structs, and this is -where DUMB makes the most use of them. - -So how are they used? - - void bar(void) { ... } /* Here's a function */ - void (*foo)(void) = &bar; /* Take a pointer */ - (*foo)(); /* Call the function */ - - char *baz(float a) { ... } /* Here's another function */ - char *(*foobarbaz)(float a) = &baz; /* Take a pointer */ - char *rv = (*foobarbaz)(0.1); /* Call the function */ - -In both these cases, note how the statement for calling the pointed-to -function (third line) resembles the definition of the function pointer -(second line). This is true of any variable in C, and can lead to some truly -obfuscated definitions if you are that way inclined. Such definitions can be -clarified with typedefs, but before you use those, it is important you -understand how the above statements work. I speak from experience: function -pointer notation looks random and scary, until you understand why it's the -way it is; then it makes perfect sense. - -(It is actually permissible to omit the & when taking a pointer and to write -e.g. foobarbaz(0.1) instead of (*foobarbaz)(0.1). However, I recommend not -doing this, since the syntax for using the pointer no longer resembles the -definition. Writing e.g. (*foobarbaz)(0.1) also makes a clear distinction -between function pointer calls and ordinary function calls, which makes code -more readable.) - -Note that function pointers have the return value and parameter list -specified. A function pointer can only point to a function with a matching -return value and matching parameters. (You can break this rule by casting the -pointer explicitly, but there is no situation where doing so is portable to -all computers, and I strongly advise against it unless you're writing system -code. If you're not sure whether you're writing system code or not, then -you're not.) - -The parameter names need not match (although the types must). If you wish to -rename a parameter in your function, you do not have to change the function -pointer accordingly. In fact, when you define a function pointer, you don't -even have to specify the names of parameters if you don't want to. I normally -do so for clarity. - -It is possible to typedef a function pointer. In order to typedef a function -pointer, you start by declaring the pointer as a variable: - - void (*myfunc)(void); - -Then you write 'typedef' before it and replace the variable name, which is -myfunc, with the type name (this rule can be applied to any variable when you -want to use typedef): - - typedef void (*MYTYPE)(void); - -Now 'MYTYPE' represents a pointer to a function with no parameters and no -return value. The following two lines are completely equivalent: - - MYTYPE myfunc; - void (*myfunc)(void); - -Note that we use MYTYPE without an asterisk (*), since it is already a -pointer. - -That's it. If you feel anything should be explained better here, or if you -feel something should be added, please don't hesitate to let me know! - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/howto.txt b/dumb/docs/howto.txt deleted file mode 100644 index 1d9a439fef..0000000000 --- a/dumb/docs/howto.txt +++ /dev/null @@ -1,845 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * howto.txt - How To Use DUMB. / / \ \ - * | < / \_ - * See readme.txt for general information on | \/ /\ / - * DUMB and how to set it up. \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -******************** -*** Introduction *** -******************** - - -Welcome to the DUMB How-To! It is assumed here that you have already set DUMB -up on your system, with or without Allegro. If not, please see readme.txt. - - -********************************* -*** Adding music to your game *** -********************************* - - -These instructions will help you add a piece of music to your game, assuming -your music is stored in a stand-alone IT, XM, S3M or MOD file. If you wish to -use a different method (such as putting the music file in an Allegro -datafile), please follow these instructions first, test your program, and -then follow the instructions further down for adapting your code. - - -1. You need to include DUMB's header file. If you have Allegro, add the - following line to the top of your source file (or at the top of each file - where you wish to use DUMB): - - #include - - If you do not have Allegro or do not wish to use it, use dumb.h instead. - - -2. You need to link with DUMB's library file or files. If you are compiling - with GCC from a command line on any platform, you need to add the - following to the command line: - - If you are using Allegro: -laldmd -ldumbd - If you are not using Allegro: -ldumbd - - If you are using MSVC from the command line: - - If you are using Allegro: /link aldmd.lib dumbd.lib - If you are not using Allegro: /link dumbd.lib - - With MSVC, you must also add /MD to the command line when compiling (not - when linking). - - Note that -laldmd or aldmd.lib must PRECEDE alleg.lib, -lalleg_s, - `allegro-config --libs`, or whatever you are already using to link with - Allegro. For MSVC users, the /MD flag selects the multithreaded DLL - implementation of the standard libraries; since DUMB is statically linked, - you have to use the same library DUMB uses. You would also need this flag - to link statically with Allegro; if you already have it, there's no need - to put it twice. - - (If anyone would like to contribute instructions for doing the above using - MSVC's IDE, please contact me. Contact details are at the end of this - file.) - - If you are using RHIDE, go to Options -> Libraries. You will need to type - 'aldmd' and 'dumbd' in two boxes, making sure 'aldmd' comes above whatever - you are using to link with Allegro (or just put 'dumbd' if you are not - using Allegro). Make sure the box next to each of these libraries is - checked. - - The above are the debugging libraries. It is VERY HIGHLY RECOMMENDED that - you use the debugging libraries at first. The reason is as follows. - Although DUMB is supposedly robust against corrupt music files and things - like lack of memory, it will NOT tolerate programmer error. If you write - faulty code, DUMB will probably crash rather than returning an error code - for you. However, the debugging libraries will abort in many cases, - enabling you to find out what the cause is. - - Once your program is up and running reliably, you can replace 'aldmd' with - 'aldmb' and 'dumbd' with 'dumb'. Don't forget to do this, or DUMB will be - a lot slower than it should be! - - -3. As you use DUMB, it may claim system resources (memory in particular). You - will need to arrange for these resources to be freed at the end. Doing so - is very easy. Simply write the following line at the top of your main - function, but below allegro_init() if you are using Allegro: - - atexit(&dumb_exit); - - This arranges for the function dumb_exit() to be called when your program - exits; you do not need to call dumb_exit() yourself. This method is - preferable to calling dumb_exit() manually, as it will free resources even - if your program aborts unexpectedly. - - If you are happy with this, please skip ahead to Step 4. If you are - interested in alternative methods, read on, but read on carefully. - - In fact it mostly doesn't matter where you put the above atexit() line, - provided it gets called only once, and before you do anything with DUMB. - If you are using DUMB with Allegro, it is recommended that you write the - functions in this order: - - allegro_init(); - atexit(&dumb_exit); - - And then you must NOT call allegro_exit() yourself (because it has to be - called after dumb_exit()). Alternatively, if you prefer not to use - atexit() (or you cannot), you will have to do the following before - exiting: - - dumb_exit(); - allegro_exit(); - - -4. DUMB does not automatically do any of its own file input. You have to tell - it how to read files. Don't worry, it's easy. Simply call the following - function near the beginning of your program, after your atexit() call: - - dumb_register_stdfiles(); - - This tells DUMB to use ordinary stdio FILE structs for reading and writing - files. If you are using Allegro and would rather DUMB used PACKFILEs, call - the following function INSTEAD: - - dumb_register_packfiles(); - - In the latter case, DUMB will be affected by any password you set with - packfile_password() in the same way that other PACKFILEs are. - - Note that the procedure for loading datafiles with embedded music is - independent of these two functions; even if you will be loading datafiles, - you can use either of these functions. If you are loading datafiles, your - executable might be slightly smaller if you use dumb_register_packfiles(). - On the other hand, dumb_register_stdfiles() will probably be faster. If - you are only ever going to load datafiles and never stand-alone files, you - can actually leave this step out; but I would recommend you put this in, - test your code with a stand-alone file, then follow the instructions in - the next section in order to adapt your code to use the datafile (you will - be reminded that you can remove the function call). - - -5. If you are using Allegro, you'll have to initialise Allegro's sound - system. In most cases the following line will do the job: - - install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL); - - You may like to initialise a MIDI driver though; see Allegro's docs for - details. Put this line after allegro_init(). - - -6. All pieces of music are stored in memory in DUH structs. To handle these, - you must define pointers to them. Such pointers look like this: - - DUH *myduh; - - You can of course replace 'myduh' with anything you like. If you are - unfamiliar with pointers, please see ptr.txt. It is very important that - you understand these if you wish to use DUMB correctly. - - You do not have direct access to the contents of a DUH struct, so do not - try. DUMB's functions provide everything you need; if you disagree, please - let me know and I shall see what I can do. Contact details are at the end - of this file. - - Given the above definition, you can load a piece of music using one of the - following lines, depending on what file format you want to load: - - myduh = dumb_load_it("a_one.it"); - myduh = dumb_load_xm("a_two.xm"); - myduh = dumb_load_s3m("a_one_two.s3m"); - myduh = dumb_load_mod("three_four.mod"); - - Obviously you can use relative or absolute paths as normal. You should - always use forward slash (/), not backslash (\), when coding in C and - similar languages. - - Every piece of music you load must be unloaded when you've finished with - it. When you type the above line in, it is good practice to type the - following line in at the same time, but put it at the end of the program: - - unload_duh(myduh); - - You will now be able to use the DUH struct anywhere in between the two - lines you just added. There is no need to check the return value; if the - DUH failed to load for one reason or another (this could be due to lack of - memory as well as the file not being there), then DUMB will do nothing - - safely. - - -7. From this step onwards, it will be assumed you're using Allegro. If not, - please read these steps anyway, and then see the section entitled - "Rendering music into a buffer". You will have to write your own playback - code using whatever sound output system is available. Alternatively you - may like to write data to a file (especially if you have a file that - consumes a lot of processor time), but beware that any streaming audio - format is likely to be substantially larger than the module file you - generate it from, and formats like MP3 will be lower quality. You might - not be able to hear the difference between the MP3 and the original, but - many people can and don't like it, so please consider them. I'm one of - them. If you really want to use a lossy compression format, I highly - recommend Ogg Vorbis: - - http://www.vorbis.com/ - - But I digress. - - In order to play the DUH you loaded, you need to define a pointer to an - AL_DUH_PLAYER struct: - - AL_DUH_PLAYER *dp; - - Two of the functions you will need are prototyped as follows: - - AL_DUH_PLAYER *al_start_duh(DUH *duh, int n_channels, long pos, - float volume, long bufsize, int freq); - - void al_stop_duh(AL_DUH_PLAYER *dp); - - As you can see, al_start_duh() returns a pointer to an AL_DUH_PLAYER - struct when you call it. You then pass this pointer to all the other - functions. Again, if it is a NULL pointer for whatever reason (usually - lack of memory), DUMB will safely do nothing. When you call al_stop_duh(), - the pointer becomes invalid and you should not use it again; if there's - any risk of the pointer being used again, it is wise to set it to NULL at - this point. You can reassign the variable with a new call to - al_start_duh() of course. - - Set 'n_channels' to 1 or 2 for mono or stereo respectively. Note that this - parameter has nothing to do with the number of samples that can play at - once in a music module. Set 'pos' to 0 to play from the beginning; each - time you add 65536, you will have advanced one second into the piece. As a - general rule, set the volume to 1.0f and adjust it later if the music is - too loud or too quiet - but see Allegro's set_volume_per_voice() function - first. - - 'bufsize' can generally be set to 4096. If your music stutters, try - increasing it; if your game freezes periodically, try reducing it. Find a - happy medium. Set 'freq' to 48000 for the best quality, though 44100 will - do in most cases. 22050 will be fine for a lot of music, though 11025 may - sound muffled. You can choose any other value, higher, lower or in - between. If your music stutters, and increasing 'bufsize' doesn't fix it, - try reducing this value. - - Once you have put in a call to al_start_duh(), it is good practice to - insert the call to al_stop_duh() at the same time. You must call - al_stop_duh() before the DUH is unloaded (unload_duh(), Step 6 above). - - Don't get impetuous, your program is not ready yet! Proceed to Step 8. - - -8. DUMB does not play music in the background for you; if you were expecting - it to do so, please see the explanation at the end of this step. For your - music to be played, you have to call another function at regular - intervals. Here is its prototype: - - int al_poll_duh(AL_DUH_PLAYER *dp); - - Do NOT call this function from inside a timer function unless you really - know what you are doing. The reasons why this is bad are explained - further down. You should call it from your main program. - - Simply writing the following line will be sufficient in general, if you - have a variable 'dp' that points to your AL_DUH_PLAYER struct. - - al_poll_duh(dp); - - As a general rule, calling this once for each logic update will do the - trick. If, however, you are executing time-consuming algorithms such as - software 3D rendering, you may wish to insert calls to this function in - the middle of those algorithms. You cannot call this function too often - (within reason); if it has nothing to do it will return immediately. - - Exactly how often you need to call the function depends on the values for - 'bufsize' and 'freq' that you passed to al_start_duh(): - - n = freq / bufsize; - - You have to call al_poll_duh() at least n times a second. Do not hesitate - to call it more often for safety; if the sound stutters, you may need to - do just that. (Or you may need to increase the buffer size or reduce the - quality settings; the only way to find out is to try.) - - For now, don't worry about al_poll_duh()'s return value. As soon as you - need it, it will be explained. - - If you are happy, please skip to Step 9. If you were expecting DUMB to - play your music in the background, please read on. - - The natural way to play music in the background on most operating systems - nowadays is to use threads. DOS was not built with multithreading in mind, - and its system operations (notably disk access) assume they will only be - used from a single thread. - - Interrupts are the next best thing to threads. A DOS hardware interrupt - could be triggered at any moment, and a handler function will be called. - This is how Allegro's timer functions work. Unfortunately, what you can do - inside an interrupt handler is very limited. For one thing, all code and - data used by the handler must be locked in memory; if not, it could get - written to disk (virtual memory). If the main program was accessing the - disk when it got interrupted, the system would then die a horrible death. - This precludes the possibility of allocating extra memory inside the - handler, and DUMB does a lot of that in al_poll_duh(). - - Given DUMB's architecture, which cannot change for reasons which will - become apparent in future versions, this renders it impossible to come up - with a portable solution for making DUMB play music in the background. - Having said that, if you wish to write your own wrapper for al_poll_duh() - and use it in a thread, there is nothing stopping you. If you do do this, - you will have to be very careful when stopping the music; see the - description of al_poll_duh() in dumb.txt for more information. - - So why not kill DOS? It is all too common a practice among programmers to - quote the phrase, "DOS is as dead as the dodo." Despite being a decidedly - derisible demonstation of the dreary device of alliteration, it shows a - distinct lack of experience. Many embedded systems still use DOS because - it provides hardware access capabilities and real-time possibilities - unparalleled by any current multitasking operating system. For an argument - closer to home, I used to use RHIDE for DOS before I switched to Linux, - and I have not found a single Freeware Windows IDE that measures up to - RHIDE. I'm sure many people are in the same boat, and really appreciate - DUMB's DOS port. - - We will not be removing DOS support from DUMB. Any blind suggestions to do - so will be met with fiery flames. You have been warned. - - -9. Test your program! - - If you have trouble, check through the above steps to make sure you didn't - miss one out. Refer to faq.txt to see if your problem is addressed there. - If you still have trouble, contact me; details are at the end of this - file. - - -********************************** -*** Controlling music playback *** -********************************** - - -Here I describe some common operations you may wish to perform. The method -for doing so will seem a bit strange sometimes, as will the names of the -structs. However, there is a reason behind everything. If you would like to -do more exotic things, or better understand some of the methods used here, -then see dumb.txt, which covers everything from the ground up. - - -To control playback quality: - - #define DUMB_RQ_ALIASING - #define DUMB_RQ_LINEAR - #define DUMB_RQ_CUBIC - #define DUMB_RQ_N_LEVELS - extern int dumb_resampling_quality; - extern int dumb_it_max_to_mix; - - Please note that dumb_resampling_quality has changed in DUMB v0.9.2. See - deprec.txt for more details on the change. - - dumb_resampling_quality can be set to any of the DUMB_RQ_* constants - (except DUMB_RQ_N_LEVELS; see below). Resampling is the term given to the - process of adjusting a sample's pitch (in this context). - dumb_resampling_quality defaults to DUMB_RQ_CUBIC, which sounds nice but - takes a lot of processor power. Try reducing it if you have an older - computer or if you are trying to mix an insane number of samples (or - both!). See dumb.txt for details on what the different values actually do. - - If you wish to give this option to your user, you can use - DUMB_RQ_N_LEVELS. All the values from 0 to DUMB_RQ_N_LEVELS - 1 will be - valid resampling levels. If a value outside this range is chosen, it is - not the end of the world; DUMB will behave as if you had chosen the value - at whichever extreme you went beyond. - - dumb_it_max_to_mix, defaulting to 64, is the maximum number of samples - DUMB will ever mix together when playing an IT, XM, S3M or MOD file. - Unlike many other music systems, DUMB will still keep track of all samples - (up to a fixed maximum of 256 of them, roughly speaking), and then will - just render as many of them as this variable permits, starting with the - loudest ones. When samples are cut or come back in, the exact timings will - not generally be predictable - but nor will they be important. - - dumb_it_max_to_mix applies to each currently playing module file - independently. So if you set it to 64, but render two modules - simultaneously, DUMB could end up mixing up to 128 samples. - - -To pause and resume playback, set the volume, get the current playback -position, or get the length of time a DUH will play for before either looping -or freezing (effect F00 in XM and MOD files, which means no new notes will be -played but any existing notes will continue): - - void al_pause_duh(AL_DUH_PLAYER *dp); - void al_resume_duh(AL_DUH_PLAYER *dp); - void al_duh_set_volume(AL_DUH_PLAYER *dp, float volume); - long al_duh_get_position(AL_DUH_PLAYER *dp); - - long duh_get_length(DUH *duh); - - These functions are pretty self-explanatory. The volume passed to - al_duh_set_volume() and the position returned by al_duh_get_position() are - in the same units as those you passed to al_start_duh(). The length - returned by duh_get_length() is in the same units as the aforementioned - position; see dumb.txt for more information on this function. Be careful - with al_duh_get_position(); it will return a position slightly ahead of - what you can hear, because the system has to keep ahead slightly to avoid - stuttering. - - -To prevent the music from looping and/or freezing: - - DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp); - DUMB_IT_SIGRENDERER *duh_get_it_sigrenderer(DUH_SIGRENDERER *sigrenderer); - - void dumb_it_set_loop_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data), void *data); - void dumb_it_set_xm_speed_zero_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data), void *data); - - int dumb_it_callback_terminate(void *data); - - If you are unfamiliar with function pointers, please see fnptr.txt. - - Note that these functions apply to IT, XM, S3M and MOD files - not just to - IT files. This holds true throughout DUMB, for all functions with "it" in - the name. The xm_speed_zero event can only occur with XM and MOD files. - - The first two functions will return a pointer to a struct contained by the - struct you pass. This system is necessary to ensure that these operations - are possible when not using Allegro. Typically you would write the - following code: - - { - DUH_SIGRENDERER *sr = al_duh_get_sigrenderer(dp); - DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sigrenderer); - dumb_it_set_loop_callback(itsr, &dumb_it_callback_terminate, NULL); - dumb_it_set_xm_speed_zero_callback - (itsr, &dumb_it_callback_terminate, NULL); - } - - Once you have done this, the return value of al_poll_duh() becomes - significant. It will be 0 as long as the music is playing. When the music - stops, al_poll_duh() will return nonzero. You can call al_stop_duh() and - do something else as soon as you wish, but calling al_poll_duh() some more - will not do any harm. - - al_poll_duh() will also return 1 if the music could not be loaded, or if - memory was short when trying to play it, or if it was a quirky music file - with no music in it (technically one with an empty order list). This - happens regardless of whether or not you execute the above code to disable - looping. Normally you shouldn't need to worry about this. - - To undo the above and make DUMB loop or freeze again, pass NULL instead of - &dumb_it_callback_terminate. If you would like to fade on looping, or loop - a finite number of times, or display a message when looping, or whatever, - you will have to write your own callback function. In this case, please - see dumb.txt. - - Note that the above code can safely be applied for a DUH that doesn't - contain a music module but contains some other kind of music. - duh_get_it_sigrenderer() will return NULL, and the code will do nothing. - - -To analyse the audio as it's generated: - - typedef int sample_t; - - typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data, - const sample_t *const *samples, int n_channels, long length); - - void duh_sigrenderer_set_analyser_callback(DUH_SIGRENDERER *sigrenderer, - DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data); - - If the above confuses you, see fnptr.txt. These functions, along with - al_duh_get_sigrenderer() from the last section, enable you to register a - callback function. Every time some samples are generated, they will be - passed to this function. This enables you to display an oscilloscope or - spectrum analyser, for example. - - Beware: your callback function may occasionally be called with - samples == NULL. This means the main program has decided to skip through - the music without generating any data. You should handle this case - elegantly, typically by returning immediately, but you may wish to make a - note of the fact that the music is being skipped, for whatever reason. - - Beware again: if the main program ever calls duh_sigrenderer_get_samples() - on a buffer that isn't all silence, this callback function will be passed - the existing buffer after mixing, and thus it will include the original - data. This will not be an issue if you stick to duh_render(), which always - starts with a buffer filled with silence. - - The samples array is two-dimensional. Refer to it as follows: - - samples[channel_number][sample_position] - - where 0 <= channel_number < n_channels, - and 0 <= sample_position < length. - - In addition you can pass any 'data' pointer you like to - duh_sigrenderer_set_analyser_callback(), and this pointer will be relayed - to your callback function each time. - - To remove the callback function, pass NULL to - duh_sigrenderer_set_analyser_callback(). - - -Everything below this point assumes some knowledge of how a music module is -constructed. If you do not have this knowledge, talk to whoever is writing -music for you, or download a tracking program and play with it (see -readme.txt). - - -To start playing an IT, XM, S3M or MOD from an arbitrary order number (the -default being 0, the beginning of the song), use the following: - - DUH_SIGRENDERER *dumb_it_start_at_order - (DUH *duh, int n_channels, int startorder); - AL_DUH_PLAYER *al_duh_encapsulate_sigrenderer - (DUH_SIGRENDERER *sigrenderer, float volume, long bufsize, int freq); - - The usage of these functions is as follows: - - { - DUH_SIGRENDERER *sr = dumb_it_start_at_order - (duh, n_channels, startorder); - dp = al_duh_encapsulate_sigrenderer(sr, volume, bufsize, freq); - } - - Replace 'dp' with whatever your AL_DUH_PLAYER pointer is. You also need - to insert suitable values for n_channels, startorder, volume, bufsize and - freq. These have the same meaning as those passed to al_start_duh(). - - WARNING: after passing a pointer to an "encapsulate" function, do not use - that pointer again. (More specifically, do not use it again if - the function returns NULL, because the function will have - destroyed the pointer if this happens, to help prevent memory - leaks.) There will be a "get" function with which you can obtain - the original pointer if it is still valid, or NULL otherwise. - - The above functions will fail (safely) if you try to use them with a DUH - that contains a different type of music. - - Notice that there is no 'pos' parameter. If you would like to skip through - the music, you can use this function: - - long duh_sigrenderer_get_samples( - DUH_SIGRENDERER *sigrenderer, - float volume, float delta, - long size, sample_t **samples - ); - - Pass 0 for volume and NULL for samples, and this function will skip - through the music nice and quickly. So insert the following between the - two above statements: - - duh_sigrenderer_get_samples(sr, 0, 65536.0f / freq, pos, NULL); - - Substitute for 'freq' and 'pos'. An explanation of the 'delta' parameter - can be found further down in this file. - - Finally, note that duh_get_length() is only meaningful when you start - playing music from order 0. - - -If an IT file contains Zxx effects, DUMB will generate MIDI messages, which -will control the low-pass resonant filters unless the IT file actively -specifies something else. In rare cases this may not be what the Zxx effects -were intended to do; if this is the case, you can block the MIDI messages as -follows. Note that this does NOT mean filters are disabled; if an instrument -specifies initial cut-off and resonance values, or has a filter envelope, -then filters will be applied. It only makes sense to use this procedure at -the beginning of playback. - - void dumb_it_set_midi_callback(DUMB_IT_SIGRENDERER *sigrenderer, - int (*callback)(void *data, int channel, unsigned char byte), - void *data); - - int dumb_it_callback_midi_block(void *data, int channel, - unsigned char byte); - - Using some functions described in the previous section, we arrive at the - following code: - - { - DUH_SIGRENDERER *sr = al_duh_get_sigrenderer(dp); - DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sigrenderer); - dumb_it_set_midi_callback(itsr, &dumb_it_callback_midi_block, NULL); - } - -DUMB offers no way of disabling filters completely. Disabling filters is not -recommended as a means to reduce processor usage, as it will completely -damage any piece of music that uses the filters. If you want lower processor -consumption, use a piece of music that does not use filters. - - -Finally, DUMB offers a myriad of functions for querying and adjusting -module playback. Those beginning with "dumb_it_sd" operate on the -DUMB_IT_SIGDATA struct, which represents the piece of music before it starts -to play. Those beginning with "dumb_it_sr" operate on the DUMB_IT_SIGRENDERER -struct, which represents a currently playing instance of the music. Note that -duh_get_length(), described above, becomes meaningless after some of these -functions are used. - -The method for getting a DUMB_IT_SIGRENDERER struct has already been given, -but the function prototypes are repeated here for convenience: - - DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp); - DUMB_IT_SIGRENDERER *duh_get_it_sigrenderer(DUH_SIGRENDERER *sigrenderer); - -Getting a DUMB_IT_SIGDATA struct is simpler: - - DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh); - -For a list of dumb_it_sd_*() and dumb_it_sr_*() functions, please see -dumb.txt. These functions are new, and may not provide exactly what you need; -if not, please let me know. - - -************************************************** -*** Embedding music files in Allegro datafiles *** -************************************************** - - -In this section it is assumed you are already reasonably familiar with how -Allegro datafiles are used. If not, please refer to Allegro's documentation. -At the time of writing, the documentation you need is off the beaten track, -so to speak, in allegro/tools/grabber.txt. - -To add a piece of music to a datafile, you need to create an object of type -"IT ", "XM ", "S3M " or "MOD " (note the spaces used as padding, although -you do not need to type these into the grabber). Then grab the piece of music -in. The grabber will treat it as a binary object. Save the datafile as usual. - - -To use a piece of music you added to the datafile, follow these steps: - - -1. Before loading the datafile, call one or more of these functions, - depending on which music format or formats you'd like to support: - - dumb_register_dat_it(DUMB_DAT_IT); - dumb_register_dat_xm(DUMB_DAT_XM); - dumb_register_dat_s3m(DUMB_DAT_S3M); - dumb_register_dat_mod(DUMB_DAT_MOD); - - Remember, do not call multiple functions unless you want to support - multiple formats. Calling more functions will add unused code to your - executable. - - It is important that you make call these before loading the datafile, - since they tell Allegro how to load the respective files straight from - datafiles in the future. They will not help Allegro interpret any module - files that have already been loaded as binary objects (but if you really - need to interpret a module that has been loaded in this fashion, have a - look at dumbfile_open_memory() in dumb.txt). - - If for whatever reason your music objects are identified by a different - type in the datafile, you can tell DUMB what that type is by changing the - parameter to the registration function above. Use Allegro's DAT_ID() - macro, e.g. DAT_ID('B','L','A','H'). This is not really recommended - though, since it would prevent a hypothetical grabber plug-in from being - able to play your music files. Use the above types if possible. - - -2. Whenever you need a pointer to a DUH struct, simply use the 'dat' field. - Do this in the same way you would for a pointer to a BITMAP struct or - anything else. If it makes you feel more comfortable, you can extract the - pointer in advance: - - DATAFILE *dat = load_datafile("smurf.dat"); - if (!dat) abort(); /* There are much nicer ways of handling failure! */ - DUH *myduh = (DUH *)dat[GAME_MUSIC].dat; - - Note that the explicit (DUH *) cast is only necessary for C++, not for C. - However, it does no harm. - - Be sure that you do NOT call unload_duh() for anything stored in the - datafile. These DUHs will be freed when you call unload_datafile(), and - freeing them twice is practically guaranteed to crash your program. - - -3. If you only ever load music as part of a datafile, and you never load any - stand-alone music files, you do not need to register a file input system - for DUMB to use. If you followed the instructions for the first section - you will have one of these two lines in your program: - - dumb_register_stdfiles(); - dumb_register_packfiles(); - - You can safely delete this line - but only if you never load any - stand-alone music files. The debugging library will bale you out if you - delete it when you shouldn't; the optimised library won't. - - -************************************* -*** Rendering music into a buffer *** -************************************* - - -NOTE: much of the API formerly described in this section has been deprecated, - and you will need to alter your code. See deprec.txt for details. If - you are reading this section for the first time, you can ignore this - note. - -Rendering to a buffer is similar to playing using an AL_DUH_PLAYER. However, -you must use a DUH_SIGRENDERER struct instead. Here are the functions: - - DUH_SIGRENDERER *duh_start_sigrenderer - (DUH *duh, int sig, int n_channels, long pos); - - int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer); - long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer); - - long duh_sigrenderer_get_samples(DUH_SIGRENDERER *sigrenderer, - float volume, float delta, long size, sample_t **samples); - - long duh_render(DUH_SIGRENDERER *sigrenderer, - int bits, int unsign, float volume, float delta, long size, void *sptr); - - void duh_end_sigrenderer(DUH_SIGRENDERER *sigrenderer); - -The parameters to duh_start_sigrenderer() have the same meanings as those to -al_start_duh(). However, note that the volume is not set at this stage. You -pass the desired volume each time you want to render a block. The 'sig' -parameter should be set to 0 for now. - -Notice that there are two rendering functions. duh_sigrenderer_get_samples() -will generate samples in the internal 32-bit format, with a normal range from --0x800000 to 0x7FFFFF and with each channel in a separate array; duh_render() -will convert to 8 or 16 bits, signed or unsigned, with stereo samples -interleaved, left first. - -When you call duh_render(), pass 8 or 16 for 'bits'. If you pass 8, 'sptr' is -expected to be an array of chars. If you pass 16, 'sptr' is expected to be an -array of shorts. Endianness therefore depends on the platform, and you should -not try to interpret 16-bit wave data as an array of chars (unless you're -writing highly system-specific code anyway). Because DUMB renders internally -with 32 bits, there is no significant speed increase in rendering an 8-bit -stream. - -If you are rendering in stereo, make sure your 'sptr' array is twice as big! - -If you set 'unsign' to a nonzero value, then the samples generated will be -centred on 0x80 or 0x8000, suitably stored in an array of unsigned chars or -unsigned shorts. If 'unsign' is zero, the samples will be centred on 0, -suitably stored in an array of signed chars or signed shorts. Note that 8-bit -WAV files are unsigned while 16-bit WAV files are signed. This convention was -used by the SoundBlaster 16 when receiving samples to be sent to the -speakers. If you wish to write 16-bit sample data to a WAV file, don't use -fwrite(); instead, take the shorts one at a time, split them up into chars as -follows, and write the chars to the file. - - short sptr[n]; - char lsb = (char)sptr[n]; - char msb = (char)(sptr[n] >> 8); - -For a 16-bit WAV file, write the LSB (less significant byte) first. - -The following applies equally to duh_render() and -duh_sigrenderer_get_samples(), except where otherwise stated. - -If you set 'delta' to 1.0f, the sound generated will be suitable for playback -at 65536 Hz. Increasing 'delta' causes the wave to speed up, given a constant -sampling rate for playback. Supposing you want to vary the playback sampling -rate but keep the pitch constant, here's the equation for 'delta': - - delta = 65536.0f / sampling_rate; - -'size' is the number of samples you want rendered. For duh_render(), they -will be rendered into an array which you pass as 'sptr'. Note that stereo -samples count as one; so if you set n_channels to 2, your array must contain -(2 * size) elements. - -For duh_sigrenderer_get_samples() you will have to use the following -functions: - - sample_t **create_sample_buffer(int n_channels, long length); - void destroy_sample_buffer(sample_t **samples); - - void dumb_silence(sample_t *samples, long length); - -create_sample_buffer() allocates the channels sequentially in memory, so the -following technique is valid: - - sample_t **samples = create_sample_buffer(n_channels, length); - dumb_silence(samples[0], n_channels * length); - -It is necessary to fill the buffer with silence like this because -duh_sigrenderer_get_samples() mixes what it renders with the existing -contents of the buffer. - -The return values from duh_render() and duh_sigrenderer_get_samples() tell -you how many samples were actually generated. In most cases, this will be the -same as the 'size' parameter. However, if you reach the end of the DUH (which -will happen if you disable looping or freezing as described further up), this -function will return less. When that happens, you can assume the stream has -finished. In the case of duh_render(), the remainder of the array will not -have been initialised, so you either have to initialise it yourself or avoid -using it. - -If for whatever reason duh_start_sigrenderer() returns NULL, then -duh_render() and duh_sigrenderer_get_samples() will generate exactly 0 -samples, duh_sigrenderer_get_n_channels() will return 0, -duh_sigrenderer_get_position() will return -1, and duh_end_sigrenderer() will -safely do nothing. - - -********************* -*** Miscellaneous *** -********************* - - -Please see dumb.txt for an API reference and for information on thread safety -with DUMB. The API reference has been stripped down, since some functions and -variables are subject to change. If something does not appear in dumb.txt, -please do not use it. - - -****************** -*** Conclusion *** -****************** - - -If you have any difficulties, or if you use DUMB successfully, please don't -hesitate to contact me (see below). - -Enjoy! - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/modplug.txt b/dumb/docs/modplug.txt deleted file mode 100644 index 65eabe8a3b..0000000000 --- a/dumb/docs/modplug.txt +++ /dev/null @@ -1,137 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * modplug.txt - Our official position regarding / / \ \ - * compatibility with ModPlug | < / \_ - * Tracker. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -******************** -*** Introduction *** -******************** - -ModPlug Tracker is a very popular tracker for Windows. Its popularity is due -to the intuitive interface and its many advanced features. The author has -done a good job with this piece of software, but sadly in doing so he has -desecrated the IT file format. - -I am not against ModPlug Tracker being used to write music modules. As -already stated, it has some very advanced and convenient features; I use it -myself. However, I believe its users should be aware of the entire situation -before using it for any serious work. - - ModPlug Tracker - http://www.modplug.com/ - - -************************* -*** Incompatibilities *** -************************* - -There are a few situations in which ModPlug Tracker misinterprets the -original module formats. I shall list the five I am most aware of, from least -to most annoying: - -5. Create a multisample instrument, for example a piano. Play a low note. - Then go up the scale, but in the pattern data, make sure the instrument - column is blank; put in only the notes. Play this with ModPlug Tracker, - and play it with Impulse Tracker. Impulse Tracker changes sample as you go - up the scale; ModPlug Tracker does not. - -4. Arpeggio and Retrigger Note effects behave badly when combined with - Portamento, which can appear in the volume column. While Retrigger Note - isn't too bad, Arpeggio sounds completely wrong. Try it and see what - happens. Then repeat the experiment in Impulse Tracker. - -3. The filter algorithm is incorrect, in more ways than one. When Jeffrey Lim - programmed the low-pass resonant filters into Impulse Tracker, he used a - standard filter algorithm with a slight modification to achieve greater - resonance. ModPlug Tracker does not incorporate this modification. - Furthermore, ModPlug Tracker uses integer arithmetic with nowhere near - enough precision; the wave output is really poor in some cases. I don't - doubt it damages the acoustic properties of the filters in subtle ways. - -2. When looping, ModPlug Tracker resets all variables. The original trackers - do not do this. - -1. Worst of all, ModPlug Tracker has no regard for playback volume, and - generally has a much lower output level than the original trackers. - -Cases 3, 2 and 1 lead people to write IT files that play badly in the -original trackers. If some of these problems could be fixed, I'd be all for -it - but these problems have been reported to the author and he had no -motivation to fix them. ModPlug Tracker has been around long enough that -fixing 3, 2 and 1 would be detrimental to too many people's music. - - -****************** -*** Extensions *** -****************** - -Worse than the incompatibilities are the extensions ModPlug Tracker makes, -mostly to the IT format. DUMB currently supports one of these extensions, -namely stereo samples, but supporting the others is not high on my list of -priorities. - -Other extensions ModPlug Tracker has provided mostly take the form of extra -effects. For instance, S98 and S99 can be used to enable or disable reverb. I -believe the latest versions of ModPlug Tracker offer alternative types of -filter, such as high-pass and band-pass. As soon as an IT file uses any of -these features, it will play incorrectly with Impulse Tracker. - -By far the most evil extension provided by ModPlug Tracker is the effect -plug-ins. These enable IT files to use VST effects. I recently downloaded an -IT file that uses some effects from a collection named "DirectX Media Audio -Effects". When can we expect these effects to be ported to Linux? - - -****************** -*** Conclusion *** -****************** - -ModPlug Tracker is trying to be two things at once. It wants to be an editor -for the existing formats, but at the same time it wants to be proprietary, -with all its own features and extensions. Unfortunately it is succeeding; -there are many IT files out there that only play right in ModPlug Tracker. In -my opinion, ModPlug Tracker should have come out with its own file format, in -which all these extensions would have found a home. - -If you are going to use ModPlug Tracker's extensions, I recommend you -ultimately convert your music to a streamed format such as Ogg Vorbis. (If -you were thinking of using MP3, then don't - consider using Ogg Vorbis -instead.) If you release IT files that use ModPlug Tracker's extensions, -please state prominently that the files are designed to be played with -ModPlug Tracker. Finally, don't ask me to support ModPlug Tracker's -extensions; ModPlug Tracker's playback code is available for use in your -games, so use that instead. - - Ogg Vorbis - http://www.vorbis.com/ - -Despite all the above problems, don't forget that ModPlug Tracker does have a -lot of very useful features for editing files. These include a function for -removing unused patterns, samples and instruments, drag-and-drop sample and -instrument ripping, drop-down menus for selecting the effects by name without -having to memorise the codes or refer to help, and lots of other nice things. -I do recommend it as an editor, provided you make sure you are aware of the -situation and do not use ModPlug Tracker's extensions or incompatibilities -inadvertently. - -Oh, and by the way, save your final version with Impulse Tracker. Then the -samples will be compressed for you! - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/ptr.txt b/dumb/docs/ptr.txt deleted file mode 100644 index bf7534d4e0..0000000000 --- a/dumb/docs/ptr.txt +++ /dev/null @@ -1,129 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * ptr.txt - Pointer explanation. / / \ \ - * | < / \_ - * | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -A pointer is a small variable (often the same size as an int BUT NOT ALWAYS) -that holds the address of something in memory. You create a pointer by adding -a * to a variable, as follows: - - int x, *y; - - x = 5; - y = &x; - -The & means 'address of', so &x gives us a pointer to x. We are storing it in -y. - - (*y)++; - -The * here means 'value at'. It's known as the 'dereferencing' operator. When -written before a pointer, as it is here, it allows you to treat the value -like a normal variable. In this case we are incrementing the value. If we -look at x, we'll find that it now contains 6, not 5. - - y++; - -Here we are incrementing the pointer itself. This is useful for traversing -through an array, but in this particular example it is not much use. - - *y++; - -Beware; this will increment the pointer, not the value stored there. It will -return the value stored at the pointer (before incrementing the pointer), so -you can use this in a bigger expression. This is why we needed brackets in -the first example. - -Note that you will not need these three examples when working with DUMB; they -are simply to help illustrate the idea of pointers. - -Also be aware that when defining pointers you attach the * to the variable, -not to the type. The following example will create a pointer and an int, not -two pointers: - - int *a, b; - -That is why I believe it's a good idea to put a space before the * and not -after it, although programmers are divided on this. - - y = 0; - y = NULL; - -These two statements are equivalent. 0, or NULL, is a special value that is -guaranteed to have a different value from any valid pointer. This is most -often used to indicate that something doesn't point anywhere. DUMB's -functions may return it on occasion. However, in simple usage of DUMB, you -will not actually need to check for it. - -Some of DUMB's functions return pointers to structs. (A struct is an -aggregration of other variables, such as ints, pointers, or other structs. -You can generally treat a struct as a single unit.) Here's an example of such -a function: - - DUH *dumb_load_it(const char *filename); - -You do not know what the DUH struct actually contains; dumb.h and aldumb.h -only give the compiler enough information to deal with pointers to them. DUMB -will take charge of everything that happens inside a DUH struct. - -The above function will create a DUH struct for you. First it allocates -the memory it needs, then it fills the struct with data, then it returns a -pointer. This DUH struct will contain the data necessary to play an IT file. -You can define a suitable variable and store the pointer in it as follows: - - DUH *duh = dumb_load_it("music.it"); - -Or this can be split up: - - DUH *duh; - duh = dumb_load_it("music.it"); - -In order to use this DUH struct later, you must pass its pointer to other -functions. To pass the pointer to a function, simply write 'duh' for the -appropriate parameter. - -When you've finished with a DUH struct (this applies equally to the other -structs DUMB deals with), you must pass it to an appropriate function for -freeing up the memory: - - unload_duh(duh); - -After you've done this, the memory will no longer be allocated, and the -pointer will have no meaning. You may wish to set it to NULL at this point -for safety. Alternatively just be sure not to use the present value of the -pointer any more. You can of course assign a new value to the pointer, e.g. -by calling dumb_load_it() again. - -Note the following: - - DUH *duh2 = duh; - -This only duplicates the pointer, not the DUH itself. You still only have one -copy of the DUH. There is no way of duplicating a DUH, short of loading it -twice. This is not a problem, because DUMB can play it 'twice at the same -time' anyway. - -That should be all you need to know about pointers in order to use DUMB. If -there's anything you feel should be explained better here, or anything else -that should be added, please don't hesitate to let me know! - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb -See readme.txt for details on using IRC. diff --git a/dumb/docs/tutorial.txt b/dumb/docs/tutorial.txt deleted file mode 100644 index a430965518..0000000000 --- a/dumb/docs/tutorial.txt +++ /dev/null @@ -1,94 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * tutorial.txt - DUMB Programmers' Tutorial. / / \ \ - * | < / \_ - * See readme.txt for general information on | \/ /\ / - * DUMB and how to set it up. \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -******************** -*** Introduction *** -******************** - - -Welcome to the DUMB Programmers' Tutorial! - -In order to follow this tutorial, you should already have set Allegro and -DUMB up on your system, including DUMB's support for Allegro and the example -programs. If you have not done so, see readme.txt for details. - -You will also need some IT files. If you would like to compose your own, then -first I must offer a word of warning: not everyone is capable of composing -music. Do not assume you will be able to learn the art. By all means have a -go; if you can learn to play tunes on the computer keyboard, you're well on -the way to being a composer! - -The best program for the job is Impulse Tracker itself, available from: - -http://www.noisemusic.org/it/ - -This is a DOS program. Users of DOS-incapable operating systems may like to -try ModPlug Tracker, but should be aware that it does not support all -combinations of effects correctly, and some IT files will sound wrong. If you -use a different operating system, or if you know of a better IT editor for -Windows, please give me some links so I can put them here! - -ModPlug Tracker is available from: http://www.modplug.com/ - -If you would like to download IT files composed by other people, check the -following sites: - -http://www.modplug.com/ -http://www.traxinspace.com/ - -Once again, if you know of more sites where IT files are available for -download, please let me know. - -Once you've got some IT files, we're ready to begin! - -Note that support for S3M files has very recently been added to DUMB, but it -is bound to be faulty. I recommend you use IT files in preference until later -releases of DUMB. - - -****************** -*** Try It Out *** -****************** - - -We'll start simply by running one of the example programs. - -Find playit.exe, in the dumb/examples folder. Choose an IT file, and pass it -to playit.exe. In DOS, you can do this by typing 'playit' followed by the -name of the IT file. In Windows, you can drag the IT file and drop it on -playit.exe. - -You should now hear the music play back. If not, make sure your speakers are -on and volume is not turned down. Try one of Allegro's example programs. If -you are using DJGPP under Windows, consider using a Windows compiler instead. -If you cannot get it working, see readme.txt for details on seeking help with -DUMB. - -When you are satisfied, press any key to stop the music and return to the -operating system. - - -************************* -*** How Does It Work? *** -************************* - - -Now load playit.c into your favourite editor. Here is an explanation of what -it does: diff --git a/dumb/examples/dumb.ini b/dumb/examples/dumb.ini deleted file mode 100644 index ee707ad29e..0000000000 --- a/dumb/examples/dumb.ini +++ /dev/null @@ -1,44 +0,0 @@ -# Please edit this file to control the playback quality for 'dumbplay'. Note -# that this does not affect DUMB when you use it in your own programs; you -# need to borrow some code from the example program in order to get that to -# happen. - -# dumb_resampling_quality can be 0 for aliasing, 1 for linear interpolation -# or 2 for cubic interpolation. See docs/dumb.txt for details on what these -# terms mean. - -# dumb_it_max_to_mix is the maximum number of samples DUMB will render at a -# time. See docs/dumb.txt for a more detailed description. - -# Increase buffer_size to combat stuttering. - -# The music module will be rendered at the sampling frequency specified by -# sound_freq. This variable is also used by Allegro for initialising the -# sound hardware. - -# buffer_size and sound_freq are passed directly to al_start_duh(). See this -# function's description in docs/dumb.txt for information about how to use -# these variables. - -# You can ignore the quality variable. Allegro uses it when relaying the -# audio stream to the sound card. Only a masochist would set it lower than 2; -# if your computer is powerful enough to run DUMB, it is powerful enough to -# use this setting with Allegro. - -# For best results, choose a value for sound_freq that your sound card can do -# exactly. See Allegro's docs, "Standard config variables", for details. If -# you do not choose an exact value, Allegro will round it to the nearest -# value it can do; then when DUMB plays the stream at a sampling frequency of -# sound_freq, Allegro will have to resample it. Allegro's 'quality = 2' -# setting is only comparable with DUMB's 'dumb_resampling_quality = 1' -# setting. Therefore, in order to appreciate DUMB's cubic resampler fully, -# you will need to make sure Allegro doesn't do any resampling, by choosing -# an exact value for sound_freq. - -[sound] -dumb_resampling_quality = 2 -dumb_it_max_to_mix = 256 -buffer_size = 4096 -sound_freq = 44100 - -quality = 2 diff --git a/dumb/examples/dumb2wav.c b/dumb/examples/dumb2wav.c deleted file mode 100644 index 9a4c509096..0000000000 --- a/dumb/examples/dumb2wav.c +++ /dev/null @@ -1,481 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * dumb2wav.c - Utility to convert DUH to WAV. / / \ \ - * | < / \_ - * By Chad Austin, based on dumbout.c by entheh. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -union { - float s32[4096]; - short s16[8192]; - char s8[16384]; -} buffer; - -sample_t ** internal_buffer; - -int loop_count = 1; - - -static int write32_le(FILE* outf, unsigned int value) { - int total = 0; - total += fputc(value & 0xFF, outf); - total += fputc((value >> 8) & 0xFF, outf); - total += fputc((value >> 16) & 0xFF, outf); - total += fputc((value >> 24) & 0xFF, outf); - return total; -} - -static int write16_le(FILE* outf, unsigned int value) { - int total = 0; - total += fputc(value & 0xFF, outf); - total += fputc((value >> 8) & 0xFF, outf); - return total; -} - - -static int loop_callback(void* data) { - return (--loop_count <= 0 ? -1 : 0); -} - - -int main(int argc, const char *argv[]) -{ - DUH *duh; - DUH_SIGRENDERER *sr; - - const char *fn = NULL; - const char *fn_out = NULL; - FILE *outf; - - int depth = 16; - int unsign = 0; - int freq = 44100; - int n_channels = 2; - int solo = -1; - float volume = 1.0f; - float delay = 0.0f; - float delta; - int bufsize; - clock_t start, end; - int data_written = 0; /* total bytes written to data chunk */ - - int i = 1; - - LONG_LONG length; - LONG_LONG done; - int dots; - - while (i < argc) { - const char *arg = argv[i++]; - if (*arg != '-') { - if (fn) { - fprintf(stderr, - "Cannot specify multiple filenames!\n" - "Second filename found: \"%s\"\n", arg); - return 1; - } - fn = arg; - continue; - } - arg++; - while (*arg) { - char *endptr; - switch (*arg++) { - case 'o': - case 'O': - if (i >= argc) { - fprintf(stderr, "Out of arguments; output filename expected!\n"); - return 1; - } - fn_out = argv[i++]; - break; - case 'd': - case 'D': - if (i >= argc) { - fprintf(stderr, "Out of arguments; delay expected!\n"); - return 1; - } - delay = (float)strtod(argv[i++], &endptr); - if (*endptr != 0 || delay < 0.0f || delay > 64.0f) { - fprintf(stderr, "Invalid delay!\n"); - return 1; - } - break; - case 'v': - case 'V': - if (i >= argc) { - fprintf(stderr, "Out of arguments; volume expected!\n"); - return 1; - } - volume = (float)strtod(argv[i++], &endptr); - if (*endptr != 0 || volume < -8.0f || volume > 8.0f) { - fprintf(stderr, "Invalid volume!\n"); - return 1; - } - break; - case 's': - case 'S': - if (i >= argc) { - fprintf(stderr, "Out of arguments; sampling rate expected!\n"); - return 1; - } - freq = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || freq < 1 || freq > 960000) { - fprintf(stderr, "Invalid sampling rate!\n"); - return 1; - } - break; - case 'f': - depth = 32; - break; - case '8': - depth = 8; - break; - case 'l': - case 'L': - if (i >= argc) { - fprintf(stderr, "Out of arguments: loop count expected!\n"); - return 1; - } - loop_count = strtol(argv[i++], &endptr, 10); - break; - case 'm': - case 'M': - n_channels = 1; - break; - case 'u': - case 'U': - unsign = 1; - break; - case 'r': - case 'R': - if (i >= argc) { - fprintf(stderr, "Out of arguments; resampling quality expected!\n"); - return 1; - } - dumb_resampling_quality = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || dumb_resampling_quality < 0 || dumb_resampling_quality > 2) { - fprintf(stderr, "Invalid resampling quality!\n"); - return 1; - } - break; - case 'c': - case 'C': - if (i >= argc) { - fprintf(stderr, "Out of arguments; channel number expected!\n"); - return 1; - } - solo = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || solo < 0 || solo >= DUMB_IT_N_CHANNELS) { - fprintf(stderr, "Invalid channel number!\n"); - return 1; - } - break; - default: - fprintf(stderr, "Invalid switch - '%c'!\n", isprint(arg[-1]) ? arg[-1] : '?'); - return 1; - } - } - } - - if (!fn) { - fprintf(stderr, - "Usage: dumb2wav [options] module [more-options]\n" - "\n" - "The module can be any IT, XM, S3M or MOD file. It will be rendered to a .wav\n" - "file of the same name, unless you specify otherwise with the -o option.\n" - "\n" - "The valid options are:\n" - "-o specify the output filename (defaults to the input filename with\n" - " the extension replaced with .wav); use - to write to standard\n" - " output or . to write nowhere (useful for measuring DUMB's\n" - " performance, and DOS and Windows don't have /dev/null!)\n" - "-d set the initial delay, in seconds (default 0.0)\n" - "-v adjust the volume (default 1.0)\n" - "-s set the sampling rate in Hz (default 44100)\n" - "-8 generate 8-bit instead of 16-bit\n" - "-f generate floating point samples instead of 16-bit\n" - "-m generate mono output instead of stereo left/right pairs\n" - "-u generated unsigned output instead of signed\n" - "-r specify the resampling quality to use\n" - "-l specify the number of times to loop (default 1)\n" - "-c specify a channel number to solo\n"); - return 1; - } - - atexit(&dumb_exit); - dumb_register_stdfiles(); - - dumb_it_max_to_mix = 256; - - duh = load_duh(fn); - if (!duh) { - duh = dumb_load_it(fn); - if (!duh) { - duh = dumb_load_xm(fn); - if (!duh) { - duh = dumb_load_s3m(fn); - if (!duh) { - duh = dumb_load_mod(fn); - if (!duh) { - fprintf(stderr, "Unable to open %s!\n", fn); - return 1; - } - } - } - } - } - - sr = duh_start_sigrenderer(duh, 0, n_channels, 0); - if (!sr) { - unload_duh(duh); - fprintf(stderr, "Unable to play file!\n"); - return 1; - } - - if (solo >= 0) { - DUMB_IT_SIGRENDERER * itsr = duh_get_it_sigrenderer(sr); - if (itsr) { - for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { - if (i != solo) { - IT_CHANNEL * channel = &itsr->channel[i]; - IT_PLAYING * playing = channel->playing; - channel->flags |= IT_CHANNEL_MUTED; - /* start_sigrenderer leaves me all of the channels the first tick triggered */ - if (playing) { - playing->ramp_volume[0] = 0; - playing->ramp_volume[1] = 0; - playing->ramp_delta[0] = 0; - playing->ramp_delta[1] = 0; - } - } - } - } - } - - if (fn_out) { - if (fn_out[0] == '-' && fn_out[1] == 0) - outf = stdout; - else if (fn_out[0] == '.' && fn_out[1] == 0) - outf = NULL; - else { - outf = fopen(fn_out, "wb"); - if (!outf) { - fprintf(stderr, "Unable to open %s for writing!\n", fn_out); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - } - } else { - char *extptr = NULL, *p; - char *fn_out = malloc(strlen(fn)+5); - if (!fn_out) { - fprintf(stderr, "Out of memory!\n"); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - strcpy(fn_out, fn); - for (p = fn_out; *p; p++) - if (*p == '.') extptr = p; - if (!extptr) extptr = p; - strcpy(extptr, ".wav"); - outf = fopen(fn_out, "wb"); - if (!outf) { - fprintf(stderr, "Unable to open %s for writing!\n", fn_out); - free(fn_out); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - free(fn_out); - } - - { - DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sr); - dumb_it_set_ramp_style(itsr, 2); - dumb_it_set_loop_callback(itsr, loop_callback, NULL); - dumb_it_set_xm_speed_zero_callback(itsr, &dumb_it_callback_terminate, NULL); - dumb_it_set_global_volume_zero_callback(itsr, &dumb_it_callback_terminate, NULL); - } - - - if (outf) { - /* write RIFF header: fill file length later */ - fwrite("RIFF", 1, 4, outf); - fwrite(" ", 1, 4, outf); - fwrite("WAVE", 1, 4, outf); - - /* write format chunk */ - fwrite("fmt ", 1, 4, outf); - - if (depth == 32) - { - write32_le(outf, 18); - write16_le(outf, 3); - } - else - { - write32_le(outf, 16); /* header length */ - write16_le(outf, 1); /* WAVE_FORMAT_PCM */ - } - write16_le(outf, n_channels); /* channel count */ - write32_le(outf, freq); /* frequency */ - write32_le(outf, freq * n_channels * depth / 8); /*bytes/sec*/ - write16_le(outf, n_channels * depth / 8); /* block alignment */ - write16_le(outf, depth); /* bits per sample */ - - if (depth == 32) - { - write16_le(outf, 0); - } - - /* start data chunk */ - fwrite("data", 1, 4, outf); - fwrite(" ", 1, 4, outf); /* fill in later */ - } - - length = (LONG_LONG)_dumb_it_build_checkpoints(duh_get_it_sigdata(duh), 0) * freq >> 16; - done = 0; - dots = 0; - delta = 65536.0f / freq; - bufsize = sizeof(buffer); - if (depth == 32) bufsize /= sizeof(*buffer.s32); - else if (depth == 16) bufsize /= sizeof(*buffer.s16); - bufsize /= n_channels; - - if (depth == 32) { - internal_buffer = create_sample_buffer(n_channels, bufsize); - if (!internal_buffer) { - fprintf(stderr, "Out of memory!\n"); - duh_end_sigrenderer(sr); - unload_duh(duh); - } - } - - { - long l = (long)floor(delay * freq + 0.5f); - l *= n_channels * (depth >> 3); - if (l) { - if (unsign && depth != 32) { - if (depth == 16) { - for (i = 0; i < 8192; i++) { - buffer.s8[i*2] = 0x00; - buffer.s8[i*2+1] = 0x80; - } - } else - memset(buffer.s8, 0x80, 16384); - } else - memset(buffer.s8, 0, 16384); - while (l >= 16384) { - if (outf) fwrite(buffer.s8, 1, 16384, outf); - l -= 16384; - data_written += 16384; - } - if (l) { - if (outf) fwrite(buffer.s8, 1, l, outf); - data_written += 1; - } - } - } - - start = clock(); - - fprintf(stderr, "................................................................\n"); - for (;;) { - int write_size; - int l; - - if (depth != 32) { - l = duh_render(sr, depth, unsign, volume, delta, bufsize, &buffer); - if (depth == 16) { - for (i = 0; i < l * n_channels; i++) { - short val = buffer.s16[i]; - buffer.s8[i*2] = val; - buffer.s8[i*2+1] = val >> 8; - } - } - } else { - int j; - dumb_silence(internal_buffer[0], bufsize * n_channels); - l = duh_sigrenderer_get_samples(sr, volume, delta, bufsize, internal_buffer); - for (i = 0; i < n_channels; i++) { - for (j = 0; j < l; j++) { - buffer.s32[j * n_channels + i] = (float)((double)internal_buffer[i][j] * (1.0 / (double)(0x800000))); - } - } - } - write_size = l * n_channels * (depth >> 3); - if (outf) fwrite(buffer.s8, 1, write_size, outf); - data_written += write_size; - if (l < bufsize) break; - done += l; - l = done * 64 / length; - while (dots < 64 && l > dots) { - fprintf(stderr, "|"); - dots++; - } - if (dots >= 64) { - putchar('\n'); - dots = 0; - done = 0; - } - } - - while (64 > dots) { - fprintf(stderr, "|"); - dots++; - } - fprintf(stderr, "\n"); - - end = clock(); - - if (depth == 32) destroy_sample_buffer(internal_buffer); - - /* fill in blanks we left in WAVE file */ - if (outf) { - /* file size, not including RIFF header */ - const int fmt_size = 8 + ((depth == 32) ? 18 : 16); - const int data_size = 8 + data_written; - const int file_size = fmt_size + data_size; - - /* can we seek stdout? */ - fseek(outf, 4, SEEK_SET); - write32_le(outf, file_size); - - fseek(outf, 12 + fmt_size + 4, SEEK_SET); - write32_le(outf, data_written); - } - - - duh_end_sigrenderer(sr); - unload_duh(duh); - if (outf && outf != stdout) fclose(outf); - - fprintf(stderr, "Elapsed time: %f seconds\n", (end - start) / (float)CLOCKS_PER_SEC); - - return 0; -} diff --git a/dumb/examples/dumbout.c b/dumb/examples/dumbout.c deleted file mode 100644 index 3082b3b497..0000000000 --- a/dumb/examples/dumbout.c +++ /dev/null @@ -1,404 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * dumbout.c - Utility to stream music to a file. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -union { - float s32[4096]; - short s16[8192]; - char s8[16384]; -} buffer; - -sample_t ** internal_buffer; - -int main(int argc, const char *const *argv) /* I'm const-crazy! */ -{ - DUH *duh; - DUH_SIGRENDERER *sr; - - const char *fn = NULL; - const char *fn_out = NULL; - FILE *outf; - - int depth = 16; - int bigendian = 0; - int unsign = 0; - int freq = 44100; - int n_channels = 2; - int solo = -1; - float volume = 1.0f; - float delay = 0.0f; - float delta; - int bufsize; - clock_t start, end; - - int i = 1; - - LONG_LONG length; - LONG_LONG done; - int dots; - - while (i < argc) { - const char *arg = argv[i++]; - if (*arg != '-') { - if (fn) { - fprintf(stderr, - "Cannot specify multiple filenames!\n" - "Second filename found: \"%s\"\n", arg); - return 1; - } - fn = arg; - continue; - } - arg++; - while (*arg) { - char *endptr; - switch (*arg++) { - case 'o': - case 'O': - if (i >= argc) { - fprintf(stderr, "Out of arguments; output filename expected!\n"); - return 1; - } - fn_out = argv[i++]; - break; - case 'd': - case 'D': - if (i >= argc) { - fprintf(stderr, "Out of arguments; delay expected!\n"); - return 1; - } - delay = (float)strtod(argv[i++], &endptr); - if (*endptr != 0 || delay < 0.0f || delay > 64.0f) { - fprintf(stderr, "Invalid delay!\n"); - return 1; - } - break; - case 'v': - case 'V': - if (i >= argc) { - fprintf(stderr, "Out of arguments; volume expected!\n"); - return 1; - } - volume = (float)strtod(argv[i++], &endptr); - if (*endptr != 0 || volume < -8.0f || volume > 8.0f) { - fprintf(stderr, "Invalid volume!\n"); - return 1; - } - break; - case 's': - case 'S': - if (i >= argc) { - fprintf(stderr, "Out of arguments; sampling rate expected!\n"); - return 1; - } - freq = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || freq < 1 || freq > 960000) { - fprintf(stderr, "Invalid sampling rate!\n"); - return 1; - } - break; - case 'f': - depth = 32; - break; - case '8': - depth = 8; - break; - case 'b': - case 'B': - bigendian = 1; - break; - case 'm': - case 'M': - n_channels = 1; - break; - case 'u': - case 'U': - unsign = 1; - break; - case 'r': - case 'R': - if (i >= argc) { - fprintf(stderr, "Out of arguments; resampling quality expected!\n"); - return 1; - } - dumb_resampling_quality = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || dumb_resampling_quality < 0 || dumb_resampling_quality > 2) { - fprintf(stderr, "Invalid resampling quality!\n"); - return 1; - } - break; - case 'c': - case 'C': - if (i >= argc) { - fprintf(stderr, "Out of arguments; channel number expected!\n"); - return 1; - } - solo = strtol(argv[i++], &endptr, 10); - if (*endptr != 0 || solo < 0 || solo >= DUMB_IT_N_CHANNELS) { - fprintf(stderr, "Invalid channel number!\n"); - return 1; - } - break; - default: - fprintf(stderr, "Invalid switch - '%c'!\n", isprint(arg[-1]) ? arg[-1] : '?'); - return 1; - } - } - } - - if (!fn) { - fprintf(stderr, - "Usage: dumbout [options] module [more-options]\n" - "\n" - "The module can be any IT, XM, S3M or MOD file. It will be rendered to a .pcm\n" - "file of the same name, unless you specify otherwise with the -o option.\n" - "\n" - "The valid options are:\n" - "-o specify the output filename (defaults to the input filename with\n" - " the extension replaced with .pcm); use - to write to standard\n" - " output or . to write nowhere (useful for measuring DUMB's\n" - " performance, and DOS and Windows don't have /dev/null!)\n" - "-d set the initial delay, in seconds (default 0.0)\n" - "-v adjust the volume (default 1.0)\n" - "-s set the sampling rate in Hz (default 44100)\n" - "-8 generate 8-bit instead of 16-bit\n" - "-f generate 32-bit floating point data instead of 16-bit\n" - "-b generate big-endian data instead of little-endian (meaningless when\n" - " using -8)\n" - "-m generate mono output instead of stereo left/right pairs\n" - "-u generated unsigned output instead of signed\n" - "-r specify the resampling quality to use\n" - "-c specify a channel number to solo\n"); - return 1; - } - - atexit(&dumb_exit); - dumb_register_stdfiles(); - - dumb_it_max_to_mix = 256; - - duh = load_duh(fn); - if (!duh) { - duh = dumb_load_it(fn); - if (!duh) { - duh = dumb_load_xm(fn); - if (!duh) { - duh = dumb_load_s3m(fn); - if (!duh) { - duh = dumb_load_mod(fn); - if (!duh) { - fprintf(stderr, "Unable to open %s!\n", fn); - return 1; - } - } - } - } - } - - sr = duh_start_sigrenderer(duh, 0, n_channels, 0); - if (!sr) { - unload_duh(duh); - fprintf(stderr, "Unable to play file!\n"); - return 1; - } - - if (solo >= 0) { - DUMB_IT_SIGRENDERER * itsr = duh_get_it_sigrenderer(sr); - if (itsr) { - for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { - if (i != solo) { - IT_CHANNEL * channel = &itsr->channel[i]; - IT_PLAYING * playing = channel->playing; - channel->flags |= IT_CHANNEL_MUTED; - /* start_sigrenderer leaves me all of the channels the first tick triggered */ - if (playing) { - playing->ramp_volume[0] = 0; - playing->ramp_volume[1] = 0; - playing->ramp_delta[0] = 0; - playing->ramp_delta[1] = 0; - } - } - } - } - } - - if (fn_out) { - if (fn_out[0] == '-' && fn_out[1] == 0) - outf = stdout; - else if (fn_out[0] == '.' && fn_out[1] == 0) - outf = NULL; - else { - outf = fopen(fn_out, "wb"); - if (!outf) { - fprintf(stderr, "Unable to open %s for writing!\n", fn_out); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - } - } else { - char *extptr = NULL, *p; - char *fn_out = malloc(strlen(fn)+5); - if (!fn_out) { - fprintf(stderr, "Out of memory!\n"); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - strcpy(fn_out, fn); - for (p = fn_out; *p; p++) - if (*p == '.') extptr = p; - if (!extptr) extptr = p; - strcpy(extptr, ".pcm"); - outf = fopen(fn_out, "wb"); - if (!outf) { - fprintf(stderr, "Unable to open %s for writing!\n", fn_out); - free(fn_out); - duh_end_sigrenderer(sr); - unload_duh(duh); - return 1; - } - free(fn_out); - } - - { - DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sr); - dumb_it_set_ramp_style(itsr, 2); - dumb_it_set_loop_callback(itsr, &dumb_it_callback_terminate, NULL); - dumb_it_set_xm_speed_zero_callback(itsr, &dumb_it_callback_terminate, NULL); - dumb_it_set_global_volume_zero_callback(itsr, &dumb_it_callback_terminate, NULL); - } - - length = (LONG_LONG)_dumb_it_build_checkpoints(duh_get_it_sigdata(duh), 0) * freq >> 16; - done = 0; - dots = 0; - delta = 65536.0f / freq; - bufsize = sizeof(buffer); - if (depth == 32) bufsize /= sizeof(*buffer.s32); - else if (depth == 16) bufsize /= sizeof(*buffer.s16); - bufsize /= n_channels; - - if (depth == 32) { - internal_buffer = create_sample_buffer(n_channels, bufsize); - if (!internal_buffer) { - fprintf(stderr, "Out of memory!\n"); - duh_end_sigrenderer(sr); - unload_duh(duh); - } - } - - { - long l = (long)floor(delay * freq + 0.5f); - l *= n_channels * (depth >> 3); - if (l) { - if (unsign && depth != 32) { - if (depth == 16) { - if (bigendian) { - for (i = 0; i < 8192; i++) { - buffer.s8[i*2] = 0x80; - buffer.s8[i*2+1] = 0x00; - } - } else { - for (i = 0; i < 8192; i++) { - buffer.s8[i*2] = 0x00; - buffer.s8[i*2+1] = 0x80; - } - } - } else - memset(buffer.s8, 0x80, 16384); - } else - memset(buffer.s8, 0, 16384); - while (l >= 16384) { - if (outf) fwrite(buffer.s8, 1, 16384, outf); - l -= 16384; - } - if (l && outf) fwrite(buffer.s8, 1, l, outf); - } - } - - start = clock(); - - fprintf(stderr, "................................................................\n"); - for (;;) { - int l; - - if (depth != 32) { - l = duh_render(sr, depth, unsign, volume, delta, bufsize, &buffer); - if (depth == 16) { - if (bigendian) { - for (i = 0; i < l * n_channels; i++) { - short val = buffer.s16[i]; - buffer.s8[i*2] = val >> 8; - buffer.s8[i*2+1] = val; - } - } else { - for (i = 0; i < l * n_channels; i++) { - short val = buffer.s16[i]; - buffer.s8[i*2] = val; - buffer.s8[i*2+1] = val >> 8; - } - } - } - } else { - int j; - dumb_silence(internal_buffer[0], bufsize * n_channels); - l = duh_sigrenderer_get_samples(sr, volume, delta, bufsize, internal_buffer); - for (i = 0; i < n_channels; i++) { - for (j = i; j < l; j++) { - buffer.s32[j * n_channels] = (float)((double)internal_buffer[i][j] * (1.0 / (double)(0x800000))); - } - } - } - if (outf) fwrite(buffer.s8, 1, l * n_channels * (depth >> 3), outf); - if (l < bufsize) break; - done += l; - l = done * 64 / length; - while (dots < 64 && l > dots) { - fprintf(stderr, "|"); - dots++; - } - } - - while (64 > dots) { - fprintf(stderr, "|"); - dots++; - } - fprintf(stderr, "\n"); - - end = clock(); - - if (depth == 32) destroy_sample_buffer(internal_buffer); - - duh_end_sigrenderer(sr); - unload_duh(duh); - if (outf && outf != stdout) fclose(outf); - - fprintf(stderr, "Elapsed time: %f seconds\n", (end - start) / (float)CLOCKS_PER_SEC); - - return 0; -} diff --git a/dumb/examples/dumbplay.c b/dumb/examples/dumbplay.c deleted file mode 100644 index 521113f698..0000000000 --- a/dumb/examples/dumbplay.c +++ /dev/null @@ -1,238 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * dumbplay.c - Not-so-simple program to play / / \ \ - * music. It used to be simpler! | < / \_ - * | \/ /\ / - * By entheh. \_ / > / - * | \ / / - * IMPORTANT NOTE: This file is not very friendly. | ' / - * I strongly recommend AGAINST using it as a \__/ - * reference for writing your own code. If you would - * like to write a program that uses DUMB, or add DUMB to an existing - * project, please use docs/howto.txt. It will help you a lot more than this - * file can. (If you have difficulty reading documentation, you are lacking - * an important coding skill, and now is as good a time as any to learn.) - */ - -#include -#include - -#ifndef ALLEGRO_DOS -#include -#endif - -/* Note that your own programs should use not "aldumb.h". <> tells - * the compiler to look in the compiler's default header directory, which is - * where DUMB should be installed before you use it (make install does this). - * Use "" when it is your own header file. This example uses "" because DUMB - * might not have been installed yet when the makefile builds it. - */ -#include "aldumb.h" - - - -#ifndef ALLEGRO_DOS -static volatile int closed = 0; -static void closehook(void) { closed = 1; } -#else -#define closed 0 -#endif - -#ifdef ALLEGRO_WINDOWS -#define GFX_DUMB_MODE GFX_GDI -#include -#define YIELD() Sleep(1) -#else -#define GFX_DUMB_MODE GFX_AUTODETECT_WINDOWED -#ifdef ALLEGRO_UNIX -#include -static void YIELD(void) -{ - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); -} -#else -#define YIELD() yield_timeslice() -#endif -#endif - - - -#ifdef ALLEGRO_DOS -static int loop_callback(void *data) -{ - (void)data; - printf("Music has looped.\n"); - return 0; -} - -static int xm_speed_zero_callback(void *data) -{ - (void)data; - printf("Music has stopped.\n"); - return 0; -} -#else -static int gfx_half_width; - -static int loop_callback(void *data) -{ - (void)data; - if (gfx_half_width) { - acquire_screen(); - textout_centre(screen, font, "Music has looped.", gfx_half_width, 36, 10); - release_screen(); - } - return 0; -} - -static int xm_speed_zero_callback(void *data) -{ - (void)data; - if (gfx_half_width) { - text_mode(0); /* In case this is overwriting "Music has looped." */ - acquire_screen(); - textout_centre(screen, font, "Music has stopped.", gfx_half_width, 36, 10); - release_screen(); - } - return 0; -} -#endif - - - -static void usage(const char *exename) -{ - allegro_message( -#ifdef ALLEGRO_WINDOWS - "Usage:\n" - " At the command line: %s file\n" - " In Windows Explorer: drag a file on to this program's icon.\n" -#else - "Usage: %s file\n" -#endif - "This will play the music file specified.\n" - "File formats supported: IT XM S3M MOD.\n" - "You can control playback quality by editing dumb.ini.\n", exename); - - exit(1); -} - - - -int main(int argc, const char *const *argv) /* I'm const-crazy! */ -{ - DUH *duh; - AL_DUH_PLAYER *dp; - - if (allegro_init()) - return 1; - - if (argc != 2) - usage(argv[0]); - - set_config_file("dumb.ini"); - - if (install_keyboard()) { - allegro_message("Failed to initialise keyboard driver!\n"); - return 1; - } - - set_volume_per_voice(0); - - if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL)) { - allegro_message("Failed to initialise sound driver!\n%s\n", allegro_error); - return 1; - } - - atexit(&dumb_exit); - - dumb_register_packfiles(); - - duh = dumb_load_it(argv[1]); - if (!duh) { - duh = dumb_load_xm(argv[1]); - if (!duh) { - duh = dumb_load_s3m(argv[1]); - if (!duh) { - duh = dumb_load_mod(argv[1]); - if (!duh) { - allegro_message("Failed to load %s!\n", argv[1]); - return 1; - } - } - } - } - - dumb_resampling_quality = get_config_int("sound", "dumb_resampling_quality", 4); - dumb_it_max_to_mix = get_config_int("sound", "dumb_it_max_to_mix", 128); - -#ifndef ALLEGRO_DOS - { - const char *fn = get_filename(argv[1]); - gfx_half_width = strlen(fn); - if (gfx_half_width < 22) gfx_half_width = 22; - gfx_half_width = (gfx_half_width + 2) * 4; - - /* set_window_title() is not const-correct (yet). */ - set_window_title((char *)"DUMB Music Player"); - - if (set_gfx_mode(GFX_DUMB_MODE, gfx_half_width*2, 80, 0, 0) == 0) { - acquire_screen(); - textout_centre(screen, font, fn, gfx_half_width, 20, 14); - textout_centre(screen, font, "Press any key to exit.", gfx_half_width, 52, 11); - release_screen(); - } else - gfx_half_width = 0; - } - -#if ALLEGRO_VERSION*10000 + ALLEGRO_SUB_VERSION*100 + ALLEGRO_WIP_VERSION >= 40105 - set_close_button_callback(&closehook); -#else - set_window_close_hook(&closehook); -#endif - -#endif - - set_display_switch_mode(SWITCH_BACKGROUND); - - dp = al_start_duh(duh, 2, 0, 1.0f, - get_config_int("sound", "buffer_size", 4096), - get_config_int("sound", "sound_freq", 44100)); - - { - DUH_SIGRENDERER *sr = al_duh_get_sigrenderer(dp); - DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sr); - dumb_it_set_loop_callback(itsr, &loop_callback, NULL); - dumb_it_set_xm_speed_zero_callback(itsr, &xm_speed_zero_callback, NULL); - } - - for (;;) { - if (keypressed()) { - readkey(); - break; - } - - if (al_poll_duh(dp) || closed) - break; - - YIELD(); - } - - al_stop_duh(dp); - - unload_duh(duh); - - return 0; -} -END_OF_MAIN(); diff --git a/dumb/examples/playduh.c b/dumb/examples/playduh.c deleted file mode 100644 index 31d7b619a8..0000000000 --- a/dumb/examples/playduh.c +++ /dev/null @@ -1,169 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * playduh.c - Simple program to play DUH files. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - -#include -#include - -#ifndef ALLEGRO_DOS -#include -#endif - -/* Note that your own programs should use not "aldumb.h". <> tells - * the compiler to look in the compiler's default header directory, which is - * where DUMB should be installed before you use it (make install does this). - * Use "" when it is your own header file. This example uses "" because DUMB - * might not have been installed yet when the makefile builds it. - */ -#include "aldumb.h" - - - -#ifndef ALLEGRO_DOS -static int closed = 0; -static void closehook(void) { closed = 1; } -#else -#define closed 0 -#endif - -#ifdef ALLEGRO_WINDOWS -#define GFX_DUMB_MODE GFX_GDI -#include -#define YIELD() Sleep(1) -#else -#define GFX_DUMB_MODE GFX_AUTODETECT_WINDOWED -#ifdef ALLEGRO_UNIX -#include -static void YIELD(void) -{ - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); -} -#else -#define YIELD() yield_timeslice() -#endif -#endif - - - -static void usage(void) -{ - allegro_message( - "Usage: playduh file.duh\n" - "This will play the .duh file specified.\n" - "You can control playback quality by editing dumb.ini.\n" - ); - - exit(1); -} - - - -int main(int argc, char *argv[]) -{ - DUH *duh; - AL_DUH_PLAYER *dp; - - if (allegro_init()) - return 1; - - if (argc != 2) - usage(); - - set_config_file("dumb.ini"); - - if (install_keyboard()) { - allegro_message("Failed to initialise keyboard driver!\n"); - return 1; - } - - set_volume_per_voice(0); - - if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL)) { - allegro_message("Failed to initialise sound driver!\n%s\n", allegro_error); - return 1; - } - - atexit(&dumb_exit); - - dumb_register_stdfiles(); - -/* - dumb_register_sigtype_sample(); - dumb_register_sigtype_combining(); - dumb_register_sigtype_stereopan(); - dumb_register_sigtype_sequence(); -*/ - - duh = load_duh(argv[1]); - if (!duh) { - allegro_message("Failed to load %s!\n", argv[1]); - return 1; - } - - dumb_resampling_quality = get_config_int("sound", "dumb_resampling_quality", 4); - // Are we sure dumb_it_max_to_mix will be unused? Can decide when editor matures... - -#ifndef ALLEGRO_DOS - { - const char *fn = get_filename(argv[1]); - int w = strlen(fn); - if (w < 22) w = 22; - w = (w + 2) * 4; - - set_window_title("DUMB - IT player"); - - if (set_gfx_mode(GFX_DUMB_MODE, w*2, 80, 0, 0) == 0) { - acquire_screen(); - textout_centre(screen, font, fn, w, 28, 14); - textout_centre(screen, font, "Press any key to exit.", w, 44, 11); - release_screen(); - } - } - - //set_window_close_hook(&closehook); -#endif - - set_display_switch_mode(SWITCH_BACKGROUND); - - dp = al_start_duh(duh, 2, 0, 1.0, - get_config_int("sound", "buffer_size", 4096), - get_config_int("sound", "sound_freq", 44100)); - - for (;;) { - if (keypressed()) { - readkey(); - break; - } - - if (al_poll_duh(dp) || closed) - break; - - YIELD(); - } - - al_stop_duh(dp); - - unload_duh(duh); - - return 0; -} -END_OF_MAIN(); - diff --git a/dumb/include/dumb.h b/dumb/include/dumb.h index cafcfea3b8..1a17e90394 100644 --- a/dumb/include/dumb.h +++ b/dumb/include/dumb.h @@ -26,7 +26,7 @@ #if defined(_DEBUG) && defined(_MSC_VER) #ifndef _CRTDBG_MAP_ALLOC -#define _CRTDBG_MAP_ALLOC +//#define _CRTDBG_MAP_ALLOC #endif #include #endif @@ -171,11 +171,13 @@ void dumb_exit(void); typedef struct DUMBFILE_SYSTEM { - void *(*open)(const char *filename); - int (*skip)(void *f, int32 n); - int (*getc)(void *f); - int32 (*getnc)(char *ptr, int32 n, void *f); - void (*close)(void *f); + void *(DUMBCALLBACK *open)(const char *filename); + int (DUMBCALLBACK *skip)(void *f, long n); + int (DUMBCALLBACK *getc)(void *f); + int32 (DUMBCALLBACK *getnc)(char *ptr, int32 n, void *f); + void (DUMBCALLBACK *close)(void *f); + int (DUMBCALLBACK *seek)(void *f, long n); + int32 (DUMBCALLBACK *get_size)(void *f); } DUMBFILE_SYSTEM; @@ -187,7 +189,15 @@ DUMBFILE *DUMBEXPORT dumbfile_open(const char *filename); DUMBFILE *DUMBEXPORT dumbfile_open_ex(void *file, const DUMBFILE_SYSTEM *dfs); int32 DUMBEXPORT dumbfile_pos(DUMBFILE *f); -int DUMBEXPORT dumbfile_skip(DUMBFILE *f, int32 n); +int DUMBEXPORT dumbfile_skip(DUMBFILE *f, long n); + +#define DFS_SEEK_SET 0 +#define DFS_SEEK_CUR 1 +#define DFS_SEEK_END 2 + +int DUMBEXPORT dumbfile_seek(DUMBFILE *f, long n, int origin); + +int32 DUMBEXPORT dumbfile_get_size(DUMBFILE *f); int DUMBEXPORT dumbfile_getc(DUMBFILE *f); @@ -383,10 +393,15 @@ int DUMBEXPORT dumb_it_scan_for_playable_orders(DUMB_IT_SIGDATA *sigdata, dumb_s DUH_SIGRENDERER *DUMBEXPORT dumb_it_start_at_order(DUH *duh, int n_channels, int startorder); -void DUMBEXPORT dumb_it_set_resampling_quality(DUMB_IT_SIGRENDERER * sigrenderer, int quality); - +enum +{ + DUMB_IT_RAMP_NONE = 0, + DUMB_IT_RAMP_ONOFF_ONLY = 1, + DUMB_IT_RAMP_FULL = 2 +}; + void DUMBEXPORT dumb_it_set_ramp_style(DUMB_IT_SIGRENDERER * sigrenderer, int ramp_style); - + void DUMBEXPORT dumb_it_set_loop_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (DUMBCALLBACK *callback)(void *data), void *data); void DUMBEXPORT dumb_it_set_xm_speed_zero_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (DUMBCALLBACK *callback)(void *data), void *data); void DUMBEXPORT dumb_it_set_midi_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (DUMBCALLBACK *callback)(void *data, int channel, unsigned char midi_byte), void *data); @@ -395,13 +410,13 @@ void DUMBEXPORT dumb_it_set_global_volume_zero_callback(DUMB_IT_SIGRENDERER *sig int DUMBCALLBACK dumb_it_callback_terminate(void *data); int DUMBCALLBACK dumb_it_callback_midi_block(void *data, int channel, unsigned char midi_byte); -/* dumb_*_mod*: restrict |= 1-Don't read 15 sample files / 2-Use old pattern counting method */ +/* dumb_*_mod*: restrict_ |= 1-Don't read 15 sample files / 2-Use old pattern counting method */ DUH *DUMBEXPORT dumb_load_it(const char *filename); DUH *DUMBEXPORT dumb_load_xm(const char *filename); DUH *DUMBEXPORT dumb_load_s3m(const char *filename); DUH *DUMBEXPORT dumb_load_stm(const char *filename); -DUH *DUMBEXPORT dumb_load_mod(const char *filename, int rstrict); +DUH *DUMBEXPORT dumb_load_mod(const char *filename, int restrict_); DUH *DUMBEXPORT dumb_load_ptm(const char *filename); DUH *DUMBEXPORT dumb_load_669(const char *filename); DUH *DUMBEXPORT dumb_load_psm(const char *filename, int subsong); @@ -409,13 +424,14 @@ DUH *DUMBEXPORT dumb_load_old_psm(const char * filename); DUH *DUMBEXPORT dumb_load_mtm(const char *filename); DUH *DUMBEXPORT dumb_load_riff(const char *filename); DUH *DUMBEXPORT dumb_load_asy(const char *filename); +DUH *DUMBEXPORT dumb_load_amf(const char *filename); DUH *DUMBEXPORT dumb_load_okt(const char *filename); DUH *DUMBEXPORT dumb_read_it(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_xm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_s3m(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_stm(DUMBFILE *f); -DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int rstrict); +DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int restrict_); DUH *DUMBEXPORT dumb_read_ptm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_669(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_psm(DUMBFILE *f, int subsong); @@ -423,13 +439,14 @@ DUH *DUMBEXPORT dumb_read_old_psm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_mtm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_riff(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_asy(DUMBFILE *f); +DUH *DUMBEXPORT dumb_read_amf(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_okt(DUMBFILE *f); DUH *DUMBEXPORT dumb_load_it_quick(const char *filename); DUH *DUMBEXPORT dumb_load_xm_quick(const char *filename); DUH *DUMBEXPORT dumb_load_s3m_quick(const char *filename); DUH *DUMBEXPORT dumb_load_stm_quick(const char *filename); -DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int rstrict); +DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int restrict_); DUH *DUMBEXPORT dumb_load_ptm_quick(const char *filename); DUH *DUMBEXPORT dumb_load_669_quick(const char *filename); DUH *DUMBEXPORT dumb_load_psm_quick(const char *filename, int subsong); @@ -437,13 +454,14 @@ DUH *DUMBEXPORT dumb_load_old_psm_quick(const char * filename); DUH *DUMBEXPORT dumb_load_mtm_quick(const char *filename); DUH *DUMBEXPORT dumb_load_riff_quick(const char *filename); DUH *DUMBEXPORT dumb_load_asy_quick(const char *filename); +DUH *DUMBEXPORT dumb_load_amf_quick(const char *filename); DUH *DUMBEXPORT dumb_load_okt_quick(const char *filename); DUH *DUMBEXPORT dumb_read_it_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_xm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_s3m_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_stm_quick(DUMBFILE *f); -DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int rstrict); +DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int restrict_); DUH *DUMBEXPORT dumb_read_ptm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_669_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_psm_quick(DUMBFILE *f, int subsong); @@ -451,8 +469,15 @@ DUH *DUMBEXPORT dumb_read_old_psm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_mtm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_riff_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_asy_quick(DUMBFILE *f); +DUH *DUMBEXPORT dumb_read_amf_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_okt_quick(DUMBFILE *f); +DUH *DUMBEXPORT dumb_read_any_quick(DUMBFILE *f, int restrict_, int subsong); +DUH *DUMBEXPORT dumb_read_any(DUMBFILE *f, int restrict_, int subsong); + +DUH *DUMBEXPORT dumb_load_any_quick(const char *filename, int restrict_, int subsong); +DUH *DUMBEXPORT dumb_load_any(const char *filename, int restrict_, int subsong); + int32 DUMBEXPORT dumb_it_build_checkpoints(DUMB_IT_SIGDATA *sigdata, int startorder); void DUMBEXPORT dumb_it_do_initial_runthrough(DUH *duh); @@ -581,6 +606,10 @@ typedef void (*DUH_SIGRENDERER_GET_CURRENT_SAMPLE)( sample_t *samples ); +typedef int32 (*DUH_SIGRENDERER_GET_POSITION)( + sigrenderer_t *sigrenderer +); + typedef void (*DUH_END_SIGRENDERER)(sigrenderer_t *sigrenderer); typedef void (*DUH_UNLOAD_SIGDATA)(sigdata_t *sigdata); @@ -596,6 +625,7 @@ typedef struct DUH_SIGTYPE_DESC DUH_SIGRENDERER_SET_SIGPARAM sigrenderer_set_sigparam; DUH_SIGRENDERER_GENERATE_SAMPLES sigrenderer_generate_samples; DUH_SIGRENDERER_GET_CURRENT_SAMPLE sigrenderer_get_current_sample; + DUH_SIGRENDERER_GET_POSITION sigrenderer_get_position; DUH_END_SIGRENDERER end_sigrenderer; DUH_UNLOAD_SIGDATA unload_sigdata; } @@ -658,10 +688,21 @@ void DUMBEXPORT dumb_destroy_click_remover_array(int n, DUMB_CLICK_REMOVER **cr) /* Resampling Helpers */ #define DUMB_RQ_ALIASING 0 -#define DUMB_RQ_LINEAR 1 -#define DUMB_RQ_CUBIC 2 -#define DUMB_RQ_N_LEVELS 3 -extern int dumb_resampling_quality; +#define DUMB_LQ_LINEAR 1 +#define DUMB_LQ_CUBIC 2 + +#define DUMB_RQ_BLEP 3 +#define DUMB_RQ_LINEAR 4 +#define DUMB_RQ_BLAM 5 +#define DUMB_RQ_CUBIC 6 +#define DUMB_RQ_FIR 7 +#define DUMB_RQ_N_LEVELS 8 + +/* Subtract quality above by this to convert to resampler.c's quality */ +#define DUMB_RESAMPLER_BASE 2 + +extern int dumb_resampling_quality; /* This specifies the default */ +void DUMBEXPORT dumb_it_set_resampling_quality(DUMB_IT_SIGRENDERER * sigrenderer, int quality); /* This overrides it */ typedef struct DUMB_RESAMPLER DUMB_RESAMPLER; @@ -669,8 +710,6 @@ typedef struct DUMB_VOLUME_RAMP_INFO DUMB_VOLUME_RAMP_INFO; typedef void (*DUMB_RESAMPLE_PICKUP)(DUMB_RESAMPLER *resampler, void *data); -#include "internal/blip_buf.h" - struct DUMB_RESAMPLER { void *src; @@ -688,9 +727,8 @@ struct DUMB_RESAMPLER signed char x8[3*2]; } x; int overshot; - int last_clock; - int last_amp[2]; - blip_t* blip_buffer[2]; + double fir_resampler_ratio; + void* fir_resampler[2]; }; struct DUMB_VOLUME_RAMP_INFO @@ -699,6 +737,7 @@ struct DUMB_VOLUME_RAMP_INFO float delta; float target; float mix; + unsigned char declick_stage; }; void dumb_reset_resampler(DUMB_RESAMPLER *resampler, sample_t *src, int src_channels, int32 pos, int32 start, int32 end, int quality); @@ -749,6 +788,11 @@ void dumb_resample_get_current_sample_n_1_2(int n, DUMB_RESAMPLER *resampler, DU void dumb_resample_get_current_sample_n_2_2(int n, DUMB_RESAMPLER *resampler, DUMB_VOLUME_RAMP_INFO * volume_left, DUMB_VOLUME_RAMP_INFO * volume_right, sample_t *dst); void dumb_end_resampler_n(int n, DUMB_RESAMPLER *resampler); +/* This sets the default panning separation for hard panned formats, + or for formats with default panning information. This must be set + before using any readers or loaders, and is not really thread safe. */ + +extern int dumb_it_default_panning_separation; /* in percent, default 25 */ /* DUH Construction */ diff --git a/dumb/include/internal/aldumb.h b/dumb/include/internal/aldumb.h new file mode 100644 index 0000000000..9c02c01fff --- /dev/null +++ b/dumb/include/internal/aldumb.h @@ -0,0 +1,27 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * internal/aldumb.h - The internal header file / / \ \ + * for DUMB with Allegro. | < / \_ + * | \/ /\ / + * \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#ifndef INTERNAL_ALDUMB_H +#define INTERNAL_ALDUMB_H + + +void _dat_unload_duh(void *duh); + + +#endif /* INTERNAL_DUMB_H */ diff --git a/dumb/include/internal/barray.h b/dumb/include/internal/barray.h index 53c9a6cf30..1ab3ff4cd6 100644 --- a/dumb/include/internal/barray.h +++ b/dumb/include/internal/barray.h @@ -3,6 +3,23 @@ #include +#ifdef BARRAY_DECORATE +#define PASTE(a,b) a ## b +#define EVALUATE(a,b) PASTE(a,b) +#define bit_array_create EVALUATE(BARRAY_DECORATE,_bit_array_create) +#define bit_array_destroy EVALUATE(BARRAY_DECORATE,_bit_array_destroy) +#define bit_array_dup EVALUATE(BARRAY_DECORATE,_bit_array_dup) +#define bit_array_reset EVALUATE(BARRAY_DECORATE,_bit_array_reset) +#define bit_array_set EVALUATE(BARRAY_DECORATE,_bit_array_set) +#define bit_array_set_range EVALUATE(BARRAY_DECORATE,_bit_array_set_range) +#define bit_array_test EVALUATE(BARRAY_DECORATE,_bit_array_test) +#define bit_array_test_range EVALUATE(BARRAY_DECORATE,_bit_array_test_range) +#define bit_array_clear EVALUATE(BARRAY_DECORATE,_bit_array_clear) +#define bit_array_clear_range EVALUATE(BARRAY_DECORATE,_bit_array_clear_range) +#define bit_array_merge EVALUATE(BARRAY_DECORATE,_bit_array_merge) +#define bit_array_mask EVALUATE(BARRAY_DECORATE,_bit_array_mask) +#endif + void * bit_array_create(size_t size); void bit_array_destroy(void * array); void * bit_array_dup(void * array); @@ -10,9 +27,13 @@ void * bit_array_dup(void * array); void bit_array_reset(void * array); void bit_array_set(void * array, size_t bit); +void bit_array_set_range(void * array, size_t bit, size_t count); + int bit_array_test(void * array, size_t bit); int bit_array_test_range(void * array, size_t bit, size_t count); + void bit_array_clear(void * array, size_t bit); +void bit_array_clear_range(void * array, size_t bit, size_t count); void bit_array_merge(void * array, void * source, size_t offset); void bit_array_mask(void * array, void * source, size_t offset); diff --git a/dumb/include/internal/blip_buf.h b/dumb/include/internal/blip_buf.h deleted file mode 100644 index 7f687c3e9c..0000000000 --- a/dumb/include/internal/blip_buf.h +++ /dev/null @@ -1,77 +0,0 @@ -/** \file -Sample buffer that resamples from input clock rate to output sample rate */ - -/* blip_buf 1.1.0 */ -#ifndef BLIP_BUF_H -#define BLIP_BUF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/** First parameter of most functions is blip_t*, or const blip_t* if nothing -is changed. */ -typedef struct blip_t blip_t; - -/** Creates new buffer that can hold at most sample_count samples. Sets rates -so that there are blip_max_ratio clocks per sample. Returns pointer to new -buffer, or NULL if insufficient memory. */ -blip_t* blip_new( int sample_count ); - -blip_t* blip_dup( blip_t* ); - -/** Sets approximate input clock rate and output sample rate. For every -clock_rate input clocks, approximately sample_rate samples are generated. */ -void blip_set_rates( blip_t*, double clock_rate, double sample_rate ); - -enum { /** Maximum clock_rate/sample_rate ratio. For a given sample_rate, -clock_rate must not be greater than sample_rate*blip_max_ratio. */ -blip_max_ratio = 1 << 20 }; - -/** Clears entire buffer. Afterwards, blip_samples_avail() == 0. */ -void blip_clear( blip_t* ); - -/** Adds positive/negative delta into buffer at specified clock time. */ -void blip_add_delta( blip_t*, unsigned int clock_time, int delta ); - -/** Same as blip_add_delta(), but uses faster, lower-quality synthesis. */ -void blip_add_delta_fast( blip_t*, unsigned int clock_time, int delta ); - -/** Length of time frame, in clocks, needed to make sample_count additional -samples available. */ -int blip_clocks_needed( const blip_t*, int sample_count ); - -enum { /** Maximum number of samples that can be generated from one time frame. */ -blip_max_frame = 4000 }; - -/** Makes input clocks before clock_duration available for reading as output -samples. Also begins new time frame at clock_duration, so that clock time 0 in -the new time frame specifies the same clock as clock_duration in the old time -frame specified. Deltas can have been added slightly past clock_duration (up to -however many clocks there are in two output samples). */ -void blip_end_frame( blip_t*, unsigned int clock_duration ); - -/** Number of buffered samples available for reading. */ -int blip_samples_avail( const blip_t* ); - -/** Reads and removes at most 'count' samples and writes them to 'out'. If -'stereo' is true, writes output to every other element of 'out', allowing easy -interleaving of two buffers into a stereo sample stream. Outputs 16-bit signed -samples. Returns number of samples actually read. */ -int blip_read_samples( blip_t*, int out [], int count ); - -/** Reads the current integrator and returns it */ -int blip_peek_sample( blip_t* ); - -/** Frees buffer. No effect if NULL is passed. */ -void blip_delete( blip_t* ); - - -/* Deprecated */ -typedef blip_t blip_buffer_t; - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/dumb/include/internal/dumbfile.h b/dumb/include/internal/dumbfile.h new file mode 100644 index 0000000000..c83cc9a003 --- /dev/null +++ b/dumb/include/internal/dumbfile.h @@ -0,0 +1,13 @@ +#ifndef DUMBFILE_H +#define DUMBFILE_H + +#include "../dumb.h" + +struct DUMBFILE +{ + const DUMBFILE_SYSTEM *dfs; + void *file; + long pos; +}; + +#endif // DUMBFILE_H diff --git a/dumb/include/internal/it.h b/dumb/include/internal/it.h index 922d9bed05..6defa759ae 100644 --- a/dumb/include/internal/it.h +++ b/dumb/include/internal/it.h @@ -33,6 +33,7 @@ #include #include "barray.h" +#include "tarray.h" /** TO DO: THINK ABOUT THE FOLLOWING: @@ -56,7 +57,6 @@ sigdata->flags & IT_COMPATIBLE_GXX */ //#define STEREO_SAMPLES_COUNT_AS_TWO #define INVALID_ORDERS_END_SONG -#define INVALID_NOTES_CAUSE_NOTE_CUT #define SUSTAIN_LOOP_OVERRIDES_NORMAL_LOOP #define VOLUME_OUT_OF_RANGE_SETS_MAXIMUM @@ -73,10 +73,9 @@ sigdata->flags & IT_COMPATIBLE_GXX #define IT_INSM_SIGNATURE DUMB_ID('M', 'S', 'N', 'I') -/* 1 minute per 4 rows, each row 6 ticks; this is divided by the tempo to get - * the interval between ticks. +/* This is divided by the tempo times 256 to get the interval between ticks. */ -#define TICK_TIME_DIVIDEND ((65536 * 60) / (4 * 6)) +#define TICK_TIME_DIVIDEND (65536 * 5 * 128) @@ -209,7 +208,7 @@ struct IT_INSTRUMENT struct IT_SAMPLE { unsigned char name[35]; - unsigned char filename[14]; + unsigned char filename[15]; unsigned char flags; unsigned char global_volume; unsigned char default_volume; @@ -414,6 +413,8 @@ struct IT_PATTERN #define IT_WAS_AN_STM 4096 +#define IT_WAS_PROCESSED 8192 /* Will be set the first time a sigdata passes through a sigrenderer */ + #define IT_ORDER_END 255 #define IT_ORDER_SKIP 254 @@ -484,7 +485,6 @@ struct IT_PLAYING unsigned char instnum; unsigned char declick_stage; - float declick_volume; float float_volume[2]; float ramp_volume[2]; @@ -602,7 +602,9 @@ struct IT_CHANNEL unsigned char new_note_action; - unsigned int arpeggio; + unsigned char const* arpeggio_table; + signed char arpeggio_offsets[3]; + int arpeggio_shift; unsigned char retrig; unsigned char xm_retrig; @@ -687,8 +689,8 @@ struct DUMB_IT_SIGRENDERER unsigned char globalvolume; signed char globalvolslide; + int tempo; signed char temposlide; - unsigned short tempo; IT_CHANNEL channel[DUMB_IT_N_CHANNELS]; @@ -722,13 +724,28 @@ struct DUMB_IT_SIGRENDERER #ifdef BIT_ARRAY_BULLSHIT /* bit array, which rows are played, only checked by pattern break or loop commands */ void * played; + + /* + Loop indicator for internal processes, may also be useful for external processes + 0 - Not looped + 1 - Looped + -1 - Continued past loop + */ + int looped; + + /* + Kept until looped + */ + LONG_LONG time_played; + + void * row_timekeeper; #endif int32 gvz_time; int gvz_sub_time; - int ramp_style; - + int ramp_style; + //int max_output; IT_PLAYING *free_playing; @@ -904,4 +921,10 @@ int32 _dumb_it_read_sample_data_adpcm4(IT_SAMPLE *sample, DUMBFILE *f); void _dumb_it_interleave_stereo_sample(IT_SAMPLE *sample); +/* Calling either of these is optional */ +void _dumb_init_cubic(); +#ifdef _USE_SSE +void _dumb_init_sse(); +#endif + #endif /* INTERNAL_IT_H */ diff --git a/dumb/include/internal/lpc.h b/dumb/include/internal/lpc.h new file mode 100644 index 0000000000..8c585fa5f0 --- /dev/null +++ b/dumb/include/internal/lpc.h @@ -0,0 +1,30 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: LPC low level routines + last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $ + + ********************************************************************/ + +#ifndef _V_LPC_H_ +#define _V_LPC_H_ + +/* simple linear scale LPC code */ +extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m); + +extern void vorbis_lpc_predict(float *coeff,float *prime,int m, + float *data,long n); + +struct DUMB_IT_SIGDATA; +extern void dumb_it_add_lpc(struct DUMB_IT_SIGDATA *sigdata); + +#endif diff --git a/dumb/include/internal/resampler.h b/dumb/include/internal/resampler.h new file mode 100644 index 0000000000..0050ebf1a7 --- /dev/null +++ b/dumb/include/internal/resampler.h @@ -0,0 +1,58 @@ +#ifndef _RESAMPLER_H_ +#define _RESAMPLER_H_ + +// Ugglay +#ifdef RESAMPLER_DECORATE +#define PASTE(a,b) a ## b +#define EVALUATE(a,b) PASTE(a,b) +#define resampler_init EVALUATE(RESAMPLER_DECORATE,_resampler_init) +#define resampler_create EVALUATE(RESAMPLER_DECORATE,_resampler_create) +#define resampler_delete EVALUATE(RESAMPLER_DECORATE,_resampler_delete) +#define resampler_dup EVALUATE(RESAMPLER_DECORATE,_resampler_dup) +#define resampler_dup_inplace EVALUATE(RESAMPLER_DECORATE,_resampler_dup_inplace) +#define resampler_set_quality EVALUATE(RESAMPLER_DECORATE,_resampler_set_quality) +#define resampler_get_free_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_free_count) +#define resampler_write_sample EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample) +#define resampler_write_sample_fixed EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample_fixed) +#define resampler_set_rate EVALUATE(RESAMPLER_DECORATE,_resampler_set_rate) +#define resampler_ready EVALUATE(RESAMPLER_DECORATE,_resampler_ready) +#define resampler_clear EVALUATE(RESAMPLER_DECORATE,_resampler_clear) +#define resampler_get_sample_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample_count) +#define resampler_get_sample EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample) +#define resampler_get_sample_float EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample_float) +#define resampler_remove_sample EVALUATE(RESAMPLER_DECORATE,_resampler_remove_sample) +#endif + +void resampler_init(void); + +void * resampler_create(void); +void resampler_delete(void *); +void * resampler_dup(const void *); +void resampler_dup_inplace(void *, const void *); + +enum +{ + RESAMPLER_QUALITY_MIN = 0, + RESAMPLER_QUALITY_ZOH = 0, + RESAMPLER_QUALITY_BLEP = 1, + RESAMPLER_QUALITY_LINEAR = 2, + RESAMPLER_QUALITY_BLAM = 3, + RESAMPLER_QUALITY_CUBIC = 4, + RESAMPLER_QUALITY_SINC = 5, + RESAMPLER_QUALITY_MAX = 5 +}; + +void resampler_set_quality(void *, int quality); + +int resampler_get_free_count(void *); +void resampler_write_sample(void *, short sample); +void resampler_write_sample_fixed(void *, int sample, unsigned char depth); +void resampler_set_rate( void *, double new_factor ); +int resampler_ready(void *); +void resampler_clear(void *); +int resampler_get_sample_count(void *); +int resampler_get_sample(void *); +float resampler_get_sample_float(void *); +void resampler_remove_sample(void *, int decay); + +#endif diff --git a/dumb/include/internal/riff.h b/dumb/include/internal/riff.h index 344a24ea38..d1e0bc0bdd 100644 --- a/dumb/include/internal/riff.h +++ b/dumb/include/internal/riff.h @@ -1,11 +1,14 @@ #ifndef RIFF_H #define RIFF_H +struct riff; + struct riff_chunk { unsigned type; - void * data; + int32 offset; unsigned size; + struct riff * nested; }; struct riff @@ -15,7 +18,7 @@ struct riff struct riff_chunk * chunks; }; -struct riff * riff_parse( unsigned char *, unsigned size, unsigned proper ); +struct riff * riff_parse( DUMBFILE * f, int32 offset, int32 size, unsigned proper ); void riff_free( struct riff * ); #endif diff --git a/dumb/include/internal/stack_alloc.h b/dumb/include/internal/stack_alloc.h new file mode 100644 index 0000000000..12c029fc3b --- /dev/null +++ b/dumb/include/internal/stack_alloc.h @@ -0,0 +1,113 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file stack_alloc.h + @brief Temporary memory allocation on stack +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef STACK_ALLOC_H +#define STACK_ALLOC_H + +#ifdef _WIN32 +# include +#else +# ifdef HAVE_ALLOCA_H +# include +# else +# include +# endif +#endif + +/** + * @def ALIGN(stack, size) + * + * Aligns the stack to a 'size' boundary + * + * @param stack Stack + * @param size New size boundary + */ + +/** + * @def PUSH(stack, size, type) + * + * Allocates 'size' elements of type 'type' on the stack + * + * @param stack Stack + * @param size Number of elements + * @param type Type of element + */ + +/** + * @def VARDECL(var) + * + * Declare variable on stack + * + * @param var Variable to declare + */ + +/** + * @def ALLOC(var, size, type) + * + * Allocate 'size' elements of 'type' on stack + * + * @param var Name of variable to allocate + * @param size Number of elements + * @param type Type of element + */ + +#ifdef ENABLE_VALGRIND + +#include + +#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) + +#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) + +#else + +#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) + +#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) + +#endif + +#if defined(VAR_ARRAYS) +#define VARDECL(var) +#define ALLOC(var, size, type) type var[size] +#elif defined(USE_ALLOCA) +#define VARDECL(var) var +#define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) +#else +#define VARDECL(var) var +#define ALLOC(var, size, type) var = PUSH(stack, size, type) +#endif + + +#endif diff --git a/dumb/include/internal/tarray.h b/dumb/include/internal/tarray.h new file mode 100644 index 0000000000..7eb3af7c60 --- /dev/null +++ b/dumb/include/internal/tarray.h @@ -0,0 +1,31 @@ +#ifndef _T_ARRAY_H_ +#define _T_ARRAY_H_ + +#include + +#ifndef LONG_LONG +#if defined __GNUC__ || defined __INTEL_COMPILER || defined __MWERKS__ +#define LONG_LONG long long +#elif defined _MSC_VER || defined __WATCOMC__ +#define LONG_LONG __int64 +#elif defined __sgi +#define LONG_LONG long long +#else +#error 64-bit integer type unknown +#endif +#endif + +void * timekeeping_array_create(size_t size); +void timekeeping_array_destroy(void * array); +void * timekeeping_array_dup(void * array); + +void timekeeping_array_reset(void * array, size_t loop_start); + +void timekeeping_array_push(void * array, size_t index, LONG_LONG time); +void timekeeping_array_bump(void * array, size_t index); + +unsigned int timekeeping_array_get_count(void * array, size_t index); + +LONG_LONG timekeeping_array_get_item(void * array, size_t index); + +#endif diff --git a/dumb/licence.txt b/dumb/licence.txt index 506ec17b65..961fe4ef8f 100644 --- a/dumb/licence.txt +++ b/dumb/licence.txt @@ -1,54 +1,87 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * licence.txt - Conditions for use of DUMB. / / \ \ - * | < / \_ - * If you do not agree to these terms, please | \/ /\ / - * do not use DUMB. \_ / > / - * | \ / / - * Information in [brackets] is provided to aid | ' / - * interpretation of the licence. \__/ - */ - - -Dynamic Universal Music Bibliotheque - -Copyright (C) 2001-2003 Ben Davis, Robert J Ohannessian and Julien Cugniere - -This software is provided 'as-is', without any express or implied warranty. -In no event shall the authors be held liable for any damages arising from the -use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim - that you wrote the original software. If you use this software in a - product, you are requested to acknowledge its use in the product - documentation, along with details on where to get an unmodified version of - this software, but this is not a strict requirement. - - [Note that the above point asks for a link to DUMB, not just a mention. - Googling for DUMB doesn't help much! The URL is "http://dumb.sf.net/".] - - [The only reason why the link is not strictly required is that such a - requirement prevents DUMB from being used in projects with certain other - licences, notably the GPL. See http://www.gnu.org/philosophy/bsd.html .] - -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - -3. This notice may not be removed from or altered in any source distribution. - -4. If you are using the Program in someone else's bedroom at any Monday - 3:05 PM, you are not allowed to modify the Program for ten minutes. [This - clause provided by Inphernic; every licence should contain at least one - clause, the reasoning behind which is far from obvious.] +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * licence.txt - Conditions for use of DUMB. / / \ \ + * | < / \_ + * If you do not agree to these terms, please | \/ /\ / + * do not use DUMB. \_ / > / + * | \ / / + * Information in [brackets] is provided to aid | ' / + * interpretation of the licence. \__/ + */ + + +Dynamic Universal Music Bibliotheque, Version 0.9.3 + +Copyright (C) 2001-2005 Ben Davis, Robert J Ohannessian and Julien Cugniere + +This software is provided 'as-is', without any express or implied warranty. +In no event shall the authors be held liable for any damages arising from the +use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim + that you wrote the original software. If you use this software in a + product, you are requested to acknowledge its use in the product + documentation, along with details on where to get an unmodified version of + this software, but this is not a strict requirement. + + [Note that the above point asks for a link to DUMB, not just a mention. + Googling for DUMB doesn't help much! The URL is "http://dumb.sf.net/".] + + [The link was originally strictly required. This was changed for two + reasons. Firstly, if many projects request an acknowledgement, the list of + acknowledgements can become quite unmanageable. Secondly, DUMB was placing + a restriction on the code using it, preventing people from using the GNU + General Public Licence which disallows any such restrictions. See + http://www.gnu.org/philosophy/bsd.html for more information on this + subject. However, if DUMB plays a significant part in your project, we do + urge you to acknowledge its use.] + +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +3. This notice may not be removed from or altered in any source distribution. + +4. If you are using the Program in someone else's bedroom on any Monday at + 3:05 pm, you are not allowed to modify the Program for ten minutes. [This + clause provided by Inphernic; every licence should contain at least one + clause, the reasoning behind which is far from obvious.] + +5. Users who wish to use DUMB for the specific purpose of playing music are + required to feed their dog on every full moon (if deemed appropriate). + [This clause provided by Allefant, who couldn't remember what Inphernic's + clause was.] + +6. No clause in this licence shall prevent this software from being depended + upon by a product licensed under the GNU General Public Licence. If such a + clause is deemed to exist, Debian, then it shall be respected in spirit as + far as possible and all other clauses shall continue to apply in full + force. + +8. Take the number stated as introducing this clause. Multiply it by two, + then subtract four. Now insert a '+' between the two digits and evaluate + the resulting sum. Call the result 'x'. If you have not yet concluded that + every numbered clause in this licence whose ordinal number is strictly + greater than 'x' (with the exception of the present clause) is null and + void, Debian, then you are hereby informed that laughter is good for one's + health and you are warmly suggested to do it. By the way, Clauses 4, 5 and + 6 are null and void. Incidentally, I like Kubuntu. The work you guys do is + awesome. (Lawyers, on the other hand ...) + +We regret that we cannot provide any warranty, not even the implied warranty +of merchantability or fitness for a particular purpose. + +Some files generated or copied by automake, autoconf and friends are +available in an extra download. These fall under separate licences but are +all free to distribute. Please check their licences as necessary. diff --git a/dumb/prj/.gitignore b/dumb/prj/.gitignore new file mode 100644 index 0000000000..36d588baa0 --- /dev/null +++ b/dumb/prj/.gitignore @@ -0,0 +1,3 @@ +dumb-build-Desktop-Release +dumb-build-Desktop-Debug +*.user diff --git a/dumb/prj/dumb/dumb.pro b/dumb/prj/dumb/dumb.pro new file mode 100644 index 0000000000..629a9294a7 --- /dev/null +++ b/dumb/prj/dumb/dumb.pro @@ -0,0 +1,130 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-12-22T16:33:53 +# +#------------------------------------------------- + +QT -= core gui + +TARGET = dumb +TEMPLATE = lib +CONFIG += staticlib + +DEFINES += _USE_SSE + +INCLUDEPATH += ../../include + +QMAKE_CFLAGS += -msse + +SOURCES += \ + ../../src/core/unload.c \ + ../../src/core/rendsig.c \ + ../../src/core/rendduh.c \ + ../../src/core/register.c \ + ../../src/core/readduh.c \ + ../../src/core/rawsig.c \ + ../../src/core/makeduh.c \ + ../../src/core/loadduh.c \ + ../../src/core/dumbfile.c \ + ../../src/core/duhtag.c \ + ../../src/core/duhlen.c \ + ../../src/core/atexit.c \ + ../../src/helpers/stdfile.c \ + ../../src/helpers/silence.c \ + ../../src/helpers/sampbuf.c \ + ../../src/helpers/riff.c \ + ../../src/helpers/resample.c \ + ../../src/helpers/memfile.c \ + ../../src/helpers/clickrem.c \ + ../../src/helpers/barray.c \ + ../../src/helpers/tarray.c \ + ../../src/it/xmeffect.c \ + ../../src/it/readxm2.c \ + ../../src/it/readxm.c \ + ../../src/it/readstm2.c \ + ../../src/it/readstm.c \ + ../../src/it/reads3m2.c \ + ../../src/it/reads3m.c \ + ../../src/it/readriff.c \ + ../../src/it/readptm.c \ + ../../src/it/readpsm.c \ + ../../src/it/readoldpsm.c \ + ../../src/it/readokt2.c \ + ../../src/it/readokt.c \ + ../../src/it/readmtm.c \ + ../../src/it/readmod2.c \ + ../../src/it/readmod.c \ + ../../src/it/readdsmf.c \ + ../../src/it/readasy.c \ + ../../src/it/readamf2.c \ + ../../src/it/readamf.c \ + ../../src/it/readam.c \ + ../../src/it/read6692.c \ + ../../src/it/read669.c \ + ../../src/it/ptmeffect.c \ + ../../src/it/loadxm2.c \ + ../../src/it/loadxm.c \ + ../../src/it/loadstm2.c \ + ../../src/it/loadstm.c \ + ../../src/it/loads3m2.c \ + ../../src/it/loads3m.c \ + ../../src/it/loadriff2.c \ + ../../src/it/loadriff.c \ + ../../src/it/loadptm2.c \ + ../../src/it/loadptm.c \ + ../../src/it/loadpsm2.c \ + ../../src/it/loadpsm.c \ + ../../src/it/loadoldpsm2.c \ + ../../src/it/loadoldpsm.c \ + ../../src/it/loadokt2.c \ + ../../src/it/loadokt.c \ + ../../src/it/loadmtm2.c \ + ../../src/it/loadmtm.c \ + ../../src/it/loadmod2.c \ + ../../src/it/loadmod.c \ + ../../src/it/loadasy2.c \ + ../../src/it/loadasy.c \ + ../../src/it/loadamf2.c \ + ../../src/it/loadamf.c \ + ../../src/it/load6692.c \ + ../../src/it/load669.c \ + ../../src/it/itunload.c \ + ../../src/it/itrender.c \ + ../../src/it/itread2.c \ + ../../src/it/itread.c \ + ../../src/it/itorder.c \ + ../../src/it/itmisc.c \ + ../../src/it/itload2.c \ + ../../src/it/itload.c \ + ../../src/it/readany.c \ + ../../src/it/loadany2.c \ + ../../src/it/loadany.c \ + ../../src/it/readany2.c \ + ../../src/helpers/sinc_resampler.c \ + ../../src/helpers/lpc.c + +HEADERS += \ + ../../include/dumb.h \ + ../../include/internal/riff.h \ + ../../include/internal/it.h \ + ../../include/internal/dumb.h \ + ../../include/internal/barray.h \ + ../../include/internal/tarray.h \ + ../../include/internal/aldumb.h \ + ../../include/internal/sinc_resampler.h \ + ../../include/internal/stack_alloc.h \ + ../../include/internal/lpc.h \ + ../../include/internal/dumbfile.h +unix:!symbian { + maemo5 { + target.path = /opt/usr/lib + } else { + target.path = /usr/lib + } + INSTALLS += target +} + +OTHER_FILES += \ + ../../src/helpers/resample.inc \ + ../../src/helpers/resamp3.inc \ + ../../src/helpers/resamp2.inc diff --git a/dumb/readme.txt b/dumb/readme.txt index f8517bac4f..e86af048ab 100644 --- a/dumb/readme.txt +++ b/dumb/readme.txt @@ -1,421 +1,541 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * readme.txt - General information on DUMB. / / \ \ - * | < / \_ - * | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -******************** -*** Introduction *** -******************** - - -Thank you for downloading DUMB! You should have the following documentation: - - readme.txt - This file - licence.txt - Conditions for the use of this software - release.txt - Release notes and changes for this and past releases - docs/ - howto.txt - Step-by-step instructions on adding DUMB to your project - faq.txt - Frequently asked questions and answers to them - dumb.txt - DUMB library reference - deprec.txt - Information about deprecated parts of the API - ptr.txt - Quick introduction to pointers for those who need it - fnptr.txt - Explanation of function pointers for those who need it - modplug.txt - Our official position regarding ModPlug Tracker - -This file will help you get DUMB set up. If you have not yet done so, please -read licence.txt and release.txt before proceeding. After you've got DUMB set -up, please refer to the files in the docs/ directory at your convenience. I -recommend you start with howto.txt. - - -**************** -*** Features *** -**************** - - -Here is the statutory feature list: - -- Freeware - -- Supports playback of IT, XM, S3M and MOD files - -- Faithful to the original trackers, especially IT; if it plays your module - wrongly, please tell me so I can fix the bug! (But please don't complain - about differences between DUMB and ModPlug Tracker; see docs/modplug.txt) - -- Accurate support for low-pass resonant filters for IT files - -- Very accurate timing and pitching; completely deterministic playback - -- Click removal - -- Facility to embed music files in other files (e.g. Allegro datafiles) - -- Three resampling quality settings: aliasing, linear interpolation and cubic - interpolation - -- Number of samples playing at once can be limited to reduce processor usage, - but samples will come back in when other louder ones stop - -- All notes will be present and correct even if you start a piece of music in - the middle - -- Fast seeking to any point before the music first loops (seeking time - increases beyond this point) - -- Audio generated can be used in any way; DUMB does not necessarily send it - straight to a sound output system - -- Makefile provided for DJGPP, MinGW, Linux, BeOS and Mac OS X; project file - provided for MSVC 6 (please contact me if you'd like to submit or request - support for a new platform; the code itself should port anywhere that has a - 32-bit C compiler) - -- Can be used with Allegro, can be used without (if you'd like to help make - DUMB more approachable to people who aren't using Allegro, please contact - me) - - -********************* -*** What you need *** -********************* - - -To use DUMB, you need a 32-bit C compiler (GCC and MSVC are fine). If you -have Allegro, DUMB can integrate with its audio streams and datafiles, making -your life easier. If you do not wish to use Allegro, you will have to do some -work to get music playing back. The 'dumbplay' example program requires -Allegro. - - Allegro - http://alleg.sf.net/ - -Neil Walker has kindly uploaded some DUMB binaries at -http://retrospec.sgn.net/allegro/ . They may not always be up to date, so you -should try to compile it yourself first. - - -********************************************** -*** How to set DUMB up with DJGPP or MinGW *** -********************************************** - - -You should have got the .zip version. If for some reason you got the .tar.gz -version instead, you may have to convert make/config.bat to DOS text file -format. WinZip does this automatically by default. Otherwise, loading it into -MS EDIT and saving it again should do the trick. You will have to do the same -for any files you want to view in Windows Notepad. If you have problems, just -go and download the .zip instead. - -Make sure you preserved the directory structure when you extracted DUMB from -the archive. Most unzipping programs will do this by default, but pkunzip -requires you to pass -d. If not, please delete DUMB and extract it again -properly. - -If you are using Windows, open an MS-DOS Prompt or a Windows Command Line. -Change to the directory into which you unzipped DUMB. - -Type the following: - - make - -DUMB will ask you whether you wish to compile for DJGPP or MinGW. Then it -will ask you whether you want support for Allegro. (You have to have made and -installed Allegro's optimised library for this to work.) Finally, it will -compile optimised and debugging builds of DUMB, along with the example -programs. When it has finished, run the following to install the libraries: - - make install - -All done! If you ever need the configuration again (e.g. if you compiled for -DJGPP before and you want to compile for MinGW now), run the following: - - make config - -See the comments in the makefile for other targets. - -Note: the makefile will only work properly if you have COMSPEC or ComSpec set -to point to command.com or cmd.exe. If you set it to point to a Unix-style -shell, the makefile won't work. - -Please let me know if you have any trouble. - -Scroll down for information on the example programs. Refer to docs/howto.txt -when you are ready to start programming with DUMB. If you use DUMB in a game, -let me know - I might decide to place a link to your game on DUMB's website! - - -****************************************************** -*** How to set DUMB up with Microsoft Visual C++ 6 *** -****************************************************** - - -You should have got the .zip version. If for some reason you got the .tar.gz -version instead, you may have to convert some files to DOS text file format. -WinZip does this automatically by default. Otherwise, loading such files into -MS EDIT and saving them again should do the trick. You will have to do this -for any files you want to view in Windows Notepad. If you have problems, just -go and download the .zip instead. - -Make sure you preserved the directory structure when you extracted DUMB from -the archive. Most unzipping programs will do this by default, but pkunzip -requires you to pass -d. If not, please delete DUMB and extract it again -properly. - -DUMB now comes with a project file for Microsoft Visual C++ 6. To add DUMB to -your project: - -1. Open your project in VC++. -2. Select Project|Insert Project into Workspace... -3. Navigate to the dumb\vc6 directory, and select dumb.dsp. -4. Select Build|Set Active Configuration..., and reselect one of your - project's configurations. -5. Select Project|Dependencies... and ensure your project is dependent on - DUMB. -6. Select Project|Settings..., Settings for: All Configurations, C/C++ tab, - Preprocessor category. Add the DUMB include directory to the Additional - Include Directories box. -7. Ensure that for all the projects in the workspace (or more likely just all - the projects in a particular dependency chain) the run-time libraries are - the same. That's in Project|Settings, C/C++ tab, Code generation category, - Use run-time library dropdown. The settings for Release and Debug are - separate, so you'll have to change them one at a time. Exactly which run- - time library you use will depend on what you need; it doesn't appear that - DUMB has any particular requirements, so set it to whatever you're using - now. - -Good thing you only have to do all that once ... - -If you have the Intel compiler installed, it will - well, should - be used to -compile DUMB. The only setting I added is /QxiM. This allows the compiler to -use PPro and MMX instructions, and so when compiling with Intel the resultant -EXE will require a Pentium II or greater. I don't think this is unreasonable. -After all, it is 2003 :) - -If you don't have the Intel compiler, VC will compile DUMB as normal. - -This project file and these instructions were provided by Tom Seddon (I hope -I got his name right; I had to guess it from his e-mail address!). They are -untested by me. If you have problems, check the download page at -http://dumb.sf.net/ to see if they are addressed; failing that, direct -queries to me and I'll try to figure them out. - -When you are ready to start using DUMB, refer to docs/howto.txt. If you use -DUMB in a game, let me know - I might decide to place a link to your game on -DUMB's website! - - -******************************************************************** -*** How to set DUMB up on Linux, BeOS and possibly even Mac OS X *** -******************************************************************** - - -You should have got the .tar.gz version. If for some reason you got the .zip -version instead, you may have to use dtou on some or all of the text files. -If you have problems, just go and download the .tar.gz instead. - -First, run the following command as a normal user: - - make - -You will be asked whether you want Allegro support. Then, unless you are on -BeOS, you will be asked where you'd like DUMB to install its headers, -libraries and examples (which will go in the include/, lib/ and bin/ -subdirectories of the prefix you specify). BeOS has fixed locations for these -files. Once you have specified these pieces of information, the optimised and -debugging builds of DUMB will be compiled, along with the examples. When it -has finished, you can install them with: - - make install - -You may need to be root for this to work. It depends on the prefix you chose. - -Note: the makefile will only work if COMSPEC and ComSpec are both undefined. -If either of these is defined, the makefile will try to build for a Windows -system, and will fail. - -Please let me know if you have any trouble. - -Information on the example programs is just below. Refer to docs/howto.txt -when you are ready to start programming with DUMB. If you use DUMB in a game, -let me know - I might decide to place a link to your game on DUMB's website! - - -**************************** -*** The example programs *** -**************************** - - -Two example programs are provided. On DOS and Windows, you can find them in -the examples subdirectory. On other systems they will be installed system- -wide. - -dumbplay - This program will only be built if you have Allegro. Pass it the filename - of an IT, XM, S3M or MOD file, and it will play it. It's not a polished - player with real-time threading or anything - so don't complain about it - stuttering while you use other programs - but it does show DUMB's fidelity - nicely. You can control the playback quality by editing dumb.ini, which - must be in the current working directory. (This is a flaw for systems - where the program is installed system-wide, but it is non-fatal.) Have a - look at the examples/dumb.ini file for further information. - -dumbout - This program does not need Allegro. You can use it to stream an IT, XM, - S3M or MOD file to raw PCM. This can be used as input to an encoder like - oggenc (with appropriate command-line options), or it can be sent to a - .pcm file which can be read by any respectable waveform editor. No .wav - support yet, sorry. This program is also convenient for timing DUMB. - Compare the time it takes to render a module with the module's playing - time! dumbout doesn't try to read any configuration file; the options are - set on the command line. - - -********************************************* -*** Downloading music or writing your own *** -********************************************* - - -If you would like to compose your own music modules, then first I must offer -a word of warning: not everyone is capable of composing music. Do not assume -you will be able to learn the art. By all means have a go; if you can learn -to play tunes on the computer keyboard, you're well on the way to being a -composer! - -The best programs for the job are the trackers that pioneered the file -formats: - - Impulse Tracker - IT files - http://www.noisemusic.org/it/ - Fast Tracker II - XM files - http://www.gwinternet.com/music/ft2/ - Scream Tracker 3 - S3M files - - http://www.united-trackers.org/resources/software/screamtracker.htm - -MOD files come from the Amiga; I do not know what PC tracker to recommend for -editing these. If you know of one, let me know! In the meantime, I would -recommend using a more advanced file format. However, don't convert your -existing MODs just for the sake of it. - -Note that Fast Tracker II is Shareware. It arguably offers the best -interface, but the IT file format is more powerful and better defined. -Impulse Tracker and Scream Tracker 3 are Freeware. DUMB is likely to be at -its best with IT files. - -These editors are DOS programs. Users of DOS-incapable operating systems may -like to try ModPlug Tracker, but should read docs/modplug.txt before using it -for any serious work. If you use a different operating system, or if you know -of any module editors for Windows that are more faithful to the original -trackers' playback, please give me some links so I can put them here! - - ModPlug Tracker - http://www.modplug.com/ - -BEWARE OF WINAMP! Although it's excellent for MP3s, it is notorious for being -one of the worst module players in existence; very few modules play correctly -with it. There are plug-ins available to improve Winamp's module support, for -example WSP. - - Winamp - http://www.winamp.com/ - WSP - http://www.spytech.cz/index.php?sec=demo - -Samples and instruments are the building blocks of music modules. You can -download samples at: - - http://www.tump.net/ - -If you would like to download module files composed by other people, check -the following sites: - - http://www.modarchive.com/ - http://www.scene.org/ - http://www.tump.net/ - http://www.homemusic.cc/main.php - http://www.modplug.com/ - -Once again, if you know of more sites where samples or module files are -available for download, please let me know. - -If you wish to use someone's music in your game, please respect the -composer's wishes. In general, you should ask the composer. Music that has -been placed in the Public Domain can be used by anyone for anything, but it -wouldn't do any harm to ask anyway if you know who the author is. In most -cases the author will be thrilled, so don't hesitate! - -A note about converting modules from one format to another: don't do it, -unless you are a musician and are prepared to go through the file and make -sure everything sounds the way it should! The module formats are all slightly -different, and converting from one format to another will usually do some -damage. - -Instead, it is recommended that you allow DUMB to interpret the original file -as it sees fit. DUMB may make mistakes (it does a lot of conversion on -loading), but future versions of DUMB will be able to rectify these mistakes. -On the other hand, if you convert the file, the damage is permanent. - - -*********************** -*** Contact details *** -*********************** - - -If you have trouble with DUMB, or want to contact me for any other reason, my -e-mail address is given below. However, I may be able to help more if you -come on to IRC EFnet #dumb. - -IRC stands for Internet Relay Chat, and is a type of chat network. Several -such networks exist, and EFnet is a popular one. In order to connect to an -IRC network, you first need an IRC client. Here are some: - - http://www.xchat.org/ - http://www.visualirc.net/beta.php - http://www.mirc.com/ - -Getting on to IRC can be a steep cliff, but it is not insurmountable, and -it's well worth it. Once you have set up the client software, you need to -connect to a server. Here is a list of EFnet servers I have had success with. -Type "/server" (without quotes), then a space, then the name of a server. - - irc.homelien.no - irc.webgiro.se - efnet.vuurwerk.nl - efnet.demon.co.uk - irc.isdnet.fr - irc.prison.net - -If these servers do not work, visit http://efnet.org/ircdb/servers.php for a -huge list of other EFnet servers to try. - -Once you're connected, type the following: - - /join #dumb - -A window will appear, and you can ask your question. It should be clear -what's going on from this point onwards. I am 'entheh'. Note that unlike many -other nerds I am not always at my computer, so if I don't answer your -question, don't take it personally! I will usually be able to read your -question when I come back. - - -****************** -*** Conclusion *** -****************** - - -This is the conclusion. - - -Ben Davis -entheh@users.sf.net -IRC EFnet #dumb +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * readme.txt - General information on DUMB. / / \ \ + * | < / \_ + * | \/ /\ / + * \_ / > / + * | \ / / + * | ' / + * \__/ + */ + + +******************** +*** Introduction *** +******************** + + +Thank you for downloading DUMB v0.9.3! You should have the following +documentation: + + readme.txt - This file + licence.txt - Conditions for the use of this software + release.txt - Release notes and changes for this and past releases + docs/ + howto.txt - Step-by-step instructions on adding DUMB to your project + faq.txt - Frequently asked questions and answers to them + dumb.txt - DUMB library reference + deprec.txt - Information about deprecated parts of the API + ptr.txt - Quick introduction to pointers for those who need it + fnptr.txt - Explanation of function pointers for those who need it + modplug.txt - Our official position regarding ModPlug Tracker + +This file will help you get DUMB set up. If you have not yet done so, please +read licence.txt and release.txt before proceeding. After you've got DUMB set +up, please refer to the files in the docs/ directory at your convenience. I +recommend you start with howto.txt. + + +**************** +*** Features *** +**************** + + +Here is the statutory feature list: + +- Freeware + +- Supports playback of IT, XM, S3M and MOD files + +- Faithful to the original trackers, especially IT; if it plays your module + wrongly, please tell me so I can fix the bug! (But please don't complain + about differences between DUMB and ModPlug Tracker; see docs/modplug.txt) + +- Accurate support for low-pass resonant filters for IT files + +- Very accurate timing and pitching; completely deterministic playback + +- Click removal + +- Facility to embed music files in other files (e.g. Allegro datafiles) + +- Three resampling quality settings: aliasing, linear interpolation and cubic + interpolation + +- Number of samples playing at once can be limited to reduce processor usage, + but samples will come back in when other louder ones stop + +- All notes will be present and correct even if you start a piece of music in + the middle + +- Option to take longer loading but seek fast to any point before the music + first loops (seeking time increases beyond this point) + +- Audio generated can be used in any way; DUMB does not necessarily send it + straight to a sound output system + +- Can be used with Allegro, can be used without (if you'd like to help make + DUMB more approachable to people who aren't using Allegro, please contact + me) + +- Makefile provided for DJGPP, MinGW, Linux, BeOS and Mac OS X + +- Project files provided for MSVC 6 + +- Autotools-based configure script available as a separate download for + masochists + +- Code should port anywhere that has a 32-bit C compiler; instructions on + compiling it manually are available further down + + +********************* +*** What you need *** +********************* + + +To use DUMB, you need a 32-bit C compiler (GCC and MSVC are fine). If you +have Allegro, DUMB can integrate with its audio streams and datafiles, making +your life easier. If you do not wish to use Allegro, you will have to do some +work to get music playing back. The 'dumbplay' example program requires +Allegro. + + Allegro - http://alleg.sf.net/ + + +********************************************** +*** How to set DUMB up with DJGPP or MinGW *** +********************************************** + + +You should have got the .zip version. If for some reason you got the .tar.gz +version instead, you may have to convert make/config.bat to DOS text file +format. WinZip does this automatically by default. Otherwise, loading it into +MS EDIT and saving it again should do the trick (but do not do this to the +Makefiles as it destroys tabs). You will have to do the same for any files +you want to view in Windows Notepad. If you have problems, just go and +download the .zip instead. + +Make sure you preserved the directory structure when you extracted DUMB from +the archive. Most unzipping programs will do this by default, but pkunzip +requires you to pass -d. If not, please delete DUMB and extract it again +properly. + +If you are using Windows, open an MS-DOS Prompt or a Windows Command Line. +Change to the directory into which you unzipped DUMB. + +If you are using MinGW (and you haven't renamed 'mingw32-make'), type: + + mingw32-make + +Otherwise, type the following: + + make + +DUMB will ask you whether you wish to compile for DJGPP or MinGW. Then it +will ask you whether you want support for Allegro. (You have to have made and +installed Allegro's optimised library for this to work.) Finally, it will +compile optimised and debugging builds of DUMB, along with the example +programs. When it has finished, run one of the following to install the +libraries: + + make install + mingw32-make install + +All done! If you ever need the configuration again (e.g. if you compiled for +DJGPP before and you want to compile for MinGW now), run one of the +following: + + make config + mingw32-make config + +See the comments in the Makefile for other targets. + +Note: the Makefile will only work properly if you have COMSPEC or ComSpec set +to point to command.com or cmd.exe. If you set it to point to a Unix-style +shell, the Makefile won't work. + +Please let me know if you have any trouble. + +As an alternative, MSYS users may attempt to use the configure script, +available in dumb-0.9.3-autotools.tar.gz. This has been found to work without +Allegro, and is untested with Allegro. I should appreciate feedback from +anyone else who tries this. I do not recommend its use, partly because it +creates dynamically linked libraries and I don't know how to stop it from +doing that (see the section on compiling DUMB manually), and partly because +autotools are plain evil. + +Scroll down for information on the example programs. Refer to docs/howto.txt +when you are ready to start programming with DUMB. If you use DUMB in a game, +let me know - I might decide to place a link to your game on DUMB's website! + + +****************************************************** +*** How to set DUMB up with Microsoft Visual C++ 6 *** +****************************************************** + + +If you have a newer version of Microsoft Visual C++ or Visual Something that +supports C++, please try these instructions and let me know if it works. + +You should have got the .zip version. If for some reason you got the .tar.gz +version instead, you may have to convert some files to DOS text file format. +WinZip does this automatically by default. Otherwise, loading such files into +MS EDIT and saving them again should do the trick. You will have to do this +for any files you want to view in Windows Notepad. If you have problems, just +go and download the .zip instead. + +Make sure you preserved the directory structure when you extracted DUMB from +the archive. Most unzipping programs will do this by default, but pkunzip +requires you to pass -d. If not, please delete DUMB and extract it again +properly. + +DUMB comes with a workspace Microsoft Visual C++ 6, containing projects for +the DUMB core, the Allegro interface library and each of the examples. The +first thing you might want to do is load the workspace up and have a look +around. You will find it in the dumb\vc6 directory under the name dumb.dsw. +Note that the aldumb and dumbplay projects require Allegro, so they won't +work if you don't have Allegro. Nevertheless, dumbplay is the best-commented +of the examples, so do have a look. + +When you are ready to add DUMB to your project, follow these instructions: + +1. Open your project in VC++. +2. Select Project|Insert Project into Workspace... +3. Navigate to the dumb\vc6\dumb directory and select dumb.dsp. + Alternatively, if you know that you are statically linking with a library + that uses the statically linked multithreaded runtime (/MT), you may wish + to select dumb_static.dsp in the dumb_static subdirectory instead. +4. Select Build|Set Active Configuration..., and reselect one of your + project's configurations. +5. Select Project|Dependencies... and ensure your project is dependent on + DUMB. +6. Select Project|Settings..., Settings for: All Configurations, C/C++ tab, + Preprocessor category. Add the DUMB include directory to the Additional + Include Directories box. +7. Ensure that for all the projects in the workspace (or more likely just all + the projects in a particular dependency chain) the run-time libraries are + the same. That's in Project|Settings, C/C++ tab, Code generation category, + Use run-time library dropdown. The settings for Release and Debug are + separate, so you'll have to change them one at a time. Exactly which run- + time library you use will depend on what you need; it doesn't appear that + DUMB has any particular requirements, so set it to whatever you're using + now. (It will have to be /MD, the multithreaded DLL library, if you are + statically linking with Allegro. If you are dynamically linking with + Allegro than it doesn't matter.) +8. If you are using Allegro, do some or all of the above for the aldumb.dsp + project in the aldumb directory too. + +Good thing you only have to do all that once ... or twice ... + +If you have the Intel compiler installed, it will - well, should - be used to +compile DUMB. The only setting I [Tom Seddon] added is /QxiM. This allows the +compiler to use PPro and MMX instructions, and so when compiling with Intel +the resultant EXE will require a Pentium II or greater. I don't think this is +unreasonable. After all, it is 2003 :) + +[Note from Ben: the Intel compiler is evil! It makes AMD processors look bad! +Patch it or boycott it or something!] + +If you don't have the Intel compiler, VC will compile DUMB as normal. + +This project file and these instructions were provided by Tom Seddon (I hope +I got his name right; I had to guess it from his e-mail address!). Chad +Austin has since changed the project files around, and I've just attempted to +hack them to incorporate new source files. I've also tried to update the +instructions using guesswork and some knowledge of Visual J++ (you heard me). +The instructions and the project files are to this day untested by me. If you +have problems, check the download page at http://dumb.sf.net/ to see if they +are addressed; failing that, direct queries to me and I'll try to figure them +out. + +If you have any comments at all on how the VC6 projects are laid out, or how +the instructions could be improved, I should be really grateful to hear them. +I am a perfectionist, after all. :) + +Scroll down for information on the example programs. When you are ready to +start using DUMB, refer to docs/howto.txt. If you use DUMB in a game, let me +know - I might decide to place a link to your game on DUMB's website! + + +****************************************************** +*** How to set DUMB up on Linux, BeOS and Mac OS X *** +****************************************************** + + +You should have got the .tar.gz version. If for some reason you got the .zip +version instead, you may have to strip all characters with ASCII code 13 from +some of the text files. If you have problems, just go and download the +.tar.gz instead. + +You have two options. There is a Makefile which should cope with most +systems. The first option is to use this default Makefile, and the procedure +is explained below. The second option is to download +dumb-0.9.3-autotools.tar.gz, extract it over the installation, run +./configure and use the generated Makefile. Users who choose to do this are +left to their own devices but advised to read the information at the end of +this section. I strongly recommend the first option. + +If you are not using the configure script, the procedure is as follows. + +First, run the following command as a normal user: + + make + +You will be asked whether you want Allegro support. Then, unless you are on +BeOS, you will be asked where you'd like DUMB to install its headers, +libraries and examples (which will go in the include/, lib/ and bin/ +subdirectories of the prefix you specify). BeOS has fixed locations for these +files. You may use shell variables here, e.g. $HOME or ${HOME}, but ~ will +not work. Once you have specified these pieces of information, the optimised +and debugging builds of DUMB will be compiled, along with the examples. When +it has finished, you can install them with: + + make install + +You may need to be root for this to work. It depends on the prefix you chose. + +Note: the Makefile will only work if COMSPEC and ComSpec are both undefined. +If either of these is defined, the Makefile will try to build for a Windows +system, and will fail. + +Please let me know if you have any trouble. + +Scroll down for information on the example programs. Refer to docs/howto.txt +when you are ready to start programming with DUMB. If you use DUMB in a game, +let me know - I might decide to place a link to your game on DUMB's website! + +Important information for users of the configure script follows. + +The Makefile generated by the configure script creates dynamically linked +libraries, and I don't know how to stop it from doing so. See the section +below on building DUMB manually for why I recommend linking DUMB statically. +However, if you choose to use the configure script, note the following. + +The default Makefile is a copy of Makefile.rdy (short for 'ready'), and it +must exist with the name Makefile.rdy in order to work. The configure script +will overwrite Makefile, so if you want the default Makefile back, just run: + + cp Makefile.rdy Makefile + +Do not use a symlink, as that would result in Makefile.rdy getting +overwritten next time the configure script is run! + +You can also access the usual build system by passing '-f Makefile.rdy' to +Make. + + +******************************************************** +*** How to build DUMB manually if nothing else works *** +******************************************************** + + +Those porting to platforms without floating point support should be aware +that DUMB does use floating point operations but not in the inner loops. They +are used for volume and note pitch calculations, and they are used when +initialising the filter algorithm for given cut-off and resonance values. +Please let me know if this is a problem for you. If there is enough demand, I +may be able to eliminate one or both of these cases. + +All of the library source code may be found in the src/ subdirectory. There +are headers in the include/ subdirectory, and src/helpers/resample.c also +#includes some .inc files in its own directory. + +There are four subdirectories under src/. For projects not using Allegro, you +will need all the files in src/core/, src/helpers/ and src/it/. If you are +using Allegro, you will want the src/allegro/ subdirectory too. For +consistency with the other build systems, the contents of src/allegro/ should +be compiled into a separate library. + +I recommend static-linking DUMB, since the version information is done via +macros and the API has a tendency to change. If you static-link, then once +your program is in binary form, you can be sure that changes to the installed +version of DUMB won't cause it to malfuction. It is my fault that the API has +been so unstable. Sorry! + +Compile each .c file separately. As mentioned above, you will need to specify +two places to look for #include files: the include/ directory and the source +file's own directory. You will also need to define the symbol +DUMB_DECLARE_DEPRECATED on the command line. + +Do not compile the .inc files separately. + +You may need to edit dumb.h and add your own definition for LONG_LONG. It +should be a 64-bit integer. If you do this, please see if you can add a check +for your compiler so that it still works with other compilers. + +DUMB has two build modes. If you define the symbol DEBUGMODE, some checks for +programmer error will be incorporated into the library. Otherwise it will be +built without any such checks. (DUMB will however always thoroughly check the +validity of files it is loading. If you ever find a module file that crashes +DUMB, please let me know!) + +I recommend building two versions of the library, one with DEBUGMODE defined +and debugging information included, and the other with compiler optimisation +enabled. If you can install DUMB system-wide so that your projects, and other +people's, can simply #include or and link with libraries +by simple name with no path, then that is ideal. + +If you successfully port DUMB to a new platform, please let me know! + + +**************************** +*** The example programs *** +**************************** + + +Three example programs are provided. On DOS and Windows, you can find them in +the examples subdirectory. On other systems they will be installed system- +wide. + +dumbplay + This program will only be built if you have Allegro. Pass it the filename + of an IT, XM, S3M or MOD file, and it will play it. It's not a polished + player with real-time threading or anything - so don't complain about it + stuttering while you use other programs - but it does show DUMB's fidelity + nicely. You can control the playback quality by editing dumb.ini, which + must be in the current working directory. (This is a flaw for systems + where the program is installed system-wide, but it is non-fatal.) Have a + look at the examples/dumb.ini file for further information. + +dumbout + This program does not need Allegro. You can use it to stream an IT, XM, + S3M or MOD file to raw PCM. This can be used as input to an encoder like + oggenc (with appropriate command-line options), or it can be sent to a + .pcm file which can be read by any respectable waveform editor. This + program is also convenient for timing DUMB. Compare the time it takes to + render a module with the module's playing time! dumbout doesn't try to + read any configuration file; the options are set on the command line. + +dumb2wav + This program is much the same as dumbout, but it writes a .wav file with + the appropriate header. Thanks go to Chad Austin for this useful tool. + + +********************************************* +*** Downloading music or writing your own *** +********************************************* + + +If you would like to compose your own music modules, then this section should +help get you started. + +The best programs for the job are the trackers that pioneered the file +formats: + + Impulse Tracker - IT files - http://www.lim.com.au/ImpulseTracker/ + Fast Tracker II - XM files - http://www.fasttracker2.com/ + Scream Tracker 3 - S3M files - No official site known, please use Google + +MOD files come from the Amiga; I do not know what PC tracker to recommend for +editing these. If you know of one, let me know! In the meantime, I would +recommend using a more advanced file format. However, don't convert your +existing MODs just for the sake of it. + +Fast Tracker II is Shareware. It offers a very flashy interface and has a +game embedded, but the IT file format is more powerful and better defined. By +all means try them both and see which you prefer; it is largely a matter of +taste (and, in some cases, religion). Impulse Tracker and Scream Tracker 3 +are Freeware, although you can donate to Impulse Tracker and receive a +slightly upgraded version. DUMB is likely to be at its best with IT files. + +These editors are DOS programs. Users of DOS-incapable operating systems may +like to try ModPlug Tracker, but should read docs/modplug.txt before using it +for any serious work. If you use a different operating system, or if you know +of any module editors for Windows that are more faithful to the original +trackers' playback, please give me some links so I can put them here! + + ModPlug Tracker - http://www.modplug.com/ + +If you have an x86 Linux system with VGA-compatible hardware (which covers +all PC graphics cards I've ever seen), you should be able to get Impulse +Tracker running with DOSEMU. You will have to give it access to the VGA ports +and run it in a true console, as it will not work with the X-based VGA +emulation. I personally added the SB16 emulation to DOSEMU, so you can even +use filters! However, it corrupts samples alarmingly often when saving on my +system - probably a DOSEMU issue. If you set this up, I am curious to know +whether it works for you. + + DOSEMU - http://www.dosemu.org/ + +BEWARE OF WINAMP! Although it's excellent for MP3s, it is notorious for being +one of the worst module players in existence; very many modules play wrongly +with it. There are plug-ins available to improve Winamp's module support, for +example WSP. + + Winamp - http://www.winamp.com/ + WSP - http://www.spytech.cz/index.php?sec=demo + +(There is a Winamp plug-in that uses DUMB, but it is unreliable. If anyone +would like to work on it, please get in touch.) + +While I am at it I should also point out that Winamp is notorious for +containing security flaws. Install it at your own risk, and if it is your +work computer, check with your boss first! + +Samples and instruments are the building blocks of music modules. You can +download samples at + + http://www.tump.net/ + +If you would like to download module files composed by other people, check +the following sites: + + http://www.modarchive.com/ + http://www.scene.org/ + http://www.tump.net/ + http://www.homemusic.cc/main.php + http://www.modplug.com/ + +Once again, if you know of more sites where samples or module files are +available for download, please let me know. + +If you wish to use someone's music in your game, please respect the +composer's wishes. In general, you should ask the composer. Music that has +been placed in the Public Domain can be used by anyone for anything, but it +wouldn't do any harm to ask anyway if you know who the author is. In many +cases the author will be thrilled, so don't hesitate! + +A note about converting modules from one format to another, or converting +from MIDI: don't do it, unless you are a musician and are prepared to go +through the file and make sure everything sounds the way it should! The +module formats are all slightly different, and MIDI is very different; +converting from one format to another will usually do some damage. + +Instead, it is recommended that you allow DUMB to interpret the original file +as it sees fit. DUMB may make mistakes (it does a lot of conversion on +loading), but future versions of DUMB will be able to rectify these mistakes. +On the other hand, if you convert the file, the damage is permanent. + + +*********************** +*** Contact details *** +*********************** + + +If you have trouble with DUMB, or want to contact me for any other reason, my +e-mail address is given below. Please do get in touch, even if I appear to +have disappeared! + +If you wish to chat online about something, perhaps on IRC, that can most +likely be arranged. Send me an e-mail. + + +****************** +*** Conclusion *** +****************** + + +This is the conclusion. + + +Ben Davis +entheh@users.sf.net diff --git a/dumb/release.txt b/dumb/release.txt index cd1648876b..527d449337 100644 --- a/dumb/release.txt +++ b/dumb/release.txt @@ -1,468 +1,561 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * release.txt - Release notes for DUMB. / / \ \ - * | < / \_ - * | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - - -****************************************** -*** DUMB v -****************************************** - -Pattern loop stuff improved; not quite right for XM files, but better than -before - -say where ModPlug's source can be obtained - -Notes now cease to exist if they have faded out, even if they are still in -the foreground. This means a new note will be started even if a Gxx occurs -on the same row, as Impulse Tracker does in this scenario. - -XM key off fixed more: now the effect value acts as a delay, matching FT2 - -Added dumb2wav example to convert mod files to WAV files. (Chad -Austin) - -Major update to VC6 build. It builds every example as well as both -dumb.lib and aldumb.lib. (Chad Austin) - -Added first pass of the automake build. Unix users can compile and -install dumb with the standard "./configure && make && make install" -dance. Caveats: Allegro isn't searched for at configuration time, so -the examples don't build. The build also does not attempt to install -aldumb.h. (Chad Austin) - -For IT files, tone portamento didn't work properly when no note was playing. -The effect value wasn't stored. Thanks to Maim from #trax on EFnet for -discovering this bug. - -XM key off fixed - doesn't overwrite note any more - -tagging system added - title -sample/instrument names/filenames -more functions (n_samples n_instruments) - -made timing more accurate; this may affect length by a second or two ... - -Thanks to networm for valgrinding the new envelope handling code - -DUMB used to process the first row when you created the DUMB_IT_SIGRENDERER. -This happened before you had a chance to install any callbacks. If an F00 -effect occurred on the first row, the music would stop immediately and the -xm_speed_zero callback would be called if it were present. Unfortunately, it -wasn't present, and the algorithm for calculating the length subsequently -went into an endless loop while waiting for it. Worse still, the same -algorithm accumulated data for fast seeking, and never stopped, so it pretty -quickly consumed all the resources. - -DUMB will now not process the first row until you first request some samples, -provided you pass zero for pos. Ironically, any MOD or XM file with F00 in -the very first row won't play anyway! But at least such files won't crash the -library now. - - * The make/config.bat file, responsible for generating make/config.txt, wrote a crucial line to the wrong place, causing it to be left out of the file. As a result, the makefile would fail to install everything for Allegro users, and enter infinite recursion for other users. If you are trying to compile with DJGPP or MinGW, please download dumb-0.9.2-fixed.zip (linked below, and incidentally including the fix for the bug detailed in the next point). - * DUMB's makefile doesn't install the example programs on any platforms. (It is supposed to install them on all platforms except DOS and Windows.) You can fix this by editing Makefile and changing the one occurrence of $COMSPEC to $(COMSPEC). Alternatively you can run the example programs from the examples directory. - * There is a subtle bug that affects a few XM files. For instruments with no associated samples, the array mapping notes to samples is uninitialised. This becomes a problem if such instruments are then used, which does happen sometimes. On many systems, memory is initialised to zero when first given to a program (for security reasons), so the problem won't come up most of the time. However, on platforms like DOS where memory isn't initialised, or in programs that reuse memory later on (this includes the XMMS plug-in), a rogue note will occasionally play. If you are worried that this might happen to you, then use DUMB CVS or wait for the next release (which won't be for a while). If you have access to an i386 Linux system, you can use Valgrind on the 'dumbout' example program to determine whether your XM file causes DUMB to use uninitialised values. - * For IT files, DUMB breaks out of single-point envelope sustain loops one tick too early. The correct behaviour for multi-point sustain loops is yet to be determined. The worst that can happen is that notes may seem to be ever so slightly shorter than they should be, except in pathological cases. This bug has not yet been fixed in CVS. - - - -****************************************** -*** DUMB v0.9.2, released 2 April 2003 *** -****************************************** - -Yes, there really has been a release. This is not a day-late April fools' -joke. - -DUMB's full name has changed! The old "Dedicated Universal Music -Bastardisation" was rather silly, and not much more than a forced attempt at -finding words beginning with D, U, M and B. I spent weeks and weeks browsing -dictionaries and hopelessly asking others for bright ideas, until the -brilliant Chris "Kitty Cat" Robinson came up with "Dynamic". I decided to -keep the U as Universal, since a DUH struct can hold digital music in any -format. Now all that remained was the B, but it didn't take me long to come -up with Bibliotheque, which, despite looking French, is indeed considered an -English word by Oxford English Dictionary Online, to which my university has -a subscription. So there you have it - the name now makes sense. - -The two most significant additions to the project would have to be the new -thread safety (with an important restriction, detailed in docs/dumb.txt), and -the new build system. The silly 'makeall' and 'makecore' scripts are gone. If -you are a GCC user, all you need do now is run 'make' and 'make install', as -for other projects. You don't even have to run a 'fix' script any more! There -are some caveats, which are covered in readme.txt. If you use Microsoft -Visual C++ 6, you no longer need to obtain GCC and GNU Make - there is a -project file just for you. - -Huge thanks go to Steve Terry for testing on Windows XP - about five times - -and to lillo for testing on BeOS and Mac OS X. Thanks also to X-G for testing -on a Windows system that has consistently posed problems for DUMB's old -makefiles. - -There was a bug whereby al_poll_duh() would sometimes cause the music to -resume playing if you called it after al_pause_duh(). Whether this was DUMB's -fault for misusing Allegro's API, or a bug in Allegro, is unclear, but this -release makes it work. - -In one of my projects, I found that my AL_DUH_PLAYER stopped playing when -there were lots of other sound effects. In order to fix this, I programmed -DUMB to set the priority of the stream's voice to 255, the maximum. I also -added al_duh_set_priority(), so you can set the priority yourself if you need -to. - -The resampling code has undergone a transformation. The bad news is that the -linear average code is no longer in use. The good news is that where DUMB's -resamplers used to require three extra samples' worth of memory to be -allocated and initialised, it now copes with just the sample data. And it -does a very good job at bouncing off loop points and otherwise hurtling -around the sample. The resampling code is considerably more complicated, but -the code that uses the resamplers is considerably simpler - and if you -noticed a slight click in some bidirectionally looping samples, you'll be -pleased to know that that click is gone! - -I have also devoted some effort to optimisation. It seemed hopeless for a -while, but then I actually figured out a way of making it faster AND more -accurate at the same time! DUMB is now quite a bit faster than it was, and it -mixes not with 16-bit precision, but with 24-bit precision. (It used 32-bit -integers all along, but the difference is that it now makes use of 256 times -as much of the integer's range.) - -There have been the usual improvements to playback. The last release occurred -rather too soon after I had fixed the XM effect memories; EAx and EBx, fine -volume ramps, had been neglected. These are now handled properly. - -In previous versions of DUMB, muted channels in IT were actually played with -surround sound panning (where the right-hand channel is inverted). This has -been fixed, so muted channels will really be muted now. - -There were also some subtle problems with the way DUMB handled New Note -Actions for IT files. It turned out that, in all releases of DUMB so far, -pitch, filter and panning envelopes and sample vibrato were not being -processed for any note that was forced into the background by a new note on -the same channel! This only affected IT files. Not only has this been fixed, -but envelope interpolation is much more accurate. Long trailing envelope- -driven fade-outs sound a lot better now! - -Since panning and filter envelopes are more precise, extra fields have been -added to the DUMB_IT_CHANNEL_STATE struct, used by -dumb_it_sr_get_channel_state(). These fields hold the 'decimal' parts of the -pan and filter cut-off. See dumb.txt for details. - -Mxx (set channel volume) now correctly only modifies the last note played on -the channel, not any previous notes that have been forced into the background -by New Note Actions, and filter effect processing is now closer to what -Impulse Tracker does. - -The XM loader was slightly flawed and could crash on files containing samples -with out-of-range loop points. One such file was given to me. This has been -fixed. - -Finally, the legal stuff. Julien Cugniere has been added to the list of -copyright owners. He deserves it, for all the work he did on the XM support! -And the licence has been changed. You are no longer required to include a -link to DUMB in a project that uses DUMB; the reasons for this relaxation are -explained in licence.txt. However, the request is still there ... - -As usual, enjoy! - - -********************************************** -*** DUMB v0.9.1, released 19 December 2002 *** -********************************************** - -Hi again! Lots to say this time, so I shall cut right to the chase. - -DUMB now supports Impulse Tracker's low-pass resonant filters! Huge thanks go -to Jeffrey Lim, author of Impulse Tracker, for giving me what information he -still had regarding the algorithm; to cut a long story short, modifying -ModPlug Tracker's source code (which is in the Public Domain) led to an -algorithm whose output matched Impulse Tracker's perfectly. - -Please note that ModPlug Tracker's filters as they stand do not match Impulse -Tracker's, and I have no interest in supporting ModPlug Tracker's variant -(especially not the integer rounding problems). Please see docs/modplug.txt, -new in this release, for details. - -Thanks also go to Fatso Huuskonen for motivating me to add filter support, -and providing me with several great IT files to test it with! - -The other important feature added for this release is click removal. Up until -now, DUMB has generated clicks when cutting notes, starting samples in the -middle, and so on. This version of DUMB will remove any such clicks. Note -that DUMB does not use volume ramps to accomplish this; the algorithm will -not take the bite out of the music! - -In other news, DUMB now supports sample vibrato for IT files, and instrument -vibrato for XM files. A slight bug in New Note Action handling for IT files -has been fixed; Note Fade will not break the sustain loops of the sample and -envelope, as it did before. Tremor handling (Ixy) had a strange bug in it, -which has been fixed. - -Support for XM files has been greatly enhanced. The XM envelope handling new -in the last release contained a huge bug, resulting in notes seeming not to -stop when they should; this has been fixed. Some XM files crashed DUMB, while -others failed to load; these problems have been solved. Effect memories now -work properly for XM and MOD files, to the best of my knowledge. Some other -differences between IT and XM have been accounted for, most notably the -Retrigger Note effects, Rxy and E9x. - -DUMB's sound quality and accuracy are not the only areas that have been -enhanced. The API has been expanded, at last. You can now detect when a -module loops, or make it play through just once. You can ask DUMB to inform -you every time it generates some samples; this is useful for visualisation. -For IT files, you can intercept the MIDI messages generated by Zxx macros, -enabling you to synchronise your game with the music to some extent. (There -is no such method for XM, S3M or MOD files yet; sorry. Also note that the -function will be called before you actually hear the sound; I cannot improve -this until DUMB has its own sound drivers, which won't be for a while.) You -can query the current order and row. Finally, operations like changing the -speed and tempo are now possible, and you can query the playback state on -each channel. - -Some parts of DUMB's API have been deprecated. Simple programs that use -Allegro will be unaffected, but if you get some compiler warnings or errors, -please review docs/deprec.txt. This file explains why those parts of the API -were deprecated, and tells you how to adapt your code; the changes you need -to make are straightforward. Sorry for the inconvenience. - -For various reasons, I have made DUMB's makefiles use different compiler -flags depending on your GCC version (unless you are using MSVC). There is no -elegant way of getting the makefiles to detect when GCC is upgraded. If you -upgrade GCC, you should execute 'make clean' in order to make DUMB detect the -GCC version again. Otherwise you may get some annoying error messages. (It is -wise to do this in any case, so that all the object files are built with the -same GCC version.) - -DUMB's example players have been unified into a single player called -'dumbplay'. The player has been enhanced to display messages when the music -loops, and when XM and MOD files freeze (effect F00; more information on this -in docs/howto.txt). - -Finally, as noted on DUMB's website, the release notes from the last release -were inaccurate. It has been verified that DUMBOGG v0.5 does still work with -that release, and still works with this release. The esoteric DUMBOGG v0.6 -has not been created yet, since DUMBOGG v0.5 still works. - -Please scroll down and read through the indented paragraphs in the notes for -the last release; they are relevant for this release too. - -That's all folks! Until next time. - - -******************************************* -*** DUMB v0.9, released 16 October 2002 *** -******************************************* - -MOD support is here! DUMB now supports all four of the common module formats. -As usual, there have also been some improvements to the way modules are -played back. Most notably, handling of tone portamento in IT files has been -improved a lot, and XM envelopes are now processed correctly. - -The other major change is that DUMB now does a dummy run through each module -on loading. It stores the playback state at thirty-second intervals. It stops -when the module first loops, and then stores the playback time. This results -in a slightly longer load time and a greater memory overhead, but seeking is -faster (to any point before the module first loops) and the length is -calculated! duh_get_length() will return this and is now documented in -docs/howto.txt and docs/dumb.txt. - -DUMB's build process has been changed to use 'mingw' wherever it used -'mingw32' before; some directories have been renamed, and the 'fix' command -you had to run for MinGW has been changed from 'fix mingw32' to 'fix mingw'. - -Last time, I directed you to scroll down and read the notes from a past -release, but ignore this point, and that point applies to something else, and -so on. Did anyone do so? Well, if you're reading this at all, you probably -did. Nevertheless, this time I shall be much less confusing and restate any -relevant information. So the least you can do is read it! - -- If your program ever aborts with exit code 37 while loading an IT file, - PLEASE LET ME KNOW! The IT file in question has a stereo compressed sample - in it, and the format is unspecified for this case (Impulse Tracker itself - doesn't use stereo samples at all). I will need the IT file in question, - and any information you can give me about how the IT file was created (e.g. - what program). (If you don't get to see an exit code, let me know anyway.) - -- If your program ever outputs a line resembling "Inst 01 Env: 0,64 8,32 - 15,48" to stderr while loading an IT file, PLEASE LET ME KNOW! You have an - old IT file (saved by an Impulse Tracker version older than 2.00), and - support for such files is STILL untested. - -- Not all parts of DUMB's API are documented yet. You will find some - functions in dumb.h which are not listed in docs/dumb.txt; the reason is - that these functions still need work and will probably change. If you - really, really want to use them, talk to me first (IRC EFnet #dumb is a - good place for this; see readme.txt for details on using IRC). I intend to - finalise and document the whole of DUMB's API for Version 1.0. - -There have been some changes to the naming conventions in DUMB's undocumented -API. DUMBOGG v0.5 will not work with this and subsequent releases of DUMB; -please upgrade to DUMBOGG v0.6. These changes should not break anything in -your own code, since you didn't use those parts of the API, did you ;) - -There is still a great deal of work to be done before DUMB's API can be -finalised, and thus it will be a while before DUMB v1.0 comes out. It should -be worth the wait. In the meantime, there will be 0.9.x releases with -additional functionality, improved playback, and possibly support for some -extra file formats. - -Finally I should like to offer an apology; there is a strong possibility that -some of DUMB's official API will change in the near future. There will not be -any drastic changes, and the corresponding changes to your source code will -be simple enough. If I didn't make these changes, DUMB's API would start to -become limited, or messy, or both, so it's for the better. I apologise in -advance for this. - -Now scroll down and read the notes for the first r... oh wait, we already did -that. I guess that's it then. You can stop reading now. - -Right after you've read this. - -And this. - -Off you go. - -Bye. - - -******************************************** -*** DUMB v0.8.1, released 11 August 2002 *** -******************************************** - -This is a minor release that fixes a few bugs. One of these bugs, however, -was pretty serious. dumb_register_dat_xm() was never coded! It was prototyped -in aldumb.h, so code would compile, but there would be an unresolved symbol -at the linking stage. This has been fixed. - -Platforms other than Unix did not have a working 'make veryclean' target; -this has been fixed. In addition, the makefiles now use 'xcopy' instead of -'copy', since on some systems GNU Make seems to have trouble calling commands -built in to the shell. - -Contrary to the errata that was on the DUMB website, the makeall.sh and -makecore.sh scripts actually DID install in /usr. This has now been -corrected, and regardless of whether you use these scripts or call make -directly, the files will now be installed to /usr/local by default. - -The XM loader used to treat stereo samples as mono samples with the data for -the right channel positioned after the data for the left channel. This -generally resulted in an unwanted echo effect. This has been fixed. - -When playing XM files, specifying an invalid instrument would cause an old -note on that channel to come back (roughly speaking). Fast Tracker 2 does not -exhibit this behaviour. This has been fixed. - -The GCC makefiles used -mpentium, which is deprecated in gcc 3.x. This was -generating warnings, and has now been fixed. - -In XM files, the length of a sample is stored in bytes. DUMB was assuming -that the length of a 16-bit sample would be even. I had two XM files where -this was not the case, and DUMB was unable to load them. This has been fixed. - -In order to accommodate the extra part of the version number, -DUMB_REVISION_VERSION has been added. DUMB_VERSION has also been added in -order to facilitate checking if the version of DUMB installed is sufficient. -See docs/dumb.txt for details. - -As a last-minute fix, the XM "Break to row" effect is now loaded properly. It -was necessary to convert from binary-coded decimal to hexadecimal (those who -have experience with Fast Tracker 2 will know what I mean). In short, this -means the effect will now work properly when breaking to row 10 or greater. - -DUMB v0.8 had faulty release date constants; DUMB_MONTH and DUMB_DAY were -swapped! For this reason, DUMB_DATE should not be compared against any date -in 2002. This note has been added to docs/dumb.txt and also to dumb.h. - -Please scroll to the end and read the release notes for the first version, -DUMB v0.7. Most of them apply equally to this release. However, the -non-portable code was rewritten for DUMB v0.8, so that point does not apply. -The point about length not being calculated also applies to XM files. - -Enjoy :) - - -**************************************** -*** DUMB v0.8, released 14 June 2002 *** -**************************************** - -Welcome to the second release of DUMB! - -In addition to these notes, please read below the release notes for the -previous version, DUMB v0.7. Most of them apply equally to this release. -However, the non-portable code has been rewritten; DUMB should now port to -big-endian platforms. - -The main improvement in this release of DUMB is the support for XM files. -Enormous thanks go to Julien Cugniere for working on this while I had to -revise for my exams! - -There was a mistake in the makefiles in the last release. The debugging -Allegro interface library was mistakenly named libaldmbd.a instead of -libaldmd.a, meaning you had to compile with -laldmbd, contrary to what the -docs said. Apologies to everyone who lost sleep trying to work out what was -wrong! The reason for using libaldmd.a is to maintain compatibility with -plain DOS, where filenames are limited to eight characters (plus a three- -letter extension). The makefiles have now been changed to match the -information in the docs, so you may have to alter your project files -accordingly. - -The example programs were faulty, and crashed on Windows if they were unable -to load the file. It was also difficult to work out how to exit them (you had -to click the taskbar button that didn't have a window, then press a key). -They have been improved in both these respects. - -I have now added a docs/faq.txt file (Frequently Asked Questions), which is -based on problems and misconceptions people have had with the first release. -Please refer to it before contacting me with problems. - -Thanks to networm for touching up the Unix makefile and writing the -instructions on using it. - -Incidentally, today (Friday 14 June) is the Robinson College May Ball at -Cambridge Uni. God knows why it's called a May Ball if it's in June. I'm not -going myself (72 GBP, and I'd have to wear a suit, ugh), but with all the -noise outside I shall enjoy pumping up the speakers tonight! - - -**************************************** -*** DUMB v0.7, released 2 March 2002 *** -**************************************** - -This is the first release of DUMB, and parts of the library are not -crystallised. Don't let this put you off! Provided you don't try to use any -features that aren't documented in docs/dumb.txt, the library should be rock -solid and you should be able to upgrade more or less without problems. - -Here are some notes on this release: - -- There is some non-portable code in this release of DUMB. It is likely that - the library will fail to load IT files with compressed samples on - big-endian machines such as the Apple Macintosh. - -- If your program ever aborts with exit code 37 while loading an IT file, - PLEASE LET ME KNOW! The IT file in question has a stereo compressed sample - in it, and the format is unspecified for this case (Impulse Tracker itself - doesn't use stereo samples at all). I will need the IT file in question, - and any information you can give me about how the IT file was created (e.g. - what program). (If you don't get to see an exit code, let me know anyway.) - -- If your program ever outputs a line resembling "Inst 01 Env: 0,64 8,32 - 15,48" to stderr while loading an IT file, PLEASE LET ME KNOW! You have an - old IT file (saved by an Impulse Tracker version older than 2.00), and - support for such files is untested. - -- The length of IT and S3M files is not currently calculated. It is just set - to ten minutes. +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * release.txt - Release notes for DUMB. / / \ \ + * | < / \_ + * | \/ /\ / + * \_ / > / + * | \ / / + * | ' / + * \__/ + */ + + +******************************************* +*** DUMB v0.9.3, released 7 August 2005 *** +******************************************* + +Hello! Welcome to a long-awaited-or-probably-just-given-up-on-by-everybody +release! New to this release are lower memory usage, faster mixing loops, +loading of text fields in the module files, and faster load functions for +projects that don't need to seek within the module or know its length. +Additionally, Chad Austin has contributed a dumb2wav tool for converting +modules to .wav files and updated the Visual Studio 6 project files to +compile all the examples as well as the library. Users of Unix-like systems +will be pleased to know that on Chad's suggestion I have made the build +system cope with variables such as $HOME or ${HOME} in the prefix. + +Chad has also contributed an Autotools build system, but neither of us +recommends its use. The Autotools are an evil black box, we haven't quite +managed to get it right, and goodness help you if it happens not to work for +you. The files are available in a separate download if you absolutely need +them. Notice that that download is almost twice as large as the rest of DUMB! + +Maybe we'll do SCons next time. + +Thanks to Chad for all his work. Chad is the author of Audiere, a portable +sound library which has started using DUMB for its module playback! Wahoo! + + http://audiere.sf.net/ + +There are three main optimisations that went into the mixing loops. + +First, I downloaded ModPlugXMMS and had a peek at the mixing code, which is +Public Domain. It uses look-up tables for the cubic mixing. I pinched the +idea, and that sped DUMB's cubic (best quality) resamplers up by a factor of +two or three. + +Secondly, the samples loaded from the file are now kept in 8-bit or 16-bit +format, whereas previously they were being converted to 24-bit-in-32-bit on +loading. This means the samples occupy a half or a quarter of the memory they +used to occupy. It also had the side-effect of speeding up the mixing loops, +but it meant I had to duplicate the resampling code. (It is all done with +macros in the source code, but it becomes two copies on the binary level.) + +Secondly, stereo samples and stereo mixing buffers are now kept in +interleaved format, where previously the two channels were done separately to +keep the code simpler. This change has made the library quite a bit bigger, +but has made the code run almost twice as fast for stereo output (tested for +modules whose samples are mostly mono)! + +DUMB is now as fast as ModPlugXMMS on my system. + +Some people have also commented that DUMB seems to take a long time loading +files. This is because immediately upon loading the file it runs the playback +engine over it up as far as the point of first loop, taking snapshots at 30- +second intervals to be used as references for fast seeking and finally +storing the playback time. Of course, most games don't need this. You can now +skip it by calling the _quick versions of the dumb_load_*(), dumb_read_*() or +dumb_register_dat_*() functions. Should you need the data later, you can call +dumb_it_do_initial_runthrough() to calculate it. Please note that this cannot +currently be done safely from a concurrent thread while the music is playing. + +As mentioned, DUMB loads the text fields in module files now. You can +retrieve the song title with duh_get_tag(). Sample names and file names and +instrument names and filenames, and the song message for IT files, are +available with a call to duh_get_it_sigdata() and various dumb_it_sd_*() +functions. Please note that text fields added as extensions by ModPlug +Tracker are not supported. + +DUMB's timing is ever so slightly more accurate. This is hardly noticeable, +but it has meant that the length computed will increase very slightly. + +There are many small playback fixes in this release: + +* The Lxx effect in XM files (set envelope position) is now supported. + +* Pattern looping is now correct for XM files. Bizarrely, an ordinary pattern + loop whose start point isn't the first row seems to cause the next pattern + to start at the row corresponding to the loop start point. That must have + been a headache for people creating XM files! Nevertheless, DUMB now + emulates this behaviour. If you have an XM file that was written in a + tracker other than Fast Tracker II and breaks in DUMB, you can get around + it by putting a D00 effect (break to row 0) right at the end of the pattern + containing the loop. + +* XM pattern looping can be infinite. DUMB should detect this and call the + loop callback when it happens. Specifically, it has a loop counter for each + channel, so each time it sets or decrements that counter, it remembers the + loop end point for that channel. When the loop terminates, the loop end + point is reset to 0. If the loop end point ever decreases during a loop, + the loop callback is called. If anyone manages to get around this check and + prevent DUMB from calling the callback, please let me know and send me an + illustrative XM file! + +* For IT files, notes are now removed from channels if they have faded out, + even if they are still in the foreground. After this has happened, a row + with a note and Gxx (tone portamento) specified will cause a new note to + start playing, which is what Impulse Tracker does in this scenario. + (Normally, Gxx prevents the new note from playing and instead causes the + old note to start sliding towards the new note.) + +* If a tone portamento command occurred when no note was playing, the effect + value wasn't stored. This has been fixed. Thanks to Maim from #trax on + EFnet for discovering this bug. + +* DUMB now treats the parameter to the undocumented XM key off effect Kxx as + a delay, consistent with Fast Tracker II's behaviour. It has also been made + not to clear the note, so a subsequent volume command will restore it, as + in Fast Tracker II. + +* DUMB used to process the first row when you created the + DUMB_IT_SIGRENDERER. This happened before you had a chance to install any + callbacks. If an F00 effect occurred on the first row, the music would stop + immediately and the xm_speed_zero callback would be called if it were + present. Unfortunately, it wasn't present, and the algorithm for + calculating the length subsequently went into an endless loop while waiting + for it. Worse still, the same algorithm accumulated data for fast seeking, + and never stopped, so it pretty quickly consumed all the resources. DUMB + will now not process the first row until you first request some samples, + provided you pass zero for pos. Of course, any MOD or XM file with F00 in + the very first row won't do much anyway, but such files won't crash the + library now. + +* There was a subtle bug that affected a few XM files. For instruments with + no associated samples, the array mapping notes to samples is uninitialised. + This became a problem if such instruments were then used, which does happen + sometimes. On many systems, memory is initialised to zero when first given + to a program (for security reasons), so the problem didn't come up most of + the time. However, on platforms like DOS where memory isn't initialised, or + in programs that reuse memory later on (this includes the XMMS plug-in with + which I discovered the bug), a rogue note would occasionally play. This has + now been fixed. + +* DUMB's envelope handling for IT files was subtly wrong. Upon note off, it + stopped obeying the sustain loop points one tick too early. Notes were + often shorter than they should have been, and in pathological cases a whole + extra iteration of the sustain loop section might have been skipped. The + envelope code has now been rewritten. Thanks go to Allefant for Valgrinding + the new code! + +Finally, there were two build problems in the last version, which were fixed +in the download marked with -fixed. They are of course correct in this +version. For the record: + +* The make/config.bat file, responsible for generating make/config.txt, wrote + a crucial line to the wrong place, causing it to be left out of the file. + As a result, the makefile would fail to install everything for Allegro + users, and enter infinite recursion for other users. This applied to people + using DJGPP and MinGW. + +* DUMB's Makefile was supposed to install the example programs on Unix-based + platforms, but it wasn't doing. The fix was to edit Makefile and change the + one occurrence of $COMSPEC to $(COMSPEC). + +That's it! I hope you enjoy this long-awaited-or-probably-just-given-up-on- +by-everybody release of DUMB! + + +****************************************** +*** DUMB v0.9.2, released 2 April 2003 *** +****************************************** + +Yes, there really has been a release. This is not a day-late April fools' +joke. + +DUMB's full name has changed! The old "Dedicated Universal Music +Bastardisation" was rather silly, and not much more than a forced attempt at +finding words beginning with D, U, M and B. I spent weeks and weeks browsing +dictionaries and hopelessly asking others for bright ideas, until the +brilliant Chris "Kitty Cat" Robinson came up with "Dynamic". I decided to +keep the U as Universal, since a DUH struct can hold digital music in any +format. Now all that remained was the B, but it didn't take me long to come +up with Bibliotheque, which, despite looking French, is indeed considered an +English word by Oxford English Dictionary Online, to which my university has +a subscription. So there you have it - the name now makes sense. + +The two most significant additions to the project would have to be the new +thread safety (with an important restriction, detailed in docs/dumb.txt), and +the new build system. The silly 'makeall' and 'makecore' scripts are gone. If +you are a GCC user, all you need do now is run 'make' and 'make install', as +for other projects. You don't even have to run a 'fix' script any more! There +are some caveats, which are covered in readme.txt. If you use Microsoft +Visual C++ 6, you no longer need to obtain GCC and GNU Make - there is a +project file just for you. + +Huge thanks go to Steve Terry for testing on Windows XP - about five times - +and to lillo for testing on BeOS and Mac OS X. Thanks also to X-G for testing +on a Windows system that has consistently posed problems for DUMB's old +makefiles. + +There was a bug whereby al_poll_duh() would sometimes cause the music to +resume playing if you called it after al_pause_duh(). Whether this was DUMB's +fault for misusing Allegro's API, or a bug in Allegro, is unclear, but this +release makes it work. + +In one of my projects, I found that my AL_DUH_PLAYER stopped playing when +there were lots of other sound effects. In order to fix this, I programmed +DUMB to set the priority of the stream's voice to 255, the maximum. I also +added al_duh_set_priority(), so you can set the priority yourself if you need +to. + +The resampling code has undergone a transformation. The bad news is that the +linear average code is no longer in use. The good news is that where DUMB's +resamplers used to require three extra samples' worth of memory to be +allocated and initialised, it now copes with just the sample data. And it +does a very good job at bouncing off loop points and otherwise hurtling +around the sample. The resampling code is considerably more complicated, but +the code that uses the resamplers is considerably simpler - and if you +noticed a slight click in some bidirectionally looping samples, you'll be +pleased to know that that click is gone! + +I have also devoted some effort to optimisation. It seemed hopeless for a +while, but then I actually figured out a way of making it faster AND more +accurate at the same time! DUMB is now quite a bit faster than it was, and it +mixes not with 16-bit precision, but with 24-bit precision. (It used 32-bit +integers all along, but the difference is that it now makes use of 256 times +as much of the integer's range.) + +There have been the usual improvements to playback. The last release occurred +rather too soon after I had fixed the XM effect memories; EAx and EBx, fine +volume ramps, had been neglected. These are now handled properly. + +In previous versions of DUMB, muted channels in IT were actually played with +surround sound panning (where the right-hand channel is inverted). This has +been fixed, so muted channels will really be muted now. + +There were also some subtle problems with the way DUMB handled New Note +Actions for IT files. It turned out that, in all releases of DUMB so far, +pitch, filter and panning envelopes and sample vibrato were not being +processed for any note that was forced into the background by a new note on +the same channel! This only affected IT files. Not only has this been fixed, +but envelope interpolation is much more accurate. Long trailing envelope- +driven fade-outs sound a lot better now! + +Since panning and filter envelopes are more precise, extra fields have been +added to the DUMB_IT_CHANNEL_STATE struct, used by +dumb_it_sr_get_channel_state(). These fields hold the 'decimal' parts of the +pan and filter cut-off. See dumb.txt for details. + +Mxx (set channel volume) now correctly only modifies the last note played on +the channel, not any previous notes that have been forced into the background +by New Note Actions, and filter effect processing is now closer to what +Impulse Tracker does. + +The XM loader was slightly flawed and could crash on files containing samples +with out-of-range loop points. One such file was given to me. This has been +fixed. + +Finally, the legal stuff. Julien Cugniere has been added to the list of +copyright owners. He deserves it, for all the work he did on the XM support! +And the licence has been changed. You are no longer required to include a +link to DUMB in a project that uses DUMB; the reasons for this relaxation are +explained in licence.txt. However, the request is still there ... + +As usual, enjoy! + + +********************************************** +*** DUMB v0.9.1, released 19 December 2002 *** +********************************************** + +Hi again! Lots to say this time, so I shall cut right to the chase. + +DUMB now supports Impulse Tracker's low-pass resonant filters! Huge thanks go +to Jeffrey Lim, author of Impulse Tracker, for giving me what information he +still had regarding the algorithm; to cut a long story short, modifying +ModPlug Tracker's source code (which is in the Public Domain) led to an +algorithm whose output matched Impulse Tracker's perfectly. + +Please note that ModPlug Tracker's filters as they stand do not match Impulse +Tracker's, and I have no interest in supporting ModPlug Tracker's variant +(especially not the integer rounding problems). Please see docs/modplug.txt, +new in this release, for details. + +Thanks also go to Fatso Huuskonen for motivating me to add filter support, +and providing me with several great IT files to test it with! + +The other important feature added for this release is click removal. Up until +now, DUMB has generated clicks when cutting notes, starting samples in the +middle, and so on. This version of DUMB will remove any such clicks. Note +that DUMB does not use volume ramps to accomplish this; the algorithm will +not take the bite out of the music! + +In other news, DUMB now supports sample vibrato for IT files, and instrument +vibrato for XM files. A slight bug in New Note Action handling for IT files +has been fixed; Note Fade will not break the sustain loops of the sample and +envelope, as it did before. Tremor handling (Ixy) had a strange bug in it, +which has been fixed. + +Support for XM files has been greatly enhanced. The XM envelope handling new +in the last release contained a huge bug, resulting in notes seeming not to +stop when they should; this has been fixed. Some XM files crashed DUMB, while +others failed to load; these problems have been solved. Effect memories now +work properly for XM and MOD files, to the best of my knowledge. Some other +differences between IT and XM have been accounted for, most notably the +Retrigger Note effects, Rxy and E9x. + +DUMB's sound quality and accuracy are not the only areas that have been +enhanced. The API has been expanded, at last. You can now detect when a +module loops, or make it play through just once. You can ask DUMB to inform +you every time it generates some samples; this is useful for visualisation. +For IT files, you can intercept the MIDI messages generated by Zxx macros, +enabling you to synchronise your game with the music to some extent. (There +is no such method for XM, S3M or MOD files yet; sorry. Also note that the +function will be called before you actually hear the sound; I cannot improve +this until DUMB has its own sound drivers, which won't be for a while.) You +can query the current order and row. Finally, operations like changing the +speed and tempo are now possible, and you can query the playback state on +each channel. + +Some parts of DUMB's API have been deprecated. Simple programs that use +Allegro will be unaffected, but if you get some compiler warnings or errors, +please review docs/deprec.txt. This file explains why those parts of the API +were deprecated, and tells you how to adapt your code; the changes you need +to make are straightforward. Sorry for the inconvenience. + +For various reasons, I have made DUMB's makefiles use different compiler +flags depending on your GCC version (unless you are using MSVC). There is no +elegant way of getting the makefiles to detect when GCC is upgraded. If you +upgrade GCC, you should execute 'make clean' in order to make DUMB detect the +GCC version again. Otherwise you may get some annoying error messages. (It is +wise to do this in any case, so that all the object files are built with the +same GCC version.) + +DUMB's example players have been unified into a single player called +'dumbplay'. The player has been enhanced to display messages when the music +loops, and when XM and MOD files freeze (effect F00; more information on this +in docs/howto.txt). + +Finally, as noted on DUMB's website, the release notes from the last release +were inaccurate. It has been verified that DUMBOGG v0.5 does still work with +that release, and still works with this release. The esoteric DUMBOGG v0.6 +has not been created yet, since DUMBOGG v0.5 still works. + +Please scroll down and read through the indented paragraphs in the notes for +the last release; they are relevant for this release too. + +That's all folks! Until next time. + + +******************************************* +*** DUMB v0.9, released 16 October 2002 *** +******************************************* + +MOD support is here! DUMB now supports all four of the common module formats. +As usual, there have also been some improvements to the way modules are +played back. Most notably, handling of tone portamento in IT files has been +improved a lot, and XM envelopes are now processed correctly. + +The other major change is that DUMB now does a dummy run through each module +on loading. It stores the playback state at thirty-second intervals. It stops +when the module first loops, and then stores the playback time. This results +in a slightly longer load time and a greater memory overhead, but seeking is +faster (to any point before the module first loops) and the length is +calculated! duh_get_length() will return this and is now documented in +docs/howto.txt and docs/dumb.txt. + +DUMB's build process has been changed to use 'mingw' wherever it used +'mingw32' before; some directories have been renamed, and the 'fix' command +you had to run for MinGW has been changed from 'fix mingw32' to 'fix mingw'. + +Last time, I directed you to scroll down and read the notes from a past +release, but ignore this point, and that point applies to something else, and +so on. Did anyone do so? Well, if you're reading this at all, you probably +did. Nevertheless, this time I shall be much less confusing and restate any +relevant information. So the least you can do is read it! + +- If your program ever aborts with exit code 37 while loading an IT file, + PLEASE LET ME KNOW! The IT file in question has a stereo compressed sample + in it, and the format is unspecified for this case (Impulse Tracker itself + doesn't use stereo samples at all). I will need the IT file in question, + and any information you can give me about how the IT file was created (e.g. + what program). (If you don't get to see an exit code, let me know anyway.) + +- If your program ever outputs a line resembling "Inst 01 Env: 0,64 8,32 + 15,48" to stderr while loading an IT file, PLEASE LET ME KNOW! You have an + old IT file (saved by an Impulse Tracker version older than 2.00), and + support for such files is STILL untested. + +- Not all parts of DUMB's API are documented yet. You will find some + functions in dumb.h which are not listed in docs/dumb.txt; the reason is + that these functions still need work and will probably change. If you + really, really want to use them, talk to me first (IRC EFnet #dumb is a + good place for this; see readme.txt for details on using IRC). I intend to + finalise and document the whole of DUMB's API for Version 1.0. + +There have been some changes to the naming conventions in DUMB's undocumented +API. DUMBOGG v0.5 will not work with this and subsequent releases of DUMB; +please upgrade to DUMBOGG v0.6. These changes should not break anything in +your own code, since you didn't use those parts of the API, did you ;) + +There is still a great deal of work to be done before DUMB's API can be +finalised, and thus it will be a while before DUMB v1.0 comes out. It should +be worth the wait. In the meantime, there will be 0.9.x releases with +additional functionality, improved playback, and possibly support for some +extra file formats. + +Finally I should like to offer an apology; there is a strong possibility that +some of DUMB's official API will change in the near future. There will not be +any drastic changes, and the corresponding changes to your source code will +be simple enough. If I didn't make these changes, DUMB's API would start to +become limited, or messy, or both, so it's for the better. I apologise in +advance for this. + +Now scroll down and read the notes for the first r... oh wait, we already did +that. I guess that's it then. You can stop reading now. + +Right after you've read this. + +And this. + +Off you go. + +Bye. + + +******************************************** +*** DUMB v0.8.1, released 11 August 2002 *** +******************************************** + +This is a minor release that fixes a few bugs. One of these bugs, however, +was pretty serious. dumb_register_dat_xm() was never coded! It was prototyped +in aldumb.h, so code would compile, but there would be an unresolved symbol +at the linking stage. This has been fixed. + +Platforms other than Unix did not have a working 'make veryclean' target; +this has been fixed. In addition, the makefiles now use 'xcopy' instead of +'copy', since on some systems GNU Make seems to have trouble calling commands +built in to the shell. + +Contrary to the errata that was on the DUMB website, the makeall.sh and +makecore.sh scripts actually DID install in /usr. This has now been +corrected, and regardless of whether you use these scripts or call make +directly, the files will now be installed to /usr/local by default. + +The XM loader used to treat stereo samples as mono samples with the data for +the right channel positioned after the data for the left channel. This +generally resulted in an unwanted echo effect. This has been fixed. + +When playing XM files, specifying an invalid instrument would cause an old +note on that channel to come back (roughly speaking). Fast Tracker 2 does not +exhibit this behaviour. This has been fixed. + +The GCC makefiles used -mpentium, which is deprecated in gcc 3.x. This was +generating warnings, and has now been fixed. + +In XM files, the length of a sample is stored in bytes. DUMB was assuming +that the length of a 16-bit sample would be even. I had two XM files where +this was not the case, and DUMB was unable to load them. This has been fixed. + +In order to accommodate the extra part of the version number, +DUMB_REVISION_VERSION has been added. DUMB_VERSION has also been added in +order to facilitate checking if the version of DUMB installed is sufficient. +See docs/dumb.txt for details. + +As a last-minute fix, the XM "Break to row" effect is now loaded properly. It +was necessary to convert from binary-coded decimal to hexadecimal (those who +have experience with Fast Tracker 2 will know what I mean). In short, this +means the effect will now work properly when breaking to row 10 or greater. + +DUMB v0.8 had faulty release date constants; DUMB_MONTH and DUMB_DAY were +swapped! For this reason, DUMB_DATE should not be compared against any date +in 2002. This note has been added to docs/dumb.txt and also to dumb.h. + +Please scroll to the end and read the release notes for the first version, +DUMB v0.7. Most of them apply equally to this release. However, the +non-portable code was rewritten for DUMB v0.8, so that point does not apply. +The point about length not being calculated also applies to XM files. + +Enjoy :) + + +**************************************** +*** DUMB v0.8, released 14 June 2002 *** +**************************************** + +Welcome to the second release of DUMB! + +In addition to these notes, please read below the release notes for the +previous version, DUMB v0.7. Most of them apply equally to this release. +However, the non-portable code has been rewritten; DUMB should now port to +big-endian platforms. + +The main improvement in this release of DUMB is the support for XM files. +Enormous thanks go to Julien Cugniere for working on this while I had to +revise for my exams! + +There was a mistake in the makefiles in the last release. The debugging +Allegro interface library was mistakenly named libaldmbd.a instead of +libaldmd.a, meaning you had to compile with -laldmbd, contrary to what the +docs said. Apologies to everyone who lost sleep trying to work out what was +wrong! The reason for using libaldmd.a is to maintain compatibility with +plain DOS, where filenames are limited to eight characters (plus a three- +letter extension). The makefiles have now been changed to match the +information in the docs, so you may have to alter your project files +accordingly. + +The example programs were faulty, and crashed on Windows if they were unable +to load the file. It was also difficult to work out how to exit them (you had +to click the taskbar button that didn't have a window, then press a key). +They have been improved in both these respects. + +I have now added a docs/faq.txt file (Frequently Asked Questions), which is +based on problems and misconceptions people have had with the first release. +Please refer to it before contacting me with problems. + +Thanks to networm for touching up the Unix makefile and writing the +instructions on using it. + +Incidentally, today (Friday 14 June) is the Robinson College May Ball at +Cambridge Uni. God knows why it's called a May Ball if it's in June. I'm not +going myself (72 GBP, and I'd have to wear a suit, ugh), but with all the +noise outside I shall enjoy pumping up the speakers tonight! + + +**************************************** +*** DUMB v0.7, released 2 March 2002 *** +**************************************** + +This is the first release of DUMB, and parts of the library are not +crystallised. Don't let this put you off! Provided you don't try to use any +features that aren't documented in docs/dumb.txt, the library should be rock +solid and you should be able to upgrade more or less without problems. + +Here are some notes on this release: + +- There is some non-portable code in this release of DUMB. It is likely that + the library will fail to load IT files with compressed samples on + big-endian machines such as the Apple Macintosh. + +- If your program ever aborts with exit code 37 while loading an IT file, + PLEASE LET ME KNOW! The IT file in question has a stereo compressed sample + in it, and the format is unspecified for this case (Impulse Tracker itself + doesn't use stereo samples at all). I will need the IT file in question, + and any information you can give me about how the IT file was created (e.g. + what program). (If you don't get to see an exit code, let me know anyway.) + +- If your program ever outputs a line resembling "Inst 01 Env: 0,64 8,32 + 15,48" to stderr while loading an IT file, PLEASE LET ME KNOW! You have an + old IT file (saved by an Impulse Tracker version older than 2.00), and + support for such files is untested. + +- The length of IT and S3M files is not currently calculated. It is just set + to ten minutes. diff --git a/dumb/src/core/dumbfile.c b/dumb/src/core/dumbfile.c index b776d038d4..4c0cbf7d31 100644 --- a/dumb/src/core/dumbfile.c +++ b/dumb/src/core/dumbfile.c @@ -33,17 +33,14 @@ void DUMBEXPORT register_dumbfile_system(const DUMBFILE_SYSTEM *dfs) ASSERT(dfs->open); ASSERT(dfs->getc); ASSERT(dfs->close); + ASSERT(dfs->seek); + ASSERT(dfs->get_size); the_dfs = dfs; } -struct DUMBFILE -{ - const DUMBFILE_SYSTEM *dfs; - void *file; - int32 pos; -}; +#include "internal/dumbfile.h" @@ -53,7 +50,7 @@ DUMBFILE *DUMBEXPORT dumbfile_open(const char *filename) ASSERT(the_dfs); - f = malloc(sizeof(*f)); + f = (DUMBFILE *) malloc(sizeof(*f)); if (!f) return NULL; @@ -82,7 +79,7 @@ DUMBFILE *DUMBEXPORT dumbfile_open_ex(void *file, const DUMBFILE_SYSTEM *dfs) ASSERT(dfs->getc); ASSERT(file); - f = malloc(sizeof(*f)); + f = (DUMBFILE *) malloc(sizeof(*f)); if (!f) { if (dfs->close) @@ -109,7 +106,7 @@ int32 DUMBEXPORT dumbfile_pos(DUMBFILE *f) -int DUMBEXPORT dumbfile_skip(DUMBFILE *f, int32 n) +int DUMBEXPORT dumbfile_skip(DUMBFILE *f, long n) { int rv; @@ -375,6 +372,26 @@ int32 DUMBEXPORT dumbfile_getnc(char *ptr, int32 n, DUMBFILE *f) +int DUMBEXPORT dumbfile_seek(DUMBFILE *f, long n, int origin) +{ + switch ( origin ) + { + case DFS_SEEK_CUR: n += f->pos; break; + case DFS_SEEK_END: n += (*f->dfs->get_size)(f->file); break; + } + f->pos = n; + return (*f->dfs->seek)(f->file, n); +} + + + +int32 DUMBEXPORT dumbfile_get_size(DUMBFILE *f) +{ + return (*f->dfs->get_size)(f->file); +} + + + int DUMBEXPORT dumbfile_error(DUMBFILE *f) { ASSERT(f); diff --git a/dumb/src/core/rendsig.c b/dumb/src/core/rendsig.c index 72da173c5c..053011a113 100644 --- a/dumb/src/core/rendsig.c +++ b/dumb/src/core/rendsig.c @@ -147,7 +147,15 @@ int DUMBEXPORT duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer) int32 DUMBEXPORT duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer) { - return sigrenderer ? sigrenderer->pos : -1; + DUH_SIGRENDERER_GET_POSITION proc; + + if (!sigrenderer) return -1; + + proc = sigrenderer->desc->sigrenderer_get_position; + if (proc) + return (*proc)(sigrenderer->sigrenderer); + else + return sigrenderer->pos; } diff --git a/dumb/src/helpers/barray.c b/dumb/src/helpers/barray.c index 95fe7af10c..23db09887f 100644 --- a/dumb/src/helpers/barray.c +++ b/dumb/src/helpers/barray.c @@ -53,6 +53,21 @@ void bit_array_set(void * array, size_t bit) } } +void bit_array_set_range(void * array, size_t bit, size_t count) +{ + if (array && count) + { + size_t * size = (size_t *) array; + if (bit < *size) + { + unsigned char * ptr = (unsigned char *)(size + 1); + size_t i; + for (i = bit; i < *size && i < bit + count; ++i) + ptr[i >> 3] |= (1U << (i & 7)); + } + } +} + int bit_array_test(void * array, size_t bit) { if (array) @@ -120,6 +135,21 @@ void bit_array_clear(void * array, size_t bit) } } +void bit_array_clear_range(void * array, size_t bit, size_t count) +{ + if (array && count) + { + size_t * size = (size_t *) array; + if (bit < *size) + { + unsigned char * ptr = (unsigned char *)(size + 1); + size_t i; + for (i = bit; i < *size && i < bit + count; ++i) + ptr[i >> 3] &= ~(1U << (i & 7)); + } + } +} + void bit_array_merge(void * dest, void * source, size_t offset) { if (dest && source) diff --git a/dumb/src/helpers/blip_buf.c b/dumb/src/helpers/blip_buf.c deleted file mode 100644 index 03c111198f..0000000000 --- a/dumb/src/helpers/blip_buf.c +++ /dev/null @@ -1,354 +0,0 @@ -/* blip_buf 1.1.0. http://www.slack.net/~ant/ */ - -#include "internal/blip_buf.h" - -#include -#include -#include -#include - -/* Library Copyright (C) 2003-2009 Shay Green. This library is free software; -you can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -library is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#if defined (BLARGG_TEST) && BLARGG_TEST - #include "blargg_test.h" -#endif - -/* Equivalent to ULONG_MAX >= 0xFFFFFFFF00000000. -Avoids constants that don't fit in 32 bits. */ -#if ULONG_MAX/0xFFFFFFFF > 0xFFFFFFFF - typedef unsigned long fixed_t; - enum { pre_shift = 32 }; - -#elif defined(ULLONG_MAX) - typedef unsigned long long fixed_t; - enum { pre_shift = 32 }; - -#else - typedef unsigned fixed_t; - enum { pre_shift = 0 }; - -#endif - -enum { time_bits = pre_shift + 20 }; - -static fixed_t const time_unit = (fixed_t) 1 << time_bits; - -enum { bass_shift = 9 }; /* affects high-pass filter breakpoint frequency */ -enum { end_frame_extra = 2 }; /* allows deltas slightly after frame length */ - -enum { half_width = 8 }; -enum { buf_extra = half_width*2 + end_frame_extra }; -enum { phase_bits = 5 }; -enum { phase_count = 1 << phase_bits }; -enum { delta_bits = 15 }; -enum { delta_unit = 1 << delta_bits }; -enum { frac_bits = time_bits - pre_shift }; - -/* We could eliminate avail and encode whole samples in offset, but that would -limit the total buffered samples to blip_max_frame. That could only be -increased by decreasing time_bits, which would reduce resample ratio accuracy. -*/ - -/** Sample buffer that resamples to output rate and accumulates samples -until they're read out */ -struct blip_t -{ - fixed_t factor; - fixed_t offset; - int avail; - int size; - int integrator; -}; - -typedef int buf_t; - -/* probably not totally portable */ -#define SAMPLES( buf ) ((buf_t*) ((buf) + 1)) - -/* Arithmetic (sign-preserving) right shift */ -#define ARITH_SHIFT( n, shift ) \ - ((n) >> (shift)) - -enum { max_sample = +32767 }; -enum { min_sample = -32768 }; - -#define CLAMP( n ) \ - {\ - if ( (short) n != n )\ - n = ARITH_SHIFT( n, 16 ) ^ max_sample;\ - } - -static void check_assumptions( void ) -{ - int n; - - #if INT_MAX < 0x7FFFFFFF || UINT_MAX < 0xFFFFFFFF - #error "int must be at least 32 bits" - #endif - - assert( (-3 >> 1) == -2 ); /* right shift must preserve sign */ - - n = max_sample * 2; - CLAMP( n ); - assert( n == max_sample ); - - n = min_sample * 2; - CLAMP( n ); - assert( n == min_sample ); - - assert( blip_max_ratio <= time_unit ); - assert( blip_max_frame <= (fixed_t) -1 >> time_bits ); -} - -blip_t* blip_new( int size ) -{ - blip_t* m; - assert( size >= 0 ); - - m = (blip_t*) malloc( sizeof *m + (size + buf_extra) * sizeof (buf_t) ); - if ( m ) - { - m->factor = time_unit / blip_max_ratio; - m->size = size; - blip_clear( m ); - check_assumptions(); - } - return m; -} - -blip_t* blip_dup( blip_t* m ) -{ - size_t size = sizeof *m + (m->size + buf_extra) * sizeof(buf_t); - blip_t* r = (blip_t*) malloc( size ); - if ( r ) memcpy( r, m, size ); - return r; -} - -void blip_delete( blip_t* m ) -{ - if ( m != NULL ) - { - /* Clear fields in case user tries to use after freeing */ - memset( m, 0, sizeof *m ); - free( m ); - } -} - -void blip_set_rates( blip_t* m, double clock_rate, double sample_rate ) -{ - double factor = time_unit * sample_rate / clock_rate; - m->factor = (fixed_t) factor; - - /* Fails if clock_rate exceeds maximum, relative to sample_rate */ - assert( 0 <= factor - m->factor && factor - m->factor < 1 ); - - /* Avoid requiring math.h. Equivalent to - m->factor = (int) ceil( factor ) */ - if ( m->factor < factor ) - m->factor++; - - /* At this point, factor is most likely rounded up, but could still - have been rounded down in the floating-point calculation. */ -} - -void blip_clear( blip_t* m ) -{ - /* We could set offset to 0, factor/2, or factor-1. 0 is suitable if - factor is rounded up. factor-1 is suitable if factor is rounded down. - Since we don't know rounding direction, factor/2 accommodates either, - with the slight loss of showing an error in half the time. Since for - a 64-bit factor this is years, the halving isn't a problem. */ - - m->offset = m->factor / 2; - m->avail = 0; - m->integrator = 0; - memset( SAMPLES( m ), 0, (m->size + buf_extra) * sizeof (buf_t) ); -} - -int blip_clocks_needed( const blip_t* m, int samples ) -{ - fixed_t needed; - - /* Fails if buffer can't hold that many more samples */ - assert( samples >= 0 && m->avail + samples <= m->size ); - - needed = (fixed_t) samples * time_unit; - if ( needed < m->offset ) - return 0; - - return (int)((needed - m->offset + m->factor - 1) / m->factor); -} - -void blip_end_frame( blip_t* m, unsigned t ) -{ - fixed_t off = t * m->factor + m->offset; - m->avail += (int)(off >> time_bits); - m->offset = off & (time_unit - 1); - - /* Fails if buffer size was exceeded */ - assert( m->avail <= m->size ); -} - -int blip_samples_avail( const blip_t* m ) -{ - return m->avail; -} - -static void remove_samples( blip_t* m, int count ) -{ - buf_t* buf = SAMPLES( m ); - int remain = m->avail + buf_extra - count; - m->avail -= count; - - memmove( &buf [0], &buf [count], remain * sizeof buf [0] ); - memset( &buf [remain], 0, count * sizeof buf [0] ); -} - -int blip_read_samples( blip_t* m, int out [], int count ) -{ - assert( count >= 0 ); - - if ( count > m->avail ) - count = m->avail; - - if ( count ) - { - buf_t const* in = SAMPLES( m ); - buf_t const* end = in + count; - int sum = m->integrator; - do - { - /* Eliminate fraction */ - int s = ARITH_SHIFT( sum, delta_bits - 8 ); - - sum += *in++; - - *out = s; - out++; - - /* High-pass filter */ - sum -= s >> (8 - (delta_bits - bass_shift)); //<< (delta_bits - bass_shift - 8); - } - while ( in != end ); - m->integrator = sum; - - remove_samples( m, count ); - } - - return count; -} - -int blip_peek_sample( blip_t* m ) -{ - return ARITH_SHIFT( m->integrator, delta_bits - 8 ); -} - -/* Things that didn't help performance on x86: - __attribute__((aligned(128))) - #define short int - restrict -*/ - -/* Sinc_Generator( 0.9, 0.55, 4.5 ) */ -static short const bl_step [phase_count + 1] [half_width] = -{ -{ 43, -115, 350, -488, 1136, -914, 5861,21022}, -{ 44, -118, 348, -473, 1076, -799, 5274,21001}, -{ 45, -121, 344, -454, 1011, -677, 4706,20936}, -{ 46, -122, 336, -431, 942, -549, 4156,20829}, -{ 47, -123, 327, -404, 868, -418, 3629,20679}, -{ 47, -122, 316, -375, 792, -285, 3124,20488}, -{ 47, -120, 303, -344, 714, -151, 2644,20256}, -{ 46, -117, 289, -310, 634, -17, 2188,19985}, -{ 46, -114, 273, -275, 553, 117, 1758,19675}, -{ 44, -108, 255, -237, 471, 247, 1356,19327}, -{ 43, -103, 237, -199, 390, 373, 981,18944}, -{ 42, -98, 218, -160, 310, 495, 633,18527}, -{ 40, -91, 198, -121, 231, 611, 314,18078}, -{ 38, -84, 178, -81, 153, 722, 22,17599}, -{ 36, -76, 157, -43, 80, 824, -241,17092}, -{ 34, -68, 135, -3, 8, 919, -476,16558}, -{ 32, -61, 115, 34, -60, 1006, -683,16001}, -{ 29, -52, 94, 70, -123, 1083, -862,15422}, -{ 27, -44, 73, 106, -184, 1152,-1015,14824}, -{ 25, -36, 53, 139, -239, 1211,-1142,14210}, -{ 22, -27, 34, 170, -290, 1261,-1244,13582}, -{ 20, -20, 16, 199, -335, 1301,-1322,12942}, -{ 18, -12, -3, 226, -375, 1331,-1376,12293}, -{ 15, -4, -19, 250, -410, 1351,-1408,11638}, -{ 13, 3, -35, 272, -439, 1361,-1419,10979}, -{ 11, 9, -49, 292, -464, 1362,-1410,10319}, -{ 9, 16, -63, 309, -483, 1354,-1383, 9660}, -{ 7, 22, -75, 322, -496, 1337,-1339, 9005}, -{ 6, 26, -85, 333, -504, 1312,-1280, 8355}, -{ 4, 31, -94, 341, -507, 1278,-1205, 7713}, -{ 3, 35, -102, 347, -506, 1238,-1119, 7082}, -{ 1, 40, -110, 350, -499, 1190,-1021, 6464}, -{ 0, 43, -115, 350, -488, 1136, -914, 5861} -}; - -/* Shifting by pre_shift allows calculation using unsigned int rather than -possibly-wider fixed_t. On 32-bit platforms, this is likely more efficient. -And by having pre_shift 32, a 32-bit platform can easily do the shift by -simply ignoring the low half. */ - -void blip_add_delta( blip_t* m, unsigned time, int delta ) -{ - unsigned fixed = (unsigned) ((time * m->factor + m->offset) >> pre_shift); - buf_t* out = SAMPLES( m ) + m->avail + (fixed >> frac_bits); - - int const phase_shift = frac_bits - phase_bits; - int phase = fixed >> phase_shift & (phase_count - 1); - short const* in = bl_step [phase]; - short const* rev = bl_step [phase_count - phase]; - - int interp = fixed >> (phase_shift - delta_bits) & (delta_unit - 1); - int delta2 = (delta * interp) >> delta_bits; - delta -= delta2; - - /* Fails if buffer size was exceeded */ - assert( out <= &SAMPLES( m ) [m->size + end_frame_extra] ); - - out [0] += in[0]*delta + in[half_width+0]*delta2; - out [1] += in[1]*delta + in[half_width+1]*delta2; - out [2] += in[2]*delta + in[half_width+2]*delta2; - out [3] += in[3]*delta + in[half_width+3]*delta2; - out [4] += in[4]*delta + in[half_width+4]*delta2; - out [5] += in[5]*delta + in[half_width+5]*delta2; - out [6] += in[6]*delta + in[half_width+6]*delta2; - out [7] += in[7]*delta + in[half_width+7]*delta2; - - in = rev; - out [ 8] += in[7]*delta + in[7-half_width]*delta2; - out [ 9] += in[6]*delta + in[6-half_width]*delta2; - out [10] += in[5]*delta + in[5-half_width]*delta2; - out [11] += in[4]*delta + in[4-half_width]*delta2; - out [12] += in[3]*delta + in[3-half_width]*delta2; - out [13] += in[2]*delta + in[2-half_width]*delta2; - out [14] += in[1]*delta + in[1-half_width]*delta2; - out [15] += in[0]*delta + in[0-half_width]*delta2; -} - -void blip_add_delta_fast( blip_t* m, unsigned time, int delta ) -{ - unsigned fixed = (unsigned) ((time * m->factor + m->offset) >> pre_shift); - buf_t* out = SAMPLES( m ) + m->avail + (fixed >> frac_bits); - - int interp = fixed >> (frac_bits - delta_bits) & (delta_unit - 1); - int delta2 = delta * interp; - - /* Fails if buffer size was exceeded */ - assert( out <= &SAMPLES( m ) [m->size + end_frame_extra] ); - - out [7] += delta * delta_unit - delta2; - out [8] += delta2; -} diff --git a/dumb/src/helpers/lpc.c b/dumb/src/helpers/lpc.c new file mode 100644 index 0000000000..ba951ece4a --- /dev/null +++ b/dumb/src/helpers/lpc.c @@ -0,0 +1,320 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: LPC low level routines + last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $ + + ********************************************************************/ + +/* Some of these routines (autocorrelator, LPC coefficient estimator) + are derived from code written by Jutta Degener and Carsten Bormann; + thus we include their copyright below. The entirety of this file + is freely redistributable on the condition that both of these + copyright notices are preserved without modification. */ + +/* Preserved Copyright: *********************************************/ + +/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, +Technische Universita"t Berlin + +Any use of this software is permitted provided that this notice is not +removed and that neither the authors nor the Technische Universita"t +Berlin are deemed to have made any representations as to the +suitability of this software for any purpose nor are held responsible +for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR +THIS SOFTWARE. + +As a matter of courtesy, the authors request to be informed about uses +this software has found, about bugs in this software, and about any +improvements that may be of general interest. + +Berlin, 28.11.1994 +Jutta Degener +Carsten Bormann + +*********************************************************************/ + +#include +#include +#include +#include "internal/stack_alloc.h" +#include "internal/lpc.h" + +/* Autocorrelation LPC coeff generation algorithm invented by + N. Levinson in 1947, modified by J. Durbin in 1959. */ + +/* Input : n elements of time doamin data + Output: m lpc coefficients, excitation energy */ + +float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ + double *aut=alloca(sizeof(*aut)*(m+1)); + double *lpc=alloca(sizeof(*lpc)*(m)); + double error; + double epsilon; + int i,j; + + /* autocorrelation, p+1 lag coefficients */ + j=m+1; + while(j--){ + double d=0; /* double needed for accumulator depth */ + for(i=j;in_samples; n++ ) { + IT_SAMPLE * sample = sigdata->sample + n; + if ( ( sample->flags & ( IT_SAMPLE_EXISTS | IT_SAMPLE_LOOP) ) == IT_SAMPLE_EXISTS ) { + /* If we have enough sample data to train the filter, use the filter to generate the padding */ + if ( sample->length >= lpc_order ) { + lpc_samples = sample->length; + if (lpc_samples > lpc_max) lpc_samples = lpc_max; + offset = sample->length - lpc_samples; + + if ( sample->flags & IT_SAMPLE_STEREO ) + { + if ( sample->flags & IT_SAMPLE_16BIT ) + { + s16 = ( signed short * ) sample->data; + s16 += offset * 2; + for ( o = 0; o < lpc_samples; o++ ) + { + lpc_input[ o ] = s16[ o * 2 + 0 ]; + lpc_input[ o + lpc_max ] = s16[ o * 2 + 1 ]; + } + } + else + { + s8 = ( signed char * ) sample->data; + s8 += offset * 2; + for ( o = 0; o < lpc_samples; o++ ) + { + lpc_input[ o ] = s8[ o * 2 + 0 ]; + lpc_input[ o + lpc_max ] = s8[ o * 2 + 1 ]; + } + } + + vorbis_lpc_from_data( lpc_input, lpc, lpc_samples, lpc_order ); + vorbis_lpc_from_data( lpc_input + lpc_max, lpc + lpc_order, lpc_samples, lpc_order ); + + vorbis_lpc_predict( lpc, lpc_input + lpc_samples - lpc_order, lpc_order, lpc_output, lpc_extra ); + vorbis_lpc_predict( lpc + lpc_order, lpc_input + lpc_max + lpc_samples - lpc_order, lpc_order, lpc_output + lpc_extra, lpc_extra ); + + if ( sample->flags & IT_SAMPLE_16BIT ) + { + s16 = ( signed short * ) realloc( sample->data, ( sample->length + lpc_extra ) * 2 * sizeof(short) ); + sample->data = s16; + + s16 += sample->length * 2; + sample->length += lpc_extra; + + for ( o = 0; o < lpc_extra; o++ ) + { + s16[ o * 2 + 0 ] = (signed short)lpc_output[ o ]; + s16[ o * 2 + 1 ] = (signed short)lpc_output[ o + lpc_extra ]; + } + } + else + { + s8 = ( signed char * ) realloc( sample->data, ( sample->length + lpc_extra ) * 2 ); + sample->data = s8; + + s8 += sample->length * 2; + sample->length += lpc_extra; + + for ( o = 0; o < lpc_extra; o++ ) + { + s8[ o * 2 + 0 ] = (signed char)lpc_output[ o ]; + s8[ o * 2 + 1 ] = (signed char)lpc_output[ o + lpc_extra ]; + } + } + } + else + { + if ( sample->flags & IT_SAMPLE_16BIT ) + { + s16 = ( signed short * ) sample->data; + s16 += offset; + for ( o = 0; o < lpc_samples; o++ ) + { + lpc_input[ o ] = s16[ o ]; + } + } + else + { + s8 = ( signed char * ) sample->data; + s8 += offset; + for ( o = 0; o < lpc_samples; o++ ) + { + lpc_input[ o ] = s8[ o ]; + } + } + + vorbis_lpc_from_data( lpc_input, lpc, lpc_samples, lpc_order ); + + vorbis_lpc_predict( lpc, lpc_input + lpc_samples - lpc_order, lpc_order, lpc_output, lpc_extra ); + + if ( sample->flags & IT_SAMPLE_16BIT ) + { + s16 = ( signed short * ) realloc( sample->data, ( sample->length + lpc_extra ) * sizeof(short) ); + sample->data = s16; + + s16 += sample->length; + sample->length += lpc_extra; + + for ( o = 0; o < lpc_extra; o++ ) + { + s16[ o ] = (signed short)lpc_output[ o ]; + } + } + else + { + s8 = ( signed char * ) realloc( sample->data, sample->length + lpc_extra ); + sample->data = s8; + + s8 += sample->length; + sample->length += lpc_extra; + + for ( o = 0; o < lpc_extra; o++ ) + { + s8[ o ] = (signed char)lpc_output[ o ]; + } + } + } + } + else + /* Otherwise, pad with silence. */ + { + offset = sample->length; + lpc_samples = lpc_extra; + + sample->length += lpc_samples; + + n = 1; + if ( sample->flags & IT_SAMPLE_STEREO ) n *= 2; + if ( sample->flags & IT_SAMPLE_16BIT ) n *= 2; + + offset *= n; + lpc_samples *= n; + + sample->data = realloc( sample->data, offset + lpc_samples ); + memset( (char*)sample->data + offset, 0, lpc_samples ); + } + } + } +} diff --git a/dumb/src/helpers/memfile.c b/dumb/src/helpers/memfile.c index 7324f509fe..19b8d021a0 100644 --- a/dumb/src/helpers/memfile.c +++ b/dumb/src/helpers/memfile.c @@ -28,13 +28,13 @@ typedef struct MEMFILE MEMFILE; struct MEMFILE { - const char *ptr; - int32 left; + const char *ptr, *ptr_begin; + long left, size; }; -static int dumb_memfile_skip(void *f, int32 n) +static int DUMBCALLBACK dumb_memfile_skip(void *f, long n) { MEMFILE *m = f; if (n > m->left) return -1; @@ -45,7 +45,7 @@ static int dumb_memfile_skip(void *f, int32 n) -static int dumb_memfile_getc(void *f) +static int DUMBCALLBACK dumb_memfile_getc(void *f) { MEMFILE *m = f; if (m->left <= 0) return -1; @@ -55,7 +55,7 @@ static int dumb_memfile_getc(void *f) -static int32 dumb_memfile_getnc(char *ptr, int32 n, void *f) +static int32 DUMBCALLBACK dumb_memfile_getnc(char *ptr, int32 n, void *f) { MEMFILE *m = f; if (n > m->left) n = m->left; @@ -67,19 +67,38 @@ static int32 dumb_memfile_getnc(char *ptr, int32 n, void *f) -static void dumb_memfile_close(void *f) +static void DUMBCALLBACK dumb_memfile_close(void *f) { free(f); } +static int DUMBCALLBACK dumb_memfile_seek(void *f, long n) +{ + MEMFILE *m = f; + + m->ptr = m->ptr_begin + n; + m->left = m->size - n; + + return 0; +} + + +static long DUMBCALLBACK dumb_memfile_get_size(void *f) +{ + MEMFILE *m = f; + return m->size; +} + static const DUMBFILE_SYSTEM memfile_dfs = { NULL, &dumb_memfile_skip, &dumb_memfile_getc, &dumb_memfile_getnc, - &dumb_memfile_close + &dumb_memfile_close, + &dumb_memfile_seek, + &dumb_memfile_get_size }; @@ -89,8 +108,10 @@ DUMBFILE *DUMBEXPORT dumbfile_open_memory(const char *data, int32 size) MEMFILE *m = malloc(sizeof(*m)); if (!m) return NULL; + m->ptr_begin = data; m->ptr = data; m->left = size; + m->size = size; return dumbfile_open_ex(m, &memfile_dfs); } diff --git a/dumb/src/helpers/resamp2.inc b/dumb/src/helpers/resamp2.inc index de65dfb340..0c55fc09cd 100644 --- a/dumb/src/helpers/resamp2.inc +++ b/dumb/src/helpers/resamp2.inc @@ -95,10 +95,8 @@ static int process_pickup(DUMB_RESAMPLER *resampler) #define SET_VOLUME_VARIABLES SET_MONO_DEST_VOLUME_VARIABLES #define RETURN_VOLUME_VARIABLES RETURN_MONO_DEST_VOLUME_VARIABLES #define VOLUMES_ARE_ZERO MONO_DEST_VOLUMES_ARE_ZERO -#define MIX_ALIAS(count) MONO_DEST_MIX_ALIAS(count) -#define PEEK_ALIAS MONO_DEST_PEEK_ALIAS -#define MIX_LINEAR(op, upd, o0, o1) MONO_DEST_MIX_LINEAR(op, upd, o0, o1) -#define MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) MONO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) +#define PEEK_FIR MONO_DEST_PEEK_FIR +#define MIX_FIR MONO_DEST_MIX_FIR #define MIX_ZEROS(op) *dst++ op 0 #include "resamp3.inc" #else @@ -111,26 +109,30 @@ static int process_pickup(DUMB_RESAMPLER *resampler) #define VOLUME_VARIABLES lvol, lvolr, lvold, lvolt, lvolm, rvol, rvolr, rvold, rvolt, rvolm #define SET_VOLUME_VARIABLES { \ if ( volume_left ) { \ - lvolr = (int)(volume_left->volume * 16777216.0); \ - lvold = (int)(volume_left->delta * 16777216.0); \ - lvolt = (int)(volume_left->target * 16777216.0); \ - lvolm = (int)(volume_left->mix * 16777216.0); \ + lvolr = xs_FloorToInt(volume_left->volume * 16777216.f); \ + lvold = xs_FloorToInt(volume_left->delta * 16777216.f); \ + lvolt = xs_FloorToInt(volume_left->target * 16777216.f); \ + lvolm = xs_FloorToInt(volume_left->mix * 16777216.f); \ lvol = MULSCV( lvolr, lvolm ); \ if ( lvolr == lvolt ) volume_left = NULL; \ } else { \ lvol = 0; \ + lvold = 0; \ lvolt = 0; \ + lvolm = 0; \ } \ if ( volume_right ) { \ - rvolr = (int)(volume_right->volume * 16777216.0); \ - rvold = (int)(volume_right->delta * 16777216.0); \ - rvolt = (int)(volume_right->target * 16777216.0); \ - rvolm = (int)(volume_right->mix * 16777216.0); \ + rvolr = xs_FloorToInt(volume_right->volume * 16777216.f); \ + rvold = xs_FloorToInt(volume_right->delta * 16777216.f); \ + rvolt = xs_FloorToInt(volume_right->target * 16777216.f); \ + rvolm = xs_FloorToInt(volume_right->mix * 16777216.f); \ rvol = MULSCV( rvolr, rvolm ); \ if ( rvolr == rvolt ) volume_right = NULL; \ } else { \ rvol = 0; \ + rvold = 0; \ rvolt = 0; \ + rvolm = 0; \ } \ } #define RETURN_VOLUME_VARIABLES { \ @@ -138,21 +140,19 @@ static int process_pickup(DUMB_RESAMPLER *resampler) if ( volume_right ) volume_right->volume = (float)rvolr / 16777216.0f; \ } #define VOLUMES_ARE_ZERO (lvol == 0 && lvolt == 0 && rvol == 0 && rvolt == 0) -#define MIX_ALIAS(count) STEREO_DEST_MIX_ALIAS(count) -#define PEEK_ALIAS STEREO_DEST_PEEK_ALIAS +#define MIX_ALIAS(op, upd, offset) STEREO_DEST_MIX_ALIAS(op, upd, offset) #define MIX_LINEAR(op, upd, o0, o1) STEREO_DEST_MIX_LINEAR(op, upd, o0, o1) #define MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) STEREO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) +#define PEEK_FIR STEREO_DEST_PEEK_FIR +#define MIX_FIR STEREO_DEST_MIX_FIR #define MIX_ZEROS(op) { *dst++ op 0; *dst++ op 0; } #include "resamp3.inc" #undef STEREO_DEST_MIX_CUBIC -#undef MONO_DEST_MIX_CUBIC #undef STEREO_DEST_MIX_LINEAR -#undef MONO_DEST_MIX_LINEAR #undef STEREO_DEST_MIX_ALIAS -#undef MONO_DEST_MIX_ALIAS #undef MONO_DEST_VOLUMES_ARE_ZERO #undef SET_MONO_DEST_VOLUME_VARIABLES #undef RETURN_MONO_DEST_VOLUME_VARIABLES @@ -160,8 +160,13 @@ static int process_pickup(DUMB_RESAMPLER *resampler) #undef MONO_DEST_VOLUME_VARIABLES #undef MONO_DEST_VOLUME_PARAMETERS #undef STEREO_DEST_PEEK_ALIAS -#undef MONO_DEST_PEEK_ALIAS #undef POKE_ALIAS +#undef MONO_DEST_PEEK_FIR +#undef STEREO_DEST_PEEK_FIR +#undef MONO_DEST_MIX_FIR +#undef STEREO_DEST_MIX_FIR +#undef ADVANCE_FIR +#undef POKE_FIR #undef COPYSRC2 #undef COPYSRC #undef DIVIDE_BY_SRC_CHANNELS diff --git a/dumb/src/helpers/resamp3.inc b/dumb/src/helpers/resamp3.inc index 05c0dfbb7e..eb07b357a0 100644 --- a/dumb/src/helpers/resamp3.inc +++ b/dumb/src/helpers/resamp3.inc @@ -50,22 +50,21 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO int VOLUME_VARIABLES; long done; long todo; - LONG_LONG todo64; + double tododbl; int quality; - int blip_samples[256*SRC_CHANNELS]; if (!resampler || resampler->dir == 0) return 0; ASSERT(resampler->dir == -1 || resampler->dir == 1); done = 0; - dt = (int)(delta * 65536.0 + 0.5); - if (dt == 0 || dt == 0x80000000) return 0; - inv_dt = (int)(1.0 / delta * 65536.0 + 0.5); + dt = xs_CRoundToInt(delta * 65536.0); + if (dt == 0 || dt == INT_MIN) return 0; + inv_dt = xs_CRoundToInt(1.0 / delta * 65536.0); SET_VOLUME_VARIABLES; if (VOLUMES_ARE_ZERO) dst = NULL; - init_cubic(); + _dumb_init_cubic(); quality = resampler->quality; @@ -79,16 +78,16 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO dt = -dt; if (resampler->dir < 0) - todo64 = ((((LONG_LONG)(resampler->pos - resampler->start) << 16) + resampler->subpos - dt) / -dt); + tododbl = ((resampler->pos - resampler->start) * 65536.f + (resampler->subpos - dt)) / -dt; else - todo64 = ((((LONG_LONG)(resampler->end - resampler->pos) << 16) - resampler->subpos - 1 + dt) / dt); + tododbl = ((resampler->end - resampler->pos) * 65536.f - (resampler->subpos + 1 - dt)) / dt; - if (todo64 < 0) + if (tododbl <= 0) todo = 0; - else if (todo64 > dst_size - done) + else if (tododbl >= dst_size - done) todo = dst_size - done; else - todo = (long) todo64; + todo = xs_FloorToInt(tododbl); done += todo; @@ -106,34 +105,30 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO subpos = (long)new_subpos & 65535; } else if (quality <= DUMB_RQ_ALIASING) { /* Aliasing, backwards */ - int todo_clocks = todo << 16, todo_clocks_set = todo_clocks; - SRCTYPE xbuf[2*SRC_CHANNELS]; + SRCTYPE xbuf[2*SRC_CHANNELS]; SRCTYPE *x = &xbuf[0]; + SRCTYPE *xstart; COPYSRC(xbuf, 0, resampler->X, 1); COPYSRC(xbuf, 1, resampler->X, 2); - if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536; - while (resampler->last_clock < todo_clocks_set && x < &xbuf[2*SRC_CHANNELS]) { + while (todo && x < &xbuf[2*SRC_CHANNELS]) { // TODO: check what happens when multiple tempo slides occur per row HEAVYASSERT(pos >= resampler->start); - POKE_ALIAS(0); - pos--; - x += SRC_CHANNELS; + MIX_ALIAS(+=, 1, 0); + subpos += dt; + pos += subpos >> 16; + x -= (subpos >> 16) * SRC_CHANNELS; + subpos &= 65535; + todo--; } - x = &src[pos*SRC_CHANNELS]; - while ( todo_clocks ) { - todo_clocks_set = todo_clocks; - if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536; - todo_clocks -= todo_clocks_set; - while ( resampler->last_clock < todo_clocks_set ) - { - POKE_ALIAS(2); - pos--; - x -= SRC_CHANNELS; - } - todo = todo_clocks_set >> 16; - MIX_ALIAS( todo ); - } - } else if (quality <= DUMB_RQ_LINEAR) { + x = xstart = &src[pos*SRC_CHANNELS]; + LOOP4(todo, + MIX_ALIAS(+=, 1, 2); + subpos += dt; + x += (subpos >> 16) * SRC_CHANNELS; + subpos &= 65535; + ); + pos += DIVIDE_BY_SRC_CHANNELS(x - xstart); + } else if (quality <= DUMB_LQ_LINEAR) { /* Linear interpolation, backwards */ SRCTYPE xbuf[3*SRC_CHANNELS]; SRCTYPE *x = &xbuf[1*SRC_CHANNELS]; @@ -159,7 +154,7 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO x += (subpos >> 16) * SRC_CHANNELS; subpos &= 65535; ); - } else { + } else if (quality <= DUMB_LQ_CUBIC) { /* Cubic interpolation, backwards */ SRCTYPE xbuf[6*SRC_CHANNELS]; SRCTYPE *x = &xbuf[3*SRC_CHANNELS]; @@ -187,6 +182,33 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO x += (subpos >> 16) * SRC_CHANNELS; subpos &= 65535; ); + } else { + /* FIR resampling, backwards */ + SRCTYPE *x; + if ( resampler->fir_resampler_ratio != delta ) { + resampler_set_rate( resampler->fir_resampler[0], delta ); + resampler_set_rate( resampler->fir_resampler[1], delta ); + resampler->fir_resampler_ratio = delta; + } + x = &src[pos*SRC_CHANNELS]; + while ( todo ) { + while ( ( resampler_get_free_count( resampler->fir_resampler[0] ) || + (!resampler_get_sample_count( resampler->fir_resampler[0] ) + #if SRC_CHANNELS == 2 + && !resampler_get_sample_count( resampler->fir_resampler[1] ) + #endif + ) ) && pos >= resampler->start ) + { + POKE_FIR(0); + pos--; + x -= SRC_CHANNELS; + } + if ( !resampler_get_sample_count( resampler->fir_resampler[0] ) ) break; + MIX_FIR; + ADVANCE_FIR; + --todo; + } + done -= todo; } diff = diff - pos; overshot = resampler->start - pos - 1; @@ -211,33 +233,29 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO subpos = (long)new_subpos & 65535; } else if (quality <= DUMB_RQ_ALIASING) { /* Aliasing, forwards */ - int todo_clocks = todo << 16, todo_clocks_set = todo_clocks; SRCTYPE xbuf[2*SRC_CHANNELS]; SRCTYPE *x = &xbuf[0]; + SRCTYPE *xstart; COPYSRC(xbuf, 0, resampler->X, 1); COPYSRC(xbuf, 1, resampler->X, 2); - if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536; - while (resampler->last_clock < todo_clocks_set && x < &xbuf[2*SRC_CHANNELS]) { + while (todo && x < &xbuf[2*SRC_CHANNELS]) { HEAVYASSERT(pos < resampler->end); - POKE_ALIAS(0); - pos++; - x += SRC_CHANNELS; + MIX_ALIAS(+=, 1, 0); + subpos += dt; + pos += subpos >> 16; + x += (subpos >> 16) * SRC_CHANNELS; + subpos &= 65535; + todo--; } - x = &src[pos*SRC_CHANNELS]; - while ( todo_clocks ) { - todo_clocks_set = todo_clocks; - if ( todo_clocks_set > 256 * 65536 ) todo_clocks_set = 256 * 65536; - todo_clocks -= todo_clocks_set; - while ( resampler->last_clock < todo_clocks_set ) - { - POKE_ALIAS(-2); - pos++; - x += SRC_CHANNELS; - } - todo = todo_clocks_set >> 16; - MIX_ALIAS( todo ); - } - } else if (quality <= DUMB_RQ_LINEAR) { + x = xstart = &src[pos*SRC_CHANNELS]; + LOOP4(todo, + MIX_ALIAS(+=, 1, -2); + subpos += dt; + x += (subpos >> 16) * SRC_CHANNELS; + subpos &= 65535; + ); + pos += DIVIDE_BY_SRC_CHANNELS(x - xstart); + } else if (quality <= DUMB_LQ_LINEAR) { /* Linear interpolation, forwards */ SRCTYPE xbuf[3*SRC_CHANNELS]; SRCTYPE *x = &xbuf[1*SRC_CHANNELS]; @@ -262,7 +280,7 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO x += (subpos >> 16) * SRC_CHANNELS; subpos &= 65535; ); - } else { + } else if (quality <= DUMB_LQ_CUBIC) { /* Cubic interpolation, forwards */ SRCTYPE xbuf[6*SRC_CHANNELS]; SRCTYPE *x = &xbuf[3*SRC_CHANNELS]; @@ -290,6 +308,33 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO x += (subpos >> 16) * SRC_CHANNELS; subpos &= 65535; ); + } else { + /* FIR resampling, forwards */ + SRCTYPE *x; + if ( resampler->fir_resampler_ratio != delta ) { + resampler_set_rate( resampler->fir_resampler[0], delta ); + resampler_set_rate( resampler->fir_resampler[1], delta ); + resampler->fir_resampler_ratio = delta; + } + x = &src[pos*SRC_CHANNELS]; + while ( todo ) { + while ( ( resampler_get_free_count( resampler->fir_resampler[0] ) || + (!resampler_get_sample_count( resampler->fir_resampler[0] ) + #if SRC_CHANNELS == 2 + && !resampler_get_sample_count( resampler->fir_resampler[1] ) + #endif + ) ) && pos < resampler->end ) + { + POKE_FIR(0); + pos++; + x += SRC_CHANNELS; + } + if ( !resampler_get_sample_count( resampler->fir_resampler[0] ) ) break; + MIX_FIR; + ADVANCE_FIR; + --todo; + } + done -= todo; } diff = pos - diff; overshot = pos - resampler->end; @@ -336,7 +381,7 @@ void dumb_resample_get_current_sample(DUMB_RESAMPLER *resampler, VOLUME_PARAMETE if (VOLUMES_ARE_ZERO) { MIX_ZEROS(=); return; } - init_cubic(); + _dumb_init_cubic(); quality = resampler->quality; @@ -347,27 +392,33 @@ void dumb_resample_get_current_sample(DUMB_RESAMPLER *resampler, VOLUME_PARAMETE if (resampler->dir < 0) { HEAVYASSERT(pos >= resampler->start); - if (dumb_resampling_quality <= DUMB_RQ_ALIASING) { + if (quality <= DUMB_RQ_ALIASING) { /* Aliasing, backwards */ - PEEK_ALIAS; - } else if (quality <= DUMB_RQ_LINEAR) { + MIX_ALIAS(=, 0, 1); + } else if (quality <= DUMB_LQ_LINEAR) { /* Linear interpolation, backwards */ MIX_LINEAR(=, 0, 2, 1); - } else { + } else if (quality <= DUMB_LQ_CUBIC) { /* Cubic interpolation, backwards */ MIX_CUBIC(=, 0, src, x, pos, 2, 1, 0); + } else { + /* FIR resampling, backwards */ + PEEK_FIR; } } else { HEAVYASSERT(pos < resampler->end); - if (dumb_resampling_quality <= DUMB_RQ_ALIASING) { + if (quality <= DUMB_RQ_ALIASING) { /* Aliasing */ - PEEK_ALIAS; - } else if (dumb_resampling_quality <= DUMB_RQ_LINEAR) { + MIX_ALIAS(=, 0, 1); + } else if (quality <= DUMB_LQ_LINEAR) { /* Linear interpolation, forwards */ MIX_LINEAR(=, 0, 1, 2); - } else { + } else if (quality <= DUMB_LQ_CUBIC) { /* Cubic interpolation, forwards */ MIX_CUBIC(=, 0, x, src, 0, 1, 2, pos); + } else { + /* FIR resampling, forwards */ + PEEK_FIR; } } } @@ -375,10 +426,8 @@ void dumb_resample_get_current_sample(DUMB_RESAMPLER *resampler, VOLUME_PARAMETE #undef MIX_ZEROS -#undef MIX_CUBIC -#undef MIX_LINEAR -#undef MIX_ALIAS -#undef PEEK_ALIAS +#undef MIX_FIR +#undef PEEK_FIR #undef VOLUMES_ARE_ZERO #undef SET_VOLUME_VARIABLES #undef RETURN_VOLUME_VARIABLES diff --git a/dumb/src/helpers/resample.c b/dumb/src/helpers/resample.c index 4424a4934a..ddbba29ebc 100644 --- a/dumb/src/helpers/resample.c +++ b/dumb/src/helpers/resample.c @@ -15,11 +15,11 @@ * In order to find a good trade-off between | \ / / * speed and accuracy in this code, some tests | ' / * were carried out regarding the behaviour of \__/ - * int32 int32 ints with gcc. The following code + * long long ints with gcc. The following code * was tested: * * int a, b, c; - * c = ((int32 int32)a * b) >> 16; + * c = ((long long)a * b) >> 16; * * DJGPP GCC Version 3.0.3 generated the following assembly language code for * the multiplication and scaling, leaving the 32-bit result in EAX. @@ -35,7 +35,7 @@ * more cycles, so this method is unsuitable for use in the low-quality * resamplers. * - * Since "int32 int32" is a gcc-specific extension, we use LONG_LONG instead, + * Since "long long" is a gcc-specific extension, we use LONG_LONG instead, * defined in dumb.h. We may investigate later what code MSVC generates, but * if it seems too slow then we suggest you use a good compiler. * @@ -45,6 +45,8 @@ #include #include "dumb.h" +#include "internal/resampler.h" + /* Compile with -DHEAVYDEBUG if you want to make sure the pick-up function is @@ -70,22 +72,87 @@ * specification doesn't override it. The following values are valid: * * 0 - DUMB_RQ_ALIASING - fastest - * 1 - DUMB_RQ_LINEAR - * 2 - DUMB_RQ_CUBIC - nicest + * 1 - DUMB_RQ_BLEP - nicer than aliasing, but slower + * 2 - DUMB_RQ_LINEAR + * 3 - DUMB_RQ_BLAM - band-limited linear interpolation, nice but slower + * 4 - DUMB_RQ_CUBIC + * 5 - DUMB_RQ_FIR - nicest * - * Values outside the range 0-2 will behave the same as the nearest + * Values outside the range 0-4 will behave the same as the nearest * value within the range. */ int dumb_resampling_quality = DUMB_RQ_CUBIC; +#if !defined(_MSC_VER) || !defined(_M_IX86) //#define MULSC(a, b) ((int)((LONG_LONG)(a) * (b) >> 16)) //#define MULSC(a, b) ((a) * ((b) >> 2) >> 14) #define MULSCV(a, b) ((int)((LONG_LONG)(a) * (b) >> 32)) #define MULSC(a, b) ((int)((LONG_LONG)((a) << 4) * ((b) << 12) >> 32)) #define MULSC16(a, b) ((int)((LONG_LONG)((a) << 12) * ((b) << 12) >> 32)) +#else +/* VC++ calls __allmull and __allshr for the above math. I don't know why. + * [Need to check if this still applies to recent versions of the compiler.] */ +static __forceinline unsigned long long MULLL(int a, int b) +{ + __asm mov eax,a + __asm imul b +} +static __forceinline int MULSCV (int a, int b) +{ +#ifndef _DEBUG + union { unsigned long long q; struct { int l, h; }; } val; + val.q = MULLL(a,b); + return val.h; +#else + __asm mov eax,a + __asm imul b + __asm mov eax,edx +#endif +} +#define MULSC(a, b) MULSCV((a) << 4, (b) << 12) +#define MULSC16(a, b) MULSCV((a) << 12, ((b) << 12)) +#endif +/* From xs_Float.h ==============================================*/ +#if __BIG_ENDIAN__ + #define _xs_iman_ 1 +#else + #define _xs_iman_ 0 +#endif //BigEndian_ + +#ifdef __GNUC__ +#define finline inline +#else +#define finline __forceinline +#endif + +union _xs_doubleints +{ + double val; + unsigned int ival[2]; +}; + +static const double _xs_doublemagic = (6755399441055744.0); //2^52 * 1.5, uses limited precisicion to floor +static const double _xs_doublemagicroundeps = (.5f-(1.5e-8)); //almost .5f = .5f - 1e^(number of exp bit) + +static finline int xs_CRoundToInt(double val) +{ + union _xs_doubleints uval; + val += _xs_doublemagic; + uval.val = val; + return uval.ival[_xs_iman_]; +} +static finline int xs_FloorToInt(double val) +{ + union _xs_doubleints uval; + val -= _xs_doublemagicroundeps; + val += _xs_doublemagic; + uval.val = val; + return uval.ival[_xs_iman_]; +} +/* Not from xs_Float.h ==========================================*/ /* Executes the content 'iterator' times. @@ -112,9 +179,6 @@ int dumb_resampling_quality = DUMB_RQ_CUBIC; } \ } #else -/* [RH] Unrolling this makes the object code ~2.5x larger with - * marginal, if any, improvement in performance. - */ #define LOOP4(iterator, CONTENT) \ { \ while ( (iterator)-- ) \ @@ -124,8 +188,6 @@ int dumb_resampling_quality = DUMB_RQ_CUBIC; } #endif - - #define PASTERAW(a, b) a ## b /* This does not expand macros in b ... */ #define PASTE(a, b) PASTERAW(a, b) /* ... but b is expanded during this substitution. */ @@ -161,17 +223,19 @@ int dumb_resampling_quality = DUMB_RQ_CUBIC; static short cubicA0[1025], cubicA1[1025]; -static void init_cubic(void) +void _dumb_init_cubic(void) { unsigned int t; /* 3*1024*1024*1024 is within range if it's unsigned */ static int done = 0; if (done) return; - done = 1; for (t = 0; t < 1025; t++) { /* int casts to pacify warnings about negating unsigned values */ cubicA0[t] = -(int)( t*t*t >> 17) + (int)( t*t >> 6) - (int)(t << 3); - cubicA1[t] = (int)(3*t*t*t >> 17) - (int)(5*t*t >> 7) + (int)(1 << 14); + cubicA1[t] = (int)(3*t*t*t >> 17) - (int)(5*t*t >> 7) + (int)(1 << 14); } + resampler_init(); + + done = 1; } @@ -189,22 +253,15 @@ static void init_cubic(void) #define SRCTYPE sample_t #define SRCBITS 24 -#define ALIAS(x) (x >> 8) +#define ALIAS(x, vol) MULSC(x, vol) #define LINEAR(x0, x1) (x0 + MULSC(x1 - x0, subpos)) -/* -#define SET_CUBIC_COEFFICIENTS(x0, x1, x2, x3) { \ - a = (3 * (x1 - x2) + (x3 - x0)) >> 1; \ - b = ((x2 << 2) + (x0 << 1) - (5 * x1 + x3)) >> 1; \ - c = (x2 - x0) >> 1; \ -} -#define CUBIC(d) MULSC(MULSC(MULSC(MULSC(a, subpos) + b, subpos) + c, subpos) + d, vol) -*/ #define CUBIC(x0, x1, x2, x3) ( \ MULSC(x0, cubicA0[subpos >> 6] << 2) + \ MULSC(x1, cubicA1[subpos >> 6] << 2) + \ MULSC(x2, cubicA1[1 + (subpos >> 6 ^ 1023)] << 2) + \ MULSC(x3, cubicA0[1 + (subpos >> 6 ^ 1023)] << 2)) #define CUBICVOL(x, vol) MULSC(x, vol) +#define FIR(x) (x >> 8) #include "resample.inc" /* Undefine the simplified macros. */ @@ -225,44 +282,30 @@ static void init_cubic(void) #define SUFFIX _16 #define SRCTYPE short #define SRCBITS 16 -#define ALIAS(x) (x) +#define ALIAS(x, vol) (x * vol >> 8) #define LINEAR(x0, x1) ((x0 << 8) + MULSC16(x1 - x0, subpos)) -/* -#define SET_CUBIC_COEFFICIENTS(x0, x1, x2, x3) { \ - a = (3 * (x1 - x2) + (x3 - x0)) << 7; \ - b = ((x2 << 2) + (x0 << 1) - (5 * x1 + x3)) << 7; \ - c = (x2 - x0) << 7; \ -} -#define CUBIC(d) MULSC(MULSC(MULSC(MULSC(a, subpos) + b, subpos) + c, subpos) + (d << 8), vol) -*/ #define CUBIC(x0, x1, x2, x3) ( \ x0 * cubicA0[subpos >> 6] + \ x1 * cubicA1[subpos >> 6] + \ x2 * cubicA1[1 + (subpos >> 6 ^ 1023)] + \ x3 * cubicA0[1 + (subpos >> 6 ^ 1023)]) -#define CUBICVOL(x, vol) (int)((LONG_LONG)(x) * (vol << 10) >> 32) +#define CUBICVOL(x, vol) MULSCV((x), ((vol) << 10)) +#define FIR(x) (x) #include "resample.inc" /* Create resamplers for 8-bit source samples. */ #define SUFFIX _8 #define SRCTYPE signed char #define SRCBITS 8 -#define ALIAS(x) (x << 8) +#define ALIAS(x, vol) (x * vol) #define LINEAR(x0, x1) ((x0 << 16) + (x1 - x0) * subpos) -/* -#define SET_CUBIC_COEFFICIENTS(x0, x1, x2, x3) { \ - a = 3 * (x1 - x2) + (x3 - x0); \ - b = ((x2 << 2) + (x0 << 1) - (5 * x1 + x3)) << 15; \ - c = (x2 - x0) << 15; \ -} -#define CUBIC(d) MULSC(MULSC(MULSC((a * subpos >> 1) + b, subpos) + c, subpos) + (d << 16), vol) -*/ #define CUBIC(x0, x1, x2, x3) (( \ x0 * cubicA0[subpos >> 6] + \ x1 * cubicA1[subpos >> 6] + \ x2 * cubicA1[1 + (subpos >> 6 ^ 1023)] + \ x3 * cubicA0[1 + (subpos >> 6 ^ 1023)]) << 6) -#define CUBICVOL(x, vol) (int)((LONG_LONG)(x) * (vol << 12) >> 32) +#define CUBICVOL(x, vol) MULSCV((x), ((vol) << 12)) +#define FIR(x) (x << 8) #include "resample.inc" diff --git a/dumb/src/helpers/resample.inc b/dumb/src/helpers/resample.inc index 364e36ccd6..ce882f759a 100644 --- a/dumb/src/helpers/resample.inc +++ b/dumb/src/helpers/resample.inc @@ -69,11 +69,11 @@ void dumb_reset_resampler(DUMB_RESAMPLER *resampler, SRCTYPE *src, int src_chann } for (i = 0; i < src_channels*3; i++) resampler->X[i] = 0; resampler->overshot = -1; - resampler->last_clock = 0; - resampler->last_amp[0] = 0; - resampler->last_amp[1] = 0; - blip_clear(resampler->blip_buffer[0]); - blip_clear(resampler->blip_buffer[1]); + resampler->fir_resampler_ratio = 0; + resampler_clear(resampler->fir_resampler[0]); + resampler_clear(resampler->fir_resampler[1]); + resampler_set_quality(resampler->fir_resampler[0], resampler->quality - DUMB_RESAMPLER_BASE); + resampler_set_quality(resampler->fir_resampler[1], resampler->quality - DUMB_RESAMPLER_BASE); } @@ -82,21 +82,6 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, { DUMB_RESAMPLER *resampler = malloc(sizeof(*resampler)); if (!resampler) return NULL; - resampler->blip_buffer[0] = blip_new( 256 ); - if (!resampler->blip_buffer[0]) - { - free(resampler); - return NULL; - } - resampler->blip_buffer[1] = blip_new( 256 ); - if (!resampler->blip_buffer[1]) - { - free(resampler->blip_buffer[0]); - free(resampler); - return NULL; - } - blip_set_rates(resampler->blip_buffer[0], 65536, 1); - blip_set_rates(resampler->blip_buffer[1], 65536, 1); dumb_reset_resampler(resampler, src, src_channels, pos, start, end, quality); return resampler; } @@ -109,6 +94,9 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, if ((vol##d < 0 && vol##r <= vol##t) || \ (vol##d > 0 && vol##r >= vol##t)) { \ pvol->volume = pvol->target; \ + if ( pvol->declick_stage == 0 || \ + pvol->declick_stage >= 3) \ + pvol->declick_stage++; \ pvol = NULL; \ vol = MULSCV( vol##t, vol##m ); \ } else { \ @@ -122,7 +110,7 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, /* Create mono source resampler. */ #define SUFFIX2 _1 #define SRC_CHANNELS 1 -#define DIVIDE_BY_SRC_CHANNELS(x) (x) +#define DIVIDE_BY_SRC_CHANNELS(x) (int)(x) #define COPYSRC(dstarray, dstindex, srcarray, srcindex) (dstarray)[dstindex] = (srcarray)[srcindex] #define COPYSRC2(dstarray, dstindex, condition, srcarray, srcindex) (dstarray)[dstindex] = condition ? (srcarray)[srcindex] : 0 #define MONO_DEST_VOLUME_PARAMETERS DUMB_VOLUME_RAMP_INFO * volume @@ -130,58 +118,27 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, #define MONO_DEST_VOLUME_ZEROS 0, 0 #define SET_MONO_DEST_VOLUME_VARIABLES { \ if ( volume ) { \ - volr = (int)(volume->volume * 16777216.0); \ - vold = (int)(volume->delta * 16777216.0); \ - volt = (int)(volume->target * 16777216.0); \ - volm = (int)(volume->mix * 16777216.0); \ + volr = xs_FloorToInt(volume->volume * 16777216.f); \ + vold = xs_FloorToInt(volume->delta * 16777216.f); \ + volt = xs_FloorToInt(volume->target * 16777216.f); \ + volm = xs_FloorToInt(volume->mix * 16777216.f); \ vol = MULSCV( volr, volm ); \ if ( volr == volt ) volume = NULL; \ } else { \ vol = 0; \ + vold = 0; \ volt = 0; \ + volm = 0; \ } \ } #define RETURN_MONO_DEST_VOLUME_VARIABLES if ( volume ) volume->volume = (float)volr / 16777216.0f #define MONO_DEST_VOLUMES_ARE_ZERO (vol == 0 && volt == 0) -#define POKE_ALIAS(offset) { \ - int delta = ALIAS(x[offset]) - resampler->last_amp[0]; \ - resampler->last_amp[0] += delta; \ - if ( delta ) blip_add_delta( resampler->blip_buffer[0], resampler->last_clock, delta ); \ - resampler->last_clock += inv_dt; \ -} -#define MONO_DEST_PEEK_ALIAS *dst = MULSC( blip_peek_sample( resampler->blip_buffer[0] ), vol ) -#define MONO_DEST_MIX_ALIAS(count) { \ - int n = 0; \ - resampler->last_clock -= count * 65536; \ - blip_end_frame( resampler->blip_buffer[0], count * 65536 ); \ - blip_read_samples( resampler->blip_buffer[0], blip_samples, count ); \ - LOOP4( count, \ - *dst++ += MULSC( blip_samples[n], vol ); \ - n++; \ - UPDATE_VOLUME( volume, vol ); \ - ); \ -} -#define STEREO_DEST_PEEK_ALIAS { \ - int sample = blip_peek_sample( resampler->blip_buffer[0] ); \ - *dst++ = MULSC( sample, lvol ); \ - *dst++ = MULSC( sample, rvol ); \ -} -#define STEREO_DEST_MIX_ALIAS(count) { \ - int sample, n = 0; \ - resampler->last_clock -= count * 65536; \ - blip_end_frame( resampler->blip_buffer[0], count * 65536 ); \ - blip_read_samples( resampler->blip_buffer[0], blip_samples, count ); \ - LOOP4( count, \ - sample = blip_samples[n++]; \ - *dst++ += MULSC( sample, lvol ); \ - *dst++ += MULSC( sample, rvol ); \ - UPDATE_VOLUME( volume_left, lvol ); \ - UPDATE_VOLUME( volume_right, rvol ); \ - ); \ -} -#define MONO_DEST_MIX_LINEAR(op, upd, o0, o1) { \ - *dst++ op MULSC(LINEAR(x[o0], x[o1]), vol); \ - if ( upd ) UPDATE_VOLUME( volume, vol ); \ +#define STEREO_DEST_MIX_ALIAS(op, upd, offset) { \ + int xm = x[offset]; \ + *dst++ op ALIAS(xm, lvol); \ + *dst++ op ALIAS(xm, rvol); \ + if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ + if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } #define STEREO_DEST_MIX_LINEAR(op, upd, o0, o1) { \ int xm = LINEAR(x[o0], x[o1]); \ @@ -190,10 +147,6 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } -#define MONO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) { \ - *dst++ op CUBICVOL(CUBIC(x0[o0], x[o1], x[o2], x3[o3]), vol); \ - if ( upd ) UPDATE_VOLUME( volume, vol ); \ -} #define STEREO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) { \ int xm = CUBIC(x0[o0], x[o1], x[o2], x3[o3]); \ *dst++ op CUBICVOL(xm, lvol); \ @@ -201,12 +154,33 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } +#define POKE_FIR(offset) { \ + resampler_write_sample( resampler->fir_resampler[0], FIR(x[offset]) ); \ +} +#define MONO_DEST_PEEK_FIR *dst = MULSC( resampler_get_sample( resampler->fir_resampler[0] ), vol ) +#define MONO_DEST_MIX_FIR { \ + *dst++ += MULSC( resampler_get_sample( resampler->fir_resampler[0] ), vol ); \ + UPDATE_VOLUME( volume, vol ); \ +} +#define ADVANCE_FIR resampler_remove_sample( resampler->fir_resampler[0], 1 ) +#define STEREO_DEST_PEEK_FIR { \ + int sample = resampler_get_sample( resampler->fir_resampler[0] ); \ + *dst++ = MULSC( sample, lvol ); \ + *dst++ = MULSC( sample, rvol ); \ +} +#define STEREO_DEST_MIX_FIR { \ + int sample = resampler_get_sample( resampler->fir_resampler[0] ); \ + *dst++ += MULSC( sample, lvol ); \ + *dst++ += MULSC( sample, rvol ); \ + UPDATE_VOLUME( volume_left, lvol ); \ + UPDATE_VOLUME( volume_right, rvol ); \ +} #include "resamp2.inc" /* Create stereo source resampler. */ #define SUFFIX2 _2 #define SRC_CHANNELS 2 -#define DIVIDE_BY_SRC_CHANNELS(x) ((x) >> 1) +#define DIVIDE_BY_SRC_CHANNELS(x) (int)((x) >> 1) #define COPYSRC(dstarray, dstindex, srcarray, srcindex) { \ (dstarray)[(dstindex)*2] = (srcarray)[(srcindex)*2]; \ (dstarray)[(dstindex)*2+1] = (srcarray)[(srcindex)*2+1]; \ @@ -226,26 +200,30 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, #define MONO_DEST_VOLUME_ZEROS 0, 0 #define SET_MONO_DEST_VOLUME_VARIABLES { \ if ( volume_left ) { \ - lvolr = (int)(volume_left->volume * 16777216.0); \ - lvold = (int)(volume_left->delta * 16777216.0); \ - lvolt = (int)(volume_left->target * 16777216.0); \ - lvolm = (int)(volume_left->mix * 16777216.0); \ + lvolr = xs_FloorToInt(volume_left->volume * 16777216.f); \ + lvold = xs_FloorToInt(volume_left->delta * 16777216.f); \ + lvolt = xs_FloorToInt(volume_left->target * 16777216.f); \ + lvolm = xs_FloorToInt(volume_left->mix * 16777216.f); \ lvol = MULSCV( lvolr, lvolm ); \ if ( lvolr == lvolt ) volume_left = NULL; \ } else { \ lvol = 0; \ + lvold = 0; \ lvolt = 0; \ + lvolm = 0; \ } \ if ( volume_right ) { \ - rvolr = (int)(volume_right->volume * 16777216.0); \ - rvold = (int)(volume_right->delta * 16777216.0); \ - rvolt = (int)(volume_right->target * 16777216.0); \ - rvolm = (int)(volume_right->mix * 16777216.0); \ + rvolr = xs_FloorToInt(volume_right->volume * 16777216.f); \ + rvold = xs_FloorToInt(volume_right->delta * 16777216.f); \ + rvolt = xs_FloorToInt(volume_right->target * 16777216.f); \ + rvolm = xs_FloorToInt(volume_right->mix * 16777216.f); \ rvol = MULSCV( rvolr, rvolm ); \ if ( rvolr == rvolt ) volume_right = NULL; \ } else { \ rvol = 0; \ + rvold = 0; \ rvolt = 0; \ + rvolm = 0; \ } \ } #define RETURN_MONO_DEST_VOLUME_VARIABLES { \ @@ -253,54 +231,9 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, if ( volume_right ) volume_right->volume = (float)rvolr / 16777216.0f; \ } #define MONO_DEST_VOLUMES_ARE_ZERO (lvol == 0 && lvolt == 0 && rvol == 0 && rvolt == 0) -#define POKE_ALIAS(offset) { \ - int deltal = ALIAS(x[(offset)*2+0]) - resampler->last_amp[0]; \ - int deltar = ALIAS(x[(offset)*2+1]) - resampler->last_amp[1]; \ - resampler->last_amp[0] += deltal; \ - resampler->last_amp[1] += deltar; \ - if ( deltal ) blip_add_delta( resampler->blip_buffer[0], resampler->last_clock, deltal ); \ - if ( deltar ) blip_add_delta( resampler->blip_buffer[1], resampler->last_clock, deltar ); \ - resampler->last_clock += inv_dt; \ -} -#define MONO_DEST_PEEK_ALIAS { \ - *dst = MULSC( blip_peek_sample( resampler->blip_buffer[0] ), lvol ) + \ - MULSC( blip_peek_sample( resampler->blip_buffer[1] ), rvol ); \ -} -#define MONO_DEST_MIX_ALIAS(count) { \ - int n = 0; \ - resampler->last_clock -= count * 65536; \ - blip_end_frame( resampler->blip_buffer[0], count * 65536 ); \ - blip_end_frame( resampler->blip_buffer[1], count * 65536 ); \ - blip_read_samples( resampler->blip_buffer[0], blip_samples, count ); \ - blip_read_samples( resampler->blip_buffer[1], blip_samples + 256, count ); \ - LOOP4( count, \ - *dst++ += MULSC( blip_samples[n], lvol ) + MULSC( blip_samples[256+n], rvol ); \ - n++; \ - UPDATE_VOLUME( volume_left, lvol ); \ - UPDATE_VOLUME( volume_right, rvol ); \ - ); \ -} -#define STEREO_DEST_PEEK_ALIAS { \ - *dst++ = MULSC( blip_peek_sample( resampler->blip_buffer[0] ), lvol ); \ - *dst++ = MULSC( blip_peek_sample( resampler->blip_buffer[1] ), rvol ); \ -} -#define STEREO_DEST_MIX_ALIAS(count) { \ - int n = 0; \ - resampler->last_clock -= count * 65536; \ - blip_end_frame( resampler->blip_buffer[0], count * 65536 ); \ - blip_end_frame( resampler->blip_buffer[1], count * 65536 ); \ - blip_read_samples( resampler->blip_buffer[0], blip_samples, count ); \ - blip_read_samples( resampler->blip_buffer[1], blip_samples + 256, count ); \ - LOOP4( count, \ - *dst++ += MULSC( blip_samples[n], lvol); \ - *dst++ += MULSC( blip_samples[256+n], rvol); \ - n++; \ - UPDATE_VOLUME( volume_left, lvol ); \ - UPDATE_VOLUME( volume_right, rvol ); \ - ); \ -} -#define MONO_DEST_MIX_LINEAR(op, upd, o0, o1) { \ - *dst++ op MULSC(LINEAR(x[(o0)*2], x[(o1)*2]), lvol) + MULSC(LINEAR(x[(o0)*2+1], x[(o1)*2+1]), rvol); \ +#define STEREO_DEST_MIX_ALIAS(op, upd, offset) { \ + *dst++ op ALIAS(x[(offset)*2], lvol); \ + *dst++ op ALIAS(x[(offset)*2+1], rvol); \ if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } @@ -310,19 +243,40 @@ DUMB_RESAMPLER *dumb_start_resampler(SRCTYPE *src, int src_channels, int32 pos, if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } -#define MONO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) { \ - *dst++ op \ - CUBICVOL(CUBIC(x0[(o0)*2], x[(o1)*2], x[(o2)*2], x3[(o3)*2]), lvol) + \ - CUBICVOL(CUBIC(x0[(o0)*2+1], x[(o1)*2+1], x[(o2)*2+1], x3[(o3)*2+1]), rvol); \ - if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ - if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ -} #define STEREO_DEST_MIX_CUBIC(op, upd, x0, x3, o0, o1, o2, o3) { \ *dst++ op CUBICVOL(CUBIC(x0[(o0)*2], x[(o1)*2], x[(o2)*2], x3[(o3)*2]), lvol); \ *dst++ op CUBICVOL(CUBIC(x0[(o0)*2+1], x[(o1)*2+1], x[(o2)*2+1], x3[(o3)*2+1]), rvol); \ if ( upd ) UPDATE_VOLUME( volume_left, lvol ); \ if ( upd ) UPDATE_VOLUME( volume_right, rvol ); \ } +#define POKE_FIR(offset) { \ + resampler_write_sample( resampler->fir_resampler[0], FIR(x[(offset)*2+0]) ); \ + resampler_write_sample( resampler->fir_resampler[1], FIR(x[(offset)*2+1]) ); \ +} +#define MONO_DEST_PEEK_FIR { \ + *dst = MULSC( resampler_get_sample( resampler->fir_resampler[0] ), lvol ) + \ + MULSC( resampler_get_sample( resampler->fir_resampler[1] ), rvol ); \ +} +#define MONO_DEST_MIX_FIR { \ + *dst++ += MULSC( resampler_get_sample( resampler->fir_resampler[0] ), lvol ) + \ + MULSC( resampler_get_sample( resampler->fir_resampler[1] ), rvol ); \ + UPDATE_VOLUME( volume_left, lvol ); \ + UPDATE_VOLUME( volume_right, rvol ); \ +} +#define ADVANCE_FIR { \ + resampler_remove_sample( resampler->fir_resampler[0], 1 ); \ + resampler_remove_sample( resampler->fir_resampler[1], 1 ); \ +} +#define STEREO_DEST_PEEK_FIR { \ + *dst++ = MULSC( resampler_get_sample( resampler->fir_resampler[0] ), lvol ); \ + *dst++ = MULSC( resampler_get_sample( resampler->fir_resampler[1] ), rvol ); \ +} +#define STEREO_DEST_MIX_FIR { \ + *dst++ += MULSC( resampler_get_sample( resampler->fir_resampler[0] ), lvol ); \ + *dst++ += MULSC( resampler_get_sample( resampler->fir_resampler[1] ), rvol ); \ + UPDATE_VOLUME( volume_left, lvol ); \ + UPDATE_VOLUME( volume_right, rvol ); \ +} #include "resamp2.inc" @@ -335,6 +289,7 @@ void dumb_end_resampler(DUMB_RESAMPLER *resampler) +#undef FIR #undef CUBICVOL #undef CUBIC #undef LINEAR diff --git a/dumb/src/helpers/resampler.c b/dumb/src/helpers/resampler.c new file mode 100644 index 0000000000..3ba288ec49 --- /dev/null +++ b/dumb/src/helpers/resampler.c @@ -0,0 +1,1512 @@ +#include +#include +#define _USE_MATH_DEFINES +#include +#if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__)) +#include +#define RESAMPLER_SSE +#endif +#ifdef __APPLE__ +#include +#if TARGET_CPU_ARM || TARGET_CPU_ARM64 +#include +#define RESAMPLER_NEON +#endif +#endif + +#ifdef _MSC_VER +#define ALIGNED _declspec(align(16)) +#else +#define ALIGNED __attribute__((aligned(16))) +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#include "internal/resampler.h" + +enum { RESAMPLER_SHIFT = 10 }; +enum { RESAMPLER_SHIFT_EXTRA = 8 }; +enum { RESAMPLER_RESOLUTION = 1 << RESAMPLER_SHIFT }; +enum { RESAMPLER_RESOLUTION_EXTRA = 1 << (RESAMPLER_SHIFT + RESAMPLER_SHIFT_EXTRA) }; +enum { SINC_WIDTH = 16 }; +enum { SINC_SAMPLES = RESAMPLER_RESOLUTION * SINC_WIDTH }; +enum { CUBIC_SAMPLES = RESAMPLER_RESOLUTION * 4 }; + +typedef union bigint +{ + unsigned long long quad; +#ifndef __BIG_ENDIAN__ + struct { unsigned int lo, hi; }; +#else + struct { unsigned int hi, lo; }; +#endif +} bigint; + +// What works well on 32-bit can make for extra work on 64-bit +#if defined(_M_X64) || defined(__amd64__) || TARGET_CPU_ARM64 +#define CLEAR_HI(p) (p.quad &= 0xffffffffu) +#define ADD_HI(a,p) (a += p.quad >> 32) +#define PHASE_REDUCE(p) (int)(p.quad >> (32 - RESAMPLER_SHIFT)) +#else +#define CLEAR_HI(p) p.hi = 0 +#define ADD_HI(a,p) a += p.hi +// Should be equivalent to (int)(p.quad >> (32 - RESAMPLER_SHIFT)), +// since the high part should get zeroed after every sample. +#define PHASE_REDUCE(p) (p.lo >> (32 - RESAMPLER_SHIFT)) +#endif + +static const float RESAMPLER_BLEP_CUTOFF = 0.90f; +static const float RESAMPLER_BLAM_CUTOFF = 0.93f; +static const float RESAMPLER_SINC_CUTOFF = 0.999f; + +ALIGNED static float cubic_lut[CUBIC_SAMPLES]; + +static float sinc_lut[SINC_SAMPLES + 1]; +static float window_lut[SINC_SAMPLES + 1]; + +enum { resampler_buffer_size = SINC_WIDTH * 4 }; + +static int fEqual(const double b, const double a) +{ + return fabs(a - b) < 1.0e-6; +} + +static double sinc(double x) +{ + return fEqual(x, 0.0) ? 1.0 : sin(x * M_PI) / (x * M_PI); +} + +#ifdef RESAMPLER_SSE +#ifdef _MSC_VER +#include +#elif defined(__clang__) || defined(__GNUC__) +static inline void +__cpuid(int *data, int selector) +{ +#if defined(__PIC__) && defined(__i386__) + asm("xchgl %%ebx, %%esi; cpuid; xchgl %%ebx, %%esi" + : "=a" (data[0]), + "=S" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "0" (selector)); +#elif defined(__PIC__) && defined(__amd64__) + asm("xchg{q} {%%}rbx, %q1; cpuid; xchg{q} {%%}rbx, %q1" + : "=a" (data[0]), + "=&r" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "0" (selector)); +#else + asm("cpuid" + : "=a" (data[0]), + "=b" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "0" (selector)); +#endif +} +#else +#define __cpuid(a,b) memset((a), 0, sizeof(int) * 4) +#endif + +static int query_cpu_feature_sse() { + int buffer[4]; + __cpuid(buffer,1); + if ((buffer[3]&(1<<25)) == 0) return 0; + return 1; +} + +static int resampler_has_sse = 0; +#endif + +void resampler_init(void) +{ + unsigned i; + double dx = (float)(SINC_WIDTH) / SINC_SAMPLES, x = 0.0; + for (i = 0; i < SINC_SAMPLES + 1; ++i, x += dx) + { + double y = x / SINC_WIDTH; +#if 0 + // Blackman + float window = 0.42659 - 0.49656 * cos(M_PI + M_PI * y) + 0.076849 * cos(2.0 * M_PI * y); +#elif 1 + // Nuttal 3 term + double window = 0.40897 + 0.5 * cos(M_PI * y) + 0.09103 * cos(2.0 * M_PI * y); +#elif 0 + // C.R.Helmrich's 2 term window + float window = 0.79445 * cos(0.5 * M_PI * y) + 0.20555 * cos(1.5 * M_PI * y); +#elif 0 + // Lanczos + float window = sinc(y); +#endif + sinc_lut[i] = (float)(fabs(x) < SINC_WIDTH ? sinc(x) : 0.0); + window_lut[i] = (float)window; + } + dx = 1.0 / RESAMPLER_RESOLUTION; + x = 0.0; + for (i = 0; i < RESAMPLER_RESOLUTION; ++i, x += dx) + { + cubic_lut[i*4] = (float)(-0.5 * x * x * x + x * x - 0.5 * x); + cubic_lut[i*4+1] = (float)( 1.5 * x * x * x - 2.5 * x * x + 1.0); + cubic_lut[i*4+2] = (float)(-1.5 * x * x * x + 2.0 * x * x + 0.5 * x); + cubic_lut[i*4+3] = (float)( 0.5 * x * x * x - 0.5 * x * x); + } +#ifdef RESAMPLER_SSE + resampler_has_sse = query_cpu_feature_sse(); +#endif +} + +typedef struct resampler +{ + int write_pos, write_filled; + int read_pos, read_filled; + bigint phase; + bigint phase_inc; + bigint inv_phase; + bigint inv_phase_inc; + unsigned char quality; + signed char delay_added; + signed char delay_removed; + double last_amp; + double accumulator; + float buffer_in[resampler_buffer_size * 2]; + float buffer_out[resampler_buffer_size + SINC_WIDTH * 2 - 1]; +} resampler; + +void * resampler_create(void) +{ + resampler * r = ( resampler * ) malloc( sizeof(resampler) ); + if ( !r ) return 0; + + r->write_pos = SINC_WIDTH - 1; + r->write_filled = 0; + r->read_pos = 0; + r->read_filled = 0; + r->phase.quad = 0; + r->phase_inc.quad = 0; + r->inv_phase.quad = 0; + r->inv_phase_inc.quad = 0; + r->quality = RESAMPLER_QUALITY_MAX; + r->delay_added = -1; + r->delay_removed = -1; + r->last_amp = 0; + r->accumulator = 0; + memset( r->buffer_in, 0, sizeof(r->buffer_in) ); + memset( r->buffer_out, 0, sizeof(r->buffer_out) ); + + return r; +} + +void resampler_delete(void * _r) +{ + free( _r ); +} + +void * resampler_dup(const void * _r) +{ + void * r_out = malloc( sizeof(resampler) ); + if ( !r_out ) return 0; + + resampler_dup_inplace(r_out, _r); + + return r_out; +} + +void resampler_dup_inplace(void *_d, const void *_s) +{ + const resampler * r_in = ( const resampler * ) _s; + resampler * r_out = ( resampler * ) _d; + + r_out->write_pos = r_in->write_pos; + r_out->write_filled = r_in->write_filled; + r_out->read_pos = r_in->read_pos; + r_out->read_filled = r_in->read_filled; + r_out->phase = r_in->phase; + r_out->phase_inc = r_in->phase_inc; + r_out->inv_phase = r_in->inv_phase; + r_out->inv_phase_inc = r_in->inv_phase_inc; + r_out->quality = r_in->quality; + r_out->delay_added = r_in->delay_added; + r_out->delay_removed = r_in->delay_removed; + r_out->last_amp = r_in->last_amp; + r_out->accumulator = r_in->accumulator; + memcpy( r_out->buffer_in, r_in->buffer_in, sizeof(r_in->buffer_in) ); + memcpy( r_out->buffer_out, r_in->buffer_out, sizeof(r_in->buffer_out) ); +} + +void resampler_set_quality(void *_r, int quality) +{ + resampler * r = ( resampler * ) _r; + if (quality < RESAMPLER_QUALITY_MIN) + quality = RESAMPLER_QUALITY_MIN; + else if (quality > RESAMPLER_QUALITY_MAX) + quality = RESAMPLER_QUALITY_MAX; + if ( r->quality != quality ) + { + if ( quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLEP || + quality == RESAMPLER_QUALITY_BLAM || r->quality == RESAMPLER_QUALITY_BLAM ) + { + r->read_pos = 0; + r->read_filled = 0; + r->last_amp = 0; + r->accumulator = 0; + memset( r->buffer_out, 0, sizeof(r->buffer_out) ); + } + r->delay_added = -1; + r->delay_removed = -1; + } + r->quality = (unsigned char)quality; +} + +int resampler_get_free_count(void *_r) +{ + resampler * r = ( resampler * ) _r; + return resampler_buffer_size - r->write_filled; +} + +static int resampler_min_filled(resampler *r) +{ + switch (r->quality) + { + default: + case RESAMPLER_QUALITY_ZOH: + case RESAMPLER_QUALITY_BLEP: + return 1; + + case RESAMPLER_QUALITY_LINEAR: + case RESAMPLER_QUALITY_BLAM: + return 2; + + case RESAMPLER_QUALITY_CUBIC: + return 4; + + case RESAMPLER_QUALITY_SINC: + return SINC_WIDTH * 2; + } +} + +static int resampler_input_delay(resampler *r) +{ + switch (r->quality) + { + default: + case RESAMPLER_QUALITY_ZOH: + case RESAMPLER_QUALITY_BLEP: + case RESAMPLER_QUALITY_LINEAR: + case RESAMPLER_QUALITY_BLAM: + return 0; + + case RESAMPLER_QUALITY_CUBIC: + return 1; + + case RESAMPLER_QUALITY_SINC: + return SINC_WIDTH - 1; + } +} + +static int resampler_output_delay(resampler *r) +{ + switch (r->quality) + { + default: + case RESAMPLER_QUALITY_ZOH: + case RESAMPLER_QUALITY_LINEAR: + case RESAMPLER_QUALITY_CUBIC: + case RESAMPLER_QUALITY_SINC: + return 0; + + case RESAMPLER_QUALITY_BLEP: + case RESAMPLER_QUALITY_BLAM: + return SINC_WIDTH - 1; + } +} + +int resampler_ready(void *_r) +{ + resampler * r = ( resampler * ) _r; + return r->write_filled > resampler_min_filled(r); +} + +void resampler_clear(void *_r) +{ + resampler * r = ( resampler * ) _r; + r->write_pos = SINC_WIDTH - 1; + r->write_filled = 0; + r->read_pos = 0; + r->read_filled = 0; + r->phase.quad = 0; + r->delay_added = -1; + r->delay_removed = -1; + memset(r->buffer_in, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0])); + memset(r->buffer_in + resampler_buffer_size, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0])); + if (r->quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLAM) + { + r->inv_phase.quad = 0; + r->last_amp = 0; + r->accumulator = 0; + memset(r->buffer_out, 0, sizeof(r->buffer_out)); + } +} + +void resampler_set_rate(void *_r, double new_factor) +{ + resampler * r = ( resampler * ) _r; + r->phase_inc.quad = (long long)(new_factor * 0x100000000ll); + new_factor = 1.0 / new_factor; + r->inv_phase_inc.quad = (long long)(new_factor * 0x100000000ll); +} + +void resampler_write_sample(void *_r, short s) +{ + resampler * r = ( resampler * ) _r; + + if ( r->delay_added < 0 ) + { + r->delay_added = 0; + r->write_filled = resampler_input_delay( r ); + } + + if ( r->write_filled < resampler_buffer_size ) + { + float s32 = s; + s32 *= 256.0; + + r->buffer_in[ r->write_pos ] = s32; + r->buffer_in[ r->write_pos + resampler_buffer_size ] = s32; + + ++r->write_filled; + + r->write_pos = ( r->write_pos + 1 ) % resampler_buffer_size; + } +} + +void resampler_write_sample_fixed(void *_r, int s, unsigned char depth) +{ + resampler * r = ( resampler * ) _r; + + if ( r->delay_added < 0 ) + { + r->delay_added = 0; + r->write_filled = resampler_input_delay( r ); + } + + if ( r->write_filled < resampler_buffer_size ) + { + double s32 = s; + s32 /= (double)(1 << (depth - 1)); + + r->buffer_in[ r->write_pos ] = (float)s32; + r->buffer_in[ r->write_pos + resampler_buffer_size ] = (float)s32; + + ++r->write_filled; + + r->write_pos = ( r->write_pos + 1 ) % resampler_buffer_size; + } +} + +static int resampler_run_zoh(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 1; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + do + { + if ( out >= out_end ) + break; + + *out++ = *in; + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} + +#ifndef RESAMPLER_NEON +static int resampler_run_blep(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 1; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + double last_amp = r->last_amp; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = (int)(RESAMPLER_BLEP_CUTOFF * RESAMPLER_RESOLUTION); + const int window_step = RESAMPLER_RESOLUTION; + + do + { + double sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = *in++ - last_amp; + + if (sample) + { + double kernel[SINC_WIDTH * 2], kernel_sum = 0.0f; + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernel[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + for (i = 0; i < SINC_WIDTH * 2; ++i) + out[i] += (float)(sample * kernel[i]); + } + + inv_phase.quad += inv_phase_inc.quad; + + ADD_HI(out, inv_phase); + + CLEAR_HI(inv_phase); + } + while ( in < in_end ); + + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_SSE +static int resampler_run_blep_sse(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 1; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + double last_amp = r->last_amp; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = (int)(RESAMPLER_BLEP_CUTOFF * RESAMPLER_RESOLUTION); + const int window_step = RESAMPLER_RESOLUTION; + + do + { + double sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = *in++ - last_amp; + + if (sample) + { + float kernel_sum = 0.0f; + __m128 kernel[SINC_WIDTH / 2]; + __m128 temp1, temp2; + __m128 samplex; + float *kernelf = (float*)(&kernel); + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + samplex = _mm_set1_ps( (float)sample ); + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = _mm_load_ps( (const float *)( kernel + i ) ); + temp1 = _mm_mul_ps( temp1, samplex ); + temp2 = _mm_loadu_ps( (const float *) out + i * 4 ); + temp1 = _mm_add_ps( temp1, temp2 ); + _mm_storeu_ps( (float *) out + i * 4, temp1 ); + } + } + + inv_phase.quad += inv_phase_inc.quad; + + ADD_HI(out, inv_phase); + + CLEAR_HI(inv_phase); + } + while ( in < in_end ); + + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_NEON +static int resampler_run_blep(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 1; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + float last_amp = r->last_amp; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = RESAMPLER_BLEP_CUTOFF * RESAMPLER_RESOLUTION; + const int window_step = RESAMPLER_RESOLUTION; + + do + { + float sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = *in++ - last_amp; + + if (sample) + { + float kernel_sum = 0.0f; + float32x4_t kernel[SINC_WIDTH / 2]; + float32x4_t temp1, temp2; + float32x4_t samplex; + float *kernelf = (float*)(&kernel); + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + samplex = vdupq_n_f32(sample); + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = vld1q_f32( (const float32_t *)( kernel + i ) ); + temp2 = vld1q_f32( (const float32_t *) out + i * 4 ); + temp2 = vmlaq_f32( temp2, temp1, samplex ); + vst1q_f32( (float32_t *) out + i * 4, temp2 ); + } + } + + inv_phase.quad += inv_phase_inc.quad; + + ADD_HI(out, inv_phase); + + CLEAR_HI(inv_phase); + } + while ( in < in_end ); + + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +static int resampler_run_linear(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + do + { + if ( out >= out_end ) + break; + + *out++ = (float)(in[0] + (in[1] - in[0]) * phase.lo * (1.f / 0x100000000ll)); + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} + +#ifndef RESAMPLER_NEON +static int resampler_run_blam(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + double last_amp = r->last_amp; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = (int)(RESAMPLER_BLAM_CUTOFF * RESAMPLER_RESOLUTION); + const int window_step = RESAMPLER_RESOLUTION; + + do + { + double sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = in[0]; + if (phase_inc.quad < 0x100000000ll) + sample += (in[1] - in[0]) * phase.quad * (1.f / 0x100000000ll); + sample -= last_amp; + + if (sample) + { + double kernel[SINC_WIDTH * 2], kernel_sum = 0.0f; + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernel[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + for (i = 0; i < SINC_WIDTH * 2; ++i) + out[i] += (float)(sample * kernel[i]); + } + + if (inv_phase_inc.quad < 0x100000000ll) + { + ++in; + inv_phase.quad += inv_phase_inc.quad; + ADD_HI(out, inv_phase); + CLEAR_HI(inv_phase); + } + else + { + phase.quad += phase_inc.quad; + ++out; + ADD_HI(in, phase); + CLEAR_HI(phase); + } + } + while ( in < in_end ); + + r->phase = phase; + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_SSE +static int resampler_run_blam_sse(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + double last_amp = r->last_amp; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = (int)(RESAMPLER_BLAM_CUTOFF * RESAMPLER_RESOLUTION); + const int window_step = RESAMPLER_RESOLUTION; + + do + { + double sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = in[0]; + if (phase_inc.quad < 0x100000000ll) + { + sample += (in[1] - in[0]) * phase.quad * (1.f / 0x100000000ll); + } + sample -= last_amp; + + if (sample) + { + float kernel_sum = 0.0f; + __m128 kernel[SINC_WIDTH / 2]; + __m128 temp1, temp2; + __m128 samplex; + float *kernelf = (float*)(&kernel); + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + samplex = _mm_set1_ps( (float)sample ); + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = _mm_load_ps( (const float *)( kernel + i ) ); + temp1 = _mm_mul_ps( temp1, samplex ); + temp2 = _mm_loadu_ps( (const float *) out + i * 4 ); + temp1 = _mm_add_ps( temp1, temp2 ); + _mm_storeu_ps( (float *) out + i * 4, temp1 ); + } + } + + if (inv_phase_inc.quad < 0x100000000ll) + { + ++in; + inv_phase.quad += inv_phase_inc.quad; + ADD_HI(out, inv_phase); + CLEAR_HI(inv_phase); + } + else + { + phase.quad += phase_inc.quad; + ++out; + + if (phase.quad >= 0x100000000ll) + { + ++in; + CLEAR_HI(phase); + } + } + } + while ( in < in_end ); + + r->phase = phase; + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_NEON +static int resampler_run_blam(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + float last_amp = r->last_amp; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + bigint inv_phase = r->inv_phase; + bigint inv_phase_inc = r->inv_phase_inc; + + const int step = RESAMPLER_BLAM_CUTOFF * RESAMPLER_RESOLUTION; + const int window_step = RESAMPLER_RESOLUTION; + + do + { + float sample; + + if ( out + SINC_WIDTH * 2 > out_end ) + break; + + sample = in[0]; + if (phase_inc.quad < 0x100000000ll) + sample += (in[1] - in[0]) * phase; + sample -= last_amp; + + if (sample) + { + float kernel_sum = 0.0; + float32x4_t kernel[SINC_WIDTH / 2]; + float32x4_t temp1, temp2; + float32x4_t samplex; + float *kernelf = (float*)(&kernel); + int phase_reduced = PHASE_REDUCE(inv_phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + int i = SINC_WIDTH; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + last_amp += sample; + sample /= kernel_sum; + samplex = vdupq_n_f32(sample); + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = vld1q_f32( (const float32_t *)( kernel + i ) ); + temp2 = vld1q_f32( (const float32_t *) out + i * 4 ); + temp2 = vmlaq_f32( temp2, temp1, samplex ); + vst1q_f32( (float32_t *) out + i * 4, temp2 ); + } + } + + if (inv_phase_inc.quad < 0x100000000ll) + { + ++in; + inv_phase.quad += inv_phase_inc.quad; + ADD_HI(out, inv_phase); + CLEAR_HI(inv_phase); + } + else + { + phase.quad += phase_inc.quad; + ++out; + + if (phase.quad >= 0x100000000ll) + { + ++in; + CLEAR_HI(phase); + } + } + } + while ( in < in_end ); + + r->phase = phase; + r->inv_phase = inv_phase; + r->last_amp = last_amp; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifndef RESAMPLER_NEON +static int resampler_run_cubic(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 4; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + do + { + float * kernel; + int i; + float sample; + + if ( out >= out_end ) + break; + + kernel = cubic_lut + PHASE_REDUCE(phase) * 4; + + for (sample = 0, i = 0; i < 4; ++i) + sample += in[i] * kernel[i]; + *out++ = sample; + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_SSE +static int resampler_run_cubic_sse(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 4; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + do + { + __m128 temp1, temp2; + __m128 samplex = _mm_setzero_ps(); + + if ( out >= out_end ) + break; + + temp1 = _mm_loadu_ps( (const float *)( in ) ); + temp2 = _mm_load_ps( (const float *)( cubic_lut + PHASE_REDUCE(phase) * 4 ) ); + temp1 = _mm_mul_ps( temp1, temp2 ); + samplex = _mm_add_ps( samplex, temp1 ); + temp1 = _mm_movehl_ps( temp1, samplex ); + samplex = _mm_add_ps( samplex, temp1 ); + temp1 = samplex; + temp1 = _mm_shuffle_ps( temp1, samplex, _MM_SHUFFLE(0, 0, 0, 1) ); + samplex = _mm_add_ps( samplex, temp1 ); + _mm_store_ss( out, samplex ); + ++out; + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_NEON +static int resampler_run_cubic(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= 4; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + do + { + float32x4_t temp1, temp2; + float32x2_t half; + + if ( out >= out_end ) + break; + + temp1 = vld1q_f32( (const float32_t *)( in ) ); + temp2 = vld1q_f32( (const float32_t *)( cubic_lut + PHASE_REDUCE(phase) * 4 ) ); + temp1 = vmulq_f32( temp1, temp2 ); + half = vadd_f32(vget_high_f32(temp1), vget_low_f32(temp1)); + *out++ = vget_lane_f32(vpadd_f32(half, half), 0); + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase) + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifndef RESAMPLER_NEON +static int resampler_run_sinc(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= SINC_WIDTH * 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + int step = phase_inc.quad > 0x100000000ll ? + (int)(RESAMPLER_RESOLUTION / (phase_inc.quad * (1.f / 0x100000000ll)) * RESAMPLER_SINC_CUTOFF) : + (int)(RESAMPLER_RESOLUTION * RESAMPLER_SINC_CUTOFF); + int window_step = RESAMPLER_RESOLUTION; + + do + { + double kernel[SINC_WIDTH * 2], kernel_sum = 0.0; + int i = SINC_WIDTH; + int phase_reduced = PHASE_REDUCE(phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + float sample; + + if ( out >= out_end ) + break; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernel[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + for (sample = 0, i = 0; i < SINC_WIDTH * 2; ++i) + sample += (float)(in[i] * kernel[i]); + *out++ = (float)(sample / kernel_sum); + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_SSE +static int resampler_run_sinc_sse(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= SINC_WIDTH * 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + int step = phase_inc.quad > 0x100000000ll ? + (int)(RESAMPLER_RESOLUTION / (phase_inc.quad * (1.f / 0x100000000ll)) * RESAMPLER_SINC_CUTOFF) : + (int)(RESAMPLER_RESOLUTION * RESAMPLER_SINC_CUTOFF); + int window_step = RESAMPLER_RESOLUTION; + + do + { + // accumulate in extended precision + float kernel_sum = 0.0; + __m128 kernel[SINC_WIDTH / 2]; + __m128 temp1, temp2; + __m128 samplex = _mm_setzero_ps(); + float *kernelf = (float*)(&kernel); + int i = SINC_WIDTH; + int phase_reduced = PHASE_REDUCE(phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + + if ( out >= out_end ) + break; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = _mm_loadu_ps( (const float *)( in + i * 4 ) ); + temp2 = _mm_load_ps( (const float *)( kernel + i ) ); + temp1 = _mm_mul_ps( temp1, temp2 ); + samplex = _mm_add_ps( samplex, temp1 ); + } + kernel_sum = 1.0f / kernel_sum; + temp1 = _mm_movehl_ps( temp1, samplex ); + samplex = _mm_add_ps( samplex, temp1 ); + temp1 = samplex; + temp1 = _mm_shuffle_ps( temp1, samplex, _MM_SHUFFLE(0, 0, 0, 1) ); + samplex = _mm_add_ps( samplex, temp1 ); + temp1 = _mm_set_ss( kernel_sum ); + samplex = _mm_mul_ps( samplex, temp1 ); + _mm_store_ss( out, samplex ); + ++out; + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +#ifdef RESAMPLER_NEON +static int resampler_run_sinc(resampler * r, float ** out_, float * out_end) +{ + int in_size = r->write_filled; + float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled; + int used = 0; + in_size -= SINC_WIDTH * 2; + if ( in_size > 0 ) + { + float* out = *out_; + float const* in = in_; + float const* const in_end = in + in_size; + bigint phase = r->phase; + bigint phase_inc = r->phase_inc; + + int step = phase_inc.quad > 0x100000000ll ? + (int)(RESAMPLER_RESOLUTION / (phase_inc.quad * (1.f / 0x100000000ll)) * RESAMPLER_SINC_CUTOFF) : + (int)(RESAMPLER_RESOLUTION * RESAMPLER_SINC_CUTOFF); + int window_step = RESAMPLER_RESOLUTION; + + do + { + // accumulate in extended precision + float kernel_sum = 0.0; + float32x4_t kernel[SINC_WIDTH / 2]; + float32x4_t temp1, temp2; + float32x4_t samplex = {0}; + float32x2_t half; + float *kernelf = (float*)(&kernel); + int i = SINC_WIDTH; + int phase_reduced = PHASE_REDUCE(phase); + int phase_adj = phase_reduced * step / RESAMPLER_RESOLUTION; + + if ( out >= out_end ) + break; + + for (; i >= -SINC_WIDTH + 1; --i) + { + int pos = i * step; + int window_pos = i * window_step; + kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase_reduced - window_pos)]; + } + for (i = 0; i < SINC_WIDTH / 2; ++i) + { + temp1 = vld1q_f32( (const float32_t *)( in + i * 4 ) ); + temp2 = vld1q_f32( (const float32_t *)( kernel + i ) ); + samplex = vmlaq_f32( samplex, temp1, temp2 ); + } + kernel_sum = 1.0 / kernel_sum; + samplex = vmulq_f32(samplex, vmovq_n_f32(kernel_sum)); + half = vadd_f32(vget_high_f32(samplex), vget_low_f32(samplex)); + *out++ = vget_lane_f32(vpadd_f32(half, half), 0); + + phase.quad += phase_inc.quad; + + ADD_HI(in, phase); + + CLEAR_HI(phase); + } + while ( in < in_end ); + + r->phase = phase; + *out_ = out; + + used = (int)(in - in_); + + r->write_filled -= used; + } + + return used; +} +#endif + +static void resampler_fill(resampler * r) +{ + int min_filled = resampler_min_filled(r); + int quality = r->quality; + while ( r->write_filled > min_filled && + r->read_filled < resampler_buffer_size ) + { + int write_pos = ( r->read_pos + r->read_filled ) % resampler_buffer_size; + int write_size = resampler_buffer_size - write_pos; + float * out = r->buffer_out + write_pos; + if ( write_size > ( resampler_buffer_size - r->read_filled ) ) + write_size = resampler_buffer_size - r->read_filled; + switch (quality) + { + case RESAMPLER_QUALITY_ZOH: + resampler_run_zoh( r, &out, out + write_size ); + break; + + case RESAMPLER_QUALITY_BLEP: + { + int used; + int write_extra = 0; + if ( write_pos >= r->read_pos ) + write_extra = r->read_pos; + if ( write_extra > SINC_WIDTH * 2 - 1 ) + write_extra = SINC_WIDTH * 2 - 1; + memcpy( r->buffer_out + resampler_buffer_size, r->buffer_out, write_extra * sizeof(r->buffer_out[0]) ); +#ifdef RESAMPLER_SSE + if ( resampler_has_sse ) + used = resampler_run_blep_sse( r, &out, out + write_size + write_extra ); + else +#endif + used = resampler_run_blep( r, &out, out + write_size + write_extra ); + memcpy( r->buffer_out, r->buffer_out + resampler_buffer_size, write_extra * sizeof(r->buffer_out[0]) ); + if (!used) + return; + break; + } + + case RESAMPLER_QUALITY_LINEAR: + resampler_run_linear( r, &out, out + write_size ); + break; + + case RESAMPLER_QUALITY_BLAM: + { + float * out_ = out; + int write_extra = 0; + if ( write_pos >= r->read_pos ) + write_extra = r->read_pos; + if ( write_extra > SINC_WIDTH * 2 - 1 ) + write_extra = SINC_WIDTH * 2 - 1; + memcpy( r->buffer_out + resampler_buffer_size, r->buffer_out, write_extra * sizeof(r->buffer_out[0]) ); +#ifdef RESAMPLER_SSE + if ( resampler_has_sse ) + resampler_run_blam_sse( r, &out, out + write_size + write_extra ); + else +#endif + resampler_run_blam( r, &out, out + write_size + write_extra ); + memcpy( r->buffer_out, r->buffer_out + resampler_buffer_size, write_extra * sizeof(r->buffer_out[0]) ); + if ( out == out_ ) + return; + break; + } + + case RESAMPLER_QUALITY_CUBIC: +#ifdef RESAMPLER_SSE + if ( resampler_has_sse ) + resampler_run_cubic_sse( r, &out, out + write_size ); + else +#endif + resampler_run_cubic( r, &out, out + write_size ); + break; + + case RESAMPLER_QUALITY_SINC: +#ifdef RESAMPLER_SSE + if ( resampler_has_sse ) + resampler_run_sinc_sse( r, &out, out + write_size ); + else +#endif + resampler_run_sinc( r, &out, out + write_size ); + break; + } + r->read_filled += (int)(out - r->buffer_out - write_pos); + } +} + +static void resampler_fill_and_remove_delay(resampler * r) +{ + resampler_fill( r ); + if ( r->delay_removed < 0 ) + { + int delay = resampler_output_delay( r ); + r->delay_removed = 0; + while ( delay-- ) + resampler_remove_sample( r, 1 ); + } +} + +int resampler_get_sample_count(void *_r) +{ + resampler * r = ( resampler * ) _r; + if ( r->read_filled < 1 && ((r->quality != RESAMPLER_QUALITY_BLEP && r->quality != RESAMPLER_QUALITY_BLAM) || r->inv_phase_inc.quad)) + resampler_fill_and_remove_delay( r ); + return r->read_filled; +} + +int resampler_get_sample(void *_r) +{ + resampler * r = ( resampler * ) _r; + if ( r->read_filled < 1 && r->phase_inc.quad) + resampler_fill_and_remove_delay( r ); + if ( r->read_filled < 1 ) + return 0; + if ( r->quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLAM ) + return (int)(r->buffer_out[ r->read_pos ] + r->accumulator); + else + return (int)r->buffer_out[ r->read_pos ]; +} + +float resampler_get_sample_float(void *_r) +{ + resampler * r = ( resampler * ) _r; + if ( r->read_filled < 1 && r->phase_inc.quad) + resampler_fill_and_remove_delay( r ); + if ( r->read_filled < 1 ) + return 0; + if ( r->quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLAM ) + return (float)(r->buffer_out[ r->read_pos ] + r->accumulator); + else + return r->buffer_out[ r->read_pos ]; +} + +void resampler_remove_sample(void *_r, int decay) +{ + resampler * r = ( resampler * ) _r; + if ( r->read_filled > 0 ) + { + if ( r->quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLAM ) + { + r->accumulator += r->buffer_out[ r->read_pos ]; + r->buffer_out[ r->read_pos ] = 0; + if (decay) + { + r->accumulator -= r->accumulator * (1.0f / 8192.0f); + if (fabs(r->accumulator) < 1e-20f) + r->accumulator = 0; + } + } + --r->read_filled; + r->read_pos = ( r->read_pos + 1 ) % resampler_buffer_size; + } +} diff --git a/dumb/src/helpers/riff.c b/dumb/src/helpers/riff.c index 38e8f2d86d..86906ace9c 100644 --- a/dumb/src/helpers/riff.c +++ b/dumb/src/helpers/riff.c @@ -1,61 +1,59 @@ #include "dumb.h" #include "internal/riff.h" -#include "internal/dumb.h" #include #include -struct riff * riff_parse( unsigned char * ptr, unsigned size, unsigned proper ) +struct riff * riff_parse( DUMBFILE * f, int32 offset, int32 size, unsigned proper ) { unsigned stream_size; struct riff * stream; - if ( size < 8 ) return 0; - if ( ptr[0] != 'R' || ptr[1] != 'I' || ptr[2] != 'F' || ptr[3] != 'F' ) return 0; + if ( size < 8 ) return 0; - stream_size = ptr[4] | ( ptr[5] << 8 ) | ( ptr[6] << 16 ) | ( ptr[7] << 24 ); - if ( stream_size + 8 > size ) return 0; + if ( dumbfile_seek(f, offset, DFS_SEEK_SET) ) return 0; + if ( dumbfile_mgetl(f) != DUMB_ID('R','I','F','F') ) return 0; + + stream_size = dumbfile_igetl(f); + if ( stream_size + 8 > (unsigned)size ) return 0; if ( stream_size < 4 ) return 0; - stream = malloc( sizeof( struct riff ) ); + stream = (struct riff *) malloc( sizeof( struct riff ) ); if ( ! stream ) return 0; - stream->type = ( ptr[8] << 24 ) | ( ptr[9] << 16 ) | ( ptr[10] << 8 ) | ptr[11]; + stream->type = dumbfile_mgetl(f); stream->chunk_count = 0; stream->chunks = 0; - ptr += 12; stream_size -= 4; - while ( stream_size ) + while ( stream_size && !dumbfile_error(f) ) { struct riff_chunk * chunk; if ( stream_size < 8 ) break; - stream->chunks = realloc( stream->chunks, ( stream->chunk_count + 1 ) * sizeof( struct riff_chunk ) ); + stream->chunks = ( struct riff_chunk * ) realloc( stream->chunks, ( stream->chunk_count + 1 ) * sizeof( struct riff_chunk ) ); if ( ! stream->chunks ) break; chunk = stream->chunks + stream->chunk_count; - chunk->type = ( ptr[0] << 24 ) | ( ptr[1] << 16 ) | ( ptr[2] << 8 ) | ptr[3]; - chunk->size = ptr[4] | ( ptr[5] << 8 ) | ( ptr[6] << 16 ) | ( ptr[7] << 24 ); - ptr += 8; + chunk->type = dumbfile_mgetl(f); + chunk->size = dumbfile_igetl(f); + chunk->offset = dumbfile_pos(f); stream_size -= 8; if ( stream_size < chunk->size ) break; - if ( chunk->type == DUMB_ID('R','I','F','F') ) + if ( chunk->type == DUMB_ID('R','I','F','F') ) { - chunk->data = riff_parse( ptr - 8, chunk->size + 8, proper ); - if ( ! chunk->data ) break; + chunk->nested = riff_parse( f, chunk->offset - 8, chunk->size + 8, proper ); + if ( ! chunk->nested ) break; } else { - chunk->data = malloc( chunk->size ); - if ( ! chunk->data ) break; - memcpy( chunk->data, ptr, chunk->size ); + chunk->nested = 0; } - ptr += chunk->size; + dumbfile_seek(f, chunk->offset + chunk->size, DFS_SEEK_SET); stream_size -= chunk->size; if ( proper && ( chunk->size & 1 ) ) { - ++ ptr; + dumbfile_skip(f, 1); -- stream_size; } ++stream->chunk_count; @@ -80,8 +78,7 @@ void riff_free( struct riff * stream ) for ( i = 0; i < stream->chunk_count; ++i ) { struct riff_chunk * chunk = stream->chunks + i; - if ( chunk->type == DUMB_ID('R','I','F','F') ) riff_free( ( struct riff * ) chunk->data ); - else free( chunk->data ); + if ( chunk->nested ) riff_free( chunk->nested ); } free( stream->chunks ); } diff --git a/dumb/src/helpers/stdfile.c b/dumb/src/helpers/stdfile.c index 94d998a4f2..fdacea463c 100644 --- a/dumb/src/helpers/stdfile.c +++ b/dumb/src/helpers/stdfile.c @@ -23,37 +23,79 @@ -static void *dumb_stdfile_open(const char *filename) +typedef struct dumb_stdfile { - return fopen(filename, "rb"); + FILE * file; + long size; +} dumb_stdfile; + + + +static void *DUMBCALLBACK dumb_stdfile_open(const char *filename) +{ + dumb_stdfile * file = ( dumb_stdfile * ) malloc( sizeof(dumb_stdfile) ); + if ( !file ) return 0; + file->file = fopen(filename, "rb"); + fseek(file->file, 0, SEEK_END); + file->size = ftell(file->file); + fseek(file->file, 0, SEEK_SET); + return file; } -static int dumb_stdfile_skip(void *f, int32 n) +static int DUMBCALLBACK dumb_stdfile_skip(void *f, long n) { - return fseek(f, n, SEEK_CUR); + dumb_stdfile * file = ( dumb_stdfile * ) f; + return fseek(file->file, n, SEEK_CUR); } -static int dumb_stdfile_getc(void *f) +static int DUMBCALLBACK dumb_stdfile_getc(void *f) { - return fgetc(f); + dumb_stdfile * file = ( dumb_stdfile * ) f; + return fgetc(file->file); } -static int32 dumb_stdfile_getnc(char *ptr, int32 n, void *f) +static int32 DUMBCALLBACK dumb_stdfile_getnc(char *ptr, int32 n, void *f) { - return (int32)fread(ptr, 1, n, f); + dumb_stdfile * file = ( dumb_stdfile * ) f; + return (int32)fread(ptr, 1, n, file->file); } -static void dumb_stdfile_close(void *f) +static void DUMBCALLBACK dumb_stdfile_close(void *f) { - fclose(f); + dumb_stdfile * file = ( dumb_stdfile * ) f; + fclose(file->file); + free(f); +} + + + +static void DUMBCALLBACK dumb_stdfile_noclose(void *f) +{ + free(f); +} + + + +static int DUMBCALLBACK dumb_stdfile_seek(void *f, long n) +{ + dumb_stdfile * file = ( dumb_stdfile * ) f; + return fseek(file->file, n, SEEK_SET); +} + + + +static long DUMBCALLBACK dumb_stdfile_get_size(void *f) +{ + dumb_stdfile * file = ( dumb_stdfile * ) f; + return file->size; } @@ -63,7 +105,9 @@ static const DUMBFILE_SYSTEM stdfile_dfs = { &dumb_stdfile_skip, &dumb_stdfile_getc, &dumb_stdfile_getnc, - &dumb_stdfile_close + &dumb_stdfile_close, + &dumb_stdfile_seek, + &dumb_stdfile_get_size }; @@ -80,14 +124,23 @@ static const DUMBFILE_SYSTEM stdfile_dfs_leave_open = { &dumb_stdfile_skip, &dumb_stdfile_getc, &dumb_stdfile_getnc, - NULL + &dumb_stdfile_noclose, + &dumb_stdfile_seek, + &dumb_stdfile_get_size }; DUMBFILE *DUMBEXPORT dumbfile_open_stdfile(FILE *p) { - DUMBFILE *d = dumbfile_open_ex(p, &stdfile_dfs_leave_open); + dumb_stdfile * file = ( dumb_stdfile * ) malloc( sizeof(dumb_stdfile) ); + DUMBFILE *d; + if ( !file ) return 0; + file->file = p; + fseek(p, 0, SEEK_END); + file->size = ftell(p); + fseek(p, 0, SEEK_SET); + d = dumbfile_open_ex(file, &stdfile_dfs_leave_open); return d; } diff --git a/dumb/src/helpers/tarray.c b/dumb/src/helpers/tarray.c new file mode 100644 index 0000000000..f3ba422d84 --- /dev/null +++ b/dumb/src/helpers/tarray.c @@ -0,0 +1,175 @@ +#include "internal/tarray.h" + +#include + + /* + Structures which contain the play times of each pattern and row combination in the song, + not guaranteed to be valid for the whole song until the loop status is no longer zero. + The initial count and restart count will both be zero on song start, then both will be + incremented until the song loops. Restart count will be reset to zero on loop for all + rows which have a time equal to or greater than the loop start point, so time keeping + functions will know which timestamp the song is currently located at. + + Timestamp lists are guaranteed to be allocated in blocks of 16 timestamps at a time. + */ + + /* + We don't need full timekeeping because the player loop only wants the first play time + of the loop start order/row. We also don't really want full timekeeping because it + involves a lot of memory allocations, which is also slow. + */ + +#undef FULL_TIMEKEEPING + +typedef struct DUMB_IT_ROW_TIME +{ + unsigned int count, restart_count; +#ifndef FULL_TIMEKEEPING + LONG_LONG first_time; +#else + LONG_LONG * times; +#endif +} DUMB_IT_ROW_TIME; + +void * timekeeping_array_create(size_t size) +{ + size_t * _size = (size_t *) calloc( 1, sizeof(size_t) + sizeof(DUMB_IT_ROW_TIME) * size ); + if ( _size ) { + *_size = size; + } + return _size; +} + +void timekeeping_array_destroy(void * array) +{ +#ifdef FULL_TIMEKEEPING + size_t i; + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + for (i = 0; i < *size; i++) { + if (s[i].times) free(s[i].times); + } +#endif + + free(array); +} + +void * timekeeping_array_dup(void * array) +{ + size_t i; + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + size_t * new_size = (size_t *) calloc( 1, sizeof(size_t) + sizeof(DUMB_IT_ROW_TIME) * *size ); + if ( new_size ) { + DUMB_IT_ROW_TIME * new_s = (DUMB_IT_ROW_TIME *)(new_size + 1); + + *new_size = *size; + + for (i = 0; i < *size; i++) { + new_s[i].count = s[i].count; + new_s[i].restart_count = s[i].restart_count; + +#ifndef FULL_TIMEKEEPING + new_s[i].first_time = s[i].first_time; +#else + if ( s[i].times ) { + size_t time_count = ( s[i].count + 15 ) & ~15; + new_s[i].times = (LONG_LONG *) malloc( sizeof(LONG_LONG) * time_count ); + if ( new_s[i].times == (void *)0 ) { + timekeeping_array_destroy( new_size ); + return (void *) 0; + } + memcpy( new_s[i].times, s[i].times, sizeof(LONG_LONG) * s[i].count ); + } +#endif + } + } + + return new_size; +} + +void timekeeping_array_reset(void * array, size_t loop_start) +{ + size_t i; + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + DUMB_IT_ROW_TIME * s_loop_start = s + loop_start; + LONG_LONG loop_start_time; + + if ( loop_start >= *size || s_loop_start->count < 1 ) return; + +#ifndef FULL_TIMEKEEPING + loop_start_time = s_loop_start->first_time; +#else + loop_start_time = s_loop_start->times[0]; +#endif + + for ( i = 0; i < *size; i++ ) { +#ifndef FULL_TIMEKEEPING + if ( s[i].count && s[i].first_time >= loop_start_time ) { +#else + if ( s[i].count && s[i].times[0] >= loop_start_time ) { +#endif + s[i].restart_count = 0; + } + } +} + +void timekeeping_array_push(void * array, size_t index, LONG_LONG time) +{ +#ifdef FULL_TIMEKEEPING + size_t i; + size_t time_count; +#endif + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + if (index >= *size) return; + +#ifndef FULL_TIMEKEEPING + if ( !s[index].count++ ) + s[index].first_time = time; +#else + time_count = ( s[index].count + 16 ) & ~15; + + s[index].times = (LONG_LONG *) realloc( s[index].times, sizeof(LONG_LONG) * time_count ); + + s[index].times[s[index].count++] = time; +#endif +} + +void timekeeping_array_bump(void * array, size_t index) +{ + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + if (index >= *size) return; + + s[index].restart_count++; +} + +unsigned int timekeeping_array_get_count(void * array, size_t index) +{ + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + if (index >= *size) return 0; + + return s[index].count; +} + +LONG_LONG timekeeping_array_get_item(void * array, size_t index) +{ + size_t * size = (size_t *) array; + DUMB_IT_ROW_TIME * s = (DUMB_IT_ROW_TIME *)(size + 1); + + if (index >= *size || s[index].restart_count >= s[index].count) return 0; + +#ifndef FULL_TIMEKEEPING + return s[index].first_time; +#else + return s[index].times[s[index].restart_count]; +#endif +} diff --git a/dumb/src/it/filter.cpp b/dumb/src/it/filter.cpp index ced641438b..6d2d45d560 100644 --- a/dumb/src/it/filter.cpp +++ b/dumb/src/it/filter.cpp @@ -1,285 +1,285 @@ -#if defined(_DEBUG) && defined(_MSC_VER) -#include -#endif - -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__amd64__) -#ifdef _MSC_VER -#include -#endif -#include -#define HAVE_SSE_VERSION 1 -#endif -#include - -#include "dumb.h" - -extern "C" { -#include "internal/it.h" -} - -#ifdef _M_IX86 -enum { - CPU_HAVE_3DNOW = 1 << 0, - CPU_HAVE_3DNOW_EX = 1 << 1, - CPU_HAVE_SSE = 1 << 2, - CPU_HAVE_SSE2 = 1 << 3, - CPU_HAVE_SSE3 = 1 << 4, -}; - -static bool query_cpu_feature_set(/*unsigned p_value*/) { - __try { - /*if (p_value & (CPU_HAVE_SSE | CPU_HAVE_SSE2 | CPU_HAVE_SSE2))*/ { - int buffer[4]; - __cpuid(buffer,1); - /*if (p_value & CPU_HAVE_SSE)*/ { - if ((buffer[3]&(1<<25)) == 0) return false; - } - /*if (p_value & CPU_HAVE_SSE2) { - if ((buffer[3]&(1<<26)) == 0) return false; - } - if (p_value & CPU_HAVE_SSE3) { - if ((buffer[2]&(1<<0)) == 0) return false; - }*/ - } - -#ifdef _M_IX86 - /*if (p_value & (CPU_HAVE_3DNOW_EX | CPU_HAVE_3DNOW)) { - int buffer_amd[4]; - __cpuid(buffer_amd,0x80000000); - if ((unsigned)buffer_amd[0] < 0x80000001) return false; - __cpuid(buffer_amd,0x80000001); - - if (p_value & CPU_HAVE_3DNOW) { - if ((buffer_amd[3]&(1<<22)) == 0) return false; - } - if (p_value & CPU_HAVE_3DNOW_EX) { - if ((buffer_amd[3]&(1<<30)) == 0) return false; - } - }*/ -#endif - return true; - } __except(1) { - return false; - } -} - -static const bool g_have_sse = query_cpu_feature_set(/*CPU_HAVE_SSE*/); -#elif defined(_M_X64) || defined(__amd64__) - -enum {g_have_sse2 = true, g_have_sse = true, g_have_3dnow = false}; - -#else - -enum {g_have_sse2 = false, g_have_sse = false, g_have_3dnow = false}; - -#endif - -static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance); -static void it_filter_sse(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance); - -extern "C" void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) -{ - if ( g_have_sse ) it_filter_sse(cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance); - else it_filter_int(cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance); -} - -#define LOG10 2.30258509299 -#define MULSCA(a, b) ((int)((LONG_LONG)((a) << 4) * (b) >> 32)) -#define SCALEB 12 - -static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) -{ - //profiler( filter ); - - sample_t currsample = state->currsample; - sample_t prevsample = state->prevsample; - - float a, b, c; - - int32 datasize; - - { - float inv_angle = (float)(sampfreq * pow(0.5, 0.25 + cutoff*(1.0/(24< 2.0f) d = 2.0f; - d = (loss - d) * inv_angle; - e = inv_angle * inv_angle; - a = 1.0f / (1.0f + d + e); - c = -e * a; - b = 1.0f - a - c; -#else - a = 1.0f / (inv_angle*inv_angle + inv_angle*loss + loss); - c = -(inv_angle*inv_angle) * a; - b = 1.0f - a - c; -#endif - } - - dst += pos * step; - datasize = size * step; - -#define INT_FILTERS -#ifdef INT_FILTERS - { - int ai = (int)(a * (1 << (16+SCALEB))); - int bi = (int)(b * (1 << (16+SCALEB))); - int ci = (int)(c * (1 << (16+SCALEB))); - int i; - - if (cr) { - sample_t startstep = MULSCA(src[0], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); - dumb_record_click(cr, pos, startstep); - } - - for (i = 0; i < datasize; i += step) { - { - sample_t newsample = MULSCA(src[i], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); - prevsample = currsample; - currsample = newsample; - } - dst[i] += currsample; - } - - if (cr) { - sample_t endstep = MULSCA(src[datasize], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); - dumb_record_click(cr, pos + size, -endstep); - } - } -#else - if (cr) { - float startstep = src[0]*a + currsample*b + prevsample*c; - dumb_record_click(cr, pos, (sample_t)startstep); - } - - { - int i = size % 3; - while (i > 0) { - { - float newsample = *src*a + currsample*b + prevsample*c; - src += step; - prevsample = currsample; - currsample = newsample; - } - *dst += (sample_t)currsample; - dst += step; - i--; - } - i = size / 3; - while (i > 0) { - float newsample; - /* Gotta love unrolled loops! */ - *dst += (sample_t)(newsample = *src*a + currsample*b + prevsample*c); - src += step; dst += step; - *dst += (sample_t)(prevsample = *src*a + newsample*b + currsample*c); - src += step; dst += step; - *dst += (sample_t)(currsample = *src*a + prevsample*b + newsample*c); - src += step; dst += step; - i--; - } - } - - if (cr) { - float endstep = src[datasize]*a + currsample*b + prevsample*c; - dumb_record_click(cr, pos + size, -(sample_t)endstep); - } -#endif - - state->currsample = currsample; - state->prevsample = prevsample; -} - -#if HAVE_SSE_VERSION -static void it_filter_sse(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) -{ - __m128 data, impulse; - __m128 temp1, temp2; - - sample_t currsample = state->currsample; - sample_t prevsample = state->prevsample; - - float imp[4]; - - //profiler( filter_sse ); On ClawHammer Athlon64 3200+, ~12000 cycles, ~500 for that x87 setup code (as opposed to ~25500 for the original integer code) - - int32 datasize; - - { - float inv_angle = (float)(sampfreq * pow(0.5, 0.25 + cutoff*(1.0/(24< 2.0f) d = 2.0f; - d = (loss - d) * inv_angle; - e = inv_angle * inv_angle; - imp[0] = 1.0f / (1.0f + d + e); - imp[2] = -e * imp[0]; - imp[1] = 1.0f - imp[0] - imp[2]; -#else - imp[0] = 1.0f / (inv_angle*inv_angle + inv_angle*loss + loss); - imp[2] = -(inv_angle*inv_angle) * imp[0]; - imp[1] = 1.0f - imp[0] - imp[2]; -#endif - imp[3] = 0; - } - - dst += pos * step; - datasize = size * step; - - { - int ai, bi, ci, i; - - if (cr) { - sample_t startstep; - ai = (int)(imp[0] * (1 << (16+SCALEB))); - bi = (int)(imp[1] * (1 << (16+SCALEB))); - ci = (int)(imp[2] * (1 << (16+SCALEB))); - startstep = MULSCA(src[0], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); - dumb_record_click(cr, pos, startstep); - } - - data = _mm_cvtsi32_ss( data, prevsample ); - data = _mm_shuffle_ps( data, data, _MM_SHUFFLE(0, 0, 0, 0) ); - data = _mm_cvtsi32_ss( data, currsample ); - impulse = _mm_loadu_ps( (const float *) &imp ); - temp1 = _mm_shuffle_ps( data, data, _MM_SHUFFLE(0, 1, 0, 0) ); - - for (i = 0; i < datasize; i += step) { - data = _mm_cvtsi32_ss( temp1, src [i] ); - temp1 = _mm_mul_ps( data, impulse ); - temp2 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 3, 2) ); - temp1 = _mm_add_ps( temp1, temp2 ); - temp2 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 0, 1) ); - temp1 = _mm_add_ps( temp1, temp2 ); - temp1 = _mm_shuffle_ps( temp1, data, _MM_SHUFFLE(0, 1, 0, 0) ); - dst [i] += _mm_cvtss_si32( temp1 ); - } - - currsample = _mm_cvtss_si32( temp1 ); - temp1 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 0, 2) ); - prevsample = _mm_cvtss_si32( temp1 ); - -#ifndef _M_X64 - _mm_empty(); -#endif - - if (cr) { - sample_t endstep = MULSCA(src[datasize], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); - dumb_record_click(cr, pos + size, -endstep); - } - } - - state->currsample = currsample; - state->prevsample = prevsample; -} -#endif +#if defined(_DEBUG) && defined(_MSC_VER) +#include +#endif + +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__amd64__) +#ifdef _MSC_VER +#include +#endif +#include +#define HAVE_SSE_VERSION 1 +#endif +#include + +#include "dumb.h" + +extern "C" { +#include "internal/it.h" +} + +#ifdef _M_IX86 +enum { + CPU_HAVE_3DNOW = 1 << 0, + CPU_HAVE_3DNOW_EX = 1 << 1, + CPU_HAVE_SSE = 1 << 2, + CPU_HAVE_SSE2 = 1 << 3, + CPU_HAVE_SSE3 = 1 << 4, +}; + +static bool query_cpu_feature_set(/*unsigned p_value*/) { + __try { + /*if (p_value & (CPU_HAVE_SSE | CPU_HAVE_SSE2 | CPU_HAVE_SSE2))*/ { + int buffer[4]; + __cpuid(buffer,1); + /*if (p_value & CPU_HAVE_SSE)*/ { + if ((buffer[3]&(1<<25)) == 0) return false; + } + /*if (p_value & CPU_HAVE_SSE2) { + if ((buffer[3]&(1<<26)) == 0) return false; + } + if (p_value & CPU_HAVE_SSE3) { + if ((buffer[2]&(1<<0)) == 0) return false; + }*/ + } + +#ifdef _M_IX86 + /*if (p_value & (CPU_HAVE_3DNOW_EX | CPU_HAVE_3DNOW)) { + int buffer_amd[4]; + __cpuid(buffer_amd,0x80000000); + if ((unsigned)buffer_amd[0] < 0x80000001) return false; + __cpuid(buffer_amd,0x80000001); + + if (p_value & CPU_HAVE_3DNOW) { + if ((buffer_amd[3]&(1<<22)) == 0) return false; + } + if (p_value & CPU_HAVE_3DNOW_EX) { + if ((buffer_amd[3]&(1<<30)) == 0) return false; + } + }*/ +#endif + return true; + } __except(1) { + return false; + } +} + +static const bool g_have_sse = query_cpu_feature_set(/*CPU_HAVE_SSE*/); +#elif defined(_M_X64) || defined(__amd64__) + +enum {g_have_sse2 = true, g_have_sse = true, g_have_3dnow = false}; + +#else + +enum {g_have_sse2 = false, g_have_sse = false, g_have_3dnow = false}; + +#endif + +static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance); +static void it_filter_sse(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance); + +extern "C" void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) +{ + if ( g_have_sse ) it_filter_sse(cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance); + else it_filter_int(cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance); +} + +#define LOG10 2.30258509299 +#define MULSCA(a, b) ((int)((LONG_LONG)((a) << 4) * (b) >> 32)) +#define SCALEB 12 + +static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) +{ + //profiler( filter ); + + sample_t currsample = state->currsample; + sample_t prevsample = state->prevsample; + + float a, b, c; + + int32 datasize; + + { + float inv_angle = (float)(sampfreq * pow(0.5, 0.25 + cutoff*(1.0/(24< 2.0f) d = 2.0f; + d = (loss - d) * inv_angle; + e = inv_angle * inv_angle; + a = 1.0f / (1.0f + d + e); + c = -e * a; + b = 1.0f - a - c; +#else + a = 1.0f / (inv_angle*inv_angle + inv_angle*loss + loss); + c = -(inv_angle*inv_angle) * a; + b = 1.0f - a - c; +#endif + } + + dst += pos * step; + datasize = size * step; + +#define INT_FILTERS +#ifdef INT_FILTERS + { + int ai = (int)(a * (1 << (16+SCALEB))); + int bi = (int)(b * (1 << (16+SCALEB))); + int ci = (int)(c * (1 << (16+SCALEB))); + int i; + + if (cr) { + sample_t startstep = MULSCA(src[0], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos, startstep); + } + + for (i = 0; i < datasize; i += step) { + { + sample_t newsample = MULSCA(src[i], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + prevsample = currsample; + currsample = newsample; + } + dst[i] += currsample; + } + + if (cr) { + sample_t endstep = MULSCA(src[datasize], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos + size, -endstep); + } + } +#else + if (cr) { + float startstep = src[0]*a + currsample*b + prevsample*c; + dumb_record_click(cr, pos, (sample_t)startstep); + } + + { + int i = size % 3; + while (i > 0) { + { + float newsample = *src*a + currsample*b + prevsample*c; + src += step; + prevsample = currsample; + currsample = newsample; + } + *dst += (sample_t)currsample; + dst += step; + i--; + } + i = size / 3; + while (i > 0) { + float newsample; + /* Gotta love unrolled loops! */ + *dst += (sample_t)(newsample = *src*a + currsample*b + prevsample*c); + src += step; dst += step; + *dst += (sample_t)(prevsample = *src*a + newsample*b + currsample*c); + src += step; dst += step; + *dst += (sample_t)(currsample = *src*a + prevsample*b + newsample*c); + src += step; dst += step; + i--; + } + } + + if (cr) { + float endstep = src[datasize]*a + currsample*b + prevsample*c; + dumb_record_click(cr, pos + size, -(sample_t)endstep); + } +#endif + + state->currsample = currsample; + state->prevsample = prevsample; +} + +#if HAVE_SSE_VERSION +static void it_filter_sse(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) +{ + __m128 data, impulse; + __m128 temp1, temp2; + + sample_t currsample = state->currsample; + sample_t prevsample = state->prevsample; + + float imp[4]; + + //profiler( filter_sse ); On ClawHammer Athlon64 3200+, ~12000 cycles, ~500 for that x87 setup code (as opposed to ~25500 for the original integer code) + + int32 datasize; + + { + float inv_angle = (float)(sampfreq * pow(0.5, 0.25 + cutoff*(1.0/(24< 2.0f) d = 2.0f; + d = (loss - d) * inv_angle; + e = inv_angle * inv_angle; + imp[0] = 1.0f / (1.0f + d + e); + imp[2] = -e * imp[0]; + imp[1] = 1.0f - imp[0] - imp[2]; +#else + imp[0] = 1.0f / (inv_angle*inv_angle + inv_angle*loss + loss); + imp[2] = -(inv_angle*inv_angle) * imp[0]; + imp[1] = 1.0f - imp[0] - imp[2]; +#endif + imp[3] = 0; + } + + dst += pos * step; + datasize = size * step; + + { + int ai, bi, ci, i; + + if (cr) { + sample_t startstep; + ai = (int)(imp[0] * (1 << (16+SCALEB))); + bi = (int)(imp[1] * (1 << (16+SCALEB))); + ci = (int)(imp[2] * (1 << (16+SCALEB))); + startstep = MULSCA(src[0], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos, startstep); + } + + data = _mm_cvtsi32_ss( data, prevsample ); + data = _mm_shuffle_ps( data, data, _MM_SHUFFLE(0, 0, 0, 0) ); + data = _mm_cvtsi32_ss( data, currsample ); + impulse = _mm_loadu_ps( (const float *) &imp ); + temp1 = _mm_shuffle_ps( data, data, _MM_SHUFFLE(0, 1, 0, 0) ); + + for (i = 0; i < datasize; i += step) { + data = _mm_cvtsi32_ss( temp1, src [i] ); + temp1 = _mm_mul_ps( data, impulse ); + temp2 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 3, 2) ); + temp1 = _mm_add_ps( temp1, temp2 ); + temp2 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 0, 1) ); + temp1 = _mm_add_ps( temp1, temp2 ); + temp1 = _mm_shuffle_ps( temp1, data, _MM_SHUFFLE(0, 1, 0, 0) ); + dst [i] += _mm_cvtss_si32( temp1 ); + } + + currsample = _mm_cvtss_si32( temp1 ); + temp1 = _mm_shuffle_ps( temp1, temp1, _MM_SHUFFLE(0, 0, 0, 2) ); + prevsample = _mm_cvtss_si32( temp1 ); + +#ifndef _M_X64 + _mm_empty(); +#endif + + if (cr) { + sample_t endstep = MULSCA(src[datasize], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos + size, -endstep); + } + } + + state->currsample = currsample; + state->prevsample = prevsample; +} +#endif diff --git a/dumb/src/it/itmisc.c b/dumb/src/it/itmisc.c index 5a45d3192e..65b504370b 100644 --- a/dumb/src/it/itmisc.c +++ b/dumb/src/it/itmisc.c @@ -21,6 +21,8 @@ #include "internal/it.h" +int dumb_it_default_panning_separation = 25; + DUMB_IT_SIGDATA *DUMBEXPORT duh_get_it_sigdata(DUH *duh) { diff --git a/dumb/src/it/itread.c b/dumb/src/it/itread.c index 1f29ad4d9e..e8661807e2 100644 --- a/dumb/src/it/itread.c +++ b/dumb/src/it/itread.c @@ -24,80 +24,11 @@ #include "internal/it.h" #ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) #endif -//#define INVESTIGATE_OLD_INSTRUMENTS - - -typedef struct tdumbfile_mem_status -{ - const unsigned char * ptr; - unsigned offset, size; -} dumbfile_mem_status; - -static int dumbfile_mem_skip(void * f, int32 n) -{ - dumbfile_mem_status * s = (dumbfile_mem_status *) f; - s->offset += n; - if (s->offset > s->size) - { - s->offset = s->size; - return 1; - } - - return 0; -} - - - -static int dumbfile_mem_getc(void * f) -{ - dumbfile_mem_status * s = (dumbfile_mem_status *) f; - if (s->offset < s->size) - { - return *(s->ptr + s->offset++); - } - return -1; -} - - - -static int32 dumbfile_mem_getnc(char * ptr, int32 n, void * f) -{ - dumbfile_mem_status * s = (dumbfile_mem_status *) f; - int32 max = s->size - s->offset; - if (max > n) max = n; - if (max) - { - memcpy(ptr, s->ptr + s->offset, max); - s->offset += max; - } - return max; -} - - - -static DUMBFILE_SYSTEM mem_dfs = { - NULL, // open - &dumbfile_mem_skip, - &dumbfile_mem_getc, - &dumbfile_mem_getnc, - NULL // close -}; - - - -static int it_seek(dumbfile_mem_status * s, int32 offset) -{ - if ( (unsigned)offset > s->size ) - return -1; - - s->offset = offset; - - return 0; -} +#define INVESTIGATE_OLD_INSTRUMENTS @@ -178,7 +109,7 @@ static int readbits(int bitwidth, readblock_crap * crap) /** WARNING - do we even need to pass `right`? */ /** WARNING - why bother memsetting at all? The whole array is written... */ // if we do memset, dumb_silence() would be neater... -static int decompress8(DUMBFILE *f, signed char *data, int len, int it215) +static int decompress8(DUMBFILE *f, signed char *data, int len, int it215, int stereo) { int blocklen, blockpos; byte bitwidth; @@ -188,7 +119,8 @@ static int decompress8(DUMBFILE *f, signed char *data, int len, int it215) memset(&crap, 0, sizeof(crap)); - memset(data, 0, len * sizeof(*data)); + for (blocklen = 0, blockpos = 0; blocklen < len; blocklen++, blockpos += 1 + stereo) + data[ blockpos ] = 0; while (len > 0) { //Read a block of compressed data: @@ -254,6 +186,7 @@ static int decompress8(DUMBFILE *f, signed char *data, int len, int it215) * code. Yay, better compression :D */ *data++ = it215 ? d2 : d1; + data += stereo; len--; blockpos++; } @@ -264,7 +197,7 @@ static int decompress8(DUMBFILE *f, signed char *data, int len, int it215) -static int decompress16(DUMBFILE *f, short *data, int len, int it215) +static int decompress16(DUMBFILE *f, short *data, int len, int it215, int stereo) { int blocklen, blockpos; byte bitwidth; @@ -274,7 +207,8 @@ static int decompress16(DUMBFILE *f, short *data, int len, int it215) memset(&crap, 0, sizeof(crap)); - memset(data, 0, len * sizeof(*data)); + for ( blocklen = 0, blockpos = 0; blocklen < len; blocklen++, blockpos += 1 + stereo ) + data[ blockpos ] = 0; while (len > 0) { //Read a block of compressed data: @@ -339,6 +273,7 @@ static int decompress16(DUMBFILE *f, short *data, int len, int it215) * code. Yay, better compression :D */ *data++ = it215 ? d2 : d1; + data += stereo; len--; blockpos++; } @@ -388,7 +323,7 @@ static int it_read_old_instrument(IT_INSTRUMENT *instrument, DUMBFILE *f) // XXX dumbfile_skip(f, 4); - dumbfile_getnc(instrument->filename, 13, f); + dumbfile_getnc((char *)instrument->filename, 13, f); instrument->filename[13] = 0; instrument->volume_envelope.flags = dumbfile_getc(f); @@ -417,7 +352,7 @@ static int it_read_old_instrument(IT_INSTRUMENT *instrument, DUMBFILE *f) */ dumbfile_skip(f, 4); - dumbfile_getnc(instrument->name, 26, f); + dumbfile_getnc((char *)instrument->name, 26, f); instrument->name[26] = 0; /* Skip unused bytes following the Instrument Name. */ @@ -503,7 +438,7 @@ static int it_read_instrument(IT_INSTRUMENT *instrument, DUMBFILE *f, int maxlen dumbfile_skip(f, 4); - dumbfile_getnc(instrument->filename, 13, f); + dumbfile_getnc((char *)instrument->filename, 13, f); instrument->filename[13] = 0; instrument->new_note_action = dumbfile_getc(f); @@ -522,7 +457,7 @@ static int it_read_instrument(IT_INSTRUMENT *instrument, DUMBFILE *f, int maxlen */ dumbfile_skip(f, 4); - dumbfile_getnc(instrument->name, 26, f); + dumbfile_getnc((char *)instrument->name, 26, f); instrument->name[26] = 0; instrument->filter_cutoff = dumbfile_getc(f); @@ -606,14 +541,14 @@ static int it_read_sample_header(IT_SAMPLE *sample, unsigned char *convert, int3 } } - dumbfile_getnc(sample->filename, 13, f); + dumbfile_getnc((char *)sample->filename, 13, f); sample->filename[13] = 0; sample->global_volume = dumbfile_getc(f); sample->flags = dumbfile_getc(f); sample->default_volume = dumbfile_getc(f); - dumbfile_getnc(sample->name, 26, f); + dumbfile_getnc((char *)sample->name, 26, f); sample->name[26] = 0; *convert = dumbfile_getc(f); @@ -683,7 +618,7 @@ int32 _dumb_it_read_sample_data_adpcm4(IT_SAMPLE *sample, DUMBFILE *f) int32 n, len, delta; signed char * ptr, * end; signed char compression_table[16]; - if (dumbfile_getnc(compression_table, 16, f) != 16) + if (dumbfile_getnc((char *)compression_table, 16, f) != 16) return -1; ptr = (signed char *) sample->data; delta = 0; @@ -704,7 +639,7 @@ int32 _dumb_it_read_sample_data_adpcm4(IT_SAMPLE *sample, DUMBFILE *f) } -static int32 it_read_sample_data(int cmwt, IT_SAMPLE *sample, unsigned char convert, DUMBFILE *f) +static int32 it_read_sample_data(IT_SAMPLE *sample, unsigned char convert, DUMBFILE *f) { int32 n; @@ -721,21 +656,22 @@ static int32 it_read_sample_data(int cmwt, IT_SAMPLE *sample, unsigned char conv } else if (sample->flags & 8) { /* If the sample is packed, then we must unpack it. */ - /** WARNING - unresolved business here... test with ModPlug? */ + /* Behavior as defined by greasemonkey's munch.py and observed by XMPlay and OpenMPT */ - if (sample->flags & IT_SAMPLE_STEREO) - //exit(37); // TODO: if this ever happens, maybe sample->length should be doubled below? - return -1; - -/* -//#ifndef STEREO_SAMPLES_COUNT_AS_TWO - ASSERT(!(sample->flags & IT_SAMPLE_STEREO)); -//#endif -*/ - if (sample->flags & IT_SAMPLE_16BIT) - decompress16(f, sample->data, datasize, ((cmwt >= 0x215) && (convert & 4))); - else - decompress8(f, sample->data, datasize, ((cmwt >= 0x215) && (convert & 4))); + if (sample->flags & IT_SAMPLE_STEREO) { + if (sample->flags & IT_SAMPLE_16BIT) { + decompress16(f, (short *) sample->data, datasize >> 1, convert & 4, 1); + decompress16(f, (short *) sample->data + 1, datasize >> 1, convert & 4, 1); + } else { + decompress8(f, (signed char *) sample->data, datasize >> 1, convert & 4, 1); + decompress8(f, (signed char *) sample->data + 1, datasize >> 1, convert & 4, 1); + } + } else { + if (sample->flags & IT_SAMPLE_16BIT) + decompress16(f, (short *) sample->data, datasize, convert & 4, 0); + else + decompress8(f, (signed char *) sample->data, datasize, convert & 4, 0); + } } else if (sample->flags & IT_SAMPLE_16BIT) { if (sample->flags & IT_SAMPLE_STEREO) { if (convert & 2) { @@ -841,7 +777,7 @@ static int it_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buff return -1; /* Read in the pattern data. */ - dumbfile_getnc(buffer, buflen, f); + dumbfile_getnc((char *)buffer, buflen, f); if (dumbfile_error(f)) return -1; @@ -1010,47 +946,8 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) unsigned char *buffer; - unsigned char *file_buffer = NULL; - unsigned int file_size = 0; - int block_size; - - dumbfile_mem_status memdata; - - do - { - void * temp = realloc( file_buffer, file_size + 32768 ); - if ( !temp ) - { - if ( file_buffer ) free( file_buffer ); - return NULL; - } - file_buffer = temp; - block_size = dumbfile_getnc( file_buffer + file_size, 32768, f ); - if ( block_size < 0 ) - { - free( file_buffer ); - return NULL; - } - file_size += block_size; - } - while ( block_size == 32768 ); - - memdata.ptr = file_buffer; - memdata.offset = 0; - memdata.size = file_size; - - f = dumbfile_open_ex(&memdata, &mem_dfs); - - if ( !f ) - { - free( file_buffer ); - return NULL; - } - if (dumbfile_mgetl(f) != IT_SIGNATURE) { - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1058,8 +955,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (!sigdata) { - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1071,7 +966,7 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) sigdata->midi = NULL; sigdata->checkpoint = NULL; - dumbfile_getnc(sigdata->name, 26, f); + dumbfile_getnc((char *)sigdata->name, 26, f); sigdata->name[26] = 0; /* Skip pattern row highlight info. */ @@ -1104,22 +999,18 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) /* Skip Reserved. */ dumbfile_skip(f, 4); - dumbfile_getnc(sigdata->channel_pan, DUMB_IT_N_CHANNELS, f); - dumbfile_getnc(sigdata->channel_volume, DUMB_IT_N_CHANNELS, f); + dumbfile_getnc((char *)sigdata->channel_pan, DUMB_IT_N_CHANNELS, f); + dumbfile_getnc((char *)sigdata->channel_volume, DUMB_IT_N_CHANNELS, f); // XXX sample count if (dumbfile_error(f) || sigdata->n_orders <= 0 || sigdata->n_instruments > 256 || sigdata->n_samples > 4000 || sigdata->n_patterns > 256) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } sigdata->order = malloc(sigdata->n_orders); if (!sigdata->order) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1127,8 +1018,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) sigdata->instrument = malloc(sigdata->n_instruments * sizeof(*sigdata->instrument)); if (!sigdata->instrument) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } } @@ -1137,8 +1026,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) sigdata->sample = malloc(sigdata->n_samples * sizeof(*sigdata->sample)); if (!sigdata->sample) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } for (n = 0; n < sigdata->n_samples; n++) @@ -1149,22 +1036,18 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) sigdata->pattern = malloc(sigdata->n_patterns * sizeof(*sigdata->pattern)); if (!sigdata->pattern) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } for (n = 0; n < sigdata->n_patterns; n++) sigdata->pattern[n].entry = NULL; } - dumbfile_getnc(sigdata->order, sigdata->n_orders, f); + dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f); sigdata->restart_position = 0; component = malloc(769 * sizeof(*component)); if (!component) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1209,8 +1092,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (dumbfile_error(f)) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1231,8 +1112,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (!sigdata->midi) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; // Should we be happy with this outcome in some situations? } @@ -1241,8 +1120,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (dumbfile_error(f) || dumbfile_skip(f, 8*i)) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } /* Read embedded MIDI configuration */ @@ -1250,18 +1127,14 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (dumbfile_skip(f, 32*9)) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } for (i = 0; i < 16; i++) { unsigned char len = 0; int j, leftdigit = -1; - if (dumbfile_getnc(mididata, 32, f) < 32) { + if (dumbfile_getnc((char *)mididata, 32, f) < 32) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } sigdata->midi->SFmacroz[i] = 0; @@ -1291,7 +1164,7 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) for (i = 0; i < 128; i++) { unsigned char len = 0; int j, leftdigit = -1; - dumbfile_getnc(mididata, 32, f); + dumbfile_getnc((char *)mididata, 32, f); for (j = 0; j < 32; j++) { if (leftdigit >= 0) { if (mididata[j] == 0) { @@ -1323,8 +1196,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) if (!buffer) { free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1353,12 +1224,10 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) continue; } - if (it_seek(&memdata, component[n].offset)) { + if (dumbfile_seek(f, component[n].offset, DFS_SEEK_SET)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1370,12 +1239,10 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) } sigdata->song_message = malloc(message_length + 1); if (sigdata->song_message) { - if (dumbfile_getnc(sigdata->song_message, message_length, f) < message_length) { + if (dumbfile_getnc((char *)sigdata->song_message, message_length, f) < message_length) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } sigdata->song_message[message_length] = 0; @@ -1392,8 +1259,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } break; @@ -1403,8 +1268,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } break; @@ -1414,8 +1277,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1442,21 +1303,17 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) m = component[n].sampfirst; while (m >= 0) { - if (it_seek(&memdata, component[m].offset)) { + if (dumbfile_seek(f, component[m].offset, DFS_SEEK_SET)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } - if (it_read_sample_data(cmwt, &sigdata->sample[component[m].n], sample_convert[component[m].n], f)) { + if (it_read_sample_data(&sigdata->sample[component[m].n], sample_convert[component[m].n], f)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - free(file_buffer); return NULL; } @@ -1500,7 +1357,7 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) } mptx_id = dumbfile_igetl( f ); - while ( memdata.offset < file_size ) + while ( !dumbfile_error(f) && dumbfile_pos(f) < dumbfile_get_size(f) ) { unsigned int size = dumbfile_igetw( f ); switch (mptx_id) @@ -1525,9 +1382,6 @@ static sigdata_t *it_load_sigdata(DUMBFILE *f) free(buffer); free(component); - dumbfile_close(f); - free(file_buffer); - _dumb_it_fix_invalid_orders(sigdata); return sigdata; @@ -1549,7 +1403,7 @@ DUH *DUMBEXPORT dumb_read_it_quick(DUMBFILE *f) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "IT"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/itrender.c b/dumb/src/it/itrender.c index d4678ab4ff..36f10adb18 100644 --- a/dumb/src/it/itrender.c +++ b/dumb/src/it/itrender.c @@ -19,16 +19,17 @@ #include #include +#include #include "dumb.h" #include "internal/dumb.h" #include "internal/it.h" +#include "internal/lpc.h" + +#include "internal/resampler.h" // #define BIT_ARRAY_BULLSHIT -#define END_RAMPING -#define RAMP_DOWN - static IT_PLAYING *new_playing(DUMB_IT_SIGRENDERER *itsr) { IT_PLAYING *r; @@ -37,28 +38,23 @@ static IT_PLAYING *new_playing(DUMB_IT_SIGRENDERER *itsr) { r = itsr->free_playing; itsr->free_playing = r->next; - blip_clear(r->resampler.blip_buffer[0]); - blip_clear(r->resampler.blip_buffer[1]); return r; } r = (IT_PLAYING *)malloc(sizeof(IT_PLAYING)); if (r) { - r->resampler.blip_buffer[0] = blip_new( 256 ); - if ( !r->resampler.blip_buffer[0] ) - { + r->resampler.fir_resampler_ratio = 0.0; + r->resampler.fir_resampler[0] = resampler_create(); + if ( !r->resampler.fir_resampler[0] ) { free( r ); return NULL; } - r->resampler.blip_buffer[1] = blip_new( 256 ); - if ( !r->resampler.blip_buffer[1] ) - { - free( r->resampler.blip_buffer[0] ); + r->resampler.fir_resampler[1] = resampler_create(); + if ( !r->resampler.fir_resampler[1] ) { + resampler_delete( r->resampler.fir_resampler[0] ); free( r ); return NULL; } - blip_set_rates(r->resampler.blip_buffer[0], 65536, 1); - blip_set_rates(r->resampler.blip_buffer[1], 65536, 1); } return r; } @@ -71,8 +67,8 @@ static void free_playing(DUMB_IT_SIGRENDERER *itsr, IT_PLAYING *playing) static void free_playing_orig(IT_PLAYING * r) { - blip_delete( r->resampler.blip_buffer[1] ); - blip_delete( r->resampler.blip_buffer[0] ); + resampler_delete( r->resampler.fir_resampler[1] ); + resampler_delete( r->resampler.fir_resampler[0] ); free( r ); } @@ -97,10 +93,7 @@ static IT_PLAYING *dup_playing(IT_PLAYING *src, IT_CHANNEL *dstchannel, IT_CHANN dst->sampnum = src->sampnum; dst->instnum = src->instnum; -#ifdef END_RAMPING dst->declick_stage = src->declick_stage; - dst->declick_volume = src->declick_volume; -#endif dst->float_volume[0] = src->float_volume[0]; dst->float_volume[1] = src->float_volume[1]; @@ -165,16 +158,15 @@ static IT_PLAYING *dup_playing(IT_PLAYING *src, IT_CHANNEL *dstchannel, IT_CHANN dst->resampler = src->resampler; dst->resampler.pickup_data = dst; - dst->resampler.blip_buffer[0] = blip_dup( dst->resampler.blip_buffer[0] ); - if ( !dst->resampler.blip_buffer[0] ) - { + dst->resampler.fir_resampler_ratio = src->resampler.fir_resampler_ratio; + dst->resampler.fir_resampler[0] = resampler_dup( src->resampler.fir_resampler[0] ); + if ( !dst->resampler.fir_resampler[0] ) { free( dst ); return NULL; } - dst->resampler.blip_buffer[1] = blip_dup( dst->resampler.blip_buffer[1] ); - if ( !dst->resampler.blip_buffer[1] ) - { - blip_delete( dst->resampler.blip_buffer[0] ); + dst->resampler.fir_resampler[1] = resampler_dup( src->resampler.fir_resampler[1] ); + if ( !dst->resampler.fir_resampler[1] ) { + resampler_delete( dst->resampler.fir_resampler[0] ); free( dst ); return NULL; } @@ -217,8 +209,8 @@ static void dup_channel(IT_CHANNEL *dst, IT_CHANNEL *src) dst->new_note_action = src->new_note_action; - dst->arpeggio = src->arpeggio; - dst->arpeggio_shift = src->arpeggio_shift; + dst->arpeggio_table = src->arpeggio_table; + memcpy(dst->arpeggio_offsets, src->arpeggio_offsets, sizeof(dst->arpeggio_offsets)); dst->retrig = src->retrig; dst->xm_retrig = src->xm_retrig; dst->retrig_tick = src->retrig_tick; @@ -282,7 +274,6 @@ static void dup_channel(IT_CHANNEL *dst, IT_CHANNEL *src) dst->playing = dup_playing(src->playing, dst, src); - #ifdef BIT_ARRAY_BULLSHIT dst->played_patjump = bit_array_dup(src->played_patjump); dst->played_patjump_order = src->played_patjump_order; @@ -352,12 +343,18 @@ static DUMB_IT_SIGRENDERER *dup_sigrenderer(DUMB_IT_SIGRENDERER *src, int n_chan dst->time_left = src->time_left; dst->sub_time_left = src->sub_time_left; + dst->ramp_style = src->ramp_style; + dst->click_remover = NULL; dst->callbacks = callbacks; #ifdef BIT_ARRAY_BULLSHIT dst->played = bit_array_dup(src->played); + + dst->looped = src->looped; + dst->time_played = src->time_played; + dst->row_timekeeper = timekeeping_array_dup(src->row_timekeeper); #endif dst->gvz_time = src->gvz_time; @@ -570,7 +567,7 @@ extern void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t * * click removal right. */ -static void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) +static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) { sample_t currsample = state->currsample; sample_t prevsample = state->prevsample; @@ -672,7 +669,178 @@ static void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t * state->currsample = currsample; state->prevsample = prevsample; } + +#if defined(_USE_SSE) && (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__)) +#include + +static void it_filter_sse(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, long pos, sample_t *src, long size, int step, int sampfreq, int cutoff, int resonance) +{ + __m128 data, impulse; + __m128 temp1, temp2; + + sample_t currsample = state->currsample; + sample_t prevsample = state->prevsample; + + float imp[4]; + + //profiler( filter_sse ); On ClawHammer Athlon64 3200+, ~12000 cycles, ~500 for that x87 setup code (as opposed to ~25500 for the original integer code) + + long datasize; + + { + float inv_angle = (float)(sampfreq * pow(0.5, 0.25 + cutoff*(1.0/(24< 2.0f) d = 2.0f; + d = (loss - d) * inv_angle; + e = inv_angle * inv_angle; + imp[0] = 1.0f / (1.0f + d + e); + imp[2] = -e * imp[0]; + imp[1] = 1.0f - imp[0] - imp[2]; +#else + imp[0] = 1.0f / (inv_angle*inv_angle + inv_angle*loss + loss); + imp[2] = -(inv_angle*inv_angle) * imp[0]; + imp[1] = 1.0f - imp[0] - imp[2]; +#endif + imp[3] = 0.0f; + } + + dst += pos * step; + datasize = size * step; + + { + int ai, bi, ci, i; + + if (cr) { + sample_t startstep; + ai = (int)(imp[0] * (1 << (16+SCALEB))); + bi = (int)(imp[1] * (1 << (16+SCALEB))); + ci = (int)(imp[2] * (1 << (16+SCALEB))); + startstep = MULSCA(src[0], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos, startstep); + } + + temp1 = _mm_setzero_ps(); + data = _mm_cvtsi32_ss( temp1, currsample ); + temp2 = _mm_cvtsi32_ss( temp1, prevsample ); + impulse = _mm_loadu_ps( (const float *) &imp ); + data = _mm_shuffle_ps( data, temp2, _MM_SHUFFLE(1, 0, 0, 1) ); + + for (i = 0; i < datasize; i += step) { + temp1 = _mm_cvtsi32_ss( data, src [i] ); + temp1 = _mm_mul_ps( temp1, impulse ); + temp2 = _mm_movehl_ps( temp2, temp1 ); + temp1 = _mm_add_ps( temp1, temp2 ); + temp2 = temp1; + temp2 = _mm_shuffle_ps( temp2, temp1, _MM_SHUFFLE(0, 0, 0, 1) ); + temp1 = _mm_add_ps( temp1, temp2 ); + temp1 = _mm_shuffle_ps( temp1, data, _MM_SHUFFLE(2, 1, 0, 0) ); + data = temp1; + dst [i] += _mm_cvtss_si32( temp1 ); + } + + currsample = _mm_cvtss_si32( temp1 ); + temp1 = _mm_shuffle_ps( temp1, data, _MM_SHUFFLE(0, 0, 0, 2) ); + prevsample = _mm_cvtss_si32( temp1 ); + + if (cr) { + sample_t endstep = MULSCA(src[datasize], ai) + MULSCA(currsample, bi) + MULSCA(prevsample, ci); + dumb_record_click(cr, pos + size, -endstep); + } + } + + state->currsample = currsample; + state->prevsample = prevsample; +} +#endif + #undef LOG10 + +#ifdef _USE_SSE +#if defined(_M_IX86) || defined(__i386__) + +#ifdef _MSC_VER +#include +#elif defined(__clang__) || defined(__GNUC__) +static inline void +__cpuid(int *data, int selector) +{ +#if defined(__PIC__) && defined(__i386__) + asm("xchgl %%ebx, %%esi; cpuid; xchgl %%ebx, %%esi" + : "=a" (data[0]), + "=S" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "0" (selector)); +#elif defined(__PIC__) && defined(__amd64__) + asm("xchg{q} {%%}rbx, %q1; cpuid; xchg{q} {%%}rbx, %q1" + : "=a" (data[0]), + "=&r" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "0" (selector)); +#else + asm("cpuid" + : "=a" (data[0]), + "=b" (data[1]), + "=c" (data[2]), + "=d" (data[3]) + : "a"(selector)); +#endif +} +#else +#define __cpuid(a,b) memset((a), 0, sizeof(int) * 4) +#endif + +static int query_cpu_feature_sse() { + int buffer[4]; + __cpuid(buffer,1); + if ((buffer[3]&(1<<25)) == 0) return 0; + return 1; +} + +static int _dumb_it_use_sse = 0; + +void _dumb_init_sse() +{ + static int initialized = 0; + if (!initialized) + { + _dumb_it_use_sse = query_cpu_feature_sse(); + initialized = 1; + } +} + +#elif defined(_M_X64) || defined(__amd64__) + +static const int _dumb_it_use_sse = 1; + +void _dumb_init_sse() { } + +#else + +static const int _dumb_it_use_sse = 0; + +void _dumb_init_sse() { } + +#endif +#endif + +static void it_filter(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample_t *dst, int32 pos, sample_t *src, int32 size, int step, int sampfreq, int cutoff, int resonance) +{ +#if defined(_USE_SSE) && (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__)) + _dumb_init_sse(); + if ( _dumb_it_use_sse ) it_filter_sse( cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance ); + else +#endif + it_filter_int( cr, state, dst, pos, src, size, step, sampfreq, cutoff, resonance ); +} #endif @@ -802,14 +970,22 @@ static void reset_tick_counts(DUMB_IT_SIGRENDERER *sigrenderer) +static const unsigned char arpeggio_mod[32] = {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1}; +static const unsigned char arpeggio_xm[32] = {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; +static const unsigned char arpeggio_okt_3[32] = {1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0}; +static const unsigned char arpeggio_okt_4[32] = {0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1}; +static const unsigned char arpeggio_okt_5[32] = {2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2}; + + + static void reset_channel_effects(IT_CHANNEL *channel) { channel->volslide = 0; channel->xm_volslide = 0; channel->panslide = 0; channel->channelvolslide = 0; - channel->arpeggio = 0; - channel->arpeggio_shift = 0; + channel->arpeggio_table = (const unsigned char *) &arpeggio_mod; + memset(channel->arpeggio_offsets, 0, sizeof(channel->arpeggio_offsets)); channel->retrig = 0; if (channel->xm_retrig) { channel->xm_retrig = 0; @@ -907,9 +1083,9 @@ static void it_pickup_stop_at_end(DUMB_RESAMPLER *resampler, void *data) static void it_pickup_stop_after_reverse(DUMB_RESAMPLER *resampler, void *data) { - (void)data; + (void)data; - resampler->dir = 0; + resampler->dir = 0; } @@ -934,13 +1110,13 @@ static void it_playing_update_resamplers(IT_PLAYING *playing) playing->resampler.pickup = &it_pickup_pingpong_loop; else playing->resampler.pickup = &it_pickup_loop; - } else if (playing->flags & IT_PLAYING_REVERSE) { - playing->resampler.start = 0; - playing->resampler.end = playing->sample->length; - playing->resampler.dir = -1; - playing->resampler.pickup = &it_pickup_stop_after_reverse; - } else { - if (playing->sample->flags & IT_SAMPLE_SUS_LOOP) + } else if (playing->flags & IT_PLAYING_REVERSE) { + playing->resampler.start = 0; + playing->resampler.end = playing->sample->length; + playing->resampler.dir = -1; + playing->resampler.pickup = &it_pickup_stop_after_reverse; + } else { + if (playing->sample->flags & IT_SAMPLE_SUS_LOOP) playing->resampler.start = playing->sample->sus_loop_start; else playing->resampler.start = 0; @@ -978,10 +1154,7 @@ static void update_retrig(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *channel) if (channel->retrig_tick <= 0) { if (channel->playing) { it_playing_reset_resamplers(channel->playing, 0); -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif } else if (sigrenderer->sigdata->flags & IT_WAS_AN_XM) it_retrigger_note(sigrenderer, channel); channel->retrig_tick = channel->xm_retrig; } @@ -1035,10 +1208,7 @@ static void update_retrig(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *channel) } if (channel->playing) { it_playing_reset_resamplers(channel->playing, 0); -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif } else if (sigrenderer->sigdata->flags & IT_WAS_AN_XM) it_retrigger_note(sigrenderer, channel); channel->retrig_tick = channel->retrig & 0x0F; } @@ -1106,10 +1276,47 @@ static void update_invert_loop(IT_CHANNEL *channel, IT_SAMPLE *sample) } +static void update_playing_effects(IT_PLAYING *playing) +{ + IT_CHANNEL *channel = playing->channel; + + if (channel->channelvolslide) { + playing->channel_volume = channel->channelvolume; + } + + if (channel->okt_toneslide) { + if (channel->okt_toneslide--) { + playing->note += channel->toneslide; + if (playing->note >= 120) { + if (channel->toneslide < 0) playing->note = 0; + else playing->note = 119; + } + } + } else if (channel->ptm_toneslide) { + if (--channel->toneslide_tick == 0) { + channel->toneslide_tick = channel->ptm_toneslide; + if (playing) { + playing->note += channel->toneslide; + if (playing->note >= 120) { + if (channel->toneslide < 0) playing->note = 0; + else playing->note = 119; + } + if (channel->playing == playing) { + channel->note = channel->truenote = playing->note; + } + if (channel->toneslide_retrig) { + it_playing_reset_resamplers(playing, 0); + playing->declick_stage = 0; + } + } + } + } +} + static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer) { - int i, j; + int i; if (sigrenderer->globalvolslide) { sigrenderer->globalvolume += sigrenderer->globalvolslide; @@ -1191,144 +1398,75 @@ static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer) else channel->channelvolume = 0; } - if (channel->playing) - channel->playing->channel_volume = channel->channelvolume; - for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) { - if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) - sigrenderer->playing[j]->channel_volume = channel->channelvolume; - } } update_tremor(channel); - if (channel->arpeggio_shift) channel->arpeggio = (channel->arpeggio << 8) | (channel->arpeggio >> channel->arpeggio_shift); - update_retrig(sigrenderer, channel); if (channel->inv_loop_speed) update_invert_loop(channel, playing ? playing->sample : NULL); - for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) { - if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) break; - } + if (playing) { + playing->slide += channel->portamento; - if (playing || j < DUMB_IT_N_NNA_CHANNELS) { - if (playing) playing->slide += channel->portamento; - for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) { - if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) - sigrenderer->playing[j]->slide += channel->portamento; - } - - if (channel->okt_toneslide) { - if (channel->okt_toneslide--) { - if (playing) { - playing->note += channel->toneslide; - if (playing->note >= 120) { - if (channel->toneslide < 0) playing->note = 0; - else playing->note = 119; + if (sigrenderer->sigdata->flags & IT_LINEAR_SLIDES) { + if (channel->toneporta && channel->destnote < 120) { + int currpitch = ((playing->note - 60) << 8) + playing->slide; + int destpitch = (channel->destnote - 60) << 8; + if (currpitch > destpitch) { + currpitch -= channel->toneporta; + if (currpitch < destpitch) { + currpitch = destpitch; + channel->destnote = IT_NOTE_OFF; } - } - for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) { - if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) { - IT_PLAYING *playing = sigrenderer->playing[j]; - playing->note += channel->toneslide; - if (playing->note >= 120) { - if (channel->toneslide < 0) playing->note = 0; - else playing->note = 119; - } - } - } - } - } else if (channel->ptm_toneslide) { - if (--channel->toneslide_tick == 0) { - channel->toneslide_tick = channel->ptm_toneslide; - if (playing) { - playing->note += channel->toneslide; - if (playing->note >= 120) { - if (channel->toneslide < 0) playing->note = 0; - else playing->note = 119; - } - channel->note = channel->truenote = playing->note; - if (channel->toneslide_retrig) { - it_playing_reset_resamplers(playing, 0); -#ifdef END_RAMPING - playing->declick_stage = 0; - playing->declick_volume = 1.f / 256.f; -#endif - } - } - for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) { - if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) { - IT_PLAYING *playing = sigrenderer->playing[j]; - playing->note += channel->toneslide; - if (playing->note >= 120) { - if (channel->toneslide < 0) playing->note = 0; - else playing->note = 119; - } - if (channel->toneslide_retrig) { - it_playing_reset_resamplers(playing, 0); -#ifdef END_RAMPING - playing->declick_stage = 0; - playing->declick_volume = 1.f / 256.f; -#endif - } - } - } - } - } - - if (playing) { - if (sigrenderer->sigdata->flags & IT_LINEAR_SLIDES) { - if (channel->toneporta && channel->destnote < 120) { - int currpitch = ((playing->note - 60) << 8) + playing->slide; - int destpitch = (channel->destnote - 60) << 8; + } else if (currpitch < destpitch) { + currpitch += channel->toneporta; if (currpitch > destpitch) { - currpitch -= channel->toneporta; - if (currpitch < destpitch) { - currpitch = destpitch; - channel->destnote = IT_NOTE_OFF; - } - } else if (currpitch < destpitch) { - currpitch += channel->toneporta; - if (currpitch > destpitch) { - currpitch = destpitch; - channel->destnote = IT_NOTE_OFF; - } + currpitch = destpitch; + channel->destnote = IT_NOTE_OFF; } - playing->slide = currpitch - ((playing->note - 60) << 8); } - } else { - if (channel->toneporta && channel->destnote < 120) { - float amiga_multiplier = playing->sample->C5_speed * (1.0f / AMIGA_DIVISOR); + playing->slide = currpitch - ((playing->note - 60) << 8); + } + } else { + if (channel->toneporta && channel->destnote < 120) { + float amiga_multiplier = playing->sample->C5_speed * (1.0f / AMIGA_DIVISOR); - float deltanote = (float)pow(DUMB_SEMITONE_BASE, 60 - playing->note); - /* deltanote is 1.0 for C-5, 0.5 for C-6, etc. */ + float deltanote = (float)pow(DUMB_SEMITONE_BASE, 60 - playing->note); + /* deltanote is 1.0 for C-5, 0.5 for C-6, etc. */ - float deltaslid = deltanote - playing->slide * amiga_multiplier; + float deltaslid = deltanote - playing->slide * amiga_multiplier; - float destdelta = (float)pow(DUMB_SEMITONE_BASE, 60 - channel->destnote); + float destdelta = (float)pow(DUMB_SEMITONE_BASE, 60 - channel->destnote); + if (deltaslid < destdelta) { + playing->slide -= channel->toneporta; + deltaslid = deltanote - playing->slide * amiga_multiplier; + if (deltaslid > destdelta) { + playing->note = channel->destnote; + playing->slide = 0; + channel->destnote = IT_NOTE_OFF; + } + } else { + playing->slide += channel->toneporta; + deltaslid = deltanote - playing->slide * amiga_multiplier; if (deltaslid < destdelta) { - playing->slide -= channel->toneporta; - deltaslid = deltanote - playing->slide * amiga_multiplier; - if (deltaslid > destdelta) { - playing->note = channel->destnote; - playing->slide = 0; - channel->destnote = IT_NOTE_OFF; - } - } else { - playing->slide += channel->toneporta; - deltaslid = deltanote - playing->slide * amiga_multiplier; - if (deltaslid < destdelta) { - playing->note = channel->destnote; - playing->slide = 0; - channel->destnote = IT_NOTE_OFF; - } + playing->note = channel->destnote; + playing->slide = 0; + channel->destnote = IT_NOTE_OFF; } } } } + + update_playing_effects(playing); } } + for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { + IT_PLAYING *playing = sigrenderer->playing[i]; + if (playing) update_playing_effects(playing); + } + update_smooth_effects(sigrenderer); } @@ -1534,7 +1672,7 @@ static void it_compatible_gxx_retrigger(DUMB_IT_SIGDATA *sigdata, IT_CHANNEL *ch int flags = 0; if (channel->sample) { if (sigdata->flags & IT_USE_INSTRUMENTS) { - if (channel->playing->env_instrument == &sigdata->instrument[channel->instrument-1]) { + if (!(channel->playing->flags & IT_PLAYING_SUSTAINOFF)) { if (channel->playing->env_instrument->volume_envelope.flags & IT_ENVELOPE_CARRY) flags |= 1; if (channel->playing->env_instrument->pan_envelope.flags & IT_ENVELOPE_CARRY) @@ -1597,34 +1735,48 @@ static void xm_note_off(DUMB_IT_SIGDATA *sigdata, IT_CHANNEL *channel) } +static void recalculate_it_envelope_node(IT_PLAYING_ENVELOPE *pe, IT_ENVELOPE *e) +{ + int envpos = pe->tick; + unsigned int pt = e->n_nodes - 1; + unsigned int i; + for (i = 0; i < (unsigned int)(e->n_nodes - 1); ++i) + { + if (envpos <= e->node_t[i]) + { + pt = i; + break; + } + } + pe->next_node = pt; +} + + +static void recalculate_it_envelope_nodes(IT_PLAYING *playing) +{ + recalculate_it_envelope_node(&playing->volume_envelope, &playing->env_instrument->volume_envelope); + recalculate_it_envelope_node(&playing->pan_envelope, &playing->env_instrument->pitch_envelope); + recalculate_it_envelope_node(&playing->pitch_envelope, &playing->env_instrument->pitch_envelope); +} + static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *channel) { - IT_PLAYING_ENVELOPE volume_envelope; - IT_PLAYING_ENVELOPE pan_envelope; - IT_PLAYING_ENVELOPE pitch_envelope; + int vol_env_tick = 0; + int pan_env_tick = 0; + int pitch_env_tick = 0; DUMB_IT_SIGDATA *sigdata = sigrenderer->sigdata; - unsigned char nna; - int i, flags = 0; + unsigned char nna = ~0; + int i, envelopes_copied = 0; if (channel->playing) { -#ifdef INVALID_NOTES_CAUSE_NOTE_CUT - if (channel->note == IT_NOTE_OFF) - nna = NNA_NOTE_OFF; - else if (channel->note >= 120 || !channel->playing->instrument || (channel->playing->flags & IT_PLAYING_DEAD)) - nna = NNA_NOTE_CUT; - else if (channel->new_note_action != 0xFF) - { - nna = channel->new_note_action; - } - else - nna = channel->playing->instrument->new_note_action; -#else if (channel->note == IT_NOTE_CUT) nna = NNA_NOTE_CUT; - if (channel->note >= 120) + else if (channel->note == IT_NOTE_OFF) nna = NNA_NOTE_OFF; + else if (channel->note > 120) + nna = NNA_NOTE_FADE; else if (!channel->playing->instrument || (channel->playing->flags & IT_PLAYING_DEAD)) nna = NNA_NOTE_CUT; else if (channel->new_note_action != 0xFF) @@ -1633,33 +1785,19 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan } else nna = channel->playing->instrument->new_note_action; -#endif - if (!(channel->playing->flags & IT_PLAYING_DEAD) && (sigdata->flags & IT_USE_INSTRUMENTS) && (channel->playing->enabled_envelopes) && channel->playing->instnum == channel->instrument) { - IT_PLAYING * playing = channel->playing; - IT_INSTRUMENT * inst = &sigdata->instrument[channel->instrument-1]; - if ((playing->enabled_envelopes & IT_ENV_VOLUME) && (inst->volume_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 1; - volume_envelope = playing->volume_envelope; - } - if ((playing->enabled_envelopes & IT_ENV_PANNING) && (inst->pan_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 2; - pan_envelope = playing->pan_envelope; - } - if ((playing->enabled_envelopes & IT_ENV_PITCH) && (inst->pitch_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 4; - pitch_envelope = playing->pitch_envelope; - } + if (!(channel->playing->flags & IT_PLAYING_SUSTAINOFF)) + { + if (nna != NNA_NOTE_CUT) + vol_env_tick = channel->playing->volume_envelope.tick; + pan_env_tick = channel->playing->pan_envelope.tick; + pitch_env_tick = channel->playing->pitch_envelope.tick; + envelopes_copied = 1; } switch (nna) { case NNA_NOTE_CUT: -#ifdef RAMP_DOWN - channel->playing->declick_stage = 2; -#else - free_playing(sigrenderer, channel->playing); - channel->playing = NULL; -#endif + channel->playing->declick_stage = 3; break; case NNA_NOTE_OFF: it_note_off(channel->playing); @@ -1672,7 +1810,7 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan channel->new_note_action = 0xFF; - if (channel->sample == 0 || channel->note >= 120) + if (channel->sample == 0 || channel->note > 120) return; channel->destnote = IT_NOTE_OFF; @@ -1708,12 +1846,7 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan switch (playing->instrument->dup_check_action) { case DCA_NOTE_CUT: -#ifdef RAMP_DOWN - playing->declick_stage = 2; -#else - free_playing(sigrenderer, playing); - sigrenderer->playing[i] = NULL; -#endif + playing->declick_stage = 3; if (channel->playing == playing) channel->playing = NULL; break; case DCA_NOTE_OFF: @@ -1753,26 +1886,17 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan if (!channel->playing) return; - if (!flags && sigdata->flags & IT_USE_INSTRUMENTS) { + if (!envelopes_copied && sigdata->flags & IT_USE_INSTRUMENTS) { for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { IT_PLAYING * playing = sigrenderer->playing[i]; if (!playing || playing->channel != channel) continue; - if (playing->enabled_envelopes && playing->instnum == channel->instrument) { - IT_INSTRUMENT * inst = &sigdata->instrument[channel->instrument-1]; - if ((playing->enabled_envelopes & IT_ENV_VOLUME) && (inst->volume_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 1; - volume_envelope = playing->volume_envelope; - } - if ((playing->enabled_envelopes & IT_ENV_PANNING) && (inst->pan_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 2; - pan_envelope = playing->pan_envelope; - } - if ((playing->enabled_envelopes & IT_ENV_PITCH) && (inst->pitch_envelope.flags & IT_ENVELOPE_CARRY)) { - flags |= 4; - pitch_envelope = playing->pitch_envelope; - } - break; - } + if (playing->flags & IT_PLAYING_SUSTAINOFF) continue; + if (nna != NNA_NOTE_CUT) + vol_env_tick = playing->volume_envelope.tick; + pan_env_tick = playing->pan_envelope.tick; + pitch_env_tick = playing->pitch_envelope.tick; + envelopes_copied = 1; + break; } } @@ -1787,12 +1911,8 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan channel->playing->env_instrument = channel->playing->instrument; channel->playing->sampnum = channel->sample; channel->playing->instnum = channel->instrument; -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif channel->playing->channel_volume = channel->channelvolume; - channel->playing->ramp_volume[0] = 31337.0; /* special */ channel->playing->note = channel->truenote; channel->playing->enabled_envelopes = 0; channel->playing->volume_offset = 0; @@ -1832,23 +1952,24 @@ static void it_retrigger_note(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *chan channel->playing->slide = 0; channel->playing->finetune = channel->playing->sample->finetune; - if (flags & 1) { - channel->playing->volume_envelope = volume_envelope; - } else { - channel->playing->volume_envelope.next_node = 0; - channel->playing->volume_envelope.tick = 0; - } - if (flags & 2) { - channel->playing->pan_envelope = pan_envelope; - } else { - channel->playing->pan_envelope.next_node = 0; - channel->playing->pan_envelope.tick = 0; - } - if (flags & 4) { - channel->playing->pitch_envelope = pitch_envelope; - } else { - channel->playing->pitch_envelope.next_node = 0; - channel->playing->pitch_envelope.tick = 0; + if (sigdata->flags & IT_USE_INSTRUMENTS) + { + if (envelopes_copied && channel->playing->env_instrument->volume_envelope.flags & IT_ENVELOPE_CARRY) { + channel->playing->volume_envelope.tick = vol_env_tick; + } else { + channel->playing->volume_envelope.tick = 0; + } + if (envelopes_copied && channel->playing->env_instrument->pan_envelope.flags & IT_ENVELOPE_CARRY) { + channel->playing->pan_envelope.tick = pan_env_tick; + } else { + channel->playing->pan_envelope.tick = 0; + } + if (envelopes_copied && channel->playing->env_instrument->pitch_envelope.flags & IT_ENVELOPE_CARRY) { + channel->playing->pitch_envelope.tick = pitch_env_tick; + } else { + channel->playing->pitch_envelope.tick = 0; + } + recalculate_it_envelope_nodes(channel->playing); } channel->playing->fadeoutcount = 1024; it_reset_filter_state(&channel->playing->filter_state[0]); @@ -1924,7 +2045,7 @@ static void post_process_it_volpan(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *e v = channel->lastvolslide; channel->lastvolslide = v; /* = effect Dx0 where x == entry->volpan - 85 */ - channel->volslide = v; + channel->volslide += v; } else if (entry->volpan <= 104) { /* Volume slide down */ unsigned char v = entry->volpan - 95; @@ -1932,7 +2053,7 @@ static void post_process_it_volpan(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *e v = channel->lastvolslide; channel->lastvolslide = v; /* = effect D0x where x == entry->volpan - 95 */ - channel->volslide = -v; + channel->volslide -= v; } else if (entry->volpan <= 114) { /* Portamento down */ unsigned char v = (entry->volpan - 105) << 2; @@ -2090,24 +2211,23 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than /*if (entry->effectvalue == 255) if (sigrenderer->callbacks->xm_speed_zero && (*sigrenderer->callbacks->xm_speed_zero)(sigrenderer->callbacks->xm_speed_zero_data)) return 1;*/ - if (sigdata->flags & IT_WAS_AN_STM) - { - int n = entry->effectvalue; - if (n >= 32) - { - sigrenderer->tick = sigrenderer->speed = n; - } - } - else - { - sigrenderer->tick = sigrenderer->speed = entry->effectvalue; - } + if (sigdata->flags & IT_WAS_AN_STM) { + int n = entry->effectvalue; + if (n >= 32) { + sigrenderer->tick = sigrenderer->speed = n; + } + } else { + sigrenderer->tick = sigrenderer->speed = entry->effectvalue; + } } else if ((sigdata->flags & (IT_WAS_AN_XM|IT_WAS_A_MOD)) == IT_WAS_AN_XM) { #ifdef BIT_ARRAY_BULLSHIT bit_array_set(sigrenderer->played, sigrenderer->order * 256 + sigrenderer->row); #endif sigrenderer->speed = 0; +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->looped = 1; +#endif if (sigrenderer->callbacks->xm_speed_zero && (*sigrenderer->callbacks->xm_speed_zero)(sigrenderer->callbacks->xm_speed_zero_data)) return 1; } @@ -2281,11 +2401,11 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than playing = sigrenderer->playing[i]; if (!playing || playing->channel != channel) continue; } - if (playing) { + if (playing) { if ((v & 0xF0) == 0xF0) - playing->slide += (v & 15) << 4; + playing->slide += (v & 15) << 4; else if ((v & 0xF0) == 0xE0) - playing->slide += (v & 15) << 2; + playing->slide += (v & 15) << 2; else if (i < 0 && sigdata->flags & IT_WAS_A_669) channel->portamento += v << 3; else if (i < 0) @@ -2392,8 +2512,10 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than channel->lastJ = v; } } - channel->arpeggio = ((v & 0xF0) << 4) | (v & 0x0F); - channel->arpeggio_shift = 16; + channel->arpeggio_offsets[0] = 0; + channel->arpeggio_offsets[1] = (v & 0xF0) >> 4; + channel->arpeggio_offsets[2] = (v & 0x0F); + channel->arpeggio_table = (const unsigned char *)(((sigdata->flags & (IT_WAS_AN_XM|IT_WAS_A_MOD))==IT_WAS_AN_XM) ? &arpeggio_xm : &arpeggio_mod); } break; case IT_SET_CHANNEL_VOLUME: @@ -2405,15 +2527,8 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than else channel->channelvolume = 64; #endif - for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) { - if (i < 0) playing = channel->playing; - else { - playing = sigrenderer->playing[i]; - if (!playing || playing->channel != channel) continue; - } - if (playing) - playing->channel_volume = channel->channelvolume; - } + if (channel->playing) + channel->playing->channel_volume = channel->channelvolume; break; case IT_CHANNEL_VOLUME_SLIDE: { @@ -2434,15 +2549,8 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than if (channel->channelvolume > 64) channel->channelvolume = 0; } else break; - for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) { - if (i < 0) playing = channel->playing; - else { - playing = sigrenderer->playing[i]; - if (!playing || playing->channel != channel) continue; - } - if (playing) - playing->channel_volume = channel->channelvolume; - } + if (channel->playing) + channel->playing->channel_volume = channel->channelvolume; } } break; @@ -2469,22 +2577,19 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than end = sample->sus_loop_end; else if (sample->flags & IT_SAMPLE_LOOP) end = sample->loop_end; - else + else { end = sample->length; + if ( sigdata->flags & IT_WAS_PROCESSED && end > 64 ) // XXX bah damn LPC and edge case modules + end -= 64; + } if ((sigdata->flags & IT_WAS_A_PTM) && (sample->flags & IT_SAMPLE_16BIT)) offset >>= 1; if (offset < end) { it_playing_reset_resamplers(playing, offset); -#ifdef END_RAMPING playing->declick_stage = 0; - playing->declick_volume = 1.f / 256.f; -#endif } else if (sigdata->flags & IT_OLD_EFFECTS) { it_playing_reset_resamplers(playing, end); -#ifdef END_RAMPING playing->declick_stage = 0; - playing->declick_volume = 1.f / 256.f; -#endif } } } @@ -2569,10 +2674,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than if (entry->effectvalue == 0) if (channel->playing) { it_playing_reset_resamplers(channel->playing, 0); -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif } break; case IT_TREMOLO: @@ -2608,7 +2710,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than } } break; - case IT_S: + case IT_S: { /* channel->lastS was set in update_pattern_variables(). */ unsigned char effectvalue = channel->lastS; @@ -2682,12 +2784,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than IT_PLAYING * playing = sigrenderer->playing[i]; if (playing && channel == playing->channel) { -#ifdef RAMP_DOWN - playing->declick_stage = 2; -#else - free_playing(sigrenderer, playing); - sigrenderer->playing[i] = NULL; -#endif + playing->declick_stage = 3; if (channel->playing == playing) channel->playing = NULL; } } @@ -2768,13 +2865,13 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than channel->playing->panbrello_depth = 0; break; case IT_S_SET_SURROUND_SOUND: - if ((effectvalue & 15) == 15) { - if (channel->playing && channel->playing->sample && - !(channel->playing->sample->flags & (IT_SAMPLE_LOOP | IT_SAMPLE_SUS_LOOP))) { - channel->playing->flags |= IT_PLAYING_REVERSE; - it_playing_reset_resamplers( channel->playing, channel->playing->sample->length - 1 ); - } - } else if ((effectvalue & 15) == 1) { + if ((effectvalue & 15) == 15) { + if (channel->playing && channel->playing->sample && + !(channel->playing->sample->flags & (IT_SAMPLE_LOOP | IT_SAMPLE_SUS_LOOP))) { + channel->playing->flags |= IT_PLAYING_REVERSE; + it_playing_reset_resamplers( channel->playing, channel->playing->sample->length - 1 ); + } + } else if ((effectvalue & 15) == 1) { channel->pan = IT_SURROUND; channel->truepan = channel->pan << IT_ENVELOPE_SHIFT; } @@ -2846,6 +2943,8 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than } break; case IT_SET_GLOBAL_VOLUME: + if ((sigdata->flags & IT_WAS_AN_S3M) && (entry->effectvalue > 64)) + break; if (entry->effectvalue <= 128) sigrenderer->globalvolume = entry->effectvalue; #ifdef VOLUME_OUT_OF_RANGE_SETS_MAXIMUM @@ -2876,10 +2975,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than break; case IT_SET_PANNING: if (sigdata->flags & IT_WAS_AN_XM) { - if (sigdata->flags & IT_WAS_A_MOD) - channel->truepan = entry->effectvalue*128; - else - channel->truepan = 32 + entry->effectvalue*64; + channel->truepan = 32 + entry->effectvalue*64; } else { if (sigdata->flags & IT_WAS_AN_S3M) channel->pan = (entry->effectvalue + 1) >> 1; @@ -2964,10 +3060,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than if (channel->sample) channel->playing->note = channel->truenote; else channel->playing->note = channel->note; it_playing_reset_resamplers(channel->playing, 0); -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif } } } @@ -3003,10 +3096,7 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than if (channel->sample) channel->playing->note = channel->truenote; else channel->playing->note = channel->note; it_playing_reset_resamplers(channel->playing, 0); -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif } } } @@ -3035,24 +3125,22 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than case IT_OKT_ARPEGGIO_4: case IT_OKT_ARPEGGIO_5: { - unsigned char low = -(entry->effectvalue >> 4); - unsigned char high = entry->effectvalue & 0x0F; + channel->arpeggio_offsets[0] = 0; + channel->arpeggio_offsets[1] = -(entry->effectvalue >> 4); + channel->arpeggio_offsets[2] = entry->effectvalue & 0x0F; switch (entry->effect) { case IT_OKT_ARPEGGIO_3: - channel->arpeggio = (low << 16) | high; - channel->arpeggio_shift = 16; + channel->arpeggio_table = (const unsigned char *)&arpeggio_okt_3; break; case IT_OKT_ARPEGGIO_4: - channel->arpeggio = (high << 16) | low; - channel->arpeggio_shift = 24; + channel->arpeggio_table = (const unsigned char *)&arpeggio_okt_4; break; case IT_OKT_ARPEGGIO_5: - channel->arpeggio = (high << 16) | (high << 8); - channel->arpeggio_shift = 16; + channel->arpeggio_table = (const unsigned char *)&arpeggio_okt_5; break; } } @@ -3106,7 +3194,7 @@ static int process_it_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entr if (entry->mask & IT_ENTRY_INSTRUMENT) channel->instrument = entry->instrument; instrument_to_sample(sigdata, channel); - if (channel->note < 120) { + if (channel->note <= 120) { if ((sigdata->flags & IT_USE_INSTRUMENTS) && channel->sample == 0) it_retrigger_note(sigrenderer, channel); /* Stop the note */ /*return 1;*/ if (entry->mask & IT_ENTRY_INSTRUMENT) @@ -3137,6 +3225,8 @@ static int process_it_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entr } } + channel->toneporta = 0; + if ((entry->mask & IT_ENTRY_VOLPAN) && entry->volpan >= 193 && entry->volpan <= 202) { /* Tone Portamento in the volume column */ static const unsigned char slidetable[] = {0, 1, 4, 8, 16, 32, 64, 96, 128, 255}; @@ -3150,16 +3240,10 @@ static int process_it_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entr v = channel->lastEF; channel->lastEF = v; } - if ((entry->mask & IT_ENTRY_NOTE) || ((sigdata->flags & IT_COMPATIBLE_GXX) && (entry->mask & IT_ENTRY_INSTRUMENT))) { - if (channel->note < 120) { - if (channel->sample) - channel->destnote = channel->truenote; - else - channel->destnote = channel->note; - } - } - channel->toneporta = v << 4; - } else { + channel->toneporta += v << 4; + } + + if ((entry->mask & IT_ENTRY_EFFECT) && (entry->effect == IT_TONE_PORTAMENTO || entry->effect == IT_VOLSLIDE_TONEPORTA)) { /* Tone Portamento in the effect column */ unsigned char v; if (entry->effect == IT_TONE_PORTAMENTO) @@ -3175,23 +3259,25 @@ static int process_it_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entr v = channel->lastEF; channel->lastEF = v; } - if ((entry->mask & IT_ENTRY_NOTE) || ((sigdata->flags & IT_COMPATIBLE_GXX) && (entry->mask & IT_ENTRY_INSTRUMENT))) { - if (channel->note < 120) { - if (channel->sample) - channel->destnote = channel->truenote; - else - channel->destnote = channel->note; - } - } - channel->toneporta = v << 4; + channel->toneporta += v << 4; } + + if ((entry->mask & IT_ENTRY_NOTE) || ((sigdata->flags & IT_COMPATIBLE_GXX) && (entry->mask & IT_ENTRY_INSTRUMENT))) { + if (channel->note <= 120) { + if (channel->sample) + channel->destnote = channel->truenote; + else + channel->destnote = channel->note; + } + } + if (channel->playing) goto skip_start_note; } if ((entry->mask & IT_ENTRY_NOTE) || ((entry->mask & IT_ENTRY_INSTRUMENT) && (!channel->playing || entry->instrument != channel->playing->instnum))) { - if (channel->note < 120) { + if (channel->note <= 120) { get_true_pan(sigdata, channel); if ((entry->mask & IT_ENTRY_NOTE) || !(sigdata->flags & (IT_WAS_AN_S3M|IT_WAS_A_PTM))) it_retrigger_note(sigrenderer, channel); @@ -3260,7 +3346,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent if (entry->mask & IT_ENTRY_INSTRUMENT) { int oldsample = channel->sample; - int oldvolume = channel->volume; channel->inv_loop_offset = 0; channel->instrument = entry->instrument; instrument_to_sample(sigdata, channel); @@ -3283,11 +3368,10 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent } else { /* Switch if sample changed */ if (oldsample != channel->sample) { -#ifdef RAMP_DOWN int i; for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { if (!sigrenderer->playing[i]) { - channel->playing->declick_stage = 2; + channel->playing->declick_stage = 3; sigrenderer->playing[i] = channel->playing; channel->playing = NULL; break; @@ -3307,13 +3391,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent channel->playing = playing; playing = NULL; channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#else - if (!channel->sample) { - free_playing(sigrenderer, channel->playing); - channel->playing = NULL; - } else { -#endif channel->playing->sampnum = channel->sample; channel->playing->sample = &sigdata->sample[channel->sample-1]; it_playing_reset_resamplers(channel->playing, 0); @@ -3321,12 +3398,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent } get_default_volpan(sigdata, channel); } -#ifdef END_RAMPING - if (channel->volume && !oldvolume) { - channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; - } -#endif } } @@ -3349,7 +3420,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent ** be brought back. A subsequent instrument change fixes that. **/ if (channel->playing) { -#ifdef RAMP_DOWN int i; if (playing) { free_playing(sigrenderer, channel->playing); @@ -3358,7 +3428,7 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent } for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { if (!sigrenderer->playing[i]) { - channel->playing->declick_stage = 2; + channel->playing->declick_stage = 3; sigrenderer->playing[i] = channel->playing; channel->playing = NULL; break; @@ -3368,10 +3438,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent free_playing(sigrenderer, channel->playing); channel->playing = NULL; } -#else - free_playing(sigrenderer, channel->playing); - channel->playing = NULL; -#endif } if (playing) free_playing(sigrenderer, playing); return; @@ -3394,7 +3460,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent // Adding the following seems to do the trick for the case where a piece starts with an instrument alone and then some notes alone. retrigger_xm_envelopes(channel->playing); } -#ifdef RAMP_DOWN else if (playing) { /* volume rampy stuff! move note to NNA */ int i; @@ -3408,7 +3473,7 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent playing = NULL; for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { if (!sigrenderer->playing[i]) { - ptemp->declick_stage = 2; + ptemp->declick_stage = 3; ptemp->flags |= IT_PLAYING_SUSTAINOFF | IT_PLAYING_FADING; sigrenderer->playing[i] = ptemp; ptemp = NULL; @@ -3417,7 +3482,6 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent } if (ptemp) free_playing(sigrenderer, ptemp); } -#endif channel->playing->flags = 0; channel->playing->resampling_quality = sigrenderer->resampling_quality; @@ -3430,12 +3494,8 @@ static void process_xm_note_data(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *ent channel->playing->env_instrument = channel->playing->instrument; channel->playing->sampnum = channel->sample; channel->playing->instnum = channel->instrument; -#ifdef END_RAMPING channel->playing->declick_stage = 0; - channel->playing->declick_volume = 1.f / 256.f; -#endif channel->playing->channel_volume = channel->channelvolume; - channel->playing->ramp_volume[0] = 31337.0; /* special */ channel->playing->note = channel->truenote; channel->playing->enabled_envelopes = 0; channel->playing->volume_offset = 0; @@ -3634,11 +3694,10 @@ static void update_tick_counts(DUMB_IT_SIGRENDERER *sigrenderer) if (sigrenderer->sigdata->flags & (IT_WAS_AN_XM | IT_WAS_A_PTM)) channel->volume = 0; else if (channel->playing) { -#ifdef RAMP_DOWN int i; for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { if (!sigrenderer->playing[i]) { - channel->playing->declick_stage = 2; + channel->playing->declick_stage = 3; sigrenderer->playing[i] = channel->playing; channel->playing = NULL; break; @@ -3648,10 +3707,6 @@ static void update_tick_counts(DUMB_IT_SIGRENDERER *sigrenderer) free_playing(sigrenderer, channel->playing); channel->playing = NULL; } -#else - free_playing(sigrenderer, channel->playing); - channel->playing = NULL; -#endif } } } else if (channel->note_delay_count) { @@ -3733,11 +3788,10 @@ static int update_it_envelope(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLA ASSERT(envelope->n_nodes > 0); - if (pe->next_node <= 0) + if (pe->tick <= 0) pe->value = envelope->node_y[0] << IT_ENVELOPE_SHIFT; - else if (pe->next_node >= envelope->n_nodes) { + else if (pe->tick >= envelope->node_t[envelope->n_nodes-1]) { pe->value = envelope->node_y[envelope->n_nodes-1] << IT_ENVELOPE_SHIFT; - return 1; } else { int ys = envelope->node_y[pe->next_node-1] << IT_ENVELOPE_SHIFT; int ts = envelope->node_t[pe->next_node-1]; @@ -3754,26 +3808,27 @@ static int update_it_envelope(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLA } pe->tick++; - while (pe->tick > envelope->node_t[pe->next_node]) { - pe->next_node++; - if ((envelope->flags & IT_ENVELOPE_SUSTAIN_LOOP) && !(playing->flags & IT_PLAYING_SUSTAINOFF)) { - if (pe->next_node > envelope->sus_loop_end) { - pe->next_node = envelope->sus_loop_start; - ASSERT(pe->next_node < envelope->n_nodes); - pe->tick = envelope->node_t[envelope->sus_loop_start]; - return 0; - } - } else if (envelope->flags & IT_ENVELOPE_LOOP_ON) { - if (pe->next_node > envelope->loop_end) { - pe->next_node = envelope->loop_start; - ASSERT(pe->next_node < envelope->n_nodes); - pe->tick = envelope->node_t[envelope->loop_start]; - return 0; - } - } - if (pe->next_node >= envelope->n_nodes) + + recalculate_it_envelope_node(pe, envelope); + + if ((envelope->flags & IT_ENVELOPE_SUSTAIN_LOOP) && !(playing->flags & IT_PLAYING_SUSTAINOFF)) { + if (pe->tick > envelope->node_t[envelope->sus_loop_end]) { + pe->next_node = envelope->sus_loop_start + 1; + ASSERT(pe->next_node <= envelope->n_nodes); + pe->tick = envelope->node_t[envelope->sus_loop_start]; return 0; + } + } else if (envelope->flags & IT_ENVELOPE_LOOP_ON) { + if (pe->tick > envelope->node_t[envelope->loop_end]) { + pe->next_node = envelope->loop_start + 1; + ASSERT(pe->next_node <= envelope->n_nodes); + pe->tick = envelope->node_t[envelope->loop_start]; + return 0; + } } + else if (pe->tick > envelope->node_t[envelope->n_nodes - 1]) + return 1; + return 0; } @@ -3863,50 +3918,70 @@ static void playing_volume_setup(DUMB_IT_SIGRENDERER * sigrenderer, IT_PLAYING * { DUMB_IT_SIGDATA * sigdata = sigrenderer->sigdata; int pan; - float volume, vol, span; + float vol, span; + float rampScale; + int ramp_style = sigrenderer->ramp_style; + + pan = apply_pan_envelope(playing); - if ((sigrenderer->n_channels == 2) && (sigdata->flags & IT_STEREO)) { - pan = apply_pan_envelope(playing); - if ((sigdata->flags & IT_WAS_AN_S3M) && IT_IS_SURROUND_SHIFTED(pan)) { - volume = -1.0f * (float)(pan) * (1.0f / (64.0f * 256.0f)); - } else { - volume = 1.0f; - } - span = (pan - (32<<8)) * sigdata->pan_separation * (1.0f / ((32<<8) * 128)); - vol = volume; - if (!IT_IS_SURROUND_SHIFTED(pan)) vol *= 1.0f - span; - playing->float_volume[0] = vol; - vol = -vol; - if (!IT_IS_SURROUND_SHIFTED(pan)) vol += 2.0f * volume; - playing->float_volume[1] = vol; - } else { - if ((sigdata->flags & IT_STEREO) && (playing->sample->flags & IT_SAMPLE_STEREO)) { - pan = apply_pan_envelope(playing); + if ((sigrenderer->n_channels >= 2) && (sigdata->flags & IT_STEREO) && (sigrenderer->n_channels != 3 || !IT_IS_SURROUND_SHIFTED(pan))) { + if (!IT_IS_SURROUND_SHIFTED(pan)) { span = (pan - (32<<8)) * sigdata->pan_separation * (1.0f / ((32<<8) * 128)); - vol = 0.5f; - if (!IT_IS_SURROUND_SHIFTED(pan)) vol *= 1.0f - span; + vol = 0.5f * (1.0f - span); playing->float_volume[0] = vol; - if (!IT_IS_SURROUND_SHIFTED(pan)) vol = 2.0f - vol; - playing->float_volume[1] = vol; + playing->float_volume[1] = 1.0f - vol; } else { - playing->float_volume[0] = 1.0f; - playing->float_volume[1] = 1.0f; + playing->float_volume[0] = -0.5f; + playing->float_volume[1] = 0.5f; } + } else { + playing->float_volume[0] = 1.0f; + playing->float_volume[1] = 1.0f; } vol = calculate_volume(sigrenderer, playing, 1.0f); playing->float_volume[0] *= vol; playing->float_volume[1] *= vol; + + rampScale = 4; - if (!sigrenderer->ramp_style || playing->ramp_volume[0] == 31337.0) { - playing->ramp_volume[0] = playing->float_volume[0]; - playing->ramp_volume[1] = playing->float_volume[1]; + if (ramp_style > 0 && playing->declick_stage == 2) { + if ((playing->ramp_volume[0] == 0 && playing->ramp_volume[1] == 0) || vol == 0) + rampScale = 48; + } + + if (ramp_style == 0 || (ramp_style < 2 && playing->declick_stage == 2)) { + if (playing->declick_stage <= 2) { + playing->ramp_volume[0] = playing->float_volume[0]; + playing->ramp_volume[1] = playing->float_volume[1]; + playing->declick_stage = 2; + } else { + playing->float_volume[0] = 0; + playing->float_volume[1] = 0; + playing->ramp_volume[0] = 0; + playing->ramp_volume[1] = 0; + playing->declick_stage = 5; + } playing->ramp_delta[0] = 0; - playing->ramp_delta[1] = 0; - } else { - playing->ramp_delta[0] = invt2g * (playing->float_volume[0] - playing->ramp_volume[0]); - playing->ramp_delta[1] = invt2g * (playing->float_volume[1] - playing->ramp_volume[1]); - } + playing->ramp_delta[1] = 0; + } else { + if (playing->declick_stage == 0) { + playing->ramp_volume[0] = 0; + playing->ramp_volume[1] = 0; + rampScale = 48; + playing->declick_stage++; + } else if (playing->declick_stage == 1) { + rampScale = 48; + } else if (playing->declick_stage >= 3) { + playing->float_volume[0] = 0; + playing->float_volume[1] = 0; + if (playing->declick_stage == 3) + playing->declick_stage++; + rampScale = 48; + } + playing->ramp_delta[0] = rampScale * invt2g * (playing->float_volume[0] - playing->ramp_volume[0]); + playing->ramp_delta[1] = rampScale * invt2g * (playing->float_volume[1] - playing->ramp_volume[1]); + } } static void process_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, float invt2g) @@ -3937,8 +4012,8 @@ static void process_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin } // Apparently some GCCs have problems here so renaming the function sounds like a better idea. -//#if !defined(_WIN32) || !defined(__GNUC__) -static double mylog2(double x) {return log(x)/log(2.0f);} +//#if defined(_MSC_VER) && _MSC_VER < 1800 +static double mylog2(double x) {return log(x)/log(2.0);} //#endif static int delta_to_note(float delta, int base) @@ -3989,7 +4064,7 @@ static void process_all_playing(DUMB_IT_SIGRENDERER *sigrenderer) DUMB_IT_SIGDATA *sigdata = sigrenderer->sigdata; int i; - float invt2g = 1.0f / ((float)TICK_TIME_DIVIDEND / (float)sigrenderer->tempo); + float invt2g = 1.0f / ((float)TICK_TIME_DIVIDEND / (float)sigrenderer->tempo / 256.0f); for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { IT_CHANNEL *channel = &sigrenderer->channel[i]; @@ -4096,7 +4171,18 @@ static void process_all_playing(DUMB_IT_SIGRENDERER *sigrenderer) if ( channel->arpeggio > 0xFF ) playing->delta = playing->sample->C5_speed * (1.f / 65536.f); } - else*/ playing->delta *= (float)pow(DUMB_SEMITONE_BASE, (signed char)(channel->arpeggio >> channel->arpeggio_shift));/* + else*/ + { + int tick = sigrenderer->tick - 1; + if ((sigrenderer->sigdata->flags & (IT_WAS_AN_XM|IT_WAS_A_MOD))!=IT_WAS_AN_XM) + tick = sigrenderer->speed - tick - 1; + else if (tick == sigrenderer->speed - 1) + tick = 0; + else + ++tick; + playing->delta *= (float)pow(DUMB_SEMITONE_BASE, channel->arpeggio_offsets[channel->arpeggio_table[tick&31]]); + } + /* }*/ playing->filter_cutoff = channel->filter_cutoff; @@ -4254,6 +4340,15 @@ static int process_tick(DUMB_IT_SIGRENDERER *sigrenderer) { sigrenderer->processorder = sigrenderer->restart_position - 1; } + +#ifdef BIT_ARRAY_BULLSHIT + /* Fix play tracking and timekeeping for orders containing skip commands */ + for (n = 0; n < 256; n++) { + bit_array_set(sigrenderer->played, sigrenderer->processorder * 256 + n); + timekeeping_array_push(sigrenderer->row_timekeeper, sigrenderer->processorder * 256 + n, sigrenderer->time_played); + timekeeping_array_bump(sigrenderer->row_timekeeper, sigrenderer->processorder * 256 + n); + } +#endif } pattern = &sigdata->pattern[n]; @@ -4276,6 +4371,9 @@ static int process_tick(DUMB_IT_SIGRENDERER *sigrenderer) && bit_array_test(sigrenderer->played, sigrenderer->processorder * 256 + sigrenderer->processrow) #endif ) { +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->looped = 1; +#endif if (sigrenderer->callbacks->loop) { if ((*sigrenderer->callbacks->loop)(sigrenderer->callbacks->loop_data)) return 1; @@ -4319,6 +4417,13 @@ static int process_tick(DUMB_IT_SIGRENDERER *sigrenderer) } } +#ifdef BIT_ARRAY_BULLSHIT + if (sigrenderer->looped == 0) { + timekeeping_array_push(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row, sigrenderer->time_played); + } + timekeeping_array_bump(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row); +#endif + if (!(sigdata->flags & IT_WAS_A_669)) reset_effects(sigrenderer); @@ -4357,20 +4462,22 @@ static int process_tick(DUMB_IT_SIGRENDERER *sigrenderer) update_effects(sigrenderer); } } else { - if ( !(sigdata->flags & IT_WAS_AN_STM) || !(sigrenderer->tick & 15)) - { - speed0: - update_effects(sigrenderer); - update_tick_counts(sigrenderer); - } + if ( !(sigdata->flags & IT_WAS_AN_STM) || !(sigrenderer->tick & 15)) { + speed0: + update_effects(sigrenderer); + update_tick_counts(sigrenderer); + } } if (sigrenderer->globalvolume == 0) { if (sigrenderer->callbacks->global_volume_zero) { - LONG_LONG t = sigrenderer->gvz_sub_time + ((LONG_LONG)TICK_TIME_DIVIDEND << 16) / sigrenderer->tempo; + LONG_LONG t = sigrenderer->gvz_sub_time + ((TICK_TIME_DIVIDEND / (sigrenderer->tempo << 8)) << 16); sigrenderer->gvz_time += (int)(t >> 16); sigrenderer->gvz_sub_time = (int)t & 65535; if (sigrenderer->gvz_time >= 65536 * 12) { +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->looped = 1; +#endif if ((*sigrenderer->callbacks->global_volume_zero)(sigrenderer->callbacks->global_volume_zero_data)) return 1; } @@ -4385,12 +4492,11 @@ static int process_tick(DUMB_IT_SIGRENDERER *sigrenderer) process_all_playing(sigrenderer); { - LONG_LONG t = ((LONG_LONG)TICK_TIME_DIVIDEND << 16) / sigrenderer->tempo; - if ( sigrenderer->sigdata->flags & IT_WAS_AN_STM ) - { - t /= 16; - } - t += sigrenderer->sub_time_left; + LONG_LONG t = (TICK_TIME_DIVIDEND / (sigrenderer->tempo << 8)) << 16; + if ( sigrenderer->sigdata->flags & IT_WAS_AN_STM ) { + t /= 16; + } + t += sigrenderer->sub_time_left; sigrenderer->time_left += (int)(t >> 16); sigrenderer->sub_time_left = (int)t & 65535; } @@ -4415,6 +4521,7 @@ static const int aiMODVol[] = 785, 801, 817, 833, 849, 865, 881, 897, 913, 929, 945, 961, 977, 993, 1009, 1024 }; +#endif static const int aiPTMVolScaled[] = { @@ -4428,7 +4535,6 @@ static const int aiPTMVolScaled[] = 836, 847, 859, 870, 881, 897, 908, 916, 927, 939, 950, 962, 969, 983, 1005, 1024 }; -#endif static float calculate_volume(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, double volume) { @@ -4475,6 +4581,19 @@ static float calculate_volume(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *play if (vol > 64 << 5) vol = 64 << 5; + if ( sigrenderer->sigdata->flags & IT_WAS_A_PTM ) + { + int v = aiPTMVolScaled[ vol >> 5 ]; + if ( vol < 64 << 5 ) + { + int f = vol & ( ( 1 << 5 ) - 1 ); + int f2 = ( 1 << 5 ) - f; + int v2 = aiPTMVolScaled[ ( vol >> 5 ) + 1 ]; + v = ( v * f2 + v2 * f ) >> 5; + } + vol = v << 1; + } + volume *= vol; /* 64 << 5 */ volume *= playing->sample->global_volume; /* 64 */ volume *= playing->channel_volume; /* 64 */ @@ -4540,11 +4659,10 @@ static int apply_pan_envelope(IT_PLAYING *playing) } -#if 0 /* Note: if a click remover is provided, and store_end_sample is set, then * the end point will be computed twice. This situation should not arise. */ -static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, float volume, float main_delta, float delta, int32 pos, int32 size, sample_t **samples, int store_end_sample, int *left_to_mix, int cr_record_which) +static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, double volume, double main_delta, double delta, int32 pos, int32 size, sample_t **samples, int store_end_sample, int *left_to_mix) { int bits; @@ -4558,33 +4676,34 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin if (*left_to_mix <= 0) volume = 0; -#ifndef END_RAMPING { int quality = sigrenderer->resampling_quality; if (playing->sample->max_resampling_quality >= 0 && quality > playing->sample->max_resampling_quality) quality = playing->sample->max_resampling_quality; playing->resampler.quality = quality; + resampler_set_quality(playing->resampler.fir_resampler[0], quality - DUMB_RESAMPLER_BASE); + resampler_set_quality(playing->resampler.fir_resampler[1], quality - DUMB_RESAMPLER_BASE); } -#endif bits = playing->sample->flags & IT_SAMPLE_16BIT ? 16 : 8; if (volume == 0) { if (playing->sample->flags & IT_SAMPLE_STEREO) - size_rendered = dumb_resample_n_2_1(bits, &playing->resampler, NULL, size, 0, 0, delta); + size_rendered = dumb_resample_n_2_2(bits, &playing->resampler, NULL, size, 0, 0, delta); else - size_rendered = dumb_resample_n_1_1(bits, &playing->resampler, NULL, size, 0, delta); + size_rendered = dumb_resample_n_1_2(bits, &playing->resampler, NULL, size, 0, 0, delta); } else { lvol.volume = playing->ramp_volume [0]; rvol.volume = playing->ramp_volume [1]; - lvol.delta = playing->ramp_delta [0] * main_delta; - rvol.delta = playing->ramp_delta [1] * main_delta; + lvol.delta = (float)(playing->ramp_delta [0] * main_delta); + rvol.delta = (float)(playing->ramp_delta [1] * main_delta); lvol.target = playing->float_volume [0]; rvol.target = playing->float_volume [1]; - rvol.mix = lvol.mix = volume; - if (sigrenderer->n_channels == 2) { + rvol.mix = lvol.mix = (float)volume; + lvol.declick_stage = rvol.declick_stage = playing->declick_stage; + if (sigrenderer->n_channels >= 2) { if (playing->sample->flags & IT_SAMPLE_STEREO) { - if ((cr_record_which & 1) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click[2]; dumb_resample_get_current_sample_n_2_2(bits, &playing->resampler, &lvol, &rvol, click); dumb_record_click(sigrenderer->click_remover[0], pos, click[0]); @@ -4597,14 +4716,14 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin samples[0][(pos + size_rendered) * 2] = click[0]; samples[0][(pos + size_rendered) * 2 + 1] = click[1]; } - if ((cr_record_which & 2) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click[2]; dumb_resample_get_current_sample_n_2_2(bits, &playing->resampler, &lvol, &rvol, click); dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click[0]); dumb_record_click(sigrenderer->click_remover[1], pos + size_rendered, -click[1]); } } else { - if ((cr_record_which & 1) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click[2]; dumb_resample_get_current_sample_n_1_2(bits, &playing->resampler, &lvol, &rvol, click); dumb_record_click(sigrenderer->click_remover[0], pos, click[0]); @@ -4617,16 +4736,18 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin samples[0][(pos + size_rendered) * 2] = click[0]; samples[0][(pos + size_rendered) * 2 + 1] = click[1]; } - if ((cr_record_which & 2) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click[2]; dumb_resample_get_current_sample_n_1_2(bits, &playing->resampler, &lvol, &rvol, click); dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click[0]); dumb_record_click(sigrenderer->click_remover[1], pos + size_rendered, -click[1]); } } - } else { + } +#if 0 // [RH] Don't need mono output + else { if (playing->sample->flags & IT_SAMPLE_STEREO) { - if ((cr_record_which & 1) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click; dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, &lvol, &rvol, &click); dumb_record_click(sigrenderer->click_remover[0], pos, click); @@ -4634,13 +4755,13 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin size_rendered = dumb_resample_n_2_1(bits, &playing->resampler, samples[0] + pos, size, &lvol, &rvol, delta); if (store_end_sample) dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, &lvol, &rvol, &samples[0][pos + size_rendered]); - if ((cr_record_which & 2) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click; dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, &lvol, &rvol, &click); dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click); } } else { - if ((cr_record_which & 1) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click; dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, &lvol, &click); dumb_record_click(sigrenderer->click_remover[0], pos, click); @@ -4648,15 +4769,19 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin size_rendered = dumb_resample_n_1_1(bits, &playing->resampler, samples[0] + pos, size, &lvol, delta); if (store_end_sample) dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, &lvol, &samples[0][pos + size_rendered]); - if ((cr_record_which & 2) && sigrenderer->click_remover) { + if (sigrenderer->click_remover) { sample_t click; dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, &lvol, &click); dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click); } } } +#endif playing->ramp_volume [0] = lvol.volume; playing->ramp_volume [1] = rvol.volume; + playing->declick_stage = (lvol.declick_stage > rvol.declick_stage) ? lvol.declick_stage : rvol.declick_stage; + if (playing->declick_stage >= 4) + playing->flags |= IT_PLAYING_DEAD; (*left_to_mix)--; } @@ -4665,290 +4790,6 @@ static int32 render_playing(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playin return size_rendered; } -#endif - -#ifdef END_RAMPING -#if 1 -static int32 render_playing_part(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, DUMB_VOLUME_RAMP_INFO * lvol, DUMB_VOLUME_RAMP_INFO * rvol, int bits, double delta, int32 pos, int32 size, sample_t **samples, int store_end_sample, int cr_record_which) -{ - int32 size_rendered = 0; - - if (sigrenderer->n_channels == 2) { - if (playing->sample->flags & IT_SAMPLE_STEREO) { - if ((cr_record_which & 1) && sigrenderer->click_remover) { - sample_t click[2]; - dumb_resample_get_current_sample_n_2_2(bits, &playing->resampler, lvol, rvol, click); - dumb_record_click(sigrenderer->click_remover[0], pos, click[0]); - dumb_record_click(sigrenderer->click_remover[1], pos, click[1]); - } - size_rendered = dumb_resample_n_2_2(bits, &playing->resampler, samples[0] + pos*2, size, lvol, rvol, delta); - if (store_end_sample) { - sample_t click[2]; - dumb_resample_get_current_sample_n_2_2(bits, &playing->resampler, lvol, rvol, click); - samples[0][(pos + size_rendered) * 2] = click[0]; - samples[0][(pos + size_rendered) * 2 + 1] = click[1]; - } - if ((cr_record_which & 2) && sigrenderer->click_remover) { - sample_t click[2]; - dumb_resample_get_current_sample_n_2_2(bits, &playing->resampler, lvol, rvol, click); - dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click[0]); - dumb_record_click(sigrenderer->click_remover[1], pos + size_rendered, -click[1]); - } - } else { - if ((cr_record_which & 1) && sigrenderer->click_remover) { - sample_t click[2]; - dumb_resample_get_current_sample_n_1_2(bits, &playing->resampler, lvol, rvol, click); - dumb_record_click(sigrenderer->click_remover[0], pos, click[0]); - dumb_record_click(sigrenderer->click_remover[1], pos, click[1]); - } - size_rendered = dumb_resample_n_1_2(bits, &playing->resampler, samples[0] + pos*2, size, lvol, rvol, delta); - if (store_end_sample) { - sample_t click[2]; - dumb_resample_get_current_sample_n_1_2(bits, &playing->resampler, lvol, rvol, click); - samples[0][(pos + size_rendered) * 2] = click[0]; - samples[0][(pos + size_rendered) * 2 + 1] = click[1]; - } - if ((cr_record_which & 2) && sigrenderer->click_remover) { - sample_t click[2]; - dumb_resample_get_current_sample_n_1_2(bits, &playing->resampler, lvol, rvol, click); - dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click[0]); - dumb_record_click(sigrenderer->click_remover[1], pos + size_rendered, -click[1]); - } - } - } -#if 0 - else { - if (playing->sample->flags & IT_SAMPLE_STEREO) { - if ((cr_record_which & 1) && sigrenderer->click_remover) { - sample_t click; - dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, lvol, rvol, &click); - dumb_record_click(sigrenderer->click_remover[0], pos, click); - } - size_rendered = dumb_resample_n_2_1(bits, &playing->resampler, samples[0] + pos, size, lvol, rvol, delta); - if (store_end_sample) - dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, lvol, rvol, &samples[0][pos + size_rendered]); - if ((cr_record_which & 2) && sigrenderer->click_remover) { - sample_t click; - dumb_resample_get_current_sample_n_2_1(bits, &playing->resampler, lvol, rvol, &click); - dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click); - } - } else { - if ((cr_record_which & 1) && sigrenderer->click_remover) { - sample_t click; - dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, lvol, &click); - dumb_record_click(sigrenderer->click_remover[0], pos, click); - } - size_rendered = dumb_resample_n_1_1(bits, &playing->resampler, samples[0] + pos, size, lvol, delta); - if (store_end_sample) - dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, lvol, &samples[0][pos + size_rendered]); - if ((cr_record_which & 2) && sigrenderer->click_remover) { - sample_t click; - dumb_resample_get_current_sample_n_1_1(bits, &playing->resampler, lvol, &click); - dumb_record_click(sigrenderer->click_remover[0], pos + size_rendered, -click); - } - } - } -#endif - return size_rendered; -} - -static int32 render_playing_ramp(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, double volume, double main_delta, double delta, int32 pos, int32 size, sample_t **samples, int store_end_sample, int *left_to_mix, int ramp_style) -{ - int bits; - - int32 size_rendered; - - DUMB_VOLUME_RAMP_INFO lvol, rvol; - - if (!size) return 0; - - if (playing->flags & IT_PLAYING_DEAD) - return 0; - - if (*left_to_mix <= 0) - volume = 0; - - { - int quality = sigrenderer->resampling_quality; - if (playing->sample->max_resampling_quality >= 0 && quality > playing->sample->max_resampling_quality) - quality = playing->sample->max_resampling_quality; - playing->resampler.quality = quality; - } - - bits = playing->sample->flags & IT_SAMPLE_16BIT ? 16 : 8; - size_rendered = size; - - if (volume == 0) { - if (playing->declick_stage < 2) { - if (playing->sample->flags & IT_SAMPLE_STEREO) - size_rendered = dumb_resample_n_2_2(bits, &playing->resampler, NULL, size, 0, 0, delta); - else - size_rendered = dumb_resample_n_1_2(bits, &playing->resampler, NULL, size, 0, 0, delta); - } else { - playing->declick_stage = 3; - } - } else { - lvol.volume = playing->ramp_volume [0]; - rvol.volume = playing->ramp_volume [1]; - lvol.delta = (float)(playing->ramp_delta [0] * main_delta); - rvol.delta = (float)(playing->ramp_delta [1] * main_delta); - lvol.target = playing->float_volume [0]; - rvol.target = playing->float_volume [1]; - rvol.mix = lvol.mix = (float)volume; - if (ramp_style) { - if (playing->declick_stage == 1) { - size_rendered = render_playing_part(sigrenderer, playing, &lvol, &rvol, bits, delta, pos, size, samples, store_end_sample, 3); - } else if (playing->declick_stage == 0 || playing->declick_stage == 2) { - double declick_count = ((ramp_style == 2) ? 327.68f : 49.152f) / main_delta; /* 5ms / 0.75ms */ - double declick_remain = playing->declick_volume * declick_count; - double declick_dir = -1; - double declick_target; - int remain; - DUMB_VOLUME_RAMP_INFO declick_lvol, declick_rvol; - if (playing->declick_stage == 0) { - declick_remain = declick_count - declick_remain; - declick_dir = 1; - } - if ((double)size < declick_remain) declick_remain = size; - remain = (int)declick_remain; - declick_target = playing->declick_volume + declick_dir / declick_count * declick_remain; - declick_lvol.volume = lvol.volume * playing->declick_volume; - declick_rvol.volume = rvol.volume * playing->declick_volume; - lvol.volume += (float)(lvol.delta * declick_remain); - rvol.volume += (float)(rvol.delta * declick_remain); - declick_lvol.target = (float)(lvol.volume * declick_target); - declick_rvol.target = (float)(rvol.volume * declick_target); - declick_lvol.delta = (float)((declick_lvol.target - declick_lvol.volume) / declick_remain); - declick_rvol.delta = (float)((declick_rvol.target - declick_rvol.volume) / declick_remain); - declick_lvol.mix = declick_rvol.mix = (float)volume; - if (remain < size) { - size_rendered = render_playing_part(sigrenderer, playing, &declick_lvol, &declick_rvol, bits, delta, pos, remain, samples, 0, 1); - if (size_rendered == remain) { - if (playing->declick_stage == 0) { - size_rendered += render_playing_part(sigrenderer, playing, &lvol, &rvol, bits, delta, pos + remain, size - remain, samples, store_end_sample, 2); - } else { - size_rendered = size; - } - } - playing->declick_stage++; - playing->declick_volume = 1; - } else { - size_rendered = render_playing_part(sigrenderer, playing, &declick_lvol, &declick_rvol, bits, delta, pos, remain, samples, store_end_sample, 3); - playing->declick_volume = (float)declick_target; - } - } else /*if (playing->declick_stage == 3)*/ { - (*left_to_mix)++; - } - } else if (playing->declick_stage < 2) { - size_rendered = render_playing_part(sigrenderer, playing, &lvol, &rvol, bits, delta, pos, size, samples, store_end_sample, 3); - } else { - playing->declick_stage = 3; - (*left_to_mix)++; - } - playing->ramp_volume [0] = lvol.volume; - playing->ramp_volume [1] = rvol.volume; - (*left_to_mix)--; - } - - if (playing->resampler.dir == 0) - playing->flags |= IT_PLAYING_DEAD; - - return size_rendered; -} -#else -static int32 render_playing_ramp(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *playing, float volume, float main_delta, float delta, int32 pos, int32 size, sample_t **samples, int store_end_sample, int *left_to_mix, int ramp_style) -{ - int32 rv, trv; - int l_t_m_temp, cr_which; - if (!size) return 0; - - rv = 0; - cr_which = 3; - - { - int quality = sigrenderer->resampling_quality; - if (playing->sample->max_resampling_quality >= 0 && quality > playing->sample->max_resampling_quality) - quality = playing->sample->max_resampling_quality; - playing->resampler.quality = quality; - } - - if (ramp_style) - { - if (playing->declick_stage == 0) { - /* ramp up! */ - cr_which = 1; - while (playing->declick_stage == 0 && size) { - l_t_m_temp = *left_to_mix; - if (size == 1) cr_which |= 2; - trv = render_playing(sigrenderer, playing, volume * playing->declick_volume, main_delta, delta, pos, 1, samples, store_end_sample, &l_t_m_temp, cr_which); - cr_which &= 2; - if (ramp_style == 2) playing->declick_volume += (1.f / 256.f) * main_delta; - else playing->declick_volume *= (float)pow(2.0f, main_delta); - if (playing->declick_volume >= 1.0f) { - playing->declick_volume = 1.0f; - playing->declick_stage = 1; - } - if (!trv) { - *left_to_mix = l_t_m_temp; - return rv; - } - rv += trv; - pos += trv; - size -= trv; - } - - if (!size) { - *left_to_mix = l_t_m_temp; - return rv; - } - - cr_which = 2; - - } -#ifdef RAMP_DOWN - else if (playing->declick_stage == 2) { - float halflife = pow(0.5, 1.0 / 64.0 * main_delta); - cr_which = 1; - while (playing->declick_stage == 2 && size) { - l_t_m_temp = *left_to_mix; - if (size == 1) cr_which |= 2; - trv = render_playing(sigrenderer, playing, volume * playing->declick_volume, main_delta, delta, pos, 1, samples, store_end_sample, &l_t_m_temp, cr_which); - cr_which &= 2; - /*if (ramp_style == 2) playing->declick_volume -= (1.f / 256.f) * main_delta; - else playing->declick_volume *= (float)pow(0.5f, main_delta);*/ - playing->declick_volume *= halflife; - if (playing->declick_volume < (1.f / 256.f)) { - playing->declick_stage = 3; - } - if (!trv) { - *left_to_mix = l_t_m_temp; - return rv; - } - rv += trv; - pos += trv; - size -= trv; - } - - if (size) rv += render_playing(sigrenderer, playing, volume * playing->declick_volume, main_delta, delta, pos, 1, samples, store_end_sample, left_to_mix, 2); - else *left_to_mix = l_t_m_temp; - - return rv; - - } else if (playing->declick_stage == 3) { - return size; - } -#endif - } else if (playing->declick_stage >= 2) { - playing->declick_stage = 3; - return size; - } - - return rv + render_playing(sigrenderer, playing, volume, main_delta, delta, pos, size, samples, store_end_sample, left_to_mix, cr_which); -} -#endif -#else -#define render_playing_ramp(sigrenderer, playing, volume, main_delta, delta, pos, size, samples, store_end_sample, left_to_mix, ramp_style) render_playing(sigrenderer, playing, volume, main_delta, delta, pos, size, samples, store_end_sample, left_to_mix, 3) -#endif typedef struct IT_TO_MIX { @@ -5046,7 +4887,7 @@ static void apply_pitch_modifications(DUMB_IT_SIGDATA *sigdata, IT_PLAYING *play -static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta, int32 pos, int32 size, sample_t **samples) +static void render_normal(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta, int32 pos, int32 size, sample_t **samples) { int i; @@ -5056,15 +4897,8 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta sample_t **samples_to_filter = NULL; - int ramp_style = sigrenderer->ramp_style; - //int max_output = sigrenderer->max_output; - if (ramp_style > 2) { - if ((sigrenderer->sigdata->flags & (IT_WAS_AN_XM | IT_WAS_A_MOD)) == IT_WAS_AN_XM) ramp_style = 2; - else ramp_style -= 3; - } - for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { if (sigrenderer->channel[i].playing && !(sigrenderer->channel[i].playing->flags & IT_PLAYING_DEAD)) { to_mix[n_to_mix].playing = sigrenderer->channel[i].playing; @@ -5101,7 +4935,7 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta if (!samples_to_filter) { samples_to_filter = allocate_sample_buffer(sigrenderer->n_channels, size + 1); if (!samples_to_filter) { - render_playing_ramp(sigrenderer, playing, 0, delta, note_delta, pos, size, NULL, 0, &left_to_mix, ramp_style); + render_playing(sigrenderer, playing, 0, delta, note_delta, pos, size, NULL, 0, &left_to_mix); continue; } } @@ -5110,7 +4944,7 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta DUMB_CLICK_REMOVER **cr = sigrenderer->click_remover; dumb_silence(samples_to_filter[0], sigrenderer->n_channels * (size + 1)); sigrenderer->click_remover = NULL; - size_rendered = render_playing_ramp(sigrenderer, playing, volume, delta, note_delta, 0, size, samples_to_filter, 1, &left_to_mix, ramp_style); + size_rendered = render_playing(sigrenderer, playing, volume, delta, note_delta, 0, size, samples_to_filter, 1, &left_to_mix); sigrenderer->click_remover = cr; if (sigrenderer->n_channels == 2) { it_filter(cr ? cr[0] : NULL, &playing->filter_state[0], samples[0 /*output*/], pos, samples_to_filter[0], size_rendered, @@ -5127,7 +4961,7 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta } else { it_reset_filter_state(&playing->filter_state[0]); it_reset_filter_state(&playing->filter_state[1]); - render_playing_ramp(sigrenderer, playing, volume, delta, note_delta, pos, size, samples /*&samples[output]*/, 0, &left_to_mix, ramp_style); + render_playing(sigrenderer, playing, volume, delta, note_delta, pos, size, samples /*&samples[output]*/, 0, &left_to_mix); } } @@ -5137,11 +4971,7 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta if (sigrenderer->channel[i].playing) { //if ((sigrenderer->channel[i].playing->flags & (IT_PLAYING_BACKGROUND | IT_PLAYING_DEAD)) == (IT_PLAYING_BACKGROUND | IT_PLAYING_DEAD)) { // This change was made so Gxx would work correctly when a note faded out or whatever. Let's hope nothing else was broken by it. - if ( -#ifdef RAMP_DOWN - (sigrenderer->channel[i].playing->declick_stage == 3) || -#endif - (sigrenderer->channel[i].playing->flags & IT_PLAYING_DEAD)) { + if (sigrenderer->channel[i].playing->flags & IT_PLAYING_DEAD) { free_playing(sigrenderer, sigrenderer->channel[i].playing); sigrenderer->channel[i].playing = NULL; } @@ -5150,11 +4980,7 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { if (sigrenderer->playing[i]) { - if ( -#ifdef RAMP_DOWN - (sigrenderer->playing[i]->declick_stage == 3) || -#endif - (sigrenderer->playing[i]->flags & IT_PLAYING_DEAD)) { + if (sigrenderer->playing[i]->flags & IT_PLAYING_DEAD) { free_playing(sigrenderer, sigrenderer->playing[i]); sigrenderer->playing[i] = NULL; } @@ -5164,6 +4990,170 @@ static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta +static void render_surround(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta, int32 pos, int32 size, sample_t **samples) +{ + int i; + + int n_to_mix = 0, n_to_mix_surround = 0; + IT_TO_MIX to_mix[DUMB_IT_TOTAL_CHANNELS]; + IT_TO_MIX to_mix_surround[DUMB_IT_TOTAL_CHANNELS]; + int left_to_mix = dumb_it_max_to_mix; + + int saved_channels = sigrenderer->n_channels; + + sample_t **samples_to_filter = NULL; + + DUMB_CLICK_REMOVER **saved_cr = sigrenderer->click_remover; + + //int max_output = sigrenderer->max_output; + + for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { + if (sigrenderer->channel[i].playing && !(sigrenderer->channel[i].playing->flags & IT_PLAYING_DEAD)) { + IT_PLAYING *playing = sigrenderer->channel[i].playing; + IT_TO_MIX *_to_mix = IT_IS_SURROUND_SHIFTED(playing->pan) ? to_mix_surround + n_to_mix_surround++ : to_mix + n_to_mix++; + _to_mix->playing = playing; + _to_mix->volume = volume == 0 ? 0 : calculate_volume(sigrenderer, playing, volume); + } + } + + for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { + if (sigrenderer->playing[i]) { /* Won't be dead; it would have been freed. */ + IT_PLAYING *playing = sigrenderer->playing[i]; + IT_TO_MIX *_to_mix = IT_IS_SURROUND_SHIFTED(playing->pan) ? to_mix_surround + n_to_mix_surround++ : to_mix + n_to_mix++; + _to_mix->playing = playing; + _to_mix->volume = volume == 0 ? 0 : calculate_volume(sigrenderer, playing, volume); + } + } + + if (volume != 0) { + qsort(to_mix, n_to_mix, sizeof(IT_TO_MIX), &it_to_mix_compare); + qsort(to_mix_surround, n_to_mix_surround, sizeof(IT_TO_MIX), &it_to_mix_compare); + } + + sigrenderer->n_channels = 2; + + for (i = 0; i < n_to_mix; i++) { + IT_PLAYING *playing = to_mix[i].playing; + double note_delta = delta * playing->delta; + int cutoff = playing->filter_cutoff << IT_ENVELOPE_SHIFT; + //int output = min( playing->output, max_output ); + + apply_pitch_modifications(sigrenderer->sigdata, playing, ¬e_delta, &cutoff); + + if (cutoff != 127 << IT_ENVELOPE_SHIFT || playing->filter_resonance != 0) { + playing->true_filter_cutoff = cutoff; + playing->true_filter_resonance = playing->filter_resonance; + } + + if (volume && (playing->true_filter_cutoff != 127 << IT_ENVELOPE_SHIFT || playing->true_filter_resonance != 0)) { + if (!samples_to_filter) { + samples_to_filter = allocate_sample_buffer(sigrenderer->n_channels, size + 1); + if (!samples_to_filter) { + render_playing(sigrenderer, playing, 0, delta, note_delta, pos, size, NULL, 0, &left_to_mix); + continue; + } + } + { + long size_rendered; + DUMB_CLICK_REMOVER **cr = sigrenderer->click_remover; + dumb_silence(samples_to_filter[0], sigrenderer->n_channels * (size + 1)); + sigrenderer->click_remover = NULL; + size_rendered = render_playing(sigrenderer, playing, volume, delta, note_delta, 0, size, samples_to_filter, 1, &left_to_mix); + sigrenderer->click_remover = cr; + it_filter(cr ? cr[0] : NULL, &playing->filter_state[0], samples[0 /*output*/], pos, samples_to_filter[0], size_rendered, + 2, (int)(65536.0f/delta), playing->true_filter_cutoff, playing->true_filter_resonance); + it_filter(cr ? cr[1] : NULL, &playing->filter_state[1], samples[0 /*output*/]+1, pos, samples_to_filter[0]+1, size_rendered, + 2, (int)(65536.0f/delta), playing->true_filter_cutoff, playing->true_filter_resonance); + } + } else { + it_reset_filter_state(&playing->filter_state[0]); + it_reset_filter_state(&playing->filter_state[1]); + render_playing(sigrenderer, playing, volume, delta, note_delta, pos, size, samples /*&samples[output]*/, 0, &left_to_mix); + } + } + + sigrenderer->n_channels = 1; + sigrenderer->click_remover = saved_cr ? saved_cr + 2 : 0; + + for (i = 0; i < n_to_mix_surround; i++) { + IT_PLAYING *playing = to_mix_surround[i].playing; + double note_delta = delta * playing->delta; + int cutoff = playing->filter_cutoff << IT_ENVELOPE_SHIFT; + //int output = min( playing->output, max_output ); + + apply_pitch_modifications(sigrenderer->sigdata, playing, ¬e_delta, &cutoff); + + if (cutoff != 127 << IT_ENVELOPE_SHIFT || playing->filter_resonance != 0) { + playing->true_filter_cutoff = cutoff; + playing->true_filter_resonance = playing->filter_resonance; + } + + if (volume && (playing->true_filter_cutoff != 127 << IT_ENVELOPE_SHIFT || playing->true_filter_resonance != 0)) { + if (!samples_to_filter) { + samples_to_filter = allocate_sample_buffer(sigrenderer->n_channels, size + 1); + if (!samples_to_filter) { + render_playing(sigrenderer, playing, 0, delta, note_delta, pos, size, NULL, 0, &left_to_mix); + continue; + } + } + { + long size_rendered; + DUMB_CLICK_REMOVER **cr = sigrenderer->click_remover; + dumb_silence(samples_to_filter[0], size + 1); + sigrenderer->click_remover = NULL; + size_rendered = render_playing(sigrenderer, playing, volume, delta, note_delta, 0, size, samples_to_filter, 1, &left_to_mix); + sigrenderer->click_remover = cr; + it_filter(cr ? cr[0] : NULL, &playing->filter_state[0], samples[1 /*output*/], pos, samples_to_filter[0], size_rendered, + 1, (int)(65536.0f/delta), playing->true_filter_cutoff, playing->true_filter_resonance); + // FIXME: filtering is not prevented by low left_to_mix! + // FIXME: change 'warning' to 'FIXME' everywhere + } + } else { + it_reset_filter_state(&playing->filter_state[0]); + it_reset_filter_state(&playing->filter_state[1]); + render_playing(sigrenderer, playing, volume, delta, note_delta, pos, size, &samples[1], 0, &left_to_mix); + } + } + + sigrenderer->n_channels = saved_channels; + sigrenderer->click_remover = saved_cr; + + destroy_sample_buffer(samples_to_filter); + + for (i = 0; i < DUMB_IT_N_CHANNELS; i++) { + if (sigrenderer->channel[i].playing) { + //if ((sigrenderer->channel[i].playing->flags & (IT_PLAYING_BACKGROUND | IT_PLAYING_DEAD)) == (IT_PLAYING_BACKGROUND | IT_PLAYING_DEAD)) { + // This change was made so Gxx would work correctly when a note faded out or whatever. Let's hope nothing else was broken by it. + if (sigrenderer->channel[i].playing->flags & IT_PLAYING_DEAD) { + free_playing(sigrenderer, sigrenderer->channel[i].playing); + sigrenderer->channel[i].playing = NULL; + } + } + } + + for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { + if (sigrenderer->playing[i]) { + if (sigrenderer->playing[i]->flags & IT_PLAYING_DEAD) { + free_playing(sigrenderer, sigrenderer->playing[i]); + sigrenderer->playing[i] = NULL; + } + } + } +} + + + +static void render(DUMB_IT_SIGRENDERER *sigrenderer, double volume, double delta, int32 pos, int32 size, sample_t **samples) +{ + if (size == 0) return; + if (sigrenderer->n_channels == 1 || sigrenderer->n_channels == 2) + render_normal(sigrenderer, volume, delta, pos, size, samples); + else if (sigrenderer->n_channels == 3) + render_surround(sigrenderer, volume, delta, pos, size, samples); +} + + + static DUMB_IT_SIGRENDERER *init_sigrenderer(DUMB_IT_SIGDATA *sigdata, int n_channels, int startorder, IT_CALLBACKS *callbacks, DUMB_CLICK_REMOVER **cr) { DUMB_IT_SIGRENDERER *sigrenderer; @@ -5194,7 +5184,7 @@ static DUMB_IT_SIGRENDERER *init_sigrenderer(DUMB_IT_SIGDATA *sigdata, int n_cha sigrenderer->sigdata = sigdata; sigrenderer->n_channels = n_channels; sigrenderer->resampling_quality = dumb_resampling_quality; - sigrenderer->ramp_style = 0; + sigrenderer->ramp_style = DUMB_IT_RAMP_FULL; sigrenderer->globalvolume = sigdata->global_volume; sigrenderer->tempo = sigdata->tempo; @@ -5300,6 +5290,14 @@ static DUMB_IT_SIGRENDERER *init_sigrenderer(DUMB_IT_SIGDATA *sigdata, int n_cha sigrenderer->processorder = startorder - 1; sigrenderer->tick = 1; +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->played = bit_array_create(sigdata->n_orders * 256); + + sigrenderer->looped = 0; + sigrenderer->time_played = 0; + sigrenderer->row_timekeeper = timekeeping_array_create(sigdata->n_orders * 256); +#endif + { int order; for (order = 0; order < sigdata->n_orders; order++) { @@ -5311,6 +5309,15 @@ static DUMB_IT_SIGRENDERER *init_sigrenderer(DUMB_IT_SIGDATA *sigdata, int n_cha if (n == IT_ORDER_END) #endif break; + +#ifdef BIT_ARRAY_BULLSHIT + /* Fix for played order detection for songs which have skips at the start of the orders list */ + for (n = 0; n < 256; n++) { + bit_array_set(sigrenderer->played, order * 256 + n); + timekeeping_array_push(sigrenderer->row_timekeeper, order * 256 + n, 0); + timekeeping_array_bump(sigrenderer->row_timekeeper, order * 256 + n); + } +#endif } /* If we get here, there were no valid orders in the song. */ _dumb_it_end_sigrenderer(sigrenderer); @@ -5321,15 +5328,17 @@ static DUMB_IT_SIGRENDERER *init_sigrenderer(DUMB_IT_SIGDATA *sigdata, int n_cha sigrenderer->time_left = 0; sigrenderer->sub_time_left = 0; -#ifdef BIT_ARRAY_BULLSHIT - sigrenderer->played = bit_array_create(sigdata->n_orders * 256); -#endif - sigrenderer->gvz_time = 0; sigrenderer->gvz_sub_time = 0; //sigrenderer->max_output = 0; + if ( !(sigdata->flags & IT_WAS_PROCESSED) ) { + dumb_it_add_lpc( sigdata ); + + sigdata->flags |= IT_WAS_PROCESSED; + } + return sigrenderer; } @@ -5346,6 +5355,8 @@ void DUMBEXPORT dumb_it_set_resampling_quality(DUMB_IT_SIGRENDERER * sigrenderer IT_PLAYING * playing = sigrenderer->channel[i].playing; playing->resampling_quality = quality; playing->resampler.quality = quality; + resampler_set_quality(playing->resampler.fir_resampler[0], quality - DUMB_RESAMPLER_BASE); + resampler_set_quality(playing->resampler.fir_resampler[1], quality - DUMB_RESAMPLER_BASE); } } for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) { @@ -5353,6 +5364,8 @@ void DUMBEXPORT dumb_it_set_resampling_quality(DUMB_IT_SIGRENDERER * sigrenderer IT_PLAYING * playing = sigrenderer->playing[i]; playing->resampling_quality = quality; playing->resampler.quality = quality; + resampler_set_quality(playing->resampler.fir_resampler[0], quality - DUMB_RESAMPLER_BASE); + resampler_set_quality(playing->resampler.fir_resampler[1], quality - DUMB_RESAMPLER_BASE); } } } @@ -5360,7 +5373,7 @@ void DUMBEXPORT dumb_it_set_resampling_quality(DUMB_IT_SIGRENDERER * sigrenderer void DUMBEXPORT dumb_it_set_ramp_style(DUMB_IT_SIGRENDERER * sigrenderer, int ramp_style) { - if (sigrenderer && ramp_style >= 0 && ramp_style <= 4) { + if (sigrenderer && ramp_style >= 0 && ramp_style <= 2) { sigrenderer->ramp_style = ramp_style; } } @@ -5473,6 +5486,10 @@ static sigrenderer_t *it_start_sigrenderer(DUH *duh, sigdata_t *vsigdata, int n_ while (pos > 0 && pos >= sigrenderer->time_left) { render(sigrenderer, 0, 1.0f, 0, sigrenderer->time_left, NULL); +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->time_played += (LONG_LONG)sigrenderer->time_left << 16; +#endif + pos -= sigrenderer->time_left; sigrenderer->time_left = 0; @@ -5485,6 +5502,10 @@ static sigrenderer_t *it_start_sigrenderer(DUH *duh, sigdata_t *vsigdata, int n_ render(sigrenderer, 0, 1.0f, 0, pos, NULL); sigrenderer->time_left -= pos; +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->time_played += (LONG_LONG)pos << 16; +#endif + return sigrenderer; } @@ -5500,6 +5521,7 @@ static int32 it_sigrenderer_get_samples( int32 pos; int dt; int32 todo; + int ret; LONG_LONG t; if (sigrenderer->order < 0) return 0; // problematic @@ -5527,9 +5549,28 @@ static int32 it_sigrenderer_get_samples( sigrenderer->sub_time_left = (int32)t & 65535; sigrenderer->time_left += (int32)(t >> 16); - if (process_tick(sigrenderer)) { +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->time_played += (LONG_LONG)todo * dt; +#endif + + ret = process_tick(sigrenderer); + + if (ret) { sigrenderer->order = -1; sigrenderer->row = -1; + } + +#ifdef BIT_ARRAY_BULLSHIT + if (sigrenderer->looped == 1) { + sigrenderer->looped = -1; + size = 0; + timekeeping_array_reset(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row); + sigrenderer->time_played = timekeeping_array_get_item(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row); + break; + } +#endif + + if (ret) { return pos; } } @@ -5542,6 +5583,10 @@ static int32 it_sigrenderer_get_samples( sigrenderer->sub_time_left = (int32)t & 65535; sigrenderer->time_left += (int32)(t >> 16); +#ifdef BIT_ARRAY_BULLSHIT + sigrenderer->time_played += (LONG_LONG)size * dt; +#endif + if (samples) dumb_remove_clicks_array(sigrenderer->n_channels, sigrenderer->click_remover, samples, pos, 512.0f / delta); @@ -5593,6 +5638,8 @@ void _dumb_it_end_sigrenderer(sigrenderer_t *vsigrenderer) #ifdef BIT_ARRAY_BULLSHIT bit_array_destroy(sigrenderer->played); + + timekeeping_array_destroy(sigrenderer->row_timekeeper); #endif free(vsigrenderer); @@ -5601,6 +5648,17 @@ void _dumb_it_end_sigrenderer(sigrenderer_t *vsigrenderer) +#ifdef BIT_ARRAY_BULLSHIT +static int32 it_sigrenderer_get_position(sigrenderer_t *vsigrenderer) +{ + DUMB_IT_SIGRENDERER *sigrenderer = vsigrenderer; + + return (int32)(sigrenderer->time_played >> 16); +} +#endif + + + DUH_SIGTYPE_DESC _dumb_sigtype_it = { SIGTYPE_IT, NULL, @@ -5608,6 +5666,11 @@ DUH_SIGTYPE_DESC _dumb_sigtype_it = { NULL, &it_sigrenderer_get_samples, &it_sigrenderer_get_current_sample, +#ifdef BIT_ARRAY_BULLSHIT + &it_sigrenderer_get_position, +#else + NULL, +#endif &_dumb_it_end_sigrenderer, &_dumb_it_unload_sigdata }; @@ -5927,7 +5990,8 @@ int DUMBEXPORT dumb_it_scan_for_playable_orders(DUMB_IT_SIGDATA *sigdata, dumb_s ba_played = bit_array_create(sigdata->n_orders * 256); if (!ba_played) return -1; - for (n = 0; n < sigdata->n_orders; n++) { + /* Skip the first order, it should always be played */ + for (n = 1; n < sigdata->n_orders; n++) { if ((sigdata->order[n] >= sigdata->n_patterns) || (is_pattern_silent(&sigdata->pattern[sigdata->order[n]], n) > 1)) bit_array_set(ba_played, n * 256); diff --git a/dumb/src/it/loadamf.c b/dumb/src/it/loadamf.c new file mode 100644 index 0000000000..5643a99411 --- /dev/null +++ b/dumb/src/it/loadamf.c @@ -0,0 +1,42 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * loadamf.c - Code to read a DSMI AMF module file, / / \ \ + * opening and closing it for you. | < / \_ + * | \/ /\ / + * \_ / > / + * By Chris Moeller. | \ / / + * | ' / + * \__/ + */ + +#include "dumb.h" +#include "internal/it.h" + + + +/* dumb_load_amf_quick(): loads a AMF file into a DUH struct, returning a + * pointer to the DUH struct. When you have finished with it, you must + * pass the pointer to unload_duh() so that the memory can be freed. + */ +DUH *DUMBEXPORT dumb_load_amf_quick(const char *filename) +{ + DUH *duh; + DUMBFILE *f = dumbfile_open(filename); + + if (!f) + return NULL; + + duh = dumb_read_amf_quick(f); + + dumbfile_close(f); + + return duh; +} diff --git a/dumb/src/it/loadamf2.c b/dumb/src/it/loadamf2.c new file mode 100644 index 0000000000..1cb3b05cbb --- /dev/null +++ b/dumb/src/it/loadamf2.c @@ -0,0 +1,34 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * loadamf2.c - Code to read a DSMI AMF module file, / / \ \ + * opening and closing it for you, and | < / \_ + * do an initial run-through. | \/ /\ / + * \_ / > / + * | \ / / + * By Chris Moeller. | ' / + * \__/ + */ + +#include "dumb.h" +#include "internal/it.h" + + + +/* dumb_load_amf(): loads a AMF file into a DUH struct, returning a pointer + * to the DUH struct. When you have finished with it, you must pass the + * pointer to unload_duh() so that the memory can be freed. + */ +DUH *DUMBEXPORT dumb_load_amf(const char *filename) +{ + DUH *duh = dumb_load_amf_quick(filename); + dumb_it_do_initial_runthrough(duh); + return duh; +} diff --git a/dumb/src/it/loadany.c b/dumb/src/it/loadany.c new file mode 100644 index 0000000000..2fe83ae08e --- /dev/null +++ b/dumb/src/it/loadany.c @@ -0,0 +1,38 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * loadany.c - Code to detect and read any of the / / \ \ + * module formats supported by DUMB, | < / \_ + * opening and closing the file for you. | \/ /\ / + * \_ / > / + * By Chris Moeller. | \ / / + * | ' / + * \__/ + */ + +#include "dumb.h" +#include "internal/it.h" + + + +DUH *DUMBEXPORT dumb_load_any_quick(const char *filename, int restrict_, int subsong) +{ + DUH *duh; + DUMBFILE *f = dumbfile_open(filename); + + if (!f) + return NULL; + + duh = dumb_read_any_quick(f, restrict_, subsong); + + dumbfile_close(f); + + return duh; +} diff --git a/dumb/src/it/loadany2.c b/dumb/src/it/loadany2.c new file mode 100644 index 0000000000..1f8839da4b --- /dev/null +++ b/dumb/src/it/loadany2.c @@ -0,0 +1,29 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * loadany2.c - Code to detect and read any of the / / \ \ + * module formats supported by DUMB, | < / \_ + * opening and closing the file for | \/ /\ / + * you, and do an initial run-through. \_ / > / + * | \ / / + * by Chris Moeller. | ' / + * \__/ + */ + +#include "dumb.h" + + + +DUH *DUMBEXPORT dumb_load_any(const char *filename, int restrict_, int subsong) +{ + DUH *duh = dumb_load_any_quick(filename, restrict_, subsong); + dumb_it_do_initial_runthrough(duh); + return duh; +} diff --git a/dumb/src/it/loadmod.c b/dumb/src/it/loadmod.c index adb4c283af..d6060f4f09 100644 --- a/dumb/src/it/loadmod.c +++ b/dumb/src/it/loadmod.c @@ -26,7 +26,7 @@ * pointer to the DUH struct. When you have finished with it, you must * pass the pointer to unload_duh() so that the memory can be freed. */ -DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int rstrict) +DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int restrict_) { DUH *duh; DUMBFILE *f = dumbfile_open(filename); @@ -34,7 +34,7 @@ DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int rstrict) if (!f) return NULL; - duh = dumb_read_mod_quick(f, rstrict); + duh = dumb_read_mod_quick(f, restrict_); dumbfile_close(f); diff --git a/dumb/src/it/loadmod2.c b/dumb/src/it/loadmod2.c index 83a416947b..c3a581740e 100644 --- a/dumb/src/it/loadmod2.c +++ b/dumb/src/it/loadmod2.c @@ -21,9 +21,9 @@ -DUH *DUMBEXPORT dumb_load_mod(const char *filename, int rstrict) +DUH *DUMBEXPORT dumb_load_mod(const char *filename, int restrict_) { - DUH *duh = dumb_load_mod_quick(filename, rstrict); + DUH *duh = dumb_load_mod_quick(filename, restrict_); dumb_it_do_initial_runthrough(duh); return duh; } diff --git a/dumb/src/it/read669.c b/dumb/src/it/read669.c index 1b83a042de..ef19302cd3 100644 --- a/dumb/src/it/read669.c +++ b/dumb/src/it/read669.c @@ -35,7 +35,7 @@ static int it_669_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int tempo, int pattern->n_rows = 64; - if (dumbfile_getnc(buffer, 64 * 3 * 8, f) < 64 * 3 * 8) + if (dumbfile_getnc((char *)buffer, 64 * 3 * 8, f) < 64 * 3 * 8) return -1; /* compute number of entries */ @@ -156,7 +156,7 @@ static int it_669_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int tempo, int static int it_669_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f) { - dumbfile_getnc(sample->name, 13, f); + dumbfile_getnc((char *)sample->name, 13, f); sample->name[13] = 0; sample->filename[0] = 0; @@ -268,7 +268,7 @@ static DUMB_IT_SIGDATA *it_669_load_sigdata(DUMBFILE *f, int * ext) return NULL; } - if (dumbfile_getnc(sigdata->name, 36, f) < 36) { + if (dumbfile_getnc((char *)sigdata->name, 36, f) < 36) { free(sigdata); return NULL; } @@ -288,13 +288,13 @@ static DUMB_IT_SIGDATA *it_669_load_sigdata(DUMBFILE *f, int * ext) free(sigdata); return NULL; } - if (dumbfile_getnc(sigdata->song_message, 36, f) < 36) { + if (dumbfile_getnc((char *)sigdata->song_message, 36, f) < 36) { _dumb_it_unload_sigdata(sigdata); return NULL; } sigdata->song_message[36] = 13; sigdata->song_message[36 + 1] = 10; - if (dumbfile_getnc(sigdata->song_message + 38, 36, f) < 36) { + if (dumbfile_getnc((char *)sigdata->song_message + 38, 36, f) < 36) { _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -314,7 +314,7 @@ static DUMB_IT_SIGDATA *it_669_load_sigdata(DUMBFILE *f, int * ext) _dumb_it_unload_sigdata(sigdata); return NULL; } - if (dumbfile_getnc(sigdata->order, 128, f) < 128) { + if (dumbfile_getnc((char *)sigdata->order, 128, f) < 128) { _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -332,12 +332,12 @@ static DUMB_IT_SIGDATA *it_669_load_sigdata(DUMBFILE *f, int * ext) } sigdata->n_orders = i; - if (dumbfile_getnc(tempolist, 128, f) < 128) { + if (dumbfile_getnc((char *)tempolist, 128, f) < 128) { _dumb_it_unload_sigdata(sigdata); return NULL; } - if (dumbfile_getnc(breaklist, 128, f) < 128) { + if (dumbfile_getnc((char *)breaklist, 128, f) < 128) { _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -413,8 +413,9 @@ static DUMB_IT_SIGDATA *it_669_load_sigdata(DUMBFILE *f, int * ext) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (i = 0; i < DUMB_IT_N_CHANNELS; i += 2) { - sigdata->channel_pan[i+0] = 48; - sigdata->channel_pan[i+1] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[i+0] = 32 + sep; + sigdata->channel_pan[i+1] = 32 - sep; } _dumb_it_fix_invalid_orders(sigdata); @@ -439,7 +440,7 @@ DUH *DUMBEXPORT dumb_read_669_quick(DUMBFILE *f) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = ext ? "669 Extended" : "669"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/read6692.c b/dumb/src/it/read6692.c index e69de29bb2..a9911d3ec1 100644 --- a/dumb/src/it/read6692.c +++ b/dumb/src/it/read6692.c @@ -0,0 +1,29 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * read6692.c - Code to read a 669 Composer module / / \ \ + * from an open file, and do an initial | < / \_ + * run-through. | \/ /\ / + * By Chris Moeller. \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#include "dumb.h" + + + +DUH *DUMBEXPORT dumb_read_669(DUMBFILE *f) +{ + DUH *duh = dumb_read_669_quick(f); + dumb_it_do_initial_runthrough(duh); + return duh; +} diff --git a/dumb/src/it/readam.c b/dumb/src/it/readam.c index 6a4994df5f..a3bf72eae3 100644 --- a/dumb/src/it/readam.c +++ b/dumb/src/it/readam.c @@ -24,7 +24,7 @@ #include "internal/it.h" #include "internal/riff.h" -static int it_riff_am_process_sample( IT_SAMPLE * sample, const unsigned char * data, int len, int ver ) +static int it_riff_am_process_sample( IT_SAMPLE * sample, DUMBFILE * f, int len, int ver ) { int header_length; int default_pan; @@ -34,49 +34,51 @@ static int it_riff_am_process_sample( IT_SAMPLE * sample, const unsigned char * int length_bytes; int loop_start; int loop_end; - int sample_rate; + int sample_rate; + + int32 start = dumbfile_pos( f ); if ( ver == 0 ) - { + { if ( len < 0x38 ) return -1; header_length = 0x38; - memcpy( sample->name, data, 28 ); + dumbfile_getnc( (char *) sample->name, 28, f ); sample->name[ 28 ] = 0; - default_pan = data[ 0x1C ]; - default_volume = data[ 0x1D ]; - flags = data[ 0x1E ] | ( data[ 0x1F ] << 8 ); - length = data[ 0x20 ] | ( data[ 0x21 ] << 8 ) | ( data[ 0x22 ] << 16 ) | ( data[ 0x23 ] << 24 ); - loop_start = data[ 0x24 ] | ( data[ 0x25 ] << 8 ) | ( data[ 0x26 ] << 16 ) | ( data[ 0x27 ] << 24 ); - loop_end = data[ 0x28 ] | ( data[ 0x29 ] << 8 ) | ( data[ 0x2A ] << 16 ) | ( data[ 0x2B ] << 24 ); - sample_rate = data[ 0x2C ] | ( data[ 0x2D ] << 8 ) | ( data[ 0x2E ] << 16 ) | ( data[ 0x2F ] << 24 ); + default_pan = dumbfile_getc( f ); + default_volume = dumbfile_getc( f ); + flags = dumbfile_igetw( f ); + length = dumbfile_igetl( f ); + loop_start = dumbfile_igetl( f ); + loop_end = dumbfile_igetl( f ); + sample_rate = dumbfile_igetl( f ); } else { if (len < 4) return -1; - header_length = data[ 0 ] | ( data[ 1 ] << 8 ) | ( data[ 2 ] << 16 ) | ( data[ 3 ] << 24 ); + header_length = dumbfile_igetl( f ); if ( header_length < 0x40 ) return -1; if ( header_length + 4 > len ) return -1; - data += 4; + start += 4; len -= 4; - memcpy( sample->name, data, 32 ); - sample->name[ 32 ] = 0; + dumbfile_getnc( (char *) sample->name, 32, f ); - default_pan = data[ 0x20 ] | ( data[ 0x21 ] << 8 ); - default_volume = data[ 0x22 ] | ( data[ 0x23 ] << 8 ); - flags = data[ 0x24 ] | ( data[ 0x25 ] << 8 ); /* | ( data[ 0x26 ] << 16 ) | ( data[ 0x27 ] << 24 );*/ - length = data[ 0x28 ] | ( data[ 0x29 ] << 8 ) | ( data[ 0x2A ] << 16 ) | ( data[ 0x2B ] << 24 ); - loop_start = data[ 0x2C ] | ( data[ 0x2D ] << 8 ) | ( data[ 0x2E ] << 16 ) | ( data[ 0x2F ] << 24 ); - loop_end = data[ 0x30 ] | ( data[ 0x31 ] << 8 ) | ( data[ 0x32 ] << 16 ) | ( data[ 0x33 ] << 24 ); - sample_rate = data[ 0x34 ] | ( data[ 0x35 ] << 8 ) | ( data[ 0x36 ] << 16 ) | ( data[ 0x37 ] << 24 ); + default_pan = dumbfile_igetw( f ); + default_volume = dumbfile_igetw( f ); + flags = dumbfile_igetw( f ); + dumbfile_skip( f, 2 ); + length = dumbfile_igetl( f ); + loop_start = dumbfile_igetl( f ); + loop_end = dumbfile_igetl( f ); + sample_rate = dumbfile_igetl( f ); if ( default_pan > 0x7FFF || default_volume > 0x7FFF ) return -1; @@ -85,9 +87,6 @@ static int it_riff_am_process_sample( IT_SAMPLE * sample, const unsigned char * default_volume = default_volume * 64 / 32767; } - /*if ( data[ 0x38 ] || data[ 0x39 ] || data[ 0x3A ] || data[ 0x3B ] ) - return -1;*/ - if ( ! length ) { sample->flags &= ~IT_SAMPLE_EXISTS; return 0; @@ -138,43 +137,49 @@ static int it_riff_am_process_sample( IT_SAMPLE * sample, const unsigned char * if ( ! sample->data ) return -1; - memcpy( sample->data, data + header_length, length_bytes ); + if ( dumbfile_seek( f, start + header_length, DFS_SEEK_SET ) ) + return -1; + + dumbfile_getnc( sample->data, length_bytes, f ); return 0; } -static int it_riff_am_process_pattern( IT_PATTERN * pattern, const unsigned char * data, int len, int ver ) +static int it_riff_am_process_pattern( IT_PATTERN * pattern, DUMBFILE * f, int len, int ver ) { - int nrows, row, pos; + int nrows, row; + long start, end; unsigned flags; + int p, q, r; IT_ENTRY * entry; - nrows = data[0] + 1; + nrows = dumbfile_getc( f ) + 1; pattern->n_rows = nrows; - data += 1; len -= 1; pattern->n_entries = 0; row = 0; - pos = 0; - while ( (row < nrows) && (pos < len) ) { - if ( ! data[ pos ] ) { + start = dumbfile_pos( f ); + end = start + len; + + while ( (row < nrows) && !dumbfile_error( f ) && (dumbfile_pos( f ) < end) ) { + p = dumbfile_getc( f ); + if ( ! p ) { ++ row; - ++ pos; continue; } - flags = data[ pos++ ] & 0xE0; + flags = p & 0xE0; - if (flags) { + if (flags) { ++ pattern->n_entries; - if (flags & 0x80) pos += 2; - if (flags & 0x40) pos += 2; - if (flags & 0x20) pos ++; + if (flags & 0x80) dumbfile_skip( f, 2 ); + if (flags & 0x40) dumbfile_skip( f, 2 ); + if (flags & 0x20) dumbfile_skip( f, 1 ); } } @@ -188,20 +193,22 @@ static int it_riff_am_process_pattern( IT_PATTERN * pattern, const unsigned char entry = pattern->entry; row = 0; - pos = 0; - while ( ( row < nrows ) && ( pos < len ) ) + dumbfile_seek( f, start, DFS_SEEK_SET ); + + while ( ( row < nrows ) && !dumbfile_error( f ) && ( dumbfile_pos( f ) < end ) ) { - if ( ! data[ pos ] ) + p = dumbfile_getc( f ); + + if ( ! p ) { IT_SET_END_ROW( entry ); ++ entry; ++ row; - ++ pos; continue; } - flags = data[ pos++ ]; + flags = p; entry->channel = flags & 0x1F; entry->mask = 0; @@ -209,31 +216,33 @@ static int it_riff_am_process_pattern( IT_PATTERN * pattern, const unsigned char { if ( flags & 0x80 ) { - _dumb_it_xm_convert_effect( data[ pos + 1 ], data[ pos ], entry, 0 ); - pos += 2; + q = dumbfile_getc( f ); + r = dumbfile_getc( f ); + _dumb_it_xm_convert_effect( r, q, entry, 0 ); } if ( flags & 0x40 ) { - if ( data[ pos ] ) + q = dumbfile_getc( f ); + r = dumbfile_getc( f ); + if ( q ) { entry->mask |= IT_ENTRY_INSTRUMENT; - entry->instrument = data[ pos ]; + entry->instrument = q; } - if ( data[ pos + 1 ] ) + if ( r ) { entry->mask |= IT_ENTRY_NOTE; - entry->note = data[ pos + 1 ] - 1; + entry->note = r - 1; } - pos += 2; } if ( flags & 0x20 ) { + q = dumbfile_getc( f ); entry->mask |= IT_ENTRY_VOLPAN; - if ( ver == 0 ) entry->volpan = data[ pos ]; - else entry->volpan = data[ pos ] * 64 / 127; - ++ pos; + if ( ver == 0 ) entry->volpan = q; + else entry->volpan = q * 64 / 127; } if (entry->mask) entry++; @@ -253,14 +262,11 @@ static int it_riff_am_process_pattern( IT_PATTERN * pattern, const unsigned char return 0; } -static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( struct riff * stream ) +static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( DUMBFILE * f, struct riff * stream ) { DUMB_IT_SIGDATA *sigdata; - int n, found; - unsigned int o; - - unsigned char * ptr; + int n, o, p, found; if ( ! stream ) goto error; @@ -275,7 +281,7 @@ static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( struct riff * stream ) found = 0; - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch( c->type ) @@ -291,23 +297,28 @@ static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( struct riff * stream ) found |= 2; break; - case DUMB_ID( 'P', 'A', 'T', 'T' ): - ptr = ( unsigned char * ) c->data; - if ( ptr[ 0 ] >= sigdata->n_patterns ) sigdata->n_patterns = ptr[ 0 ] + 1; - o = ptr[ 1 ] | ( ptr[ 2 ] << 8 ) | ( ptr[ 3 ] << 16 ) | ( ptr[ 4 ] << 24 ); - if ( o + 5 > c->size ) goto error_sd; + case DUMB_ID( 'P', 'A', 'T', 'T' ): + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_sd; + o = dumbfile_getc( f ); + if ( o >= sigdata->n_patterns ) sigdata->n_patterns = o + 1; + o = dumbfile_igetl( f ); + if ( (unsigned)o + 5 > c->size ) goto error_sd; break; case DUMB_ID( 'I', 'N', 'S', 'T' ): { - if ( c->size < 0xE1 ) goto error; - ptr = ( unsigned char * ) c->data; - if ( ptr[ 1 ] >= sigdata->n_samples ) sigdata->n_samples = ptr[ 1 ] + 1; - if ( c->size >= 0x121 && ( ptr[ 0xE1 ] == 'S' && ptr[ 0xE2 ] == 'A' && - ptr[ 0xE3 ] == 'M' && ptr[ 0xE4 ] == 'P' ) ) - { - unsigned size = ptr[ 0xE5 ] | ( ptr[ 0xE6 ] << 8 ) | ( ptr[ 0xE7 ] << 16 ) | ( ptr[ 0xE8 ] << 24 ); - if ( size + 0xE1 + 8 > c->size ) goto error; + if ( c->size < 0xE1 ) goto error_sd; + if ( dumbfile_seek( f, c->offset + 1, DFS_SEEK_SET ) ) goto error_sd; + o = dumbfile_getc( f ); + if ( o >= sigdata->n_samples ) sigdata->n_samples = o + 1; + if ( c->size >= 0x121 ) + { + if ( dumbfile_seek( f, c->offset + 0xE1, DFS_SEEK_SET ) ) goto error_sd; + if ( dumbfile_mgetl( f ) == DUMB_ID('S','A','M','P') ) + { + unsigned size = dumbfile_igetl( f ); + if ( size + 0xE1 + 8 > c->size ) goto error_sd; + } } } break; @@ -336,36 +347,41 @@ static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( struct riff * stream ) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'M', 'A', 'I', 'N' ): - ptr = ( unsigned char * ) c->data; - memcpy( sigdata->name, c->data, 64 ); + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + dumbfile_getnc( (char *) sigdata->name, 64, f ); sigdata->name[ 64 ] = 0; sigdata->flags = IT_STEREO | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_WAS_AN_S3M; - if ( ! ( ptr[ 0x40 ] & 1 ) ) sigdata->flags |= IT_LINEAR_SLIDES; - if ( ( ptr[ 0x40 ] & ~3 ) || ! ( ptr[ 0x40 ] & 2 ) ) goto error_usd; // unknown flags - sigdata->n_pchannels = ptr[ 0x41 ]; - sigdata->speed = ptr[ 0x42 ]; - sigdata->tempo = ptr[ 0x43 ]; + o = dumbfile_getc( f ); + if ( ! ( o & 1 ) ) sigdata->flags |= IT_LINEAR_SLIDES; + if ( ( o & ~3 ) || ! ( o & 2 ) ) goto error_usd; // unknown flags + sigdata->n_pchannels = dumbfile_getc( f ); + sigdata->speed = dumbfile_getc( f ); + sigdata->tempo = dumbfile_getc( f ); - sigdata->global_volume = ptr[ 0x48 ]; + dumbfile_skip( f, 4 ); - if ( (int)c->size < 0x48 + sigdata->n_pchannels ) goto error_usd; + sigdata->global_volume = dumbfile_getc( f ); - for ( o = 0; (int)o < sigdata->n_pchannels; ++o ) + if ( c->size < 0x48 + (unsigned)sigdata->n_pchannels ) goto error_usd; + + for ( o = 0; o < sigdata->n_pchannels; ++o ) { - sigdata->channel_pan[ o ] = ptr[ 0x49 + o ]; - if ( ptr[ 0x49 + o ] >= 128 ) + p = dumbfile_getc( f ); + sigdata->channel_pan[ o ] = p; + if ( p >= 128 ) { sigdata->channel_volume[ o ] = 0; } @@ -389,43 +405,46 @@ static DUMB_IT_SIGDATA *it_riff_amff_load_sigdata( struct riff * stream ) sample->name[ 0 ] = 0; } - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'O', 'R', 'D', 'R' ): - ptr = ( unsigned char * ) c->data; - sigdata->n_orders = ptr[ 0 ] + 1; - if ( sigdata->n_orders + 1 > (int)c->size ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + sigdata->n_orders = dumbfile_getc( f ) + 1; + if ( (unsigned)sigdata->n_orders + 1 > c->size ) goto error_usd; sigdata->order = malloc( sigdata->n_orders ); if ( ! sigdata->order ) goto error_usd; - memcpy( sigdata->order, ptr + 1, sigdata->n_orders ); + dumbfile_getnc( (char *) sigdata->order, sigdata->n_orders, f ); break; case DUMB_ID( 'P', 'A', 'T', 'T' ): - ptr = ( unsigned char * ) c->data; - o = ptr[ 1 ] | ( ptr[ 2 ] << 8 ) | ( ptr[ 3 ] << 16 ) | ( ptr[ 4 ] << 24 ); - if ( it_riff_am_process_pattern( sigdata->pattern + ptr[ 0 ], ptr + 5, o, 0 ) ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + o = dumbfile_getc( f ); + p = dumbfile_igetl( f ); + if ( it_riff_am_process_pattern( sigdata->pattern + o, f, p, 0 ) ) goto error_usd; break; case DUMB_ID( 'I', 'N', 'S', 'T' ): { IT_SAMPLE * sample; - ptr = ( unsigned char * ) c->data; - sample = sigdata->sample + ptr[ 1 ]; - if ( c->size >= 0x121 && ( ptr[ 0xE1 ] == 'S' && ptr[ 0xE2 ] == 'A' && - ptr[ 0xE3 ] == 'M' && ptr[ 0xE4 ] == 'P' ) ) - { - unsigned size = ptr[ 0xE5 ] | ( ptr[ 0xE6 ] << 8 ) | ( ptr[ 0xE7 ] << 16 ) | ( ptr[ 0xE8 ] << 24 ); - if ( it_riff_am_process_sample( sample, ptr + 0xE1 + 8, size, 0 ) ) goto error_usd; + if ( dumbfile_seek( f, c->offset + 1, DFS_SEEK_SET ) ) goto error_usd; + sample = sigdata->sample + dumbfile_getc( f ); + if ( c->size >= 0x121 ) + { + if ( dumbfile_seek( f, c->offset + 0xE1, DFS_SEEK_SET ) ) goto error_usd; + if ( dumbfile_mgetl( f ) == DUMB_ID('S','A','M','P') ) + { + unsigned size = dumbfile_igetl( f ); + if ( it_riff_am_process_sample( sample, f, size, 0 ) ) goto error_usd; + break; + } } - else - { - memcpy( sample->name, ptr + 2, 28 ); - sample->name[ 28 ] = 0; - } - } + dumbfile_seek( f, c->offset + 2, DFS_SEEK_SET ); + dumbfile_getnc( (char *) sample->name, 28, f ); + sample->name[ 28 ] = 0; + } break; } } @@ -443,15 +462,13 @@ error: return NULL; } -static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) +static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( DUMBFILE * f, struct riff * stream ) { DUMB_IT_SIGDATA *sigdata; int n, o, p, found; - unsigned char * ptr; - - if ( ! stream ) goto error; + if ( ! f || ! stream ) goto error; if ( stream->type != DUMB_ID( 'A', 'M', ' ', ' ' ) ) goto error; @@ -464,7 +481,7 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) found = 0; - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch( c->type ) @@ -481,19 +498,20 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) break; case DUMB_ID( 'P', 'A', 'T', 'T' ): - ptr = ( unsigned char * ) c->data; - if ( ptr[ 0 ] >= sigdata->n_patterns ) sigdata->n_patterns = ptr[ 0 ] + 1; - o = ptr[ 1 ] | ( ptr[ 2 ] << 8 ) | ( ptr[ 3 ] << 16 ) | ( ptr[ 4 ] << 24 ); - if ( o + 5 > (int)c->size ) goto error_sd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_sd; + o = dumbfile_getc( f ); + if ( o >= sigdata->n_patterns ) sigdata->n_patterns = o + 1; + o = dumbfile_igetl( f ); + if ( (unsigned)o + 5 > c->size ) goto error_sd; break; case DUMB_ID( 'R', 'I', 'F', 'F' ): { - struct riff * str = ( struct riff * ) c->data; + struct riff * str = c->nested; switch ( str->type ) { case DUMB_ID( 'A', 'I', ' ', ' ' ): - for ( o = 0; (unsigned int)o < str->chunk_count; ++o ) + for ( o = 0; (unsigned)o < str->chunk_count; ++o ) { struct riff_chunk * chk = str->chunks + o; switch( chk->type ) @@ -503,24 +521,26 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) struct riff * temp; unsigned size; unsigned sample_found; - ptr = ( unsigned char * ) chk->data; - size = ptr[ 0 ] | ( ptr[ 1 ] << 8 ) | ( ptr[ 2 ] << 16 ) | ( ptr[ 3 ] << 24 ); - if ( size < 0x142 ) goto error; + if ( dumbfile_seek( f, chk->offset, DFS_SEEK_SET ) ) goto error_sd; + size = dumbfile_igetl( f ); + if ( size < 0x142 ) goto error_sd; sample_found = 0; - if ( ptr[ 5 ] >= sigdata->n_samples ) sigdata->n_samples = ptr[ 5 ] + 1; - temp = riff_parse( ptr + 4 + size, chk->size - size - 4, 1 ); + dumbfile_skip( f, 1 ); + p = dumbfile_getc( f ); + if ( p >= sigdata->n_samples ) sigdata->n_samples = p + 1; + temp = riff_parse( f, chk->offset + 4 + size, chk->size - size - 4, 1 ); if ( temp ) { if ( temp->type == DUMB_ID( 'A', 'S', ' ', ' ' ) ) { - for ( p = 0; (unsigned int)p < temp->chunk_count; ++p ) + for ( p = 0; (unsigned)p < temp->chunk_count; ++p ) { if ( temp->chunks[ p ].type == DUMB_ID( 'S', 'A', 'M', 'P' ) ) { if ( sample_found ) { riff_free( temp ); - goto error; + goto error_sd; } sample_found = 1; } @@ -559,37 +579,42 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'I', 'N', 'I', 'T' ): - ptr = ( unsigned char * ) c->data; - memcpy( sigdata->name, c->data, 64 ); + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + dumbfile_getnc( (char *) sigdata->name, 64, f ); sigdata->name[ 64 ] = 0; sigdata->flags = IT_STEREO | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_WAS_AN_S3M; - if ( ! ( ptr[ 0x40 ] & 1 ) ) sigdata->flags |= IT_LINEAR_SLIDES; - if ( ( ptr[ 0x40 ] & ~3 ) || ! ( ptr[ 0x40 ] & 2 ) ) goto error_usd; // unknown flags - sigdata->n_pchannels = ptr[ 0x41 ]; - sigdata->speed = ptr[ 0x42 ]; - sigdata->tempo = ptr[ 0x43 ]; + o = dumbfile_getc( f ); + if ( ! ( o & 1 ) ) sigdata->flags |= IT_LINEAR_SLIDES; + if ( ( o & ~3 ) || ! ( o & 2 ) ) goto error_usd; // unknown flags + sigdata->n_pchannels = dumbfile_getc( f ); + sigdata->speed = dumbfile_getc( f ); + sigdata->tempo = dumbfile_getc( f ); - sigdata->global_volume = ptr[ 0x48 ]; + dumbfile_skip( f, 4 ); - if ( (int)c->size < 0x48 + sigdata->n_pchannels ) goto error_usd; + sigdata->global_volume = dumbfile_getc( f ); + + if ( c->size < 0x48 + (unsigned)sigdata->n_pchannels ) goto error_usd; for ( o = 0; o < sigdata->n_pchannels; ++o ) { - if ( ptr[ 0x49 + o ] <= 128 ) + p = dumbfile_getc( f ); + if ( p <= 128 ) { - sigdata->channel_pan[ o ] = ptr[ 0x49 + o ] / 2; + sigdata->channel_pan[ o ] = p / 2; } else { @@ -615,33 +640,34 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) sample->name[ 0 ] = 0; } - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'O', 'R', 'D', 'R' ): - ptr = ( unsigned char * ) c->data; - sigdata->n_orders = ptr[ 0 ] + 1; - if ( sigdata->n_orders + 1 > (int)c->size ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + sigdata->n_orders = dumbfile_getc( f ) + 1; + if ( (unsigned)sigdata->n_orders + 1 > c->size ) goto error_usd; sigdata->order = malloc( sigdata->n_orders ); if ( ! sigdata->order ) goto error_usd; - memcpy( sigdata->order, ptr + 1, sigdata->n_orders ); + dumbfile_getnc( (char *) sigdata->order, sigdata->n_orders, f ); break; case DUMB_ID( 'P', 'A', 'T', 'T' ): - ptr = ( unsigned char * ) c->data; - o = ptr[ 1 ] | ( ptr[ 2 ] << 8 ) | ( ptr[ 3 ] << 16 ) | ( ptr[ 4 ] << 24 ); - if ( it_riff_am_process_pattern( sigdata->pattern + ptr[ 0 ], ptr + 5, o, 1 ) ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + o = dumbfile_getc( f ); + p = dumbfile_igetl( f ); + if ( it_riff_am_process_pattern( sigdata->pattern + o, f, p, 1 ) ) goto error_usd; break; case DUMB_ID( 'R', 'I', 'F', 'F' ): { - struct riff * str = ( struct riff * ) c->data; + struct riff * str = c->nested; switch ( str->type ) { case DUMB_ID('A', 'I', ' ', ' '): - for ( o = 0; (unsigned int)o < str->chunk_count; ++o ) + for ( o = 0; (unsigned)o < str->chunk_count; ++o ) { struct riff_chunk * chk = str->chunks + o; switch( chk->type ) @@ -652,16 +678,18 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) unsigned size; unsigned sample_found; IT_SAMPLE * sample; - ptr = ( unsigned char * ) chk->data; - size = ptr[ 0 ] | ( ptr[ 1 ] << 8 ) | ( ptr[ 2 ] << 16 ) | ( ptr[ 3 ] << 24 ); - temp = riff_parse( ptr + 4 + size, chk->size - size - 4, 1 ); + if ( dumbfile_seek( f, chk->offset, DFS_SEEK_SET ) ) goto error_usd; + size = dumbfile_igetl( f ); + dumbfile_skip( f, 1 ); + p = dumbfile_getc( f ); + temp = riff_parse( f, chk->offset + 4 + size, chk->size - size - 4, 1 ); sample_found = 0; - sample = sigdata->sample + ptr[ 5 ]; + sample = sigdata->sample + p; if ( temp ) { if ( temp->type == DUMB_ID( 'A', 'S', ' ', ' ' ) ) { - for ( p = 0; (unsigned int)p < temp->chunk_count; ++p ) + for ( p = 0; (unsigned)p < temp->chunk_count; ++p ) { struct riff_chunk * c = temp->chunks + p; if ( c->type == DUMB_ID( 'S', 'A', 'M', 'P' ) ) @@ -671,7 +699,11 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) riff_free( temp ); goto error_usd; } - if ( it_riff_am_process_sample( sigdata->sample + ptr[ 5 ], ( unsigned char * ) c->data, c->size, 1 ) ) + { + riff_free( temp ); + goto error_usd; + } + if ( it_riff_am_process_sample( sample, f, c->size, 1 ) ) { riff_free( temp ); goto error_usd; @@ -684,7 +716,8 @@ static DUMB_IT_SIGDATA *it_riff_am_load_sigdata( struct riff * stream ) } if ( ! sample_found ) { - memcpy( sample->name, ptr + 6, 32 ); + dumbfile_seek( f, chk->offset + 6, DFS_SEEK_SET ); + dumbfile_getnc( (char *) sample->name, 32, f ); sample->name[ 32 ] = 0; } } @@ -709,15 +742,14 @@ error: return NULL; } - -DUH *dumb_read_riff_amff( struct riff * stream ) +DUH *dumb_read_riff_amff( DUMBFILE * f, struct riff * stream ) { sigdata_t *sigdata; - int32 length; + long length; DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_riff_amff_load_sigdata( stream ); + sigdata = it_riff_amff_load_sigdata( f, stream ); if (!sigdata) return NULL; @@ -727,20 +759,20 @@ DUH *dumb_read_riff_amff( struct riff * stream ) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "RIFF AMFF"; return make_duh( length, 2, ( const char * const (*) [ 2 ] ) tag, 1, & descptr, & sigdata ); } } -DUH *dumb_read_riff_am( struct riff * stream ) +DUH *dumb_read_riff_am( DUMBFILE * f, struct riff * stream ) { sigdata_t *sigdata; DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_riff_am_load_sigdata( stream ); + sigdata = it_riff_am_load_sigdata( f, stream ); if (!sigdata) return NULL; @@ -748,7 +780,7 @@ DUH *dumb_read_riff_am( struct riff * stream ) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "RIFF AM"; return make_duh( -1, 2, ( const char * const (*) [ 2 ] ) tag, 1, & descptr, & sigdata ); diff --git a/dumb/src/it/readamf.c b/dumb/src/it/readamf.c new file mode 100644 index 0000000000..83f6075e7c --- /dev/null +++ b/dumb/src/it/readamf.c @@ -0,0 +1,557 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * readamf.c - Code to read a DSMI AMF module from / / \ \ + * an open file. | < / \_ + * | \/ /\ / + * By Chris Moeller. \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#include +#include +#include + +#include "dumb.h" +#include "internal/it.h" + + + +static void it_amf_process_track( IT_ENTRY *entry_table, unsigned char *track, int rows, int channels ) +{ + int last_instrument = 0; + int tracksize = track[ 0 ] + ( track[ 1 ] << 8 ) + ( track[ 2 ] << 16 ); + track += 3; + while ( tracksize-- ) { + unsigned int row = track[ 0 ]; + unsigned int command = track[ 1 ]; + unsigned int argument = track[ 2 ]; + IT_ENTRY * entry = entry_table + row * channels; + if ( row >= ( unsigned int ) rows ) break; + if ( command < 0x7F ) { + entry->mask |= IT_ENTRY_NOTE | IT_ENTRY_INSTRUMENT | IT_ENTRY_VOLPAN; + entry->note = command; + if ( ! entry->instrument ) entry->instrument = last_instrument; + entry->volpan = argument; + } + else if ( command == 0x7F ) { + signed char row_delta = ( signed char ) argument; + int row_source = ( int ) row + ( int ) row_delta; + if ( row_source >= 0 && row_source < ( int ) rows ) { + *entry = entry_table[ row_source * channels ]; + } + } + else if ( command == 0x80 ) { + entry->mask |= IT_ENTRY_INSTRUMENT; + last_instrument = argument + 1; + entry->instrument = last_instrument; + } + else if ( command == 0x83 ) { + entry->mask |= IT_ENTRY_VOLPAN; + entry->volpan = argument; + } + else { + unsigned int effect = command & 0x7F; + unsigned int effectvalue = argument; + switch (effect) { + case 0x01: effect = IT_SET_SPEED; break; + + case 0x02: effect = IT_VOLUME_SLIDE; + case 0x0A: if ( effect == 0x0A ) effect = IT_VOLSLIDE_TONEPORTA; + case 0x0B: if ( effect == 0x0B ) effect = IT_VOLSLIDE_VIBRATO; + if ( effectvalue & 0x80 ) effectvalue = ( -( signed char ) effectvalue ) & 0x0F; + else effectvalue = ( effectvalue & 0x0F ) << 4; + break; + + case 0x04: + if ( effectvalue & 0x80 ) { + effect = IT_PORTAMENTO_UP; + effectvalue = ( -( signed char ) effectvalue ) & 0x7F; + } + else { + effect = IT_PORTAMENTO_DOWN; + } + break; + + case 0x06: effect = IT_TONE_PORTAMENTO; break; + + case 0x07: effect = IT_TREMOR; break; + + case 0x08: effect = IT_ARPEGGIO; break; + + case 0x09: effect = IT_VIBRATO; break; + + case 0x0C: effect = IT_BREAK_TO_ROW; break; + + case 0x0D: effect = IT_JUMP_TO_ORDER; break; + + case 0x0F: effect = IT_RETRIGGER_NOTE; break; + + case 0x10: effect = IT_SET_SAMPLE_OFFSET; break; + + case 0x11: + if ( effectvalue ) { + effect = IT_VOLUME_SLIDE; + if ( effectvalue & 0x80 ) + effectvalue = 0xF0 | ( ( -( signed char ) effectvalue ) & 0x0F ); + else + effectvalue = 0x0F | ( ( effectvalue & 0x0F ) << 4 ); + } + else + effect = 0; + break; + + case 0x12: + case 0x16: + if ( effectvalue ) { + int mask = ( effect == 0x16 ) ? 0xE0 : 0xF0; + effect = ( effectvalue & 0x80 ) ? IT_PORTAMENTO_UP : IT_PORTAMENTO_DOWN; + if ( effectvalue & 0x80 ) + effectvalue = mask | ( ( -( signed char ) effectvalue ) & 0x0F ); + else + effectvalue = mask | ( effectvalue & 0x0F ); + } + else + effect = 0; + break; + + case 0x13: + effect = IT_S; + effectvalue = EFFECT_VALUE( IT_S_NOTE_DELAY, effectvalue & 0x0F ); + break; + + case 0x14: + effect = IT_S; + effectvalue = EFFECT_VALUE( IT_S_DELAYED_NOTE_CUT, effectvalue & 0x0F ); + break; + + case 0x15: effect = IT_SET_SONG_TEMPO; break; + + case 0x17: + effectvalue = ( effectvalue + 64 ) & 0x7F; + if ( entry->mask & IT_ENTRY_EFFECT ) { + if ( !( entry->mask & IT_ENTRY_VOLPAN ) ) { + entry->mask |= IT_ENTRY_VOLPAN; + entry->volpan = ( effectvalue / 2 ) + 128; + } + effect = 0; + } + else { + effect = IT_SET_PANNING; + } + break; + + default: effect = effectvalue = 0; + } + if ( effect ) { + entry->mask |= IT_ENTRY_EFFECT; + entry->effect = effect; + entry->effectvalue = effectvalue; + } + } + track += 3; + } +} + +static int it_amf_process_pattern( IT_PATTERN *pattern, IT_ENTRY *entry_table, int rows, int channels ) +{ + int i, j; + int n_entries = rows; + IT_ENTRY * entry; + + pattern->n_rows = rows; + + for ( i = 0, j = channels * rows; i < j; i++ ) { + if ( entry_table[ i ].mask ) { + n_entries++; + } + } + + pattern->n_entries = n_entries; + + pattern->entry = entry = malloc( n_entries * sizeof( IT_ENTRY ) ); + if ( !entry ) { + return -1; + } + + for ( i = 0; i < rows; i++ ) { + for ( j = 0; j < channels; j++ ) { + if ( entry_table[ i * channels + j ].mask ) { + *entry = entry_table[ i * channels + j ]; + entry->channel = j; + entry++; + } + } + IT_SET_END_ROW( entry ); + entry++; + } + + return 0; +} + +static int it_amf_read_sample_header( IT_SAMPLE *sample, DUMBFILE *f, int * offset, int ver ) +{ + int exists; + + exists = dumbfile_getc( f ); + + dumbfile_getnc( (char *) sample->name, 32, f ); + sample->name[32] = 0; + + dumbfile_getnc( (char *) sample->filename, 13, f ); + sample->filename[13] = 0; + + *offset = dumbfile_igetl( f ); + sample->length = dumbfile_igetl( f ); + sample->C5_speed = dumbfile_igetw( f ); + sample->default_volume = dumbfile_getc( f ); + sample->global_volume = 64; + if ( sample->default_volume > 64 ) sample->default_volume = 64; + + if ( ver >= 11 ) { + sample->loop_start = dumbfile_igetl( f ); + sample->loop_end = dumbfile_igetl( f ); + } else { + sample->loop_start = dumbfile_igetw( f ); + sample->loop_end = sample->length; + } + + if ( sample->length <= 0 ) { + sample->flags = 0; + return 0; + } + + sample->flags = exists == 1 ? IT_SAMPLE_EXISTS : 0; + + sample->default_pan = 0; + sample->finetune = 0; + + if ( sample->loop_end > sample->loop_start + 2 && sample->loop_end <= sample->length ) + sample->flags |= IT_SAMPLE_LOOP; + + sample->vibrato_speed = 0; + sample->vibrato_depth = 0; + sample->vibrato_rate = 0; + sample->vibrato_waveform = 0; // do we have to set _all_ these? + sample->max_resampling_quality = -1; + + return dumbfile_error(f); +} + + + +static int it_amf_read_sample_data( IT_SAMPLE *sample, DUMBFILE *f ) +{ + int i, read_length = 0; + + sample->data = malloc( sample->length ); + + if ( !sample->data ) + return -1; + + if ( sample->length ) + read_length = dumbfile_getnc( sample->data, sample->length, f ); + + for ( i = 0; i < read_length; i++ ) { + ( ( char * ) sample->data )[ i ] ^= 0x80; + } + + for ( i = read_length; i < sample->length; i++ ) { + ( ( char * ) sample->data )[ i ] = 0; + } + + return 0; /* Sometimes the last sample is truncated :( */ +} + +static DUMB_IT_SIGDATA *it_amf_load_sigdata(DUMBFILE *f, int * version) +{ + DUMB_IT_SIGDATA *sigdata; + int i, j, ver, ntracks, realntracks, nchannels; + + int maxsampleseekpos = 0; + int sampleseekpos[256]; + + unsigned short *orderstotracks; + unsigned short *trackmap; + unsigned int tracksize[256]; + + unsigned char **track; + + static const char sig[] = "AMF"; + + char signature [3]; + + if ( dumbfile_getnc( signature, 3, f ) != 3 || + memcmp( signature, sig, 3 ) ) { + return NULL; + } + + *version = ver = dumbfile_getc( f ); + if ( ver < 10 || ver > 14) { + return NULL; + } + + sigdata = malloc(sizeof(*sigdata)); + if (!sigdata) { + return NULL; + } + + dumbfile_getnc( (char *) sigdata->name, 32, f ); + sigdata->name[ 32 ] = 0; + sigdata->n_samples = dumbfile_getc( f ); + sigdata->n_orders = dumbfile_getc( f ); + ntracks = dumbfile_igetw( f ); + nchannels = dumbfile_getc( f ); + + if ( dumbfile_error( f ) || + sigdata->n_samples < 1 || sigdata->n_samples > 255 || + sigdata->n_orders < 1 || sigdata->n_orders > 255 || + ! ntracks || + nchannels < 1 || nchannels > 32 ) { + free( sigdata ); + return NULL; + } + + memset( sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS ); + + if ( ver >= 11 ) { + int nchannels = ( ver >= 13 ) ? 32 : 16; + for ( i = 0; i < nchannels; i++ ) { + signed char panpos = dumbfile_getc( f ); + int pan = ( panpos + 64 ) / 2; + if ( pan < 0 ) pan = 0; + else if ( pan > 64 ) pan = IT_SURROUND; + sigdata->channel_pan[ i ] = pan; + } + } + else { + int sep = 32 * dumb_it_default_panning_separation / 100; + for ( i = 0; i < 16; i++ ) { + sigdata->channel_pan[ i ] = ( dumbfile_getc( f ) & 1 ) ? 32 - sep : 32 + sep; + } + } + + sigdata->tempo = 125; + sigdata->speed = 6; + if ( ver >= 13 ) { + i = dumbfile_getc( f ); + if ( i >= 32 ) sigdata->tempo = i; + i = dumbfile_getc( f ); + if ( i <= 32 ) sigdata->speed = i; + } + + sigdata->order = malloc( sigdata->n_orders ); + if ( !sigdata->order ) { + free( sigdata ); + return NULL; + } + + orderstotracks = malloc( sigdata->n_orders * nchannels * sizeof( unsigned short ) ); + if ( !orderstotracks ) { + free( sigdata->order ); + free( sigdata ); + return NULL; + } + + for ( i = 0; i < sigdata->n_orders; i++ ) { + sigdata->order[ i ] = i; + tracksize[ i ] = 64; + if ( ver >= 14 ) { + tracksize[ i ] = dumbfile_igetw( f ); + } + for ( j = 0; j < nchannels; j++ ) { + orderstotracks[ i * nchannels + j ] = dumbfile_igetw( f ); + } + } + + if ( dumbfile_error( f ) ) { + free( orderstotracks ); + free( sigdata->order ); + free( sigdata ); + return NULL; + } + + sigdata->sample = malloc( sigdata->n_samples * sizeof( *sigdata->sample ) ); + if ( !sigdata->sample ) { + free( orderstotracks ); + free( sigdata->order ); + free( sigdata ); + return NULL; + } + + sigdata->restart_position = 0; + + sigdata->song_message = NULL; + sigdata->instrument = NULL; + sigdata->pattern = NULL; + sigdata->midi = NULL; + sigdata->checkpoint = NULL; + + sigdata->n_instruments = 0; + + for ( i = 0; i < sigdata->n_samples; ++i ) + sigdata->sample[i].data = NULL; + + for ( i = 0; i < sigdata->n_samples; ++i ) { + int offset; + if ( it_amf_read_sample_header( &sigdata->sample[i], f, &offset, ver ) ) { + goto error_ott; + } + sampleseekpos[ i ] = offset; + if ( offset > maxsampleseekpos ) maxsampleseekpos = offset; + } + + sigdata->n_patterns = sigdata->n_orders; + + sigdata->pattern = malloc( sigdata->n_patterns * sizeof( *sigdata->pattern ) ); + if ( !sigdata->pattern ) { + goto error_ott; + } + for (i = 0; i < sigdata->n_patterns; ++i) + sigdata->pattern[i].entry = NULL; + + trackmap = malloc( ntracks * sizeof( unsigned short ) ); + if ( !trackmap ) { + goto error_ott; + } + + if ( dumbfile_getnc( ( char * ) trackmap, ntracks * sizeof( unsigned short ), f ) != (long)(ntracks * sizeof( unsigned short )) ) { + goto error_tm; + } + + realntracks = 0; + + for ( i = 0; i < ntracks; i++ ) { + if ( trackmap[ i ] > realntracks ) realntracks = trackmap[ i ]; + } + + track = calloc( realntracks, sizeof( unsigned char * ) ); + if ( !track ) { + goto error_tm; + } + + for ( i = 0; i < realntracks; i++ ) { + int tracksize = dumbfile_igetw( f ); + tracksize += dumbfile_getc( f ) << 16; + track[ i ] = malloc( tracksize * 3 + 3 ); + if ( !track[ i ] ) { + goto error_all; + } + track[ i ][ 0 ] = tracksize & 255; + track[ i ][ 1 ] = ( tracksize >> 8 ) & 255; + track[ i ][ 2 ] = ( tracksize >> 16 ) & 255; + if ( dumbfile_getnc( (char *) track[ i ] + 3, tracksize * 3, f ) != tracksize * 3 ) { + goto error_all; + } + } + + for ( i = 1; i <= maxsampleseekpos; i++ ) { + for ( j = 0; j < sigdata->n_samples; j++ ) { + if ( sampleseekpos[ j ] == i ) { + if ( it_amf_read_sample_data( &sigdata->sample[ j ], f ) ) { + goto error_all; + } + break; + } + } + } + + /* Process tracks into patterns */ + for ( i = 0; i < sigdata->n_patterns; i++ ) { + IT_ENTRY * entry_table = calloc( tracksize[ i ] * nchannels, sizeof( IT_ENTRY ) ); + if ( !entry_table ) { + goto error_all; + } + for ( j = 0; j < nchannels; j++ ) { + int ntrack = orderstotracks[ i * nchannels + j ]; + if ( ntrack && ntrack <= ntracks ) { + int realtrack = trackmap[ ntrack - 1 ]; + if ( realtrack ) { + realtrack--; + if ( realtrack < realntracks && track[ realtrack ] ) { + it_amf_process_track( entry_table + j, track[ realtrack ], tracksize[ i ], nchannels ); + } + } + } + } + if ( it_amf_process_pattern( &sigdata->pattern[ i ], entry_table, tracksize[ i ], nchannels ) ) { + free( entry_table ); + goto error_all; + } + free( entry_table ); + } + + /* Now let's initialise the remaining variables, and we're done! */ + sigdata->flags = IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_STEREO | IT_WAS_AN_S3M; + + sigdata->global_volume = 128; + sigdata->mixing_volume = 48; + sigdata->pan_separation = 128; + + _dumb_it_fix_invalid_orders(sigdata); + + for ( i = 0; i < realntracks; i++ ) { + if ( track[ i ] ) { + free( track[ i ] ); + } + } + free( track ); + free( trackmap ); + free( orderstotracks ); + + return sigdata; + +error_all: + for ( i = 0; i < realntracks; i++ ) { + if ( track[ i ] ) { + free( track[ i ] ); + } + } + free( track ); +error_tm: + free( trackmap ); +error_ott: + free( orderstotracks ); + _dumb_it_unload_sigdata( sigdata ); + return NULL; +} + + + +DUH *DUMBEXPORT dumb_read_amf_quick(DUMBFILE *f) +{ + sigdata_t *sigdata; + + DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; + + int version; + + sigdata = it_amf_load_sigdata(f, &version); + + if (!sigdata) + return NULL; + + { + const char *tag[2][2]; + char ver_string[14]; + tag[0][0] = "TITLE"; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); + tag[1][0] = "FORMAT"; + memcpy( ver_string, "DSMI AMF v", 10 ); + ver_string[10] = '0' + version / 10; + ver_string[11] = '.'; + ver_string[12] = '0' + version % 10; + ver_string[13] = 0; + tag[1][1] = ver_string; + return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); + } +} diff --git a/dumb/src/it/readamf2.c b/dumb/src/it/readamf2.c new file mode 100644 index 0000000000..b339d3bfa8 --- /dev/null +++ b/dumb/src/it/readamf2.c @@ -0,0 +1,29 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * readamf2.c - Function to read a DSMI AMF module / / \ \ + * from an open file and do an initial | < / \_ + * run-through. | \/ /\ / + * \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#include "dumb.h" + + + +DUH *DUMBEXPORT dumb_read_amf(DUMBFILE *f) +{ + DUH *duh = dumb_read_amf_quick(f); + dumb_it_do_initial_runthrough(duh); + return duh; +} diff --git a/dumb/src/it/readany.c b/dumb/src/it/readany.c new file mode 100644 index 0000000000..9d90776ff0 --- /dev/null +++ b/dumb/src/it/readany.c @@ -0,0 +1,132 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * readany.c - Code to detect and read any of the / / \ \ + * module formats supported by DUMB. | < / \_ + * | \/ /\ / + * By Chris Moeller. \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#include +#include + +#include "dumb.h" + +#ifdef _MSC_VER + #define strnicmp _strnicmp +#else + #if defined(unix) || defined(__unix__) || defined(__unix) + #include + #endif + #define strnicmp strncasecmp +#endif + +enum { maximum_signature_size = 0x30 }; + +DUH *DUMBEXPORT dumb_read_any_quick(DUMBFILE *f, int restrict_, int subsong) +{ + unsigned char signature[ maximum_signature_size ]; + unsigned long signature_size; + DUH * duh = NULL; + + signature_size = dumbfile_get_size(f); + + signature_size = dumbfile_getnc( (char *)signature, maximum_signature_size, f ); + dumbfile_seek( f, 0, DFS_SEEK_SET ); + + if (signature_size >= 4 && + signature[0] == 'I' && signature[1] == 'M' && + signature[2] == 'P' && signature[3] == 'M') + { + duh = dumb_read_it_quick( f ); + } + else if (signature_size >= 17 && !memcmp(signature, "Extended Module: ", 17)) + { + duh = dumb_read_xm_quick( f ); + } + else if (signature_size >= 0x30 && + signature[0x2C] == 'S' && signature[0x2D] == 'C' && + signature[0x2E] == 'R' && signature[0x2F] == 'M') + { + duh = dumb_read_s3m_quick( f ); + } + else if (signature_size >= 30 && + /*signature[28] == 0x1A &&*/ signature[29] == 2 && + ( ! strnicmp( ( const char * ) signature + 20, "!Scream!", 8 ) || + ! strnicmp( ( const char * ) signature + 20, "BMOD2STM", 8 ) || + ! strnicmp( ( const char * ) signature + 20, "WUZAMOD!", 8 ) ) ) + { + duh = dumb_read_stm_quick( f ); + } + else if (signature_size >= 2 && + ((signature[0] == 0x69 && signature[1] == 0x66) || + (signature[0] == 0x4A && signature[1] == 0x4E))) + { + duh = dumb_read_669_quick( f ); + } + else if (signature_size >= 0x30 && + signature[0x2C] == 'P' && signature[0x2D] == 'T' && + signature[0x2E] == 'M' && signature[0x2F] == 'F') + { + duh = dumb_read_ptm_quick( f ); + } + else if (signature_size >= 4 && + signature[0] == 'P' && signature[1] == 'S' && + signature[2] == 'M' && signature[3] == ' ') + { + duh = dumb_read_psm_quick( f, subsong ); + } + else if (signature_size >= 4 && + signature[0] == 'P' && signature[1] == 'S' && + signature[2] == 'M' && signature[3] == 254) + { + duh = dumb_read_old_psm_quick( f ); + } + else if (signature_size >= 3 && + signature[0] == 'M' && signature[1] == 'T' && + signature[2] == 'M') + { + duh = dumb_read_mtm_quick( f ); + } + else if ( signature_size >= 4 && + signature[0] == 'R' && signature[1] == 'I' && + signature[2] == 'F' && signature[3] == 'F') + { + duh = dumb_read_riff_quick( f ); + } + else if ( signature_size >= 24 && + !memcmp( signature, "ASYLUM Music Format", 19 ) && + !memcmp( signature + 19, " V1.0", 5 ) ) + { + duh = dumb_read_asy_quick( f ); + } + else if ( signature_size >= 3 && + signature[0] == 'A' && signature[1] == 'M' && + signature[2] == 'F') + { + duh = dumb_read_amf_quick( f ); + } + else if ( signature_size >= 8 && + !memcmp( signature, "OKTASONG", 8 ) ) + { + duh = dumb_read_okt_quick( f ); + } + + if ( !duh ) + { + dumbfile_seek( f, 0, DFS_SEEK_SET ); + duh = dumb_read_mod_quick( f, restrict_ ); + } + + return duh; +} diff --git a/dumb/src/it/readany2.c b/dumb/src/it/readany2.c new file mode 100644 index 0000000000..083d0b12c3 --- /dev/null +++ b/dumb/src/it/readany2.c @@ -0,0 +1,29 @@ +/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * readany2.c - Code to detect and read any of the / / \ \ + * module formats supported by DUMB | < / \_ + * from an open file and do an initial | \/ /\ / + * run-through. \_ / > / + * | \ / / + * by Chris Moeller. | ' / + * \__/ + */ + +#include "dumb.h" + + + +DUH *DUMBEXPORT dumb_read_any(DUMBFILE *f, int restrict_, int subsong) +{ + DUH *duh = dumb_read_any_quick(f, restrict_, subsong); + dumb_it_do_initial_runthrough(duh); + return duh; +} diff --git a/dumb/src/it/readasy.c b/dumb/src/it/readasy.c index 5738b78a1b..9b88b9a6b3 100644 --- a/dumb/src/it/readasy.c +++ b/dumb/src/it/readasy.c @@ -35,7 +35,7 @@ static int it_asy_read_pattern( IT_PATTERN *pattern, DUMBFILE *f, unsigned char pattern->n_rows = 64; - if ( dumbfile_getnc( buffer, 64 * 8 * 4, f ) != 64 * 8 * 4 ) + if ( dumbfile_getnc( (char *) buffer, 64 * 8 * 4, f ) != 64 * 8 * 4 ) return -1; /* compute number of entries */ @@ -72,6 +72,13 @@ static int it_asy_read_pattern( IT_PATTERN *pattern, DUMBFILE *f, unsigned char } _dumb_it_xm_convert_effect( buffer[ pos + 2 ], buffer[ pos + 3 ], entry, 1 ); + + // fixup + switch ( entry->effect ) { + case IT_SET_PANNING: + entry->effectvalue <<= 1; + break; + } if ( entry->mask ) ++entry; } @@ -101,7 +108,7 @@ If the sample name begins with a '#' character (ASCII $23 (35)) then this is assumed not to be an instrument name, and is probably a message. */ - dumbfile_getnc( sample->name, 22, f ); + dumbfile_getnc( (char *) sample->name, 22, f ); sample->name[22] = 0; sample->filename[0] = 0; @@ -212,7 +219,7 @@ static DUMB_IT_SIGDATA *it_asy_load_sigdata(DUMBFILE *f) return NULL; } - if ( dumbfile_getnc( sigdata->order, sigdata->n_orders, f ) != sigdata->n_orders || + if ( dumbfile_getnc( (char *) sigdata->order, sigdata->n_orders, f ) != sigdata->n_orders || dumbfile_skip( f, 256 - sigdata->n_orders ) ) { free( sigdata->order ); free( sigdata ); @@ -296,10 +303,11 @@ static DUMB_IT_SIGDATA *it_asy_load_sigdata(DUMBFILE *f) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (i = 0; i < DUMB_IT_N_CHANNELS; i += 4) { - sigdata->channel_pan[i+0] = 16; - sigdata->channel_pan[i+1] = 48; - sigdata->channel_pan[i+2] = 48; - sigdata->channel_pan[i+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[i+0] = 32 - sep; + sigdata->channel_pan[i+1] = 32 + sep; + sigdata->channel_pan[i+2] = 32 + sep; + sigdata->channel_pan[i+3] = 32 - sep; } _dumb_it_fix_invalid_orders(sigdata); @@ -323,7 +331,7 @@ DUH *DUMBEXPORT dumb_read_asy_quick(DUMBFILE *f) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "ASYLUM Music Format"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/readdsmf.c b/dumb/src/it/readdsmf.c index be545a678c..7dd88c99da 100644 --- a/dumb/src/it/readdsmf.c +++ b/dumb/src/it/readdsmf.c @@ -24,22 +24,22 @@ #include "internal/it.h" #include "internal/riff.h" -DUH *dumb_read_riff_dsmf( struct riff * stream ); - -static int it_riff_dsmf_process_sample( IT_SAMPLE * sample, const unsigned char * data, int len ) +static int it_riff_dsmf_process_sample( IT_SAMPLE * sample, DUMBFILE * f, int len ) { int flags; - memcpy( sample->filename, data, 13 ); - sample->filename[ 13 ] = 0; - - flags = data[ 13 ] | ( data[ 14 ] << 8 ); - sample->default_volume = data[ 15 ]; - sample->length = data[ 16 ] | ( data[ 17 ] << 8 ) | ( data[ 18 ] << 16 ) | ( data[ 19 ] << 24 ); - sample->loop_start = data[ 20 ] | ( data[ 21 ] << 8 ) | ( data[ 22 ] << 16 ) | ( data[ 23 ] << 24 ); - sample->loop_end = data[ 24 ] | ( data[ 25 ] << 8 ) | ( data[ 26 ] << 16 ) | ( data[ 27 ] << 24 ); - sample->C5_speed = ( data[ 32 ] | ( data[ 33 ] << 8 ) ) * 2; - memcpy( sample->name, data + 36, 28 ); + dumbfile_getnc( (char *) sample->filename, 13, f ); + sample->filename[ 14 ] = 0; + + flags = dumbfile_igetw( f ); + sample->default_volume = dumbfile_getc( f ); + sample->length = dumbfile_igetl( f ); + sample->loop_start = dumbfile_igetl( f ); + sample->loop_end = dumbfile_igetl( f ); + dumbfile_skip( f, 32 - 28 ); + sample->C5_speed = dumbfile_igetw( f ) * 2; + dumbfile_skip( f, 36 - 34 ); + dumbfile_getnc( (char *) sample->name, 28, f ); sample->name[ 28 ] = 0; /*if ( data[ 0x38 ] || data[ 0x39 ] || data[ 0x3A ] || data[ 0x3B ] ) @@ -82,7 +82,7 @@ static int it_riff_dsmf_process_sample( IT_SAMPLE * sample, const unsigned char if ( ! sample->data ) return -1; - memcpy( sample->data, data + 64, sample->length ); + dumbfile_getnc( sample->data, sample->length, f ); if ( ! ( flags & 2 ) ) { @@ -93,39 +93,42 @@ static int it_riff_dsmf_process_sample( IT_SAMPLE * sample, const unsigned char return 0; } -static int it_riff_dsmf_process_pattern( IT_PATTERN * pattern, const unsigned char * data, int len ) +static int it_riff_dsmf_process_pattern( IT_PATTERN * pattern, DUMBFILE * f, int len ) { - int length, row, pos; + int length, row; unsigned flags; + long start, end; + int p, q, r; IT_ENTRY * entry; - length = data[ 0 ] | ( data[ 1 ] << 8 ); + length = dumbfile_igetw( f ); if ( length > len ) return -1; - data += 2; len = length - 2; pattern->n_rows = 64; pattern->n_entries = 64; row = 0; - pos = 0; - while ( (row < 64) && (pos < len) ) { - if ( ! data[ pos ] ) { + start = dumbfile_pos( f ); + end = start + len; + + while ( (row < 64) && !dumbfile_error( f ) && (dumbfile_pos( f ) < end) ) { + p = dumbfile_getc( f ); + if ( ! p ) { ++ row; - ++ pos; continue; } - flags = data[ pos++ ] & 0xF0; + flags = p & 0xF0; if (flags) { ++ pattern->n_entries; - if (flags & 0x80) pos ++; - if (flags & 0x40) pos ++; - if (flags & 0x20) pos ++; - if (flags & 0x10) pos += 2; + if (flags & 0x80) dumbfile_skip( f, 1 ); + if (flags & 0x40) dumbfile_skip( f, 1 ); + if (flags & 0x20) dumbfile_skip( f, 1 ); + if (flags & 0x10) dumbfile_skip( f, 2 ); } } @@ -137,20 +140,21 @@ static int it_riff_dsmf_process_pattern( IT_PATTERN * pattern, const unsigned ch entry = pattern->entry; row = 0; - pos = 0; - while ( ( row < 64 ) && ( pos < len ) ) + if ( dumbfile_seek( f, start, DFS_SEEK_SET ) ) return -1; + + while ( ( row < 64 ) && !dumbfile_error( f ) && ( dumbfile_pos( f ) < end ) ) { - if ( ! data[ pos ] ) + p = dumbfile_getc( f ); + if ( ! p ) { IT_SET_END_ROW( entry ); ++ entry; ++ row; - ++ pos; continue; } - flags = data[ pos++ ]; + flags = p; entry->channel = flags & 0x0F; entry->mask = 0; @@ -158,35 +162,35 @@ static int it_riff_dsmf_process_pattern( IT_PATTERN * pattern, const unsigned ch { if ( flags & 0x80 ) { - if ( data[ pos ] ) + q = dumbfile_getc( f ); + if ( q ) { entry->mask |= IT_ENTRY_NOTE; - entry->note = data[ pos ] - 1; + entry->note = q - 1; } - ++ pos; } if ( flags & 0x40 ) { - if ( data[ pos ] ) + q = dumbfile_getc( f ); + if ( q ) { entry->mask |= IT_ENTRY_INSTRUMENT; - entry->instrument = data[ pos ]; + entry->instrument = q; } - ++ pos; } if ( flags & 0x20 ) { entry->mask |= IT_ENTRY_VOLPAN; - entry->volpan = data[ pos ]; - ++ pos; + entry->volpan = dumbfile_getc( f ); } if ( flags & 0x10 ) { - _dumb_it_xm_convert_effect( data[ pos ], data[ pos + 1 ], entry, 0 ); - pos += 2; + q = dumbfile_getc( f ); + r = dumbfile_getc( f ); + _dumb_it_xm_convert_effect( q, r, entry, 0 ); } if (entry->mask) entry++; @@ -206,14 +210,12 @@ static int it_riff_dsmf_process_pattern( IT_PATTERN * pattern, const unsigned ch return 0; } -static DUMB_IT_SIGDATA *it_riff_dsmf_load_sigdata( struct riff * stream ) +static DUMB_IT_SIGDATA *it_riff_dsmf_load_sigdata( DUMBFILE * f, struct riff * stream ) { DUMB_IT_SIGDATA *sigdata; int n, o, found; - unsigned char * ptr; - if ( ! stream ) goto error; if ( stream->type != DUMB_ID( 'D', 'S', 'M', 'F' ) ) goto error; @@ -227,7 +229,7 @@ static DUMB_IT_SIGDATA *it_riff_dsmf_load_sigdata( struct riff * stream ) found = 0; - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch( c->type ) @@ -270,39 +272,42 @@ static DUMB_IT_SIGDATA *it_riff_dsmf_load_sigdata( struct riff * stream ) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'S', 'O', 'N', 'G' ): - ptr = ( unsigned char * ) c->data; - memcpy( sigdata->name, c->data, 28 ); + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + dumbfile_getnc( (char *) sigdata->name, 28, f ); sigdata->name[ 28 ] = 0; - sigdata->flags = IT_WAS_AN_XM | IT_WAS_A_MOD | IT_STEREO | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX; - sigdata->n_orders = ptr[ 36 ] | ( ptr[ 37 ] << 8 ); + sigdata->flags = IT_STEREO | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX; + dumbfile_skip( f, 36 - 28 ); + sigdata->n_orders = dumbfile_igetw( f ); //sigdata->n_samples = ptr[ 38 ] | ( ptr[ 39 ] << 8 ); // whatever //sigdata->n_patterns = ptr[ 40 ] | ( ptr[ 41 ] << 8 ); - sigdata->n_pchannels = ptr[ 42 ] | ( ptr[ 43 ] << 8 ); - sigdata->global_volume = ptr[ 44 ]; - sigdata->mixing_volume = ptr[ 45 ]; - sigdata->speed = ptr[ 46 ]; - sigdata->tempo = ptr[ 47 ]; + dumbfile_skip( f, 42 - 38 ); + sigdata->n_pchannels = dumbfile_igetw( f ); + sigdata->global_volume = dumbfile_getc( f ); + sigdata->mixing_volume = dumbfile_getc( f ); + sigdata->speed = dumbfile_getc( f ); + sigdata->tempo = dumbfile_getc( f ); for ( o = 0; o < 16; ++o ) { - sigdata->channel_pan[ o ] = ptr[ 48 + o ] / 2; + sigdata->channel_pan[ o ] = dumbfile_getc( f ) / 2; } sigdata->order = malloc( 128 ); if ( ! sigdata->order ) goto error_usd; - memcpy( sigdata->order, ptr + 64, 128 ); + dumbfile_getnc( (char *) sigdata->order, 128, f ); break; } @@ -324,18 +329,20 @@ static DUMB_IT_SIGDATA *it_riff_dsmf_load_sigdata( struct riff * stream ) sigdata->n_samples = 0; sigdata->n_patterns = 0; - for ( n = 0; (unsigned int)n < stream->chunk_count; ++n ) + for ( n = 0; (unsigned)n < stream->chunk_count; ++n ) { struct riff_chunk * c = stream->chunks + n; switch ( c->type ) { case DUMB_ID( 'P', 'A', 'T', 'T' ): - if ( it_riff_dsmf_process_pattern( sigdata->pattern + sigdata->n_patterns, ( unsigned char * ) c->data, c->size ) ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + if ( it_riff_dsmf_process_pattern( sigdata->pattern + sigdata->n_patterns, f, c->size ) ) goto error_usd; ++ sigdata->n_patterns; break; case DUMB_ID( 'I', 'N', 'S', 'T' ): - if ( it_riff_dsmf_process_sample( sigdata->sample + sigdata->n_samples, ( unsigned char * ) c->data, c->size ) ) goto error_usd; + if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_usd; + if ( it_riff_dsmf_process_sample( sigdata->sample + sigdata->n_samples, f, c->size ) ) goto error_usd; ++ sigdata->n_samples; break; } @@ -354,13 +361,13 @@ error: return NULL; } -DUH *dumb_read_riff_dsmf( struct riff * stream ) +DUH *dumb_read_riff_dsmf( DUMBFILE * f, struct riff * stream ) { sigdata_t *sigdata; DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_riff_dsmf_load_sigdata( stream ); + sigdata = it_riff_dsmf_load_sigdata( f, stream ); if (!sigdata) return NULL; @@ -368,7 +375,7 @@ DUH *dumb_read_riff_dsmf( struct riff * stream ) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "RIFF DSMF"; return make_duh( -1, 2, ( const char * const (*) [ 2 ] ) tag, 1, & descptr, & sigdata ); diff --git a/dumb/src/it/readmod.c b/dumb/src/it/readmod.c index 801b1ce766..80c61459d1 100644 --- a/dumb/src/it/readmod.c +++ b/dumb/src/it/readmod.c @@ -38,14 +38,14 @@ static int it_mod_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, if (n_channels == 0) { /* Read the first four channels, leaving gaps for the rest. */ for (pos = 0; pos < 64*8*4; pos += 8*4) - dumbfile_getnc(buffer + pos, 4*4, f); + dumbfile_getnc((char *)buffer + pos, 4*4, f); /* Read the other channels into the gaps we left. */ for (pos = 4*4; pos < 64*8*4; pos += 8*4) - dumbfile_getnc(buffer + pos, 4*4, f); + dumbfile_getnc((char *)buffer + pos, 4*4, f); n_channels = 8; } else - dumbfile_getnc(buffer, 64 * n_channels * 4, f); + dumbfile_getnc((char *)buffer, 64 * n_channels * 4, f); if (dumbfile_error(f)) return -1; @@ -118,7 +118,7 @@ static int it_mod_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, -static int it_mod_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f) +static int it_mod_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f, int stk) { int finetune, loop_start, loop_length; @@ -131,7 +131,7 @@ If the sample name begins with a '#' character (ASCII $23 (35)) then this is assumed not to be an instrument name, and is probably a message. */ - dumbfile_getnc(sample->name, 22, f); + dumbfile_getnc((char *)sample->name, 22, f); sample->name[22] = 0; sample->filename[0] = 0; @@ -141,7 +141,8 @@ assumed not to be an instrument name, and is probably a message. /** Each finetune step changes the note 1/8th of a semitone. */ sample->global_volume = 64; sample->default_volume = dumbfile_getc(f); // Should we be setting global_volume to this instead? - loop_start = dumbfile_mgetw(f) << 1; + loop_start = dumbfile_mgetw(f); + if ( !stk ) loop_start <<= 1; loop_length = dumbfile_mgetw(f) << 1; if ( loop_length > 2 && loop_start + loop_length > sample->length && loop_start / 2 + loop_length <= sample->length ) loop_start /= 2; @@ -164,7 +165,7 @@ told to stop. sample->flags = IT_SAMPLE_EXISTS; sample->default_pan = 0; - sample->C5_speed = (int)( AMIGA_CLOCK / 214.0 ); //(int32)(16726.0*pow(DUMB_PITCH_BASE, finetune*32)); + sample->C5_speed = (int)( AMIGA_CLOCK / 214.0 ); //(long)(16726.0*pow(DUMB_PITCH_BASE, finetune*32)); sample->finetune = finetune * 32; // the above line might be wrong @@ -270,209 +271,28 @@ static int it_mod_read_sample_data(IT_SAMPLE *sample, DUMBFILE *f, uint32 fft) -typedef struct BUFFERED_MOD BUFFERED_MOD; - -struct BUFFERED_MOD -{ - unsigned char *buffered; - int32 ptr, len; - DUMBFILE *remaining; -}; - - - -static int buffer_mod_skip(void *f, int32 n) -{ - BUFFERED_MOD *bm = f; - if (bm->buffered) { - bm->ptr += n; - if (bm->ptr >= bm->len) { - free(bm->buffered); - bm->buffered = NULL; - return dumbfile_skip(bm->remaining, bm->ptr - bm->len); - } - return 0; - } - return dumbfile_skip(bm->remaining, n); -} - - - -static int buffer_mod_getc(void *f) -{ - BUFFERED_MOD *bm = f; - if (bm->buffered) { - int rv = bm->buffered[bm->ptr++]; - if (bm->ptr >= bm->len) { - free(bm->buffered); - bm->buffered = NULL; - } - return rv; - } - return dumbfile_getc(bm->remaining); -} - - - -static int32 buffer_mod_getnc(char *ptr, int32 n, void *f) -{ - BUFFERED_MOD *bm = f; - if (bm->buffered) { - int left = bm->len - bm->ptr; - if (n >= left) { - memcpy(ptr, bm->buffered + bm->ptr, left); - free(bm->buffered); - bm->buffered = NULL; - if (n - left) { - int rv = dumbfile_getnc(ptr + left, n - left, bm->remaining); - return left + MAX(rv, 0); - } else { - return left; - } - } - memcpy(ptr, bm->buffered + bm->ptr, n); - bm->ptr += n; - return n; - } - return dumbfile_getnc(ptr, n, bm->remaining); -} - - - -static void buffer_mod_close(void *f) -{ - BUFFERED_MOD *bm = f; - if (bm->buffered) free(bm->buffered); - /* Do NOT close bm->remaining */ - free(f); -} - - - -DUMBFILE_SYSTEM buffer_mod_dfs = { - NULL, - &buffer_mod_skip, - &buffer_mod_getc, - &buffer_mod_getnc, - &buffer_mod_close -}; - - #define MOD_FFT_OFFSET (20 + 31*(22+2+1+1+2+2) + 1 + 1 + 128) -static DUMBFILE *dumbfile_buffer_mod(DUMBFILE *f, uint32 *fft) -{ - BUFFERED_MOD *bm = malloc(sizeof(*bm)); - if (!bm) return NULL; - - bm->buffered = malloc(MOD_FFT_OFFSET + 4); - if (!bm->buffered) { - free(bm); - return NULL; - } - - bm->len = dumbfile_getnc(bm->buffered, MOD_FFT_OFFSET + 4, f); - - if (bm->len > 0) { - if (bm->len >= MOD_FFT_OFFSET + 4) - *fft = (uint32)bm->buffered[MOD_FFT_OFFSET ] << 24 - | (uint32)bm->buffered[MOD_FFT_OFFSET+1] << 16 - | (uint32)bm->buffered[MOD_FFT_OFFSET+2] << 8 - | (uint32)bm->buffered[MOD_FFT_OFFSET+3]; - else - *fft = 0; - bm->ptr = 0; - } else { - free(bm->buffered); - bm->buffered = NULL; - } - - bm->remaining = f; - - return dumbfile_open_ex(bm, &buffer_mod_dfs); -} - -static DUMBFILE *dumbfile_buffer_mod_2(DUMBFILE *f, int n_samples, IT_SAMPLE *sample, int32 *total_sample_size, int32 *remain) -{ - int32 read; - int sample_number; - BUFFERED_MOD *bm = malloc(sizeof(*bm)); - unsigned char *ptr; - if (!bm) return NULL; - - bm->buffered = malloc(32768); - if (!bm->buffered) { - free(bm); - return NULL; - } - - bm->len = 0; - *remain = 0; - - read = dumbfile_getnc(bm->buffered, 32768, f); - - if (read >= 0) { - bm->len += read; - *remain += read; - - while (read >= 32768) { - bm->buffered = realloc(bm->buffered, *remain + 32768); - if (!bm->buffered) { - free(bm); - return 0; - } - read = dumbfile_getnc(bm->buffered + *remain, 32768, f); - if (read >= 0) { - bm->len += read; - *remain += read; - } - } - } - - if (*remain) { - bm->ptr = 0; - ptr = bm->buffered + *remain; - sample_number = n_samples - 1; - *total_sample_size = 0; - while (ptr > bm->buffered && sample_number >= 0) { - if (sample[sample_number].flags & IT_SAMPLE_EXISTS) { - ptr -= (sample[sample_number].length + 1) / 2 + 5 + 16; - if (ptr >= bm->buffered && !memcmp(ptr, "ADPCM", 5)) { /* BAH */ - *total_sample_size += (sample[sample_number].length + 1) / 2 + 5 + 16; - } else { - *total_sample_size += sample[sample_number].length; - ptr -= sample[sample_number].length - ((sample[sample_number].length + 1) / 2 + 5 + 16); - } - } - sample_number--; - } - } else { - free(bm->buffered); - bm->buffered = NULL; - } - - bm->remaining = f; - - return dumbfile_open_ex(bm, &buffer_mod_dfs); -} - - -static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) +static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int restrict_) { DUMB_IT_SIGDATA *sigdata; int n_channels; int i; - uint32 fft = 0; - DUMBFILE *rem = NULL; + uint32 fft; - f = dumbfile_buffer_mod(f, &fft); - if (!f) - return NULL; + if ( dumbfile_seek(f, MOD_FFT_OFFSET, DFS_SEEK_SET) ) + return NULL; + + fft = dumbfile_mgetl(f); + if (dumbfile_error(f)) + return NULL; + + if ( dumbfile_seek(f, 0, DFS_SEEK_SET) ) + return NULL; sigdata = malloc(sizeof(*sigdata)); if (!sigdata) { - dumbfile_close(f); return NULL; } @@ -481,10 +301,9 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) full 20 chars in length, it will be null- terminated. */ - if (dumbfile_getnc(sigdata->name, 20, f) < 20) { + if (dumbfile_getnc((char *)sigdata->name, 20, f) < 20) { free(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } sigdata->name[20] = 0; @@ -567,11 +386,10 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) } // moo - if ( ( rstrict & 1 ) && sigdata->n_samples == 15 ) + if ( ( restrict_ & 1 ) && sigdata->n_samples == 15 ) { free(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } sigdata->n_pchannels = n_channels ? n_channels : 8; /* special case for 0, see above */ @@ -579,8 +397,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->sample = malloc(sigdata->n_samples * sizeof(*sigdata->sample)); if (!sigdata->sample) { free(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } sigdata->song_message = NULL; @@ -596,10 +413,9 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->sample[i].data = NULL; for (i = 0; i < sigdata->n_samples; i++) { - if (it_mod_read_sample_header(&sigdata->sample[i], f)) { + if (it_mod_read_sample_header(&sigdata->sample[i], f, sigdata->n_samples == 15)) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } } @@ -609,8 +425,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) /* if (sigdata->n_orders <= 0 || sigdata->n_orders > 128) { // is this right? _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - return NULL; + return NULL; }*/ //if (sigdata->restart_position >= sigdata->n_orders) @@ -619,13 +434,11 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->order = malloc(128); /* We may need to scan the extra ones! */ if (!sigdata->order) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } - if (dumbfile_getnc(sigdata->order, 128, f) < 128) { + if (dumbfile_getnc((char *)sigdata->order, 128, f) < 128) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - return NULL; + return NULL; } if (sigdata->n_orders <= 0 || sigdata->n_orders > 128) { // is this right? @@ -648,44 +461,67 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->n_patterns = -1; - if ( ( rstrict & 2 ) ) + if ( ( restrict_ & 2 ) ) { - int32 total_sample_size; - int32 remain; - rem = f; - f = dumbfile_buffer_mod_2(rem, sigdata->n_samples, sigdata->sample, &total_sample_size, &remain); - if (!f) { - _dumb_it_unload_sigdata(sigdata); - dumbfile_close(rem); - return NULL; - } + unsigned char buffer[5]; + long sample_number; + long total_sample_size; + long offset = dumbfile_pos(f); + long remain = dumbfile_get_size(f) - offset; + if ( dumbfile_error( f ) || + dumbfile_seek( f, 0, SEEK_END ) ) { + _dumb_it_unload_sigdata(sigdata); + return NULL; + } + sample_number = sigdata->n_samples - 1; + total_sample_size = 0; + while (dumbfile_pos(f) > offset && sample_number >= 0) { + if (sigdata->sample[sample_number].flags & IT_SAMPLE_EXISTS) { + if ( dumbfile_seek(f, -((sigdata->sample[sample_number].length + 1) / 2 + 5 + 16), DFS_SEEK_CUR) || + dumbfile_getnc((char *)buffer, 5, f) < 5 ) { + _dumb_it_unload_sigdata(sigdata); + return NULL; + } + if ( !memcmp( buffer, "ADPCM", 5 ) ) { /* BAH */ + total_sample_size += (sigdata->sample[sample_number].length + 1) / 2 + 5 + 16; + if ( dumbfile_seek(f, -5, DFS_SEEK_CUR) ) { + _dumb_it_unload_sigdata(sigdata); + return NULL; + } + } else { + total_sample_size += sigdata->sample[sample_number].length; + if ( dumbfile_seek(f, -(sigdata->sample[sample_number].length - ((sigdata->sample[sample_number].length + 1) / 2 + 5 + 16) + 5), DFS_SEEK_CUR) ) { + _dumb_it_unload_sigdata(sigdata); + return NULL; + } + } + } + --sample_number; + } + if (remain > total_sample_size) { sigdata->n_patterns = ( remain - total_sample_size + 4 ) / ( 256 * sigdata->n_pchannels ); if (fft == DUMB_ID('M',0,0,0) || fft == DUMB_ID('8',0,0,0)) { remain -= sigdata->n_patterns * 256 * sigdata->n_pchannels; if (dumbfile_skip(f, remain - total_sample_size)) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - dumbfile_close(rem); return NULL; } } } } else - { - for (i = 0; i < 128; i++) - { - if (sigdata->order[i] > sigdata->n_patterns) - sigdata->n_patterns = sigdata->order[i]; - } + { + for (i = 0; i < 128; i++) + { + if (sigdata->order[i] > sigdata->n_patterns) + sigdata->n_patterns = sigdata->order[i]; + } sigdata->n_patterns++; } if ( sigdata->n_patterns <= 0 ) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - if (rem) dumbfile_close(rem); return NULL; } @@ -698,8 +534,6 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->pattern = malloc(sigdata->n_patterns * sizeof(*sigdata->pattern)); if (!sigdata->pattern) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - if (rem) dumbfile_close(rem); return NULL; } for (i = 0; i < sigdata->n_patterns; i++) @@ -710,16 +544,12 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) unsigned char *buffer = malloc(256 * sigdata->n_pchannels); /* 64 rows * 4 bytes */ if (!buffer) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - if (rem) dumbfile_close(rem); return NULL; } for (i = 0; i < sigdata->n_patterns; i++) { if (it_mod_read_pattern(&sigdata->pattern[i], f, n_channels, buffer) != 0) { free(buffer); _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - if (rem) dumbfile_close(rem); return NULL; } } @@ -730,8 +560,6 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) for (i = 0; i < sigdata->n_samples; i++) { if (it_mod_read_sample_data(&sigdata->sample[i], f, fft)) { _dumb_it_unload_sigdata(sigdata); - dumbfile_close(f); - if (rem) dumbfile_close(rem); return NULL; } } @@ -754,10 +582,6 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) } }*/ - dumbfile_close(f); /* Destroy the BUFFERED_MOD DUMBFILE we were using. */ - if (rem) dumbfile_close(rem); /* And the BUFFERED_MOD DUMBFILE used to pre-read the signature. */ - /* The DUMBFILE originally passed to our function is intact. */ - /* Now let's initialise the remaining variables, and we're done! */ sigdata->flags = IT_WAS_AN_XM | IT_WAS_A_MOD | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_STEREO; @@ -773,10 +597,11 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (i = 0; i < DUMB_IT_N_CHANNELS; i += 4) { - sigdata->channel_pan[i+0] = 16; - sigdata->channel_pan[i+1] = 48; - sigdata->channel_pan[i+2] = 48; - sigdata->channel_pan[i+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[i+0] = 32 - sep; + sigdata->channel_pan[i+1] = 32 + sep; + sigdata->channel_pan[i+2] = 32 + sep; + sigdata->channel_pan[i+3] = 32 - sep; } _dumb_it_fix_invalid_orders(sigdata); @@ -786,13 +611,13 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) -DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int rstrict) +DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int restrict_) { sigdata_t *sigdata; DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_mod_load_sigdata(f, rstrict); + sigdata = it_mod_load_sigdata(f, restrict_); if (!sigdata) return NULL; @@ -800,7 +625,7 @@ DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int rstrict) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "MOD"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/readmod2.c b/dumb/src/it/readmod2.c index a20ccd24ef..62c1c92625 100644 --- a/dumb/src/it/readmod2.c +++ b/dumb/src/it/readmod2.c @@ -21,9 +21,9 @@ -DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int rstrict) +DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int restrict_) { - DUH *duh = dumb_read_mod_quick(f, rstrict); + DUH *duh = dumb_read_mod_quick(f, restrict_); dumb_it_do_initial_runthrough(duh); return duh; } diff --git a/dumb/src/it/readmtm.c b/dumb/src/it/readmtm.c index 0412d7f5c6..e618789a0d 100644 --- a/dumb/src/it/readmtm.c +++ b/dumb/src/it/readmtm.c @@ -96,7 +96,7 @@ static int it_mtm_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f) { int finetune, flags; - dumbfile_getnc(sample->name, 22, f); + dumbfile_getnc((char *)sample->name, 22, f); sample->name[22] = 0; sample->filename[0] = 0; @@ -125,7 +125,7 @@ static int it_mtm_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f) } sample->default_pan = 0; - sample->C5_speed = (int)( AMIGA_CLOCK / 214.0 );//(int32)(16726.0*pow(DUMB_PITCH_BASE, finetune*32)); + sample->C5_speed = (int)( AMIGA_CLOCK / 214.0 );//(long)(16726.0*pow(DUMB_PITCH_BASE, finetune*32)); sample->finetune = finetune * 32; // the above line might be wrong @@ -195,7 +195,7 @@ static DUMB_IT_SIGDATA *it_mtm_load_sigdata(DUMBFILE *f, int * version) sigdata = malloc(sizeof(*sigdata)); if (!sigdata) goto error; - dumbfile_getnc(sigdata->name, 20, f); + dumbfile_getnc((char *)sigdata->name, 20, f); sigdata->name[20] = 0; n_tracks = dumbfile_igetw(f); @@ -216,7 +216,7 @@ static DUMB_IT_SIGDATA *it_mtm_load_sigdata(DUMBFILE *f, int * version) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); - if (dumbfile_getnc(sigdata->channel_pan, 32, f) < 32) goto error_sd; + if (dumbfile_getnc((char *)sigdata->channel_pan, 32, f) < 32) goto error_sd; for (n = 0; n < 32; n++) { if (sigdata->channel_pan[n] <= 15) { @@ -229,10 +229,11 @@ static DUMB_IT_SIGDATA *it_mtm_load_sigdata(DUMBFILE *f, int * version) } for (n = 32; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } sigdata->sample = malloc(sigdata->n_samples * sizeof(*sigdata->sample)); @@ -268,14 +269,14 @@ static DUMB_IT_SIGDATA *it_mtm_load_sigdata(DUMBFILE *f, int * version) sigdata->order = malloc(sigdata->n_orders); if (!sigdata->order) goto error_usd; - if (dumbfile_getnc(sigdata->order, sigdata->n_orders, f) < sigdata->n_orders) goto error_usd; + if (dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f) < sigdata->n_orders) goto error_usd; if (sigdata->n_orders < 128) if (dumbfile_skip(f, 128 - sigdata->n_orders)) goto error_usd; track = malloc(192 * n_tracks); if (!track) goto error_usd; - if (dumbfile_getnc(track, 192 * n_tracks, f) < 192 * n_tracks) goto error_ft; + if (dumbfile_getnc((char *)track, 192 * n_tracks, f) < 192 * n_tracks) goto error_ft; sigdata->pattern = malloc(sigdata->n_patterns * sizeof(*sigdata->pattern)); if (!sigdata->pattern) goto error_ft; @@ -319,7 +320,6 @@ static DUMB_IT_SIGDATA *it_mtm_load_sigdata(DUMBFILE *f, int * version) size_t l; int m; - for (l = 0, n = 0; n <= o; n += 40) { l += strlen_max(&comment[n], 40) + 2; } @@ -396,7 +396,7 @@ DUH *DUMBEXPORT dumb_read_mtm_quick(DUMBFILE *f) char version[16]; const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; version[0] = 'M'; version[1] = 'T'; diff --git a/dumb/src/it/readokt.c b/dumb/src/it/readokt.c index b662e55c44..9f9cd74fbf 100644 --- a/dumb/src/it/readokt.c +++ b/dumb/src/it/readokt.c @@ -322,8 +322,8 @@ unsigned get_chunk_count(IFF_CHUNKED *mod, unsigned type) static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) { DUMB_IT_SIGDATA *sigdata; - unsigned n_channels; - unsigned i, j, k, l; + int n_channels; + int i, j, k, l; IFF_CHUNKED *mod; const IFF_CHUNK *chunk; @@ -403,12 +403,12 @@ static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) sigdata->n_instruments = 0; - for (i = 0; i < (unsigned)sigdata->n_samples; i++) + for (i = 0; (unsigned)i < (unsigned)sigdata->n_samples; i++) sigdata->sample[i].data = NULL; chunk = get_chunk_by_type(mod, DUMB_ID('S','A','M','P'), 0); - for (i = 0; i < (unsigned)sigdata->n_samples; i++) { + for (i = 0; (unsigned)i < (unsigned)sigdata->n_samples; i++) { it_okt_read_sample_header(&sigdata->sample[i], chunk->data + 32 * i); } @@ -431,7 +431,7 @@ static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) } chunk = get_chunk_by_type(mod, DUMB_ID('P','A','T','T'), 0); - if (!chunk || chunk->size < (unsigned)sigdata->n_orders) { + if (!chunk || chunk->size < (unsigned)sigdata->n_orders) { _dumb_it_unload_sigdata(sigdata); free_okt(mod); return NULL; @@ -471,11 +471,11 @@ static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) free_okt(mod); return NULL; } - for (i = 0; i < (unsigned)sigdata->n_patterns; i++) + for (i = 0; (unsigned)i < (unsigned)sigdata->n_patterns; i++) sigdata->pattern[i].entry = NULL; /* Read in the patterns */ - for (i = 0; i < (unsigned)sigdata->n_patterns; i++) { + for (i = 0; (unsigned)i < (unsigned)sigdata->n_patterns; i++) { chunk = get_chunk_by_type(mod, DUMB_ID('P','B','O','D'), i); if (it_okt_read_pattern(&sigdata->pattern[i], chunk->data, chunk->size, n_channels) != 0) { _dumb_it_unload_sigdata(sigdata); @@ -486,7 +486,7 @@ static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) /* And finally, the sample data */ k = get_chunk_count(mod, DUMB_ID('S','B','O','D')); - for (i = 0, j = 0; i < (unsigned)sigdata->n_samples && j < k; i++) { + for (i = 0, j = 0; (unsigned)i < (unsigned)sigdata->n_samples && j < k; i++) { if (sigdata->sample[i].flags & IT_SAMPLE_EXISTS) { chunk = get_chunk_by_type(mod, DUMB_ID('S','B','O','D'), j); if (it_okt_read_sample_data(&sigdata->sample[i], (const char *)chunk->data, chunk->size)) { @@ -497,7 +497,7 @@ static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f) j++; } } - for (; i < (unsigned)sigdata->n_samples; i++) { + for (; (unsigned)i < (unsigned)sigdata->n_samples; i++) { sigdata->sample[i].flags = 0; } @@ -544,7 +544,7 @@ DUH *DUMBEXPORT dumb_read_okt_quick(DUMBFILE *f) DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_okt_load_sigdata(f); + sigdata = it_okt_load_sigdata(f); if (!sigdata) return NULL; diff --git a/dumb/src/it/readoldpsm.c b/dumb/src/it/readoldpsm.c index 5c0441c788..5ddff531f9 100644 --- a/dumb/src/it/readoldpsm.c +++ b/dumb/src/it/readoldpsm.c @@ -33,19 +33,18 @@ static int CDECL psm_sample_compare(const void *e1, const void *e2) return a - b; } -static int it_old_psm_read_samples(IT_SAMPLE ** sample, DUMBFILE * f, int * num, const unsigned char * prebuffer, int32 data_pos, int32 data_size) +static int it_old_psm_read_samples(IT_SAMPLE ** sample, DUMBFILE * f, int * num) { - int n, o, pos, count = *num, true_num, snum, offset, flags, finetune, delta; + int n, o, count = *num, true_num, snum, offset, flags, finetune, delta; - unsigned char * buffer, * sbuffer = 0; + unsigned char * buffer; const unsigned char * sdata; + int32 sample_bytes; buffer = malloc(count * 64); if (!buffer) goto error; - if (dumbfile_getnc(buffer, count * 64, f) < count * 64) goto error_fb; - - pos = dumbfile_pos(f); + if (dumbfile_getnc((char *)buffer, count * 64, f) < count * 64) goto error_fb; true_num = 0; @@ -94,9 +93,10 @@ static int it_old_psm_read_samples(IT_SAMPLE ** sample, DUMBFILE * f, int * num, finetune = buffer[(n * 64) + 60]; s->default_volume = buffer[(n * 64) + 61]; s->C5_speed = buffer[(n * 64) + 62] | (buffer[(n * 64) + 63] << 8); - if (finetune < 16) { + if (finetune & 15) { + finetune &= 15; if (finetune >= 8) finetune -= 16; - //s->C5_speed = (int32)((double)s->C5_speed * pow(DUMB_PITCH_BASE, finetune*32)); + //s->C5_speed = (long)((double)s->C5_speed * pow(DUMB_PITCH_BASE, finetune*32)); s->finetune = finetune * 32; } else s->finetune = 0; @@ -127,22 +127,12 @@ static int it_old_psm_read_samples(IT_SAMPLE ** sample, DUMBFILE * f, int * num, s->vibrato_waveform = IT_VIBRATO_SINE; s->max_resampling_quality = -1; - s->data = malloc(s->length * ((flags & 4) ? 2 : 1)); + sample_bytes = s->length * ((flags & 4) ? 2 : 1); + s->data = malloc(sample_bytes); if (!s->data) goto error_fb; - if ((offset >= data_pos) && - ((offset + s->length * ((flags & 4) ? 2 : 1)) <= (data_pos + data_size))) { - sdata = prebuffer + offset - data_pos; - } else if (offset >= pos) { - if (dumbfile_skip(f, offset - pos)) goto error_fb; - pos = offset; - offset = s->length * ((flags & 4) ? 2 : 1); - sbuffer = malloc(offset); - if (!sbuffer) goto error_fb; - if (dumbfile_getnc(sbuffer, offset, f) < offset) goto error_fsb; - sdata = sbuffer; - } else - goto error_fb; + if (dumbfile_seek(f, offset, DFS_SEEK_SET) || dumbfile_getnc(s->data, sample_bytes, f) < sample_bytes) goto error_fb; + sdata = ( const unsigned char * ) s->data; if (flags & 0x10) { if (flags & 8) { @@ -190,26 +180,19 @@ static int it_old_psm_read_samples(IT_SAMPLE ** sample, DUMBFILE * f, int * num, } } } - - if (sbuffer) { - free(sbuffer); - sbuffer = 0; - } } free(buffer); return 0; -error_fsb: - if (sbuffer) free(sbuffer); error_fb: free(buffer); error: return -1; } -static int it_old_psm_read_patterns(IT_PATTERN * pattern, DUMBFILE * f, int num, int size, int pchans, int sflags) +static int it_old_psm_read_patterns(IT_PATTERN * pattern, DUMBFILE * f, int num, int size, int pchans) { int n, offset, psize, rows, chans, row, flags, channel; @@ -217,12 +200,10 @@ static int it_old_psm_read_patterns(IT_PATTERN * pattern, DUMBFILE * f, int num, IT_ENTRY * entry; - (void)sflags; /* Avoid unused parameter warning from GCC */ - buffer = malloc(size); if (!buffer) goto error; - if (dumbfile_getnc(buffer, size, f) < size) goto error_fb; + if (dumbfile_getnc((char *)buffer, size, f) < size) goto error_fb; offset = 0; @@ -520,8 +501,6 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) { DUMB_IT_SIGDATA *sigdata; - unsigned char * ptr = 0; - PSM_COMPONENT *component; int n_components = 0; @@ -532,7 +511,7 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) sigdata = malloc(sizeof(*sigdata)); if (!sigdata) goto error; - if (dumbfile_getnc(sigdata->name, 60, f) < 60 || + if (dumbfile_getnc((char *)sigdata->name, 60, f) < 60 || sigdata->name[59] != 0x1A) goto error_sd; sigdata->name[59] = 0; @@ -619,43 +598,31 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } for (n = 0; n < n_components; n++) { int o; - int32 data_pos, data_size; - /* Whee, sample data may be before the sample headers */ - - data_pos = dumbfile_pos(f); - if (data_pos > component[n].offset) goto error_fc; - - data_size = component[n].offset - data_pos; - - if (data_size) { - ptr = malloc(data_size); - if (!ptr) goto error_fc; - - if (dumbfile_getnc(ptr, data_size, f) < data_size) goto error_fp; - } + if ( dumbfile_seek(f, component[n].offset, DFS_SEEK_SET) ) goto error_fc; switch (component[n].type) { case PSM_COMPONENT_ORDERS: - if (dumbfile_getnc(sigdata->order, sigdata->n_orders, f) < sigdata->n_orders) goto error_fp; + if (dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f) < sigdata->n_orders) goto error_fc; if (n_orders > sigdata->n_orders) if (dumbfile_skip(f, n_orders - sigdata->n_orders)) - goto error_fp; - if (dumbfile_igetw(f)) goto error_fp; + goto error_fc; + if (dumbfile_igetw(f)) goto error_fc; break; case PSM_COMPONENT_PANPOS: - if (dumbfile_getnc(sigdata->channel_pan, sigdata->n_pchannels, f) < sigdata->n_pchannels) goto error_fp; + if (dumbfile_getnc((char *)sigdata->channel_pan, sigdata->n_pchannels, f) < sigdata->n_pchannels) goto error_fc; for (o = 0; o < sigdata->n_pchannels; o++) { sigdata->channel_pan[o] -= (sigdata->channel_pan[o] & 8) >> 3; sigdata->channel_pan[o] = ((int)sigdata->channel_pan[o] << 5) / 7; @@ -663,11 +630,11 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) break; case PSM_COMPONENT_PATTERNS: - if (it_old_psm_read_patterns(sigdata->pattern, f, sigdata->n_patterns, total_pattern_size, sigdata->n_pchannels, flags)) goto error_fp; + if (it_old_psm_read_patterns(sigdata->pattern, f, sigdata->n_patterns, total_pattern_size, sigdata->n_pchannels)) goto error_fc; break; case PSM_COMPONENT_SAMPLE_HEADERS: - if (it_old_psm_read_samples(&sigdata->sample, f, &sigdata->n_samples, ptr, data_pos, data_size)) goto error_fp; + if (it_old_psm_read_samples(&sigdata->sample, f, &sigdata->n_samples)) goto error_fc; break; case PSM_COMPONENT_COMMENTS: @@ -675,17 +642,12 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) o = dumbfile_igetw(f); if (o > 0) { sigdata->song_message = malloc(o + 1); - if (dumbfile_getnc(sigdata->song_message, o, f) < o) goto error_fp; + if (dumbfile_getnc((char *)sigdata->song_message, o, f) < o) goto error_fc; sigdata->song_message[o] = 0; } } break; } - - if (ptr) { - free(ptr); - ptr = 0; - } } _dumb_it_fix_invalid_orders(sigdata); @@ -694,8 +656,6 @@ static DUMB_IT_SIGDATA *it_old_psm_load_sigdata(DUMBFILE *f) return sigdata; -error_fp: - if (ptr) free(ptr); error_fc: free(component); error_usd: @@ -721,7 +681,7 @@ DUH *DUMBEXPORT dumb_read_old_psm_quick(DUMBFILE *f) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "PSM (old)"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/readpsm.c b/dumb/src/it/readpsm.c index d6fc099c5e..ca82089344 100644 --- a/dumb/src/it/readpsm.c +++ b/dumb/src/it/readpsm.c @@ -24,7 +24,11 @@ #include "internal/it.h" #ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifdef _MSC_VER +#define snprintf sprintf_s #endif #define PSMV_OLD 940730 @@ -77,7 +81,7 @@ static int it_psm_process_sample(IT_SAMPLE * sample, const unsigned char * data, panpos = data[0x43]; defvol = data[0x44]; samplerate = data[0x49] | (data[0x4A] << 8) | (data[0x4B] << 16) | (data[0x4C] << 24); - } else if (version == PSMV_NEW) { + } else /*if (version == PSMV_NEW)*/ { memcpy(sample->name, data + 0x11, 34); sample->name[34] = 0; @@ -150,7 +154,7 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da if (len < 10) return -1; data += 8; len -= 8; - } else if (version == PSMV_NEW) { + } else /*if (version == PSMV_NEW)*/ { if (len < 14) return -1; data += 12; len -= 12; @@ -287,7 +291,7 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da if (version == PSMV_OLD) { if ((data[pos] < 0x80)) entry->note = (data[pos]>>4)*12+(data[pos]&0x0f)+12; else entry->mask &= ~IT_ENTRY_NOTE; - } else if (version == PSMV_NEW) { + } else /*if (version == PSMV_NEW)*/ { if ((data[pos]) && (data[pos] < 84)) entry->note = data[pos] + 35; else entry->mask &= ~IT_ENTRY_NOTE; } @@ -311,25 +315,25 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da case 1: entry->effect = IT_VOLUME_SLIDE; if (version == PSMV_OLD) entry->effectvalue = ((length&0x1e)<<3) | 0xF; - else if (version == PSMV_NEW) entry->effectvalue = (length<<4) | 0xF; + else /*if (version == PSMV_NEW)*/ entry->effectvalue = (length<<4) | 0xF; break; case 2: entry->effect = IT_VOLUME_SLIDE; if (version == PSMV_OLD) entry->effectvalue = (length << 3) & 0xF0; - else if (version == PSMV_NEW) entry->effectvalue = (length << 4) & 0xF0; + else /*if (version == PSMV_NEW)*/ entry->effectvalue = (length << 4) & 0xF0; break; case 3: entry->effect = IT_VOLUME_SLIDE; if (version == PSMV_OLD) entry->effectvalue = (length >> 1) | 0xF0; - else if (version == PSMV_NEW) entry->effectvalue = length | 0xF0; + else /*if (version == PSMV_NEW)*/ entry->effectvalue = length | 0xF0; break; case 4: entry->effect = IT_VOLUME_SLIDE; if (version == PSMV_OLD) entry->effectvalue = (length >> 1) & 0xF; - else if (version == PSMV_NEW) entry->effectvalue = length & 0xF; + else /*if (version == PSMV_NEW)*/ entry->effectvalue = length & 0xF; break; case 12: @@ -337,7 +341,7 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da if (version == PSMV_OLD) { if (length < 4) entry->effectvalue = length | 0xF0; else entry->effectvalue = length >> 2; - } else if (version == PSMV_NEW) { + } else /*if (version == PSMV_NEW)*/ { entry->effectvalue = length; } break; @@ -347,7 +351,7 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da if (version == PSMV_OLD) { if (length < 4) entry->effectvalue = length | 0xF0; else entry->effectvalue = length >> 2; - } else if (version == PSMV_NEW) { + } else /*if (version == PSMV_NEW)*/ { entry->effectvalue = length; } break; @@ -355,7 +359,7 @@ static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * da case 15: entry->effect = IT_TONE_PORTAMENTO; if (version == PSMV_OLD) entry->effectvalue = length >> 2; - else if (version == PSMV_NEW) entry->effectvalue = length; + else /*if (version == PSMV_NEW)*/ entry->effectvalue = length; break; case 0x15: @@ -496,7 +500,7 @@ static DUMB_IT_SIGDATA *it_psm_load_sigdata(DUMBFILE *f, int * ver, int subsong) if (n) { ptr = malloc(n); if (!ptr) goto error_fc; - if (dumbfile_getnc(ptr, n, f) < n) + if (dumbfile_getnc((char *)ptr, n, f) < n) { free(ptr); goto error_fc; @@ -655,10 +659,11 @@ static DUMB_IT_SIGDATA *it_psm_load_sigdata(DUMBFILE *f, int * ver, int subsong) memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS); for (n = 0; n < DUMB_IT_N_CHANNELS; n += 4) { - sigdata->channel_pan[n ] = 16; - sigdata->channel_pan[n+1] = 48; - sigdata->channel_pan[n+2] = 48; - sigdata->channel_pan[n+3] = 16; + int sep = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[n ] = 32 - sep; + sigdata->channel_pan[n+1] = 32 + sep; + sigdata->channel_pan[n+2] = 32 + sep; + sigdata->channel_pan[n+3] = 32 - sep; } for (n = 0; n < n_song_chunks; n++) { @@ -688,7 +693,7 @@ static DUMB_IT_SIGDATA *it_psm_load_sigdata(DUMBFILE *f, int * ver, int subsong) memcpy(event[n_events].data, ptr + 1, 4); ptr += 5; length -= 5; - } else if (found == PSMV_NEW) { + } else /*if (found == PSMV_NEW)*/ { if (length < 9) goto error_ev; memcpy(event[n_events].data, ptr + 1, 8); ptr += 9; @@ -808,7 +813,7 @@ static DUMB_IT_SIGDATA *it_psm_load_sigdata(DUMBFILE *f, int * ver, int subsong) n_patterns++; break; } - } else if (found == PSMV_NEW) { + } else /*if (found == PSMV_NEW)*/ { if (length < 12) goto error_ev; if (!pattcmp(ptr + 4, e->data, 8)) { if (it_psm_process_pattern(&sigdata->pattern[n_patterns], ptr, length, speed, bpm, pan, vol, found)) goto error_ev; @@ -926,8 +931,10 @@ static DUMB_IT_SIGDATA *it_psm_load_sigdata(DUMBFILE *f, int * ver, int subsong) sigdata->sample = malloc(sigdata->n_samples * sizeof(*sigdata->sample)); if (!sigdata->sample) goto error_ev; - for (n = 0; n < sigdata->n_samples; n++) + for (n = 0; n < sigdata->n_samples; n++) { sigdata->sample[n].data = NULL; + sigdata->sample[n].flags = 0; + } o = 0; for (n = 0; n < n_chunks; n++) { @@ -983,7 +990,7 @@ static int CDECL it_order_compare(const void *e1, const void *e2) { } /* -static int CDECL it_optimize_compare(const void *e1, const void *e2) { +static int it_optimize_compare(const void *e1, const void *e2) { if (((const IT_ENTRY *)e1)->channel < ((const IT_ENTRY *)e2)->channel) return -1; @@ -1078,7 +1085,7 @@ static int it_pattern_compare(const IT_PATTERN * p1, const IT_PATTERN * p2) { static void dumb_it_optimize_orders(DUMB_IT_SIGDATA * sigdata) { int n, o, p; - //int last_invalid = (sigdata->flags & IT_WAS_AN_XM) ? 255 : 253; + /*int last_invalid = (sigdata->flags & IT_WAS_AN_XM) ? 255 : 253;*/ unsigned char * order_list; int n_patterns; @@ -1222,7 +1229,7 @@ int pattcmp( const unsigned char * a, const unsigned char * b, size_t l ) if ( i < l ) { - na = strtoul( a + i, &p, 10 ); + na = strtoul( (const char *)a + i, &p, 10 ); if ( p == (const char *)a + i ) return 1; } @@ -1233,7 +1240,7 @@ int pattcmp( const unsigned char * a, const unsigned char * b, size_t l ) if ( j < l ) { - nb = strtoul( b + j, &p, 10 ); + nb = strtoul( (const char *)b + j, &p, 10 ); if ( p == (const char *)b + j ) return -1; } @@ -1265,14 +1272,15 @@ DUH *DUMBEXPORT dumb_read_psm_quick(DUMBFILE *f, int subsong) char version[16]; const char *tag[3][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "PSM"; if ( ver ) { tag[2][0] = "FORMATVERSION"; #if NEED_ITOA - sprintf(version, "%d", ver); + snprintf( version, 15, "%u", ver ); + version[15] = 0; #else itoa(ver, version, 10); #endif diff --git a/dumb/src/it/readptm.c b/dumb/src/it/readptm.c index cceb909222..885929e42d 100644 --- a/dumb/src/it/readptm.c +++ b/dumb/src/it/readptm.c @@ -26,30 +26,13 @@ -/** WARNING: this is duplicated in itread.c */ -static int it_seek(DUMBFILE *f, int32 offset) -{ - int32 pos = dumbfile_pos(f); - - if (pos > offset) - return -1; - - if (pos < offset) - if (dumbfile_skip(f, offset - pos)) - return -1; - - return 0; -} - - - static int it_ptm_read_sample_header(IT_SAMPLE *sample, int32 *offset, DUMBFILE *f) { int flags; flags = dumbfile_getc(f); - dumbfile_getnc(sample->filename, 12, f); + dumbfile_getnc((char *)sample->filename, 12, f); sample->filename[12] = 0; sample->default_volume = dumbfile_getc(f); @@ -67,7 +50,7 @@ static int it_ptm_read_sample_header(IT_SAMPLE *sample, int32 *offset, DUMBFILE /* GUSBegin, GUSLStart, GUSLEnd, GUSLoop, reserverd */ dumbfile_skip(f, 4+4+4+1+1); - dumbfile_getnc(sample->name, 28, f); + dumbfile_getnc((char *)sample->name, 28, f); sample->name[28] = 0; /* @@ -195,7 +178,7 @@ static int it_ptm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char * pattern->n_entries++; if (b) { if (buflen + used[b] >= 65536) return -1; - dumbfile_getnc(buffer + buflen, used[b], f); + dumbfile_getnc((char *)buffer + buflen, used[b], f); buflen += used[b]; } else { /* End of row */ @@ -351,7 +334,7 @@ static DUMB_IT_SIGDATA *it_ptm_load_sigdata(DUMBFILE *f) if (!sigdata) return NULL; /* Skip song name. */ - dumbfile_getnc(sigdata->name, 28, f); + dumbfile_getnc((char *)sigdata->name, 28, f); sigdata->name[28] = 0; if (dumbfile_getc(f) != 0x1A || dumbfile_igetw(f) != 0x203) { @@ -446,7 +429,7 @@ static DUMB_IT_SIGDATA *it_ptm_load_sigdata(DUMBFILE *f) } /* Orders, byte each, length = sigdata->n_orders (should be even) */ - dumbfile_getnc(sigdata->order, sigdata->n_orders, f); + dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f); sigdata->restart_position = 0; component = malloc(768*sizeof(*component)); @@ -455,7 +438,7 @@ static DUMB_IT_SIGDATA *it_ptm_load_sigdata(DUMBFILE *f) return NULL; } - if (it_seek(f, 352)) { + if (dumbfile_seek(f, 352, DFS_SEEK_SET)) { _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -467,7 +450,7 @@ static DUMB_IT_SIGDATA *it_ptm_load_sigdata(DUMBFILE *f) n_components++; } - if (it_seek(f, 608)) { + if (dumbfile_seek(f, 608, DFS_SEEK_SET)) { _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -510,7 +493,7 @@ static DUMB_IT_SIGDATA *it_ptm_load_sigdata(DUMBFILE *f) } for (n = 0; n < n_components; n++) { - if (it_seek(f, component[n].offset)) { + if (dumbfile_seek(f, component[n].offset, DFS_SEEK_SET)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); @@ -560,7 +543,7 @@ DUH *DUMBEXPORT dumb_read_ptm_quick(DUMBFILE *f) { const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "PTM"; return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata); diff --git a/dumb/src/it/readriff.c b/dumb/src/it/readriff.c index 658808fbfe..c78f400b9e 100644 --- a/dumb/src/it/readriff.c +++ b/dumb/src/it/readriff.c @@ -22,9 +22,9 @@ #include "internal/riff.h" -DUH *dumb_read_riff_amff( struct riff * stream ); -DUH *dumb_read_riff_am( struct riff * stream ); -DUH *dumb_read_riff_dsmf( struct riff * stream ); +DUH *dumb_read_riff_amff( DUMBFILE * f, struct riff * stream ); +DUH *dumb_read_riff_am( DUMBFILE * f, struct riff * stream ); +DUH *dumb_read_riff_dsmf( DUMBFILE * f, struct riff * stream ); /* dumb_read_riff_quick(): reads a RIFF file into a DUH struct, returning a * pointer to the DUH struct. When you have finished with it, you must pass @@ -34,37 +34,21 @@ DUH *DUMBEXPORT dumb_read_riff_quick( DUMBFILE * f ) { DUH * duh; struct riff * stream; + long size; - { - unsigned char * buffer = 0; - int32 size = 0; - int32 read; - do - { - buffer = realloc( buffer, 32768 + size ); - if ( ! buffer ) return 0; - read = dumbfile_getnc( buffer + size, 32768, f ); - if ( read < 0 ) - { - free( buffer ); - return 0; - } - size += read; - } - while ( read == 32768 ); - stream = riff_parse( buffer, size, 1 ); - if ( ! stream ) stream = riff_parse( buffer, size, 0 ); - free( buffer ); - } + size = dumbfile_get_size(f); + + stream = riff_parse( f, 0, size, 1 ); + if ( ! stream ) stream = riff_parse( f, 0, size, 0 ); if ( ! stream ) return 0; if ( stream->type == DUMB_ID( 'A', 'M', ' ', ' ' ) ) - duh = dumb_read_riff_am( stream ); + duh = dumb_read_riff_am( f, stream ); else if ( stream->type == DUMB_ID( 'A', 'M', 'F', 'F' ) ) - duh = dumb_read_riff_amff( stream ); + duh = dumb_read_riff_amff( f, stream ); else if ( stream->type == DUMB_ID( 'D', 'S', 'M', 'F' ) ) - duh = dumb_read_riff_dsmf( stream ); + duh = dumb_read_riff_dsmf( f, stream ); else duh = 0; riff_free( stream ); diff --git a/dumb/src/it/reads3m.c b/dumb/src/it/reads3m.c index c55e9f6155..82a942d4db 100644 --- a/dumb/src/it/reads3m.c +++ b/dumb/src/it/reads3m.c @@ -24,26 +24,6 @@ #include "dumb.h" #include "internal/it.h" -//#define S3M_BROKEN_OVERLAPPED_SAMPLES - -/** WARNING: this is duplicated in itread.c */ -static int it_seek(DUMBFILE *f, int32 offset) -{ - int32 pos = dumbfile_pos(f); - - if (pos > offset) { - return -1; - } - - if (pos < offset) - if (dumbfile_skip(f, offset - pos)) - return -1; - - return 0; -} - - - static int it_s3m_read_sample_header(IT_SAMPLE *sample, int32 *offset, unsigned char *pack, int cwtv, DUMBFILE *f) { unsigned char type; @@ -51,13 +31,13 @@ static int it_s3m_read_sample_header(IT_SAMPLE *sample, int32 *offset, unsigned type = dumbfile_getc(f); - dumbfile_getnc(sample->filename, 12, f); + dumbfile_getnc((char *)sample->filename, 12, f); sample->filename[12] = 0; if (type > 1) { /** WARNING: no adlib support */ dumbfile_skip(f, 3 + 12 + 1 + 1 + 2 + 2 + 2 + 12); - dumbfile_getnc(sample->name, 28, f); + dumbfile_getnc((char *)sample->name, 28, f); sample->name[28] = 0; dumbfile_skip(f, 4); sample->flags &= ~IT_SAMPLE_EXISTS; @@ -92,7 +72,7 @@ static int it_s3m_read_sample_header(IT_SAMPLE *sample, int32 *offset, unsigned /* Skip four unused bytes and three internal variables. */ dumbfile_skip(f, 4+2+2+4); - dumbfile_getnc(sample->name, 28, f); + dumbfile_getnc((char *)sample->name, 28, f); sample->name[28] = 0; if (type == 0 || sample->length <= 0) { @@ -214,7 +194,7 @@ static int it_s3m_read_sample_data(IT_SAMPLE *sample, int ffi, unsigned char pac -static int it_s3m_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buffer, int maxlen) +static int it_s3m_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buffer) { int length; int buflen = 0; @@ -246,18 +226,13 @@ static int it_s3m_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char * * against buffer overflow, this method should work with all sensibly * written S3M files. If you find one for which it does not work, please * let me know at entheh@users.sf.net so I can look at it. + * + * "for a good reason" ? What's this nonsense? -kode54 + * */ - /* Discard the length. */ - /* read at most length bytes, in case of retarded crap */ length = dumbfile_igetw(f); - if (maxlen) - { - maxlen -= 2; - if (length > maxlen) length = maxlen; - } - if (dumbfile_error(f) || !length) return -1; @@ -278,7 +253,7 @@ static int it_s3m_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char * if (b) { if (buflen + used[b] >= 65536) return -1; if (buflen + used[b] <= length) - dumbfile_getnc(buffer + buflen, used[b], f); + dumbfile_getnc((char *)buffer + buflen, used[b], f); else memset(buffer + buflen, 0, used[b]); buflen += used[b]; @@ -478,7 +453,7 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) sigdata = malloc(sizeof(*sigdata)); if (!sigdata) return NULL; - dumbfile_getnc(sigdata->name, 28, f); + dumbfile_getnc((char *)sigdata->name, 28, f); sigdata->name[28] = 0; n = dumbfile_getc(f); @@ -557,14 +532,13 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) return NULL; } - sigdata->global_volume = dumbfile_getc(f) * 16 / 11; - if ( !sigdata->global_volume || sigdata->global_volume > 93 ) sigdata->global_volume = 93; + sigdata->global_volume = dumbfile_getc(f); + if ( !sigdata->global_volume || sigdata->global_volume > 64 ) sigdata->global_volume = 64; sigdata->speed = dumbfile_getc(f); if (sigdata->speed == 0) sigdata->speed = 6; // Should we? What about tempo? sigdata->tempo = dumbfile_getc(f); master_volume = dumbfile_getc(f); // 7 bits; +128 for stereo - //what do we do with master_volume? it's not the same as mixing volume... - sigdata->mixing_volume = 48; + sigdata->mixing_volume = master_volume & 127; if (master_volume & 128) sigdata->flags |= IT_STEREO; @@ -583,12 +557,13 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) /* Channel settings for 32 channels, 255=unused, +128=disabled */ { int i; + int sep = (7 * dumb_it_default_panning_separation + 50) / 100; for (i = 0; i < 32; i++) { int c = dumbfile_getc(f); if (!(c & (128 | 16))) { /* +128=disabled, +16=Adlib */ if (sigdata->n_pchannels < i + 1) sigdata->n_pchannels = i + 1; sigdata->channel_volume[i] = 64; - sigdata->channel_pan[i] = c & 8 ? 12 : 3; + sigdata->channel_pan[i] = c & 8 ? 7 + sep : 7 - sep; /** WARNING: ah, but it should be 7 for mono... */ } else { /** WARNING: this could be improved if we support channel muting... */ @@ -599,7 +574,7 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) } /* Orders, byte each, length = sigdata->n_orders (should be even) */ - dumbfile_getnc(sigdata->order, sigdata->n_orders, f); + dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f); sigdata->restart_position = 0; component = malloc(768*sizeof(*component)); @@ -673,45 +648,12 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) return NULL; } - /* Voila, I must deal with a very dumb S3M myself. This file refers to the same file offset twice - * for two different patterns. Solution: Eliminate it. - */ - for (n = 0; n < n_components; n++) { - if (component[n].type == S3M_COMPONENT_PATTERN) { - int m; - for (m = n + 1; m < n_components; m++) { - if (component[m].type == S3M_COMPONENT_PATTERN) { - if (component[n].offset == component[m].offset) { - int o, pattern; - pattern = component[m].n; - n_components--; - for (o = m; o < n_components; o++) { - component[o] = component[o + 1]; - } - for (o = 0; o < sigdata->n_orders; o++) { - if (sigdata->order[o] == pattern) { - sigdata->order[o] = component[n].n; - } - } - sigdata->pattern[pattern].n_rows = 64; - sigdata->pattern[pattern].n_entries = 0; - m--; - } else - break; - } - } - } - } - - for (n = 0; n < n_components; n++) { - int32 offset = 0; + int32 offset; int m; -#ifdef S3M_BROKEN_OVERLAPPED_SAMPLES - int last; -#endif - if (it_seek(f, component[n].offset)) { + offset = 0; + if (dumbfile_seek(f, component[n].offset, DFS_SEEK_SET)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); @@ -721,7 +663,7 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) switch (component[n].type) { case S3M_COMPONENT_PATTERN: - if (it_s3m_read_pattern(&sigdata->pattern[component[n].n], f, buffer, (n + 1 < n_components) ? (component[n+1].offset - component[n].offset) : 0)) { + if (it_s3m_read_pattern(&sigdata->pattern[component[n].n], f, buffer)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); @@ -759,41 +701,9 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) m = component[n].sampfirst; -#ifdef S3M_BROKEN_OVERLAPPED_SAMPLES - last = -1; -#endif - while (m >= 0) { // XXX -#ifdef S3M_BROKEN_OVERLAPPED_SAMPLES - if ( last >= 0 ) { - if ( dumbfile_pos( f ) > component[m].offset ) { - IT_SAMPLE * s1 = &sigdata->sample[component[last].n]; - IT_SAMPLE * s2 = &sigdata->sample[component[m].n]; - if ( ( s1->flags | s2->flags ) & ( IT_SAMPLE_16BIT | IT_SAMPLE_STEREO ) ) { - free(buffer); - free(component); - _dumb_it_unload_sigdata(sigdata); - return NULL; - } - if ( component[m].offset >= component[last].offset && - component[m].offset + s2->length <= component[last].offset + s1->length ) { - s2->left = malloc( s2->length ); - if ( ! s2->left ) { - free(buffer); - free(component); - _dumb_it_unload_sigdata(sigdata); - return NULL; - } - memcpy( s2->left, ( const char * ) s1->left + component[m].offset - component[last].offset, s2->length ); - last = -1; - } - } - } else last = 0; - - if ( last >= 0 ) { -#endif - if (it_seek(f, component[m].offset)) { + if (dumbfile_seek(f, component[m].offset, DFS_SEEK_SET)) { free(buffer); free(component); _dumb_it_unload_sigdata(sigdata); @@ -807,11 +717,6 @@ static DUMB_IT_SIGDATA *it_s3m_load_sigdata(DUMBFILE *f, int * cwtv) return NULL; } -#ifdef S3M_BROKEN_OVERLAPPED_SAMPLES - last = m; - } -#endif - m = component[m].sampnext; } } @@ -846,7 +751,7 @@ DUH *DUMBEXPORT dumb_read_s3m_quick(DUMBFILE *f) char version[8]; const char *tag[3][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; tag[1][1] = "S3M"; tag[2][0] = "TRACKERVERSION"; diff --git a/dumb/src/it/readstm.c b/dumb/src/it/readstm.c index 42f14e532b..94bb2f3e34 100644 --- a/dumb/src/it/readstm.c +++ b/dumb/src/it/readstm.c @@ -25,13 +25,18 @@ #include "dumb.h" #include "internal/it.h" -#ifndef _WIN32 -#define strnicmp strncasecmp +#ifdef _MSC_VER + #define strnicmp _strnicmp +#else + #if defined(unix) || defined(__unix__) || defined(__unix) + #include + #endif + #define strnicmp strncasecmp #endif static int it_stm_read_sample_header( IT_SAMPLE *sample, DUMBFILE *f, unsigned short *offset ) { - dumbfile_getnc( sample->filename, 12, f ); + dumbfile_getnc( (char *) sample->filename, 12, f ); sample->filename[12] = 0; memcpy( sample->name, sample->filename, 13 ); @@ -56,6 +61,7 @@ static int it_stm_read_sample_header( IT_SAMPLE *sample, DUMBFILE *f, unsigned s /* Looks like no-existy. */ sample->flags &= ~IT_SAMPLE_EXISTS; sample->length = 0; + *offset = 0; return dumbfile_error( f ); } @@ -81,7 +87,7 @@ static int it_stm_read_sample_header( IT_SAMPLE *sample, DUMBFILE *f, unsigned s return dumbfile_error(f); } -static int it_stm_read_sample_data( IT_SAMPLE *sample, void *data_block, long offset ) +static int it_stm_read_sample_data( IT_SAMPLE *sample, DUMBFILE * f ) { if ( ! sample->length ) return 0; @@ -89,9 +95,9 @@ static int it_stm_read_sample_data( IT_SAMPLE *sample, void *data_block, long of if (!sample->data) return -1; - memcpy( sample->data, (unsigned char*)data_block + offset, sample->length ); + dumbfile_getnc( sample->data, sample->length, f ); - return 0; + return dumbfile_error( f ); } static int it_stm_read_pattern( IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buffer ) @@ -103,7 +109,7 @@ static int it_stm_read_pattern( IT_PATTERN *pattern, DUMBFILE *f, unsigned char pattern->n_rows = 64; - if ( dumbfile_getnc( buffer, 64 * 4 * 4, f ) != 64 * 4 * 4 ) + if ( dumbfile_getnc( (char *) buffer, 64 * 4 * 4, f ) != 64 * 4 * 4 ) return -1; pattern->n_entries = 64; @@ -190,17 +196,13 @@ static DUMB_IT_SIGDATA *it_stm_load_sigdata(DUMBFILE *f, int * version) unsigned short sample_offset[ 31 ]; - void *data_block; - - int n; - - long o, p, q; + int n; sigdata = malloc(sizeof(*sigdata)); if (!sigdata) return NULL; /* Skip song name. */ - dumbfile_getnc(sigdata->name, 20, f); + dumbfile_getnc((char *)sigdata->name, 20, f); sigdata->name[20] = 0; dumbfile_getnc(tracker_name, 8, f); @@ -277,10 +279,11 @@ static DUMB_IT_SIGDATA *it_stm_load_sigdata(DUMBFILE *f, int * version) } memset( sigdata->channel_volume, 64, 4 ); - sigdata->channel_pan[ 0 ] = 48; - sigdata->channel_pan[ 1 ] = 16; - sigdata->channel_pan[ 2 ] = 48; - sigdata->channel_pan[ 3 ] = 16; + n = 32 * dumb_it_default_panning_separation / 100; + sigdata->channel_pan[ 0 ] = 32 + n; + sigdata->channel_pan[ 1 ] = 32 - n; + sigdata->channel_pan[ 2 ] = 32 + n; + sigdata->channel_pan[ 3 ] = 32 - n; for ( n = 0; n < sigdata->n_samples; ++n ) { if ( it_stm_read_sample_header( &sigdata->sample[ n ], f, &sample_offset[ n ] ) ) { @@ -296,7 +299,7 @@ static DUMB_IT_SIGDATA *it_stm_load_sigdata(DUMBFILE *f, int * version) } /* Orders, byte each, length = sigdata->n_orders (should be even) */ - dumbfile_getnc( sigdata->order, *version >= 0x200 ? 128 : 64, f ); + dumbfile_getnc( (char *) sigdata->order, *version >= 0x200 ? 128 : 64, f ); if (*version < 0x200) memset( sigdata->order + 64, 0xFF, 64 ); sigdata->restart_position = 0; @@ -329,60 +332,21 @@ static DUMB_IT_SIGDATA *it_stm_load_sigdata(DUMBFILE *f, int * version) free( buffer ); } - o = LONG_MAX; - p = 0; - - for ( n = 0; n < sigdata->n_samples; ++n ) { - if ((sigdata->sample[ n ].flags & IT_SAMPLE_EXISTS) && sample_offset[ n ]) { - q = ((long)sample_offset[ n ]) * 16; - if (q < o) { - o = q; - } - if (q + sigdata->sample[ n ].length > p) { - p = q + sigdata->sample[ n ].length; - } - } - else { - sigdata->sample[ n ].flags = 0; - sigdata->sample[ n ].length = 0; - } - } - - data_block = malloc( p - o ); - if ( !data_block ) { - _dumb_it_unload_sigdata( sigdata ); - return NULL; - } - - for ( n = 0, q = o / 16; n < sigdata->n_samples; ++n ) { - if ( sample_offset[ n ] ) { - sample_offset[ n ] = (unsigned short)(sample_offset[ n ] - q); - } - } - - q = o - dumbfile_pos( f ); - p -= o; - o = 0; - if ( q >= 0 ) dumbfile_skip( f, q ); - else { - o = -q; - memset ( data_block, 0, o ); - } - if ( dumbfile_getnc( (char*)data_block + o, p - o, f ) != p - o ) { - free( data_block ); - _dumb_it_unload_sigdata( sigdata ); - return NULL; - } - - for ( n = 0; n < sigdata->n_samples; ++n ) { - if ( it_stm_read_sample_data( &sigdata->sample[ n ], data_block, ((long)sample_offset[ n ]) * 16 ) ) { - free( data_block ); - _dumb_it_unload_sigdata( sigdata ); - return NULL; - } - } - - free( data_block ); + for ( n = 0; n < sigdata->n_samples; ++n ) { + if ( sample_offset[ n ] ) + { + if ( dumbfile_seek( f, sample_offset[ n ] * 16, DFS_SEEK_SET ) || + it_stm_read_sample_data( &sigdata->sample[ n ], f ) ) { + _dumb_it_unload_sigdata( sigdata ); + return NULL; + } + } + else + { + sigdata->sample[ n ].flags = 0; + sigdata->sample[ n ].length = 0; + } + } _dumb_it_fix_invalid_orders(sigdata); @@ -405,7 +369,7 @@ DUH *DUMBEXPORT dumb_read_stm_quick(DUMBFILE *f) char version[16]; const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; version[0] = 'S'; version[1] = 'T'; diff --git a/dumb/src/it/readxm.c b/dumb/src/it/readxm.c index 7b92cb9548..a06fd1e992 100644 --- a/dumb/src/it/readxm.c +++ b/dumb/src/it/readxm.c @@ -23,6 +23,7 @@ #include "dumb.h" #include "internal/it.h" +#include "internal/dumbfile.h" #include #include @@ -185,7 +186,7 @@ static void it_xm_convert_volume(int volume, IT_ENTRY *entry) -static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, unsigned char **bufferptr, int *buffersize, int version) +static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, unsigned char *buffer, int version) { int size; int pos; @@ -193,7 +194,6 @@ static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, int row; int effect, effectvalue; IT_ENTRY *entry; - unsigned char *buffer; /* pattern header size */ if (dumbfile_igetl(f) != ( version == 0x0102 ? 0x08 : 0x09 ) ) { @@ -220,20 +220,12 @@ static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, if (size == 0) return 0; - if (size > *buffersize) { - if (*bufferptr != NULL) { - free(*bufferptr); - } - *bufferptr = malloc(size); - *buffersize = size; - } - buffer = *bufferptr; - if (buffer == NULL) { - TRACE("XM error: out of memory reading pattern\n"); + if (size > 1280 * n_channels) { + TRACE("XM error: pattern data size > %d bytes\n", 1280 * n_channels); return -1; } - if (dumbfile_getnc(buffer, size, f) < size) + if (dumbfile_getnc((char *)buffer, size, f) < size) return -1; /* compute number of entries */ @@ -378,15 +370,7 @@ struct LIMITED_XM DUMBFILE *remaining; }; -/* XXX */ -struct DUMBFILE -{ - DUMBFILE_SYSTEM *dfs; - void *file; - long pos; -}; - -static int limit_xm_resize(void *f, long n) +static int DUMBCALLBACK limit_xm_resize(void *f, long n) { DUMBFILE *df = f; LIMITED_XM *lx = df->file; @@ -398,7 +382,7 @@ static int limit_xm_resize(void *f, long n) memset( buffered + lx->allocated, 0, n - lx->allocated ); lx->allocated = n; } - if ( dumbfile_getnc( lx->buffered, n, lx->remaining ) < n ) return -1; + if ( dumbfile_getnc( (char *)lx->buffered, n, lx->remaining ) < n ) return -1; } else if (!n) { if ( lx->buffered ) free( lx->buffered ); lx->buffered = NULL; @@ -409,14 +393,14 @@ static int limit_xm_resize(void *f, long n) return 0; } -static int limit_xm_skip_end(void *f, int32 n) +static int DUMBCALLBACK limit_xm_skip_end(void *f, int32 n) { DUMBFILE *df = f; LIMITED_XM *lx = df->file; return dumbfile_skip( lx->remaining, n ); } -static int limit_xm_skip(void *f, int32 n) +static int DUMBCALLBACK limit_xm_skip(void *f, long n) { LIMITED_XM *lx = f; lx->ptr += n; @@ -425,7 +409,7 @@ static int limit_xm_skip(void *f, int32 n) -static int limit_xm_getc(void *f) +static int DUMBCALLBACK limit_xm_getc(void *f) { LIMITED_XM *lx = f; if (lx->ptr >= lx->allocated) { @@ -436,7 +420,7 @@ static int limit_xm_getc(void *f) -static int32 limit_xm_getnc(char *ptr, int32 n, void *f) +static int32 DUMBCALLBACK limit_xm_getnc(char *ptr, int32 n, void *f) { LIMITED_XM *lx = f; int left; @@ -457,7 +441,7 @@ static int32 limit_xm_getnc(char *ptr, int32 n, void *f) -static void limit_xm_close(void *f) +static void DUMBCALLBACK limit_xm_close(void *f) { LIMITED_XM *lx = f; if (lx->buffered) free(lx->buffered); @@ -467,12 +451,32 @@ static void limit_xm_close(void *f) +/* These two can be stubs since this implementation doesn't use seeking */ +static int DUMBCALLBACK limit_xm_seek(void *f, long n) +{ + (void)f; + (void)n; + return 1; +} + + + +static long DUMBCALLBACK limit_xm_get_size(void *f) +{ + (void)f; + return 0; +} + + + DUMBFILE_SYSTEM limit_xm_dfs = { NULL, &limit_xm_skip, &limit_xm_getc, &limit_xm_getnc, - &limit_xm_close + &limit_xm_close, + &limit_xm_seek, + &limit_xm_get_size }; static DUMBFILE *dumbfile_limit_xm(DUMBFILE *f) @@ -513,9 +517,9 @@ static int it_xm_read_instrument(IT_INSTRUMENT *instrument, XM_INSTRUMENT_EXTRA if ( limit_xm_resize( f, size - 4 ) < 0 ) return -1; - dumbfile_getnc(instrument->name, 22, f); + dumbfile_getnc((char *)instrument->name, 22, f); instrument->name[22] = 0; - trim_whitespace(instrument->name, 22); + trim_whitespace((char *)instrument->name, 22); instrument->filename[0] = 0; dumbfile_skip(f, 1); /* Instrument type. Should be 0, but seems random. */ extra->n_samples = dumbfile_igetw(f); @@ -673,9 +677,9 @@ static int it_xm_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f) reserved = dumbfile_getc(f); - dumbfile_getnc(sample->name, 22, f); + dumbfile_getnc((char *)sample->name, 22, f); sample->name[22] = 0; - trim_whitespace(sample->name, 22); + trim_whitespace((char *)sample->name, 22); sample->filename[0] = 0; @@ -763,13 +767,22 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D { int old; int32 i; +// long truncated_size; int n_channels; int32 datasizebytes; - void *ibuffer; if (!(sample->flags & IT_SAMPLE_EXISTS)) return dumbfile_skip(f, roguebytes); +#if 0 + /* let's get rid of the sample data coming after the end of the loop */ + if ((sample->flags & IT_SAMPLE_LOOP) && sample->loop_end < sample->length && roguebytes != 4) { + truncated_size = sample->length - sample->loop_end; + sample->length = sample->loop_end; + } else { + truncated_size = 0; + } +#endif n_channels = sample->flags & IT_SAMPLE_STEREO ? 2 : 1; datasizebytes = sample->length; @@ -848,7 +861,7 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D * players that don't know about it (and FastTracker 2 itself), the two * channels are not stored interleaved but rather, one after the other. */ int old_r = 0; - ibuffer = malloc(sample->length << ((sample->flags & IT_SAMPLE_16BIT) ? 2 : 1)); + void *ibuffer = malloc(sample->length << ((sample->flags & IT_SAMPLE_16BIT) ? 2 : 1)); if (ibuffer == NULL) { /* No memory => ignore stereo bits at the end */ @@ -925,12 +938,12 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) return NULL; /* song name */ - if (dumbfile_getnc(sigdata->name, 20, f) < 20) { + if (dumbfile_getnc((char *)sigdata->name, 20, f) < 20) { free(sigdata); return NULL; } sigdata->name[20] = 0; - trim_whitespace(sigdata->name, 20); + trim_whitespace((char *)sigdata->name, 20); if (dumbfile_getc(f) != 0x1A) { TRACE("XM error: 0x1A not found\n"); @@ -986,6 +999,16 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) if (sigdata->speed == 0) sigdata->speed = 6; // Should we? What about tempo? sigdata->tempo = dumbfile_igetw(f); + // FT2 always clips restart position against the song length + if (sigdata->restart_position > sigdata->n_orders) + sigdata->restart_position = sigdata->n_orders; + // And FT2 starts playback on order 0, regardless of length, + // and only checks if the next order is greater than or equal + // to this, not the current pattern. Work around this with + // DUMB's playback core by overriding a zero length with one. + if (sigdata->n_orders == 0) + sigdata->n_orders = 1; + /* sanity checks */ // XXX i = header_size - 4 - 2 * 8; /* Maximum number of orders expected */ @@ -1003,7 +1026,7 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) _dumb_it_unload_sigdata(sigdata); return NULL; } - dumbfile_getnc(sigdata->order, sigdata->n_orders, f); + dumbfile_getnc((char *)sigdata->order, sigdata->n_orders, f); dumbfile_skip(f, i - sigdata->n_orders); if (dumbfile_error(f)) { @@ -1027,13 +1050,14 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) sigdata->pattern[i].entry = NULL; { - unsigned char *buffer = NULL; - int buffersize = 0; + unsigned char *buffer = malloc(1280 * n_channels); /* 256 rows * 5 bytes */ + if (!buffer) { + _dumb_it_unload_sigdata(sigdata); + return NULL; + } for (i = 0; i < sigdata->n_patterns; i++) { - if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, &buffer, &buffersize, * version) != 0) { - if (buffer != NULL) { - free(buffer); - } + if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, buffer, * version) != 0) { + free(buffer); _dumb_it_unload_sigdata(sigdata); return NULL; } @@ -1271,13 +1295,15 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) sigdata->pattern[i].entry = NULL; { - unsigned char *buffer = NULL; - int buffersize = 0; + unsigned char *buffer = malloc(1280 * n_channels); /* 256 rows * 5 bytes */ + if (!buffer) { + free(roguebytes); + _dumb_it_unload_sigdata(sigdata); + return NULL; + } for (i = 0; i < sigdata->n_patterns; i++) { - if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, &buffer, &buffersize, * version) != 0) { - if (buffer != NULL) { - free(buffer); - } + if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, buffer, * version) != 0) { + free(buffer); free(roguebytes); _dumb_it_unload_sigdata(sigdata); return NULL; @@ -1486,7 +1512,7 @@ DUH *DUMBEXPORT dumb_read_xm_quick(DUMBFILE *f) char version[16]; const char *tag[2][2]; tag[0][0] = "TITLE"; - tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name; + tag[0][1] = (const char *)(((DUMB_IT_SIGDATA *)sigdata)->name); tag[1][0] = "FORMAT"; version[0] = 'X'; version[1] = 'M'; diff --git a/dumb/src/sigtypes/combine.c b/dumb/src/sigtypes/combine.c deleted file mode 100644 index 497f085cf2..0000000000 --- a/dumb/src/sigtypes/combine.c +++ /dev/null @@ -1,243 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * combine.c - The combining (COMB) signal type. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * This takes multiple monaural signals and | \ / / - * combines them into a single multichannel | ' / - * signal. It assumes the correct number of \__/ - * channels is passed. An ASSERT() is in place - * to check the number of channels when you - * compile with -DDEBUGMODE. As an exception, if one channel is passed the - * signals are all mixed together. - */ - -#include - -#include "dumb.h" - - - -#define SIGTYPE_COMBINING DUMB_ID('C','O','M','B') - - - -typedef struct COMBINING_SIGNAL -{ - int n_signals; - int sig[ZERO_SIZE]; -} -COMBINING_SIGNAL; - - - -typedef struct COMBINING_SAMPINFO -{ - int n_signals; - int downmix; - DUH_SIGNAL_SAMPINFO *csampinfo[ZERO_SIZE]; -} -COMBINING_SAMPINFO; - - - -static void *combining_load_signal(DUH *duh, DUMBFILE *file) -{ - COMBINING_SIGNAL *signal; - int n_signals; - - (void)duh; - - n_signals = dumbfile_getc(file); - - /* No point in combining only one signal! */ - if (dumbfile_error(file) || n_signals <= 1) - return NULL; - - signal = malloc(sizeof(*signal) + n_signals * sizeof(*signal->sig)); - if (!signal) - return NULL; - - signal->n_signals = n_signals; - - { - int n; - for (n = 0; n < signal->n_signals; n++) { - signal->sig[n] = dumbfile_igetl(file); - if (dumbfile_error(file)) { - free(signal); - return NULL; - } - } - } - - return signal; -} - - - -static void *combining_start_samples(DUH *duh, void *signal, int n_channels, long pos) -{ -#define signal ((COMBINING_SIGNAL *)signal) - - COMBINING_SAMPINFO *sampinfo; - - sampinfo = malloc(sizeof(*sampinfo) + signal->n_signals * sizeof(*sampinfo->csampinfo)); - if (!sampinfo) - return NULL; - - sampinfo->n_signals = signal->n_signals; - if (n_channels == 1) - sampinfo->downmix = 1; - else if (n_channels == signal->n_signals) - sampinfo->downmix = 0; - else { - TRACE("Combining signal discrepancy: %d signals, %d channels.\n", signal->n_signals, n_channels); - free(sampinfo); - return NULL; - } - - { - int worthwhile = 0; - - { - int n; - for (n = 0; n < signal->n_signals; n++) { - sampinfo->csampinfo[n] = duh_signal_start_samples(duh, signal->sig[n], 1, pos); - if (sampinfo->csampinfo[n]) - worthwhile = 1; - } - } - - if (!worthwhile) { - free(sampinfo); - return NULL; - } - } - - return sampinfo; - -#undef signal -} - - - -static long combining_render_samples( - void *sampinfo, - float volume, float delta, - long size, sample_t **samples -) -{ -#define sampinfo ((COMBINING_SAMPINFO *)sampinfo) - - long max_size; - - int n; - - if (sampinfo->downmix) - volume /= sampinfo->n_signals; - - max_size = duh_signal_render_samples(sampinfo->csampinfo[0], volume, delta, size, samples); - - if (sampinfo->downmix) { - - long s; - long sz; - - sample_t *sampbuf = malloc(size * sizeof(sample_t)); - - if (!sampbuf) - return 0; - - for (n = 1; n < sampinfo->n_signals; n++) { - sz = duh_signal_render_samples(sampinfo->csampinfo[n], volume, delta, size, &sampbuf); - if (sz > max_size) { - for (s = max_size; s < sz; s++) - samples[0][s] = sampbuf[s]; - sz = max_size; - max_size = s; - } - for (s = 0; s < sz; s++) - samples[0][s] += sampbuf[s]; - } - - free(sampbuf); - - } else { - - long *sz = malloc(size * sizeof(*sz)); - long s; - - if (!sz) - return 0; - - sz[0] = max_size; - - for (n = 1; n < sampinfo->n_signals; n++) { - sz[n] = duh_signal_render_samples(sampinfo->csampinfo[n], volume, delta, size, samples + n); - if (sz[n] > max_size) - max_size = sz[n]; - } - - for (n = 0; n < sampinfo->n_signals; n++) - for (s = sz[n]; s < max_size; s++) - samples[n][s] = 0; - - free(sz); - - } - - return max_size; - -#undef sampinfo -} - - - -static void combining_end_samples(void *sampinfo) -{ -#define sampinfo ((COMBINING_SAMPINFO *)sampinfo) - - int n; - - for (n = 0; n < sampinfo->n_signals; n++) - duh_signal_end_samples(sampinfo->csampinfo[n]); - - free(sampinfo); - -#undef sampinfo -} - - - -static void combining_unload_signal(void *signal) -{ - free(signal); -} - - - -static DUH_SIGTYPE_DESC sigtype_combining = { - SIGTYPE_COMBINING, - &combining_load_signal, - &combining_start_samples, - NULL, - &combining_render_samples, - &combining_end_samples, - &combining_unload_signal -}; - - -void dumb_register_sigtype_combining(void) -{ - dumb_register_sigtype(&sigtype_combining); -} diff --git a/dumb/src/sigtypes/sample.c b/dumb/src/sigtypes/sample.c deleted file mode 100644 index 4695de9188..0000000000 --- a/dumb/src/sigtypes/sample.c +++ /dev/null @@ -1,340 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * sample.c - The sample (SAMP) signal type. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * This only supports monaural samples. For | \ / / - * multiple channels, use multiple samples and | ' / - * a combining signal (COMB). \__/ - */ - -/* NOTE: filters need not be credited yet, as they will be moved elsewhere. */ -/** WARNING don't forget to move these filters somewhere */ - -#include -#include - -#include "dumb.h" - - -/** WARNING move these things somewhere useful, for DUH writing - this applies to other signal types too */ -#define SIGTYPE_SAMPLE DUMB_ID('S','A','M','P') - - - -#define SAMPFLAG_16BIT 1 /* sample in file is 16 bit, rather than 8 bit */ -#define SAMPFLAG_LOOP 2 /* loop indefinitely */ -#define SAMPFLAG_XLOOP 4 /* loop x times; only relevant if LOOP not set */ -#define SAMPFLAG_PINGPONG 8 /* loop back and forth, if LOOP or XLOOP set */ - - -/* SAMPPARAM_N_LOOPS: add 'value' iterations to the loop. 'value' is assumed - * to be positive. - */ -#define SAMPPARAM_N_LOOPS 0 - - - -typedef struct SAMPLE_SIGDATA -{ - long size; - int flags; - long loop_start; - long loop_end; - sample_t *samples; -} -SAMPLE_SIGDATA; - - - -typedef struct SAMPLE_SIGRENDERER -{ - SAMPLE_SIGDATA *sigdata; - int n_channels; - DUMB_RESAMPLER r; - int n_loops; -} -SAMPLE_SIGRENDERER; - - - -static sigdata_t *sample_load_sigdata(DUH *duh, DUMBFILE *file) -{ - SAMPLE_SIGDATA *sigdata; - long size; - long n; - int flags; - - (void)duh; - - size = dumbfile_igetl(file); - - if (dumbfile_error(file) || size <= 0) - return NULL; - - flags = dumbfile_getc(file); - if (flags < 0) - return NULL; - - sigdata = malloc(sizeof(*sigdata)); - if (!sigdata) - return NULL; - - sigdata->samples = malloc(size * sizeof(sample_t)); - if (!sigdata->samples) { - free(sigdata); - return NULL; - } - - sigdata->size = size; - sigdata->flags = flags; - - if (sigdata->flags & (SAMPFLAG_LOOP | SAMPFLAG_XLOOP)) { - sigdata->loop_start = dumbfile_igetl(file); - - if (dumbfile_error(file) || (unsigned long)sigdata->loop_start >= (unsigned long)size) { - free(sigdata->samples); - free(sigdata); - return NULL; - } - - if (sigdata->flags & SAMPFLAG_LOOP) - sigdata->loop_end = size; - else { - sigdata->loop_end = dumbfile_igetl(file); - - if (dumbfile_error(file) || sigdata->loop_end <= sigdata->loop_start || sigdata->loop_end > size) { - free(sigdata->samples); - free(sigdata); - return NULL; - } - } - } else { - sigdata->loop_start = 0; - sigdata->loop_end = size; - } - - if (sigdata->flags & SAMPFLAG_16BIT) { - for (n = 0; n < size; n++) { - int m = dumbfile_igetw(file); - if (m < 0) { - free(sigdata->samples); - free(sigdata); - return NULL; - } - sigdata->samples[n] = (int)(signed short)m << 8; - } - } else { - for (n = 0; n < size; n++) { - int m = dumbfile_getc(file); - if (m < 0) { - free(sigdata->samples); - free(sigdata); - return NULL; - } - sigdata->samples[n] = (int)(signed char)m << 16; - } - } - - return sigdata; -} - - - -static void sample_pickup(DUMB_RESAMPLER *r, void *data) -{ - SAMPLE_SIGRENDERER *sigrenderer = data; - - if (!(sigrenderer->sigdata->flags & (SAMPFLAG_LOOP | SAMPFLAG_XLOOP))) { - r->dir = 0; - return; - } - - if (!(sigrenderer->sigdata->flags & SAMPFLAG_LOOP) && sigrenderer->n_loops == 0) { - r->dir = 0; - return; - } - - if (sigrenderer->sigdata->flags & SAMPFLAG_PINGPONG) { - if (r->dir < 0) { - r->pos = (r->start << 1) - 1 - r->pos; - r->subpos ^= 65535; - r->dir = 1; - } else { - r->pos = (r->end << 1) - 1 - r->pos; - r->subpos ^= 65535; - r->dir = -1; - } - } else - r->pos -= r->end - r->start; - - if (!(sigrenderer->sigdata->flags & SAMPFLAG_LOOP)) { - if (sigrenderer->n_loops > 0) { - sigrenderer->n_loops--; - if (sigrenderer->n_loops == 0) { - r->start = 0; - r->end = sigrenderer->sigdata->size; - } - } - } -} - - - -static sigrenderer_t *sample_start_sigrenderer(DUH *duh, sigdata_t *data, int n_channels, long pos) -{ - SAMPLE_SIGDATA *sigdata = data; - SAMPLE_SIGRENDERER *sigrenderer; - - (void)duh; - - sigrenderer = malloc(sizeof(*sigrenderer)); - if (!sigrenderer) return NULL; - - sigrenderer->sigdata = data; - sigrenderer->n_channels = n_channels; - dumb_reset_resampler(&sigrenderer->r, sigdata->samples, pos, 0, sigdata->size); - sigrenderer->r.pickup = &sample_pickup; - sigrenderer->r.pickup_data = sigrenderer; - sigrenderer->n_loops = 0; - - return sigrenderer; -} - - - -#if 0 -/* The name says it all ;-) */ -static void sample_cheap_low_pass_filter(sample *src, long size, float max_freq) { - - long i; - float fact = max_freq / 44100.0f; - - for (i = 0; i < size-1; i++) { - float d = src[i+1] - src[i]; - if (d > fact) - src[i+1] += fact - d; - else if (d < -fact) - src[i+1] += -d - fact; - } - - return; -} - - - -/* Dithering with noise shaping filter. Set shape = 0 for no shaping. */ -static void sample_dither_filter(float *src, long size, float shape) { - float r1 = 0, r2 = 0; - float s1 = 0, s2 = 0; /* Feedback buffer */ - float o = 0.5f / 255; - float tmp; - int i; - - for (i = 0; i < size; i++) { - r2 = r1; - r1 = rand() / (float)RAND_MAX; - - tmp = src[i] + shape * (s1 + s1 - s2); - src[i] = tmp + o * (r1 - r2); - src[i] = MID(-1.0f, src[i], 1.0f); - - s2 = s1; - s1 = tmp - src[i]; - } - return; -} -#endif - - - -static void sample_sigrenderer_set_sigparam(sigrenderer_t *data, unsigned char id, long value) -{ - SAMPLE_SIGRENDERER *sigrenderer = data; - - if (id == SAMPPARAM_N_LOOPS) { - if ((sigrenderer->sigdata->flags & (SAMPFLAG_LOOP | SAMPFLAG_XLOOP)) == SAMPFLAG_XLOOP) { - sigrenderer->n_loops += value; - sigrenderer->r.start = sigrenderer->n_loops ? sigrenderer->sigdata->loop_start : 0; - sigrenderer->r.end = sigrenderer->n_loops ? sigrenderer->sigdata->loop_end : sigrenderer->sigdata->size; - } - } -} - - - -static long sample_sigrenderer_get_samples( - sigrenderer_t *data, - float volume, float delta, - long size, sample_t **samples -) -{ - SAMPLE_SIGRENDERER *sigrenderer = data; - - DUMB_RESAMPLER initial_r = sigrenderer->r; - - long s = dumb_resample(&sigrenderer->r, samples[0], size, volume, delta); - - int n; - for (n = 1; n < sigrenderer->n_channels; n++) { - sigrenderer->r = initial_r; - dumb_resample(&sigrenderer->r, samples[n], size, volume, delta); - } - - return s; -} - - - -static void sample_sigrenderer_get_current_sample(sigrenderer_t *data, float volume, sample_t *samples) -{ - SAMPLE_SIGRENDERER *sigrenderer = data; - int n; - for (n = 0; n < sigrenderer->n_channels; n++) - samples[n] = dumb_resample_get_current_sample(&sigrenderer->r, volume); -} - - - -static void sample_end_sigrenderer(sigrenderer_t *sigrenderer) -{ - free(sigrenderer); -} - - - -static void sample_unload_sigdata(sigdata_t *data) -{ - SAMPLE_SIGDATA *sigdata = data; - free(sigdata->samples); - free(data); -} - - - -static DUH_SIGTYPE_DESC sigtype_sample = { - SIGTYPE_SAMPLE, - &sample_load_sigdata, - &sample_start_sigrenderer, - &sample_sigrenderer_set_sigparam, - &sample_sigrenderer_get_samples, - &sample_sigrenderer_get_current_sample, - &sample_end_sigrenderer, - &sample_unload_sigdata -}; - - - -void dumb_register_sigtype_sample(void) -{ - dumb_register_sigtype(&sigtype_sample); -} diff --git a/dumb/src/sigtypes/sequence.c b/dumb/src/sigtypes/sequence.c deleted file mode 100644 index cfade4d67f..0000000000 --- a/dumb/src/sigtypes/sequence.c +++ /dev/null @@ -1,592 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * sequence.c - The sequence (SEQU) signal type. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * | \ / / - * | ' / - * \__/ - */ - -#include -#include -#include - -#include "dumb.h" - - - -#define SIGTYPE_SEQUENCE DUMB_ID('S','E','Q','U') - - - -/* We have 256 intervals per semitone, 12 * 256 per octave - 2 ** (1 / (12 * 256)) = 1.000225659305069791926712241547647863626 - - pow(DUMB_PITCH_BASE, x) = 1.5 - x = log2(1.5) / log2(DUMB_PITCH_BASE) - x = log2(1.5) * 12 * 256 - x = 1797.004802 - cf. - x = 7 * 256 = 1792 - - so, for the perfect fifth temperament, use an interval of 1797. -*/ - - - -/* Sequencing format - * ----------------- - * - * NOTE: A LOT OF THIS IS NOW REDUNDANT. PLEASE REFER TO duhspecs.txt. - * - * When a signal is initiated, it claims a reference number. If any other - * currently playing signal has the same number, that signal becomes - * anonymous and inaccessible; that is, if multiple signals were initiated - * with the same reference, the reference belongs to the most recent. - * - * Signals can be stopped, or have their pitch, volume or parameters changed, - * using the reference number. A signal may stop prematurely if it runs out - * of data, in which case the reference number becomes void, and operations - * on it will be ignored. Such a situation will not flag any kind of warning, - * since it may be the result of inaccuracies when resampling. - * - * The sequence consists of a series of commands. All commands begin with a - * long int, which is the time to wait after the last command (or the - * beginning of the sequence) before executing this command. 65536 represents - * one second. A time of -1 (or in fact any negative time) terminates the - * sequence, but any currently playing signals will continue until they run - * out. Make sure no non-terminating signals are playing when the sequence - * ends! - * - * The time, if nonnegative, is followed by one byte indicating the type of - * command. This byte can have the following values: - * - * SEQUENCE_START_SIGNAL - * unsigned char ref; - Reference. Need more than 256? Use two sequences, - * and get your brain seen to. - * int sig; - The index of the signal to initiate. - * long pos; - The position at which to start. 65536 represents one second. - * unsigned short volume; - Volume. 65535 represents the maximum volume, so - * you will want to go lower than this if you are - * playing more than one signal at once. - * signed short pitch; - Pitch. 0 represents a frequency of 65536 Hz. Scale - * is logarithmic. Add 256 to increase pitch by one - * semitone in the even temperament, or add 12*256 to - * increase pitch by one octave in any temperament - * (i.e. double the frequency). - * - * SEQUENCE_SET_VOLUME - * unsigned char ref; - * unsigned short volume; - * - * SEQUENCE_SET_PITCH - * unsigned char ref; - * signed short pitch; - * - * SEQUENCE_SET_PARAMETER - * unsigned char ref; - * unsigned char id; - * long value; - * - see the description of the set_parameter function pointer for - * information on 'id' and 'value'. - * - * SEQUENCE_STOP_SIGNAL - * unsigned char ref; - */ - - - -#define SEQUENCE_START_SIGNAL 0 -#define SEQUENCE_SET_VOLUME 1 -#define SEQUENCE_SET_PITCH 2 -#define SEQUENCE_SET_PARAMETER 3 -#define SEQUENCE_STOP_SIGNAL 4 - - - -typedef struct SEQUENCE_PLAYING -{ - struct SEQUENCE_PLAYING *next; - - DUH_SIGNAL_SAMPINFO *sampinfo; - - int ref; - - int pitch; - int volume; -} -SEQUENCE_PLAYING; - - - -typedef struct SEQUENCE_SAMPINFO -{ - DUH *duh; - - int n_channels; - - unsigned char *signal; - - long time_left; - int sub_time_left; - - SEQUENCE_PLAYING *playing; -} -SEQUENCE_SAMPINFO; - - - -#define sequence_c(signal) ((int)*((*(signal))++)) - - -static int sequence_w(unsigned char **signal) -{ - int v = (*signal)[0] | ((*signal)[1] << 8); - *signal += 2; - return v; -} - - -static long sequence_l(unsigned char **signal) -{ - long v = (*signal)[0] | ((*signal)[1] << 8) | ((*signal)[2] << 16) | ((*signal)[3] << 24); - *signal += 4; - return v; -} - - -static long sequence_cl(unsigned char **signal) -{ - long v = sequence_c(signal); - if (v & 0x80) { - v &= 0x7F; - v |= sequence_c(signal) << 7; - if (v & 0x4000) { - v &= 0x3FFF; - v |= sequence_c(signal) << 14; - if (v & 0x200000) { - v &= 0x1FFFFF; - v |= sequence_c(signal) << 21; - if (v & 0x10000000) { - v &= 0x0FFFFFFF; - v |= sequence_c(signal) << 28; - } - } - } - } - return v; -} - - - -static void *sequence_load_signal(DUH *duh, DUMBFILE *file) -{ - long size; - unsigned char *signal; - - (void)duh; - - size = dumbfile_igetl(file); - if (dumbfile_error(file) || size <= 0) - return NULL; - - signal = malloc(size); - if (!signal) - return NULL; - - if (dumbfile_getnc((char *)signal, size, file) < size) { - free(signal); - return NULL; - } - - return signal; -} - - - -static long render( - SEQUENCE_SAMPINFO *sampinfo, - float volume, float delta, - long pos, long size, sample_t **samples -) -{ - sample_t **splptr; - - SEQUENCE_PLAYING **playing_p = &sampinfo->playing; - - long max_size = 0; - long part_size; - - int n; - long i; - - for (n = 0; n < sampinfo->n_channels; n++) - memset(samples[n] + pos, 0, size * sizeof(sample_t)); - - splptr = malloc(sampinfo->n_channels * sizeof(*splptr)); - if (!splptr) - return 0; - - splptr[0] = malloc(sampinfo->n_channels * size * sizeof(sample_t)); - if (!splptr[0]) { - free(splptr); - return 0; - } - - for (n = 1; n < sampinfo->n_channels; n++) - splptr[n] = splptr[n - 1] + size; - - while (*playing_p) { - SEQUENCE_PLAYING *playing = *playing_p; - - part_size = duh_signal_render_samples( - playing->sampinfo, - volume * (float)playing->volume * (1.0f / 65535.0f), - (float)(pow(DUMB_PITCH_BASE, playing->pitch) * delta), - size, splptr - ); - - for (n = 0; n < sampinfo->n_channels; n++) - for (i = 0; i < part_size; i++) - samples[n][pos+i] += splptr[n][i]; - - if (part_size > max_size) - max_size = part_size; - - if (part_size < size) { - *playing_p = playing->next; - duh_signal_end_samples(playing->sampinfo); - free(playing); - } else - playing_p = &playing->next; - } - - free(splptr[0]); - free(splptr); - - return max_size; -} - - - -/* 'offset' is added to the position at which the signal should start. It is - * currently assumed to be positive, and is currently only used when seeking - * forwards in the sequence. - */ -static void sequence_command(SEQUENCE_SAMPINFO *sampinfo, long offset) -{ - int command = sequence_c(&sampinfo->signal); - - if (command == SEQUENCE_START_SIGNAL) { - - int ref = sequence_c(&sampinfo->signal); - int sig = sequence_cl(&sampinfo->signal); - long pos = sequence_cl(&sampinfo->signal); - int volume = sequence_w(&sampinfo->signal); - int pitch = (int)(signed short)sequence_w(&sampinfo->signal); - - SEQUENCE_PLAYING *playing = sampinfo->playing; - - while (playing) { - if (playing->ref == ref) - playing->ref = -1; - playing = playing->next; - } - - playing = malloc(sizeof(SEQUENCE_PLAYING)); - - if (playing) { - playing->sampinfo = duh_signal_start_samples(sampinfo->duh, sig, sampinfo->n_channels, pos + offset); - - if (playing->sampinfo) { - playing->ref = ref; - playing->pitch = pitch; - playing->volume = volume; - - playing->next = sampinfo->playing; - sampinfo->playing = playing; - } else - free(playing); - } - - } else if (command == SEQUENCE_SET_VOLUME) { - - int ref = sequence_c(&sampinfo->signal); - int volume = sequence_w(&sampinfo->signal); - - SEQUENCE_PLAYING *playing = sampinfo->playing; - - while (playing) { - if (playing->ref == ref) { - playing->volume = volume; - break; - } - playing = playing->next; - } - - } else if (command == SEQUENCE_SET_PITCH) { - - int ref = sequence_c(&sampinfo->signal); - int pitch = (int)(signed short)sequence_w(&sampinfo->signal); - - SEQUENCE_PLAYING *playing = sampinfo->playing; - - while (playing) { - if (playing->ref == ref) { - playing->pitch = pitch; - break; - } - playing = playing->next; - } - - } else if (command == SEQUENCE_SET_PARAMETER) { - - int ref = sequence_c(&sampinfo->signal); - unsigned char id = sequence_c(&sampinfo->signal); - long value = sequence_l(&sampinfo->signal); - - SEQUENCE_PLAYING *playing = sampinfo->playing; - - while (playing) { - if (playing->ref == ref) { - duh_signal_set_parameter(playing->sampinfo, id, value); - break; - } - playing = playing->next; - } - - } else if (command == SEQUENCE_STOP_SIGNAL) { - - int ref = sequence_c(&sampinfo->signal); - - SEQUENCE_PLAYING **playing_p = &sampinfo->playing; - - while (*playing_p) { - SEQUENCE_PLAYING *playing = *playing_p; - - if (playing->ref == ref) { - duh_signal_end_samples(playing->sampinfo); - *playing_p = playing->next; - free(playing); - break; - } - - playing_p = &playing->next; - } - - } else { - - TRACE("Error in sequence: unknown command %d.\n", command); - sampinfo->signal = NULL; - - } -} - - - -static void *sequence_start_samples(DUH *duh, void *signal, int n_channels, long pos) -{ - SEQUENCE_SAMPINFO *sampinfo; - long time = sequence_cl((unsigned char **)&signal); - - if (time < 0) - return NULL; - - sampinfo = malloc(sizeof(SEQUENCE_SAMPINFO)); - if (!sampinfo) - return NULL; - - sampinfo->duh = duh; - sampinfo->n_channels = n_channels; - sampinfo->signal = signal; - sampinfo->playing = NULL; - - /* Seek to 'pos'. */ - while (time < pos) { - pos -= time; - - sequence_command(sampinfo, pos); - - time = sequence_cl(&sampinfo->signal); - - if (time < 0) { - sampinfo->signal = NULL; - return sampinfo; - } - } - - sampinfo->time_left = time - pos; - sampinfo->sub_time_left = 0; - - return sampinfo; -} - - - -static long sequence_render_samples( - void *sampinfo, - float volume, float delta, - long size, sample_t **samples -) -{ - -#define sampinfo ((SEQUENCE_SAMPINFO *)sampinfo) - - long pos = 0; - - int dt = (int)(delta * 65536.0f + 0.5f); - - long todo; - LONG_LONG t; - - while (sampinfo->signal) { - todo = (long)((((LONG_LONG)sampinfo->time_left << 16) | sampinfo->sub_time_left) / dt); - - if (todo >= size) - break; - - if (todo) { - render(sampinfo, volume, delta, pos, todo, samples); - - pos += todo; - size -= todo; - - todo = (long)((((LONG_LONG)sampinfo->time_left << 16) | sampinfo->sub_time_left) / dt); - t = sampinfo->sub_time_left - (LONG_LONG)todo * dt; - sampinfo->sub_time_left = (long)t & 65535; - sampinfo->time_left += (long)(t >> 16); - } - - sequence_command(sampinfo, 0); - - todo = sequence_cl(&sampinfo->signal); - - if (todo >= 0) - sampinfo->time_left += todo; - else - sampinfo->signal = NULL; - } - - if (sampinfo->signal) { - render(sampinfo, volume, delta, pos, size, samples); - - pos += size; - - t = sampinfo->sub_time_left - (LONG_LONG)size * dt; - sampinfo->sub_time_left = (long)t & 65535; - sampinfo->time_left += (long)(t >> 16); - } else - pos += render(sampinfo, volume, delta, pos, size, samples); - - return pos; - - -/** WARNING - remove this... */ -#if 0 - float size_unified = size * delta; - - int n; - - sample_t **samples2 = malloc(sampinfo->n_channels * sizeof(*samples2)); - memcpy(samples2, samples, sampinfo->n_channels * sizeof(*samples2)); - - while (sampinfo->signal && sampinfo->time < size_unified) { - - { - long sz = (long)(sampinfo->time / delta); - - if (sz) - render(sampinfo, volume, delta, sz, samples2); - - for (n = 0; n < sampinfo->n_channels; n++) - samples2[n] += sz; - - size -= sz; - pos += sz; - - sampinfo->time -= sz * delta; - } - - sequence_command(sampinfo, 0); - - { - long time = sequence_cl(&sampinfo->signal); - - if (time >= 0) - sampinfo->time += (float)time; - else - sampinfo->signal = NULL; - } - - size_unified = size * delta; - } - - if (sampinfo->signal) { - render(sampinfo, volume, delta, size, samples2); - sampinfo->time -= size_unified; - pos += size; - } else - pos += render(sampinfo, volume, delta, size, samples2); - - free(samples2); - - return pos; -#endif - -#undef sampinfo - -} - - - -static void sequence_end_samples(void *sampinfo) -{ - SEQUENCE_PLAYING *playing = ((SEQUENCE_SAMPINFO *)sampinfo)->playing; - - while (playing) { - SEQUENCE_PLAYING *next = playing->next; - - duh_signal_end_samples(playing->sampinfo); - free(playing); - - playing = next; - } - - free(sampinfo); -} - - - -static void sequence_unload_signal(void *signal) -{ - free(signal); -} - - - -static DUH_SIGTYPE_DESC sigtype_sequence = { - SIGTYPE_SEQUENCE, - &sequence_load_signal, - &sequence_start_samples, - NULL, - &sequence_render_samples, - &sequence_end_samples, - &sequence_unload_signal -}; - - - -void dumb_register_sigtype_sequence(void) -{ - dumb_register_sigtype(&sigtype_sequence); -} diff --git a/dumb/src/sigtypes/sterpan.c b/dumb/src/sigtypes/sterpan.c deleted file mode 100644 index 22fe5d28e4..0000000000 --- a/dumb/src/sigtypes/sterpan.c +++ /dev/null @@ -1,206 +0,0 @@ -/* _______ ____ __ ___ ___ - * \ _ \ \ / \ / \ \ / / ' ' ' - * | | \ \ | | || | \/ | . . - * | | | | | | || ||\ /| | - * | | | | | | || || \/ | | ' ' ' - * | | | | | | || || | | . . - * | |_/ / \ \__// || | | - * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque - * / \ - * / . \ - * sterpan.c - The stereo pan (SPAN) signal type. / / \ \ - * | < / \_ - * By entheh. | \/ /\ / - * \_ / > / - * This takes a single monaural signal and | \ / / - * expands it to two channels, applying a | ' / - * stereo pan in the process. The stereo pan \__/ - * is generated by delaying and damping the - * channel opposite the sound source. If only - * one channel is requested of this signal, it will simply chain to the other - * signal. - * - * In order for the delay to work properly, this must be played at 65536 Hz. - * The pitch at which you want the sample to play can be passed in parameter - * #1. Parameter #0 specifies the panning position, -256 to 256. - * - * NOTE: THIS IS NOT HOW IT WORKS AT THE MOMENT. AT THE MOMENT, THIS ROUTINE - * SIMPLY VARIES THE VOLUMES. - */ - -#include - -#include "dumb.h" - - - -#define SIGTYPE_STEREOPAN DUMB_ID('S','P','A','N') - - - -#define SPANPARAM_PAN 0 - - - -typedef struct STEREOPAN_SIGNAL -{ - int sig; -} -STEREOPAN_SIGNAL; - - - -typedef struct STEREOPAN_SAMPINFO -{ - float pan; - int stereo; - DUH_SIGNAL_SAMPINFO *csampinfo; -} -STEREOPAN_SAMPINFO; - - - -static void *stereopan_load_signal(DUH *duh, DUMBFILE *file) -{ - STEREOPAN_SIGNAL *signal; - - (void)duh; - - signal = malloc(sizeof(*signal)); - - if (!signal) - return NULL; - - signal->sig = dumbfile_igetl(file); - - if (dumbfile_error(file)) { - free(signal); - return NULL; - } - - return signal; -} - - - -static void *stereopan_start_samples(DUH *duh, void *signal, int n_channels, long pos) -{ - STEREOPAN_SAMPINFO *sampinfo; - -#define signal ((STEREOPAN_SIGNAL *)signal) - - if ((unsigned int)(n_channels - 1) >= 2) { - TRACE("Stereo pan signal requiring 1 or 2 channels called with %d channels.\n", n_channels); - return NULL; - } - - sampinfo = malloc(sizeof(*sampinfo)); - if (!sampinfo) - return NULL; - - sampinfo->pan = 0; - - sampinfo->stereo = n_channels - 1; - - sampinfo->csampinfo = duh_signal_start_samples(duh, signal->sig, 1, pos); - if (!sampinfo->csampinfo) { - free(sampinfo); - return NULL; - } - -#undef signal - - return sampinfo; -} - - - -static void stereopan_set_parameter(void *sampinfo, unsigned char id, long value) -{ -#define sampinfo ((STEREOPAN_SAMPINFO *)sampinfo) - - if (id == SPANPARAM_PAN && value >= -256 && value <= 256) - sampinfo->pan = value * (1.0f / 256.0f); - -#undef sampinfo -} - - - -static long stereopan_render_samples( - void *sampinfo, - float volume, float delta, - long size, sample_t **samples -) -{ -#define sampinfo ((STEREOPAN_SAMPINFO *)sampinfo) - - if (!sampinfo->stereo) - return duh_signal_render_samples(sampinfo->csampinfo, volume, delta, size, samples); - - if (sampinfo->pan >= 0) { - long sz = duh_signal_render_samples(sampinfo->csampinfo, volume * (1.0f + sampinfo->pan), delta, size, samples + 1); - long s; - int vol; - - volume = (1.0f - sampinfo->pan) / (1.0f + sampinfo->pan); - vol = (int)(volume * 65536 + 0.5); - - for (s = 0; s < sz; s++) - samples[0][s] = (samples[1][s] * vol) >> 16; - - return sz; - } else { - long sz = duh_signal_render_samples(sampinfo->csampinfo, volume * (1.0f - sampinfo->pan), delta, size, samples); - long s; - int vol; - - volume = (1.0f + sampinfo->pan) / (1.0f - sampinfo->pan); - vol = (int)(volume * 65536 + 0.5); - - for (s = 0; s < sz; s++) - samples[1][s] = (samples[0][s] * vol) >> 16; - - return sz; - } - -#undef sampinfo -} - - - -static void stereopan_end_samples(void *sampinfo) -{ -#define sampinfo ((STEREOPAN_SAMPINFO *)sampinfo) - - duh_signal_end_samples(sampinfo->csampinfo); - free(sampinfo); - -#undef sampinfo -} - - - -static void stereopan_unload_signal(void *signal) -{ - free(signal); -} - - - -static DUH_SIGTYPE_DESC sigtype_stereopan = { - SIGTYPE_STEREOPAN, - &stereopan_load_signal, - &stereopan_start_samples, - &stereopan_set_parameter, - &stereopan_render_samples, - &stereopan_end_samples, - &stereopan_unload_signal -}; - - - -void dumb_register_sigtype_stereopan(void) -{ - dumb_register_sigtype(&sigtype_stereopan); -} diff --git a/dumb/src/tools/it/load_it.cpp b/dumb/src/tools/it/load_it.cpp deleted file mode 100644 index ed88e70648..0000000000 --- a/dumb/src/tools/it/load_it.cpp +++ /dev/null @@ -1,824 +0,0 @@ -#ifdef FORTIFY -#include "fortify.h" -#endif -#include -#ifdef MSS -#include "mss.h" -#endif - -#include - -#include "allegro.h" -#include "modulus.h" -#include "typedef.hpp" - -int detect_it(char *f) { - int sig; - PACKFILE *fn = pack_fopen(f, "rb"); - - if (fn == NULL) - return FALSE; - - sig = pack_mgetl(fn); - if (sig != AL_ID('I','M','P','M')) { - pack_fclose(fn); - return FALSE; - } - pack_fclose(fn); - - return TRUE; -} - -MODULUS *create_it() { - MODULUS *m = (MODULUS*)malloc(sizeof(MODULUS)); - if (!m) - return NULL; - memset(m, 0, sizeof(MODULUS)); - return m; -} - -void destroy_it(MODULUS *j) { - - if (song->Music == j) - stop_it(); - - //remove patterns: - for (int i=0; iNumPatterns; i++) { - free(j->Pattern[i].Note); - } - if (j->Pattern) - free(j->Pattern); - //remove instruments; - if (j->Instrument) - free(j->Instrument); - //remove samples; - for (int i=0; iNumSamples; i++) { - destroy_sample(j->Sample[i].Sample); - } - if (j->Sample) - free(j->Sample); - //remove orders: - if (j->Order) - free(j->Order); - //remove channels: - for (int i=0; i<64; i++) { - if (j->Channel[i].VChannel) { - MODULUS_VCHANNEL *vchn = song->Music->Channel[i].VChannel; - MODULUS_VCHANNEL *prev = NULL; - - if (!vchn) - continue; - - for (;;) { - deallocate_voice(vchn->voice); - - prev = vchn; - vchn = vchn->next; - free(prev); - - if (!vchn) - break; - } - } - } - free(j); -} - -//#define DEBUG_IT_SIZE - -int get_module_size(MODULUS *j) { - int a, b, c, d = 0, e; - a = sizeof(MODULUS) + j->NumOrders; - b = j->NumInstruments * sizeof(MODULUS_INSTRUMENT); - c = j->NumSamples * sizeof(MODULUS_SAMPLE); - - for (int i=0; iNumSamples; i++) - d += j->Sample[i].SampleLength * (j->Sample[i].Flag & 2 ? sizeof(short) : 1) * (j->Sample[i].Flag & 4 ? 2: 1); - - e = 4 + sizeof(MODULUS_PATTERN) * j->NumPatterns; - - for (int i=0; iNumPatterns; i++) - e += j->Pattern[i].NumNotes * sizeof(MODULUS_NOTE); - #ifdef DEBUG_IT_SIZE - printf("Base: %i, Instruments(%i): %i, Samples(%i): %i, Data: %i, Patterns(%i): %i\n", a, j->NumInstruments, b, j->NumSamples, c, d, j->NumPatterns, e); - #endif - - return a+b+c+d+e; -} - -#define MAX_IT_CHN 64 - -//#define DEBUG_HEADER -//#define DEBUG_INSTRUMENTS -//#define DEBUG_SAMPLES -//#define DEBUG_PATTERNS - -static dword *sourcebuf = NULL; -static dword *sourcepos = NULL; -static byte rembits = 0; - -int readblock(PACKFILE *f) { - long size; - int c = pack_igetw(f); - if (c == -1) - return 0; - size = c; - - sourcebuf = (dword*)malloc(size+4); - if (!sourcebuf) - return 0; - - c = pack_fread(sourcebuf, size, f); - if (c < 1) { - free(sourcebuf); - sourcebuf = NULL; - return 0; - } - sourcepos = sourcebuf; - rembits = 32; - return 1; -} - -void freeblock() { - if (sourcebuf) - free(sourcebuf); - sourcebuf = NULL; -} - -dword readbits(char b) { - dword val; - if (b <= rembits) { - val = *sourcepos & ((1 << b) - 1); - *sourcepos >>= b; - rembits -= b; - } - else { - dword nbits = b - rembits; - val = *sourcepos; - sourcepos++; - val |= ((*sourcepos & ((1 << nbits) - 1)) << rembits); - *sourcepos >>= nbits; - rembits = 32 - nbits; - } - return val; -} - -void decompress8(PACKFILE *f, void *data, int len, int tver) { - char *destbuf = (char*)data; - char *destpos = destbuf; - int blocklen, blockpos; - byte bitwidth; - word val; - char d1, d2; - - memset(destbuf, 0, len); - - while (len>0) { - //Read a block of compressed data: - if (!readblock(f)) - return; - //Set up a few variables - blocklen = (len < 0x8000) ? len : 0x8000; //Max block length is 0x8000 bytes - blockpos = 0; - bitwidth = 9; - d1 = d2 = 0; - //Start the decompression: - while (blockpos < blocklen) { - //Read a value: - val = readbits(bitwidth); - //Check for bit width change: - - if (bitwidth < 7) { //Method 1: - if (val == (1 << (bitwidth - 1))) { - val = readbits(3) + 1; - bitwidth = (val < bitwidth) ? val : val + 1; - continue; - } - } - else if (bitwidth < 9) { //Method 2 - byte border = (0xFF >> (9 - bitwidth)) - 4; - - if (val > border && val <= (border + 8)) { - val -= border; - bitwidth = (val < bitwidth) ? val : val + 1; - continue; - } - } - else if (bitwidth == 9) { //Method 3 - if (val & 0x100) { - bitwidth = (val + 1) & 0xFF; - continue; - } - } - else { //Illegal width, abort ? - freeblock(); - return; - } - - //Expand the value to signed byte: - char v; //The sample value: - if (bitwidth < 8) { - byte shift = 8 - bitwidth; - v = (val << shift); - v >>= shift; - } - else - v = (char)val; - - //And integrate the sample value - //(It always has to end with integration doesn't it ? ;-) - d1 += v; - d2 += d1; - - //Store ! - *destpos = ((tver == 0x215) ? d2 : d1); - destpos++; - blockpos++; - } - freeblock(); - len -= blocklen; - } - return; -} - -void decompress16(PACKFILE *f, void *data, int len, int tver) { - //make the output buffer: - short *destbuf = (short*)data; - short *destpos = destbuf; - int blocklen, blockpos; - byte bitwidth; - long val; - short d1, d2; - - memset(destbuf, 0, len); - - while (len>0) { - //Read a block of compressed data: - if (!readblock(f)) - return; - //Set up a few variables - blocklen = (len < 0x4000) ? len : 0x4000; // Max block length is 0x4000 bytes - blockpos = 0; - bitwidth = 17; - d1 = d2 = 0; - //Start the decompression: - while (blockpos < blocklen) { - val = readbits(bitwidth); - //Check for bit width change: - - if (bitwidth < 7) { //Method 1: - if (val == (1 << (bitwidth - 1))) { - val = readbits(4) + 1; - bitwidth = (val < bitwidth) ? val : val + 1; - continue; - } - } - else if (bitwidth < 17) { //Method 2 - word border = (0xFFFF >> (17 - bitwidth)) - 8; - - if (val > border && val <= (border + 16)) { - val -= border; - bitwidth = val < bitwidth ? val : val + 1; - continue; - } - } - else if (bitwidth == 17) { //Method 3 - if (val & 0x10000) { - bitwidth = (val + 1) & 0xFF; - continue; - } - } - else { //Illegal width, abort ? - freeblock(); - return; - } - - //Expand the value to signed byte: - short v; //The sample value: - if (bitwidth < 16) { - byte shift = 16 - bitwidth; - v = (val << shift); - v >>= shift; - } - else - v = (short)val; - - //And integrate the sample value - //(It always has to end with integration doesn't it ? ;-) - d1 += v; - d2 += d1; - - //Store ! - *destpos = ((tver == 0x215) ? d2 : d1); - destpos++; - blockpos++; - } - freeblock(); - len -= blocklen; - } - return; -} - -MODULUS *load_it(char *file) { - PACKFILE *f; - MODULUS *j = create_it(); - int tver, tver2, flag, msglen, msgoffs; - int *insoffs = NULL, *samoffs = NULL, *patoffs = NULL; - - if (!j) - return NULL; - - if (!detect_it(file)) - return NULL; - - f = pack_fopen(file, "rb"); - - if (!f) { - #ifdef DEBUG_HEADER - printf("Error Opening!\n"); - #endif - return NULL; - } - - pack_fseek(f, 30); - pack_igetw(f); //I have no idea... - - j->NumOrders = pack_igetw(f); - j->NumInstruments = pack_igetw(f); - j->NumSamples = pack_igetw(f); - j->NumPatterns = pack_igetw(f); - - #ifdef DEBUG_HEADER - printf("Loading IT: %i Orders %i Instruments, %i Samples, %i Patterns\n", j->NumOrders, j->NumInstruments, j->NumSamples, j->NumPatterns); - #endif - - tver = pack_igetw(f); - j->Version = tver2 = pack_igetw(f); - - #ifdef DEBUG_HEADER - printf("Tracker ver: %X, %X\n", tver, tver2); - #endif - - j->Flags = pack_igetw(f); - flag = pack_igetw(f); - - j->GlobalVolume = pack_getc(f); - j->MixVolume = pack_getc(f); - j->Speed = pack_getc(f); - j->Tempo = pack_getc(f); - j->PanningSeperation = pack_getc(f); - - #ifdef DEBUG_HEADER - printf("Global Volume: %i, Mixing Volume: %i, Speed: %i, Tempo: %i, PanSep: %i\n", j->GlobalVolume, j->MixVolume, j->Speed, j->Tempo, j->PanningSeperation); - #endif - - pack_getc(f); //Damn....I need more info on this. - - msglen = pack_igetw(f); - msgoffs = pack_igetl(f); - - pack_fseek(f, 4); - - #ifdef DEBUG_HEADER - printf("Channel Pan:"); - #endif - - for (int i=0; iChannel[i].Pan = pack_getc(f); - #ifdef DEBUG_HEADER - printf(" %i", j->Channel[i].Pan); - #endif - } - #ifdef DEBUG_HEADER - printf("\nChannel Vol:"); - #endif - for (int i=0; iChannel[i].Volume = pack_getc(f); - #ifdef DEBUG_HEADER - printf(" %i", j->Channel[i].Volume); - #endif - } - #ifdef DEBUG_HEADER - printf("\n"); - #endif - - j->Order = (unsigned char *)malloc(j->NumOrders); - pack_fread(j->Order, j->NumOrders, f); - - if (j->NumInstruments) - insoffs = (int*)malloc(4 * j->NumInstruments); - if (j->NumSamples) - samoffs = (int*)malloc(4 * j->NumSamples); - if (j->NumPatterns) - patoffs = (int*)malloc(4 * j->NumPatterns); - - pack_fread(insoffs, 4 * j->NumInstruments, f); - pack_fread(samoffs, 4 * j->NumSamples, f); - pack_fread(patoffs, 4 * j->NumPatterns, f); - - if (flag&1) { //Song message attached - //Ignore. - } - if (flag & 4) { //skip something: - short u; - char dummy[8]; - u = pack_igetw(f); - for (int i=0; iNumInstruments) - j->Instrument = (MODULUS_INSTRUMENT*)malloc(sizeof(MODULUS_INSTRUMENT) * j->NumInstruments); - #ifdef DEBUG_INSTRUMENTS - if (!j->Instrument) - printf("No Mem for Instruments!\n"); - #endif - - - for (int i=0; iNumInstruments; i++) { - pack_fclose(f); - f = pack_fopen(file, "rb"); - #ifdef DEBUG_INSTRUMENTS - if (!f) - printf("Error Opening!\n"); - #endif - pack_fseek(f, insoffs[i] + 17); - - j->Instrument[i].NewNoteAction = pack_getc(f); - j->Instrument[i].DuplicateCheckType = pack_getc(f); - j->Instrument[i].DuplicateCheckAction = pack_getc(f); - j->Instrument[i].FadeOut = pack_igetw(f); - j->Instrument[i].PitchPanSeperation = pack_getc(f); - j->Instrument[i].PitchPanCenter = pack_getc(f); - j->Instrument[i].GlobalVolume = pack_getc(f); - j->Instrument[i].DefaultPan = pack_getc(f); - #ifdef DEBUG_INSTRUMENTS - printf("I%02i @ 0x%X, NNA %i, DCT %i, DCA %i, FO %i, PPS %i, PPC %i, GVol %i, DPan %i\n", i, insoffs[i], j->Instrument[i].NewNoteAction, j->Instrument[i].DuplicateCheckType, j->Instrument[i].DuplicateCheckAction, j->Instrument[i].FadeOut, j->Instrument[i].PitchPanSeperation, j->Instrument[i].PitchPanCenter, j->Instrument[i].GlobalVolume, j->Instrument[i].DefaultPan); - #endif - - pack_fseek(f, 38); - - for (int k=0; k<120; k++) { - j->Instrument[i].NoteNote[k] = pack_getc(f); - j->Instrument[i].NoteSample[k] = pack_getc(f) - 1; - } - - j->Instrument[i].VolumeEnvelope.Flag = pack_getc(f); - j->Instrument[i].VolumeEnvelope.NumNodes = pack_getc(f); - j->Instrument[i].VolumeEnvelope.LoopBegin = pack_getc(f); - j->Instrument[i].VolumeEnvelope.LoopEnd = pack_getc(f); - j->Instrument[i].VolumeEnvelope.SustainLoopBegin = pack_getc(f); - j->Instrument[i].VolumeEnvelope.SustainLoopEnd = pack_getc(f); - for (int k=0; kInstrument[i].VolumeEnvelope.NumNodes; k++) { - j->Instrument[i].VolumeEnvelope.NodeY[k] = pack_getc(f); - j->Instrument[i].VolumeEnvelope.NodeTick[k] = pack_igetw(f); - } - pack_fseek(f, 75 - j->Instrument[i].VolumeEnvelope.NumNodes * 3); - - j->Instrument[i].PanningEnvelope.Flag = pack_getc(f); - j->Instrument[i].PanningEnvelope.NumNodes = pack_getc(f); - j->Instrument[i].PanningEnvelope.LoopBegin = pack_getc(f); - j->Instrument[i].PanningEnvelope.LoopEnd = pack_getc(f); - j->Instrument[i].PanningEnvelope.SustainLoopBegin = pack_getc(f); - j->Instrument[i].PanningEnvelope.SustainLoopEnd = pack_getc(f); - for (int k=0; kInstrument[i].PanningEnvelope.NumNodes; k++) { - j->Instrument[i].PanningEnvelope.NodeY[k] = pack_getc(f); - j->Instrument[i].PanningEnvelope.NodeTick[k] = pack_igetw(f); - } - pack_fseek(f, 75 - j->Instrument[i].PanningEnvelope.NumNodes * 3); - - j->Instrument[i].PitchEnvelope.Flag = pack_getc(f); - j->Instrument[i].PitchEnvelope.NumNodes = pack_getc(f); - j->Instrument[i].PitchEnvelope.LoopBegin = pack_getc(f); - j->Instrument[i].PitchEnvelope.LoopEnd = pack_getc(f); - j->Instrument[i].PitchEnvelope.SustainLoopBegin = pack_getc(f); - j->Instrument[i].PitchEnvelope.SustainLoopEnd = pack_getc(f); - for (int k=0; kInstrument[i].PitchEnvelope.NumNodes; k++) { - j->Instrument[i].PitchEnvelope.NodeY[k] = pack_getc(f); - j->Instrument[i].PitchEnvelope.NodeTick[k] = pack_igetw(f); - } - } - - if (j->NumSamples) - j->Sample = (MODULUS_SAMPLE*)malloc(sizeof(MODULUS_SAMPLE) * j->NumSamples); - - #ifdef DEBUG_SAMPLES - if (!j->Sample) - printf("No Mem for Samples!\n"); - #endif - - for (int i=0; iNumSamples; i++) { - int sam_samptr, convert; - - pack_fclose(f); - f = pack_fopen(file, "rb"); - #ifdef DEBUG_SAMPLES - if (!f) - printf("Error opening!\n"); - #endif - - pack_fseek(f, samoffs[i] + 17); - - j->Sample[i].GlobalVolume = pack_getc(f); - j->Sample[i].Flag = pack_getc(f); - j->Sample[i].Volume = pack_getc(f); - - #ifdef DEBUG_SAMPLES - printf("S%02i @ 0x%X, Vol: %i/%i, Flag: %i", i, samoffs[i], j->Sample[i].GlobalVolume, j->Sample[i].Volume, j->Sample[i].Flag); - #endif - - pack_fseek(f, 26); - - convert = pack_getc(f); - pack_getc(f); //Panning ? - - j->Sample[i].SampleLength = pack_igetl(f); - j->Sample[i].LoopBegin = pack_igetl(f); - j->Sample[i].LoopEnd = pack_igetl(f); - j->Sample[i].C5Speed = pack_igetl(f); - j->Sample[i].SustainLoopBegin = pack_igetl(f); - j->Sample[i].SustainLoopEnd = pack_igetl(f); - - #ifdef DEBUG_SAMPLES - printf(", SLen: %i, LpB: %i, LpE: %i, C5S: %i\n", j->Sample[i].SampleLength, j->Sample[i].LoopBegin, j->Sample[i].LoopEnd, j->Sample[i].C5Speed); - #endif - - sam_samptr = pack_igetl(f); - - j->Sample[i].VibratoSpeed = pack_getc(f); - j->Sample[i].VibratoDepth = pack_getc(f); - j->Sample[i].VibratoRate = pack_getc(f); - j->Sample[i].VibratoWaveForm = pack_getc(f); - - #ifdef DEBUG_SAMPLES - printf("SusLpB: %i, SusLpE: %i, VibSp: %i, VibDep: %i, VibWav: %i, VibRat: %i\n", j->Sample[i].SustainLoopBegin, j->Sample[i].SustainLoopEnd, j->Sample[i].VibratoSpeed, j->Sample[i].VibratoDepth, j->Sample[i].VibratoWaveForm, j->Sample[i].VibratoRate); - #endif - - if (j->Sample[i].Flag & 1 == 0) - continue; - - pack_fclose(f); - f = pack_fopen(file, "rb"); - pack_fseek(f, sam_samptr); - - int len = j->Sample[i].SampleLength * (j->Sample[i].Flag & 2 ? sizeof(short) : 1) * (j->Sample[i].Flag & 4 ? 2: 1); - - #ifdef DEBUG_SAMPLES - printf("Len: %i, Size: %i KB\n", j->Sample[i].SampleLength, len/1024); - #endif - - SAMPLE *sam = create_sample(j->Sample[i].Flag & 2 ? 16 : 8, j->Sample[i].Flag & 4 ? TRUE : FALSE, j->Sample[i].C5Speed, j->Sample[i].SampleLength); - - if (j->Sample[i].Flag & 8) { // If the sample is packed, then we must unpack it - if (j->Sample[i].Flag & 2) - decompress16(f, sam->data, j->Sample[i].SampleLength, tver2); - else - decompress8(f, sam->data, j->Sample[i].SampleLength, tver2); - } else { - pack_fread(sam->data, len, f); - } - - if (j->Sample[i].Flag & SAMPLE_USELOOP) { - sam->loop_start = j->Sample[i].LoopBegin; - sam->loop_end = j->Sample[i].LoopEnd; - } - - j->Sample[i].Sample = sam; - - void *dat = sam->data; - - if (convert & 2) { //Change the byte order for 16-bit samples: - if (sam->bits == 16) { - for (int k=0; kbits == 8) { - for (int k=0; k>1); k++) { - ((short*)dat)[k] ^= 0x8000; - } - } - } - } - - if (j->NumPatterns) - j->Pattern = (MODULUS_PATTERN*)malloc(sizeof(MODULUS_PATTERN) * j->NumPatterns); - unsigned char *buf = (unsigned char*)alloca(65536); - unsigned char *cmask = (unsigned char*)alloca(64), - *cnote = (unsigned char*)alloca(64), - *cinstrument = (unsigned char*)alloca(64), - *cvol = (unsigned char*)alloca(64), - *ccom = (unsigned char*)alloca(64), - *ccomval = (unsigned char*)alloca(64); - - for (int i=0; iNumPatterns; i++) { - int numnotes = 0, len, pos = 0, mask = 0, chn = 0; - - memset(cmask, 0, 64); - memset(cnote, 0, 64); - memset(cinstrument, 0, 64); - memset(cvol, 0, 64); - memset(ccom, 0, 64); - memset(ccomval, 0, 64); - - pack_fclose(f); - f = pack_fopen(file, "rb"); - pack_fseek(f, patoffs[i]); - - len = pack_igetw(f); - j->Pattern[i].NumRows = pack_igetw(f); - - pack_fseek(f, 4); - pack_fread(buf, len, f); - - while (pos < len) { - int b = buf[pos]; - pos++; - if (!b) { //If end of row: - numnotes++; - continue; - } - chn = (b - 1) & 63; - - if (b & 128) { - mask = buf[pos]; - pos++; - cmask[chn] = mask; - } - else - mask = cmask[chn]; - - if (mask) - numnotes++; - if (mask & 1) - pos++; - if (mask & 2) - pos++; - if (mask & 4) - pos++; - if (mask & 8) - pos+=2; //Guessing here - } - j->Pattern[i].NumNotes = numnotes; - j->Pattern[i].Note = (MODULUS_NOTE*)malloc(sizeof(MODULUS_NOTE) * numnotes); - memset(j->Pattern[i].Note, 0, sizeof(MODULUS_NOTE) * numnotes); - - pos = 0; - memset(cmask, 0, 64); - mask = 0; - numnotes = 0; - while (pos < len) { - int b = buf[pos]; - #ifdef DEBUG_PATTERNS - printf("NumNote: %i ", numnotes); - #endif - - pos++; - if (!b) { //If end of row: - j->Pattern[i].Note[numnotes].Channel = -1; - numnotes++; - #ifdef DEBUG_PATTERNS - printf("Channel: -1\n"); - #endif - continue; - } - chn = (b - 1) & 63; - - if (b & 128) { - mask = buf[pos]; - pos++; - cmask[chn] = mask; - } - else - mask = cmask[chn]; - #ifdef DEBUG_PATTERNS - printf("Channel: %i Mask: %i ", chn, mask); - #endif - - if (mask) - j->Pattern[i].Note[numnotes].Channel = chn; - - if (mask & 1) { - j->Pattern[i].Note[numnotes].Note = buf[pos]; - j->Pattern[i].Note[numnotes].Mask |= 1; - cnote[chn] = buf[pos]; - #ifdef DEBUG_PATTERNS - printf("Note: %i ", buf[pos]); - #endif - pos++; - } - if (mask & 2) { - j->Pattern[i].Note[numnotes].Instrument = buf[pos]; - j->Pattern[i].Note[numnotes].Mask |= 2; - cinstrument[chn] = buf[pos]; - #ifdef DEBUG_PATTERNS - printf("Inst: %i ", buf[pos]); - #endif - pos++; - } - if (mask & 4) { - if (buf[pos] <= 64 || (buf[pos] >= 128 && buf[pos] <= 192)) - if (buf[pos] <= 64) { - j->Pattern[i].Note[numnotes].Volume = buf[pos]; - j->Pattern[i].Note[numnotes].Mask |= 4; - } - else { - j->Pattern[i].Note[numnotes].Panning = buf[pos] - 128; - j->Pattern[i].Note[numnotes].Mask |= 8; - } - #ifdef DEBUG_PATTERNS - printf("Vol: %i ", buf[pos]); - #endif - cvol[chn] = buf[pos]; - pos++; - } - if (mask & 8) { - j->Pattern[i].Note[numnotes].Command = buf[pos]; - j->Pattern[i].Note[numnotes].CommandValue = buf[pos+1]; - j->Pattern[i].Note[numnotes].Mask |= 16; - ccom[chn] = buf[pos]; - ccomval[chn] = buf[pos+1]; - #ifdef DEBUG_PATTERNS - printf("Com: %i CommArg: %i ", buf[pos], buf[pos+1]); - #endif - pos+=2; - } - if (mask & 16) { - j->Pattern[i].Note[numnotes].Note = cnote[chn]; - j->Pattern[i].Note[numnotes].Mask |= 1; - #ifdef DEBUG_PATTERNS - printf("LNote: %i ", cnote[chn]); - #endif - } - if (mask & 32) { - j->Pattern[i].Note[numnotes].Instrument = cinstrument[chn]; - j->Pattern[i].Note[numnotes].Mask |= 2; - #ifdef DEBUG_PATTERNS - printf("LInst: %i ", cinstrument[chn]); - #endif - } - if (mask & 64) { - if (cvol[chn] <= 64 || (cvol[chn] >= 128 && cvol[chn] <= 192)) - if (cvol[chn] <= 64) { - j->Pattern[i].Note[numnotes].Volume = cvol[chn]; - j->Pattern[i].Note[numnotes].Mask |= 4; - } - else { - j->Pattern[i].Note[numnotes].Panning = cvol[chn] - 128; - j->Pattern[i].Note[numnotes].Mask |= 8; - } - #ifdef DEBUG_PATTERNS - printf("LVol: %i ", cvol[chn]); - #endif - } - if (mask & 128) { - j->Pattern[i].Note[numnotes].Command = ccom[chn]; - j->Pattern[i].Note[numnotes].CommandValue = ccomval[chn]; - j->Pattern[i].Note[numnotes].Mask |= 16; - #ifdef DEBUG_PATTERNS - printf("LCom: %i LComArg: %i ", ccom[chn], ccomval[chn]); - #endif - } - #ifdef DEBUG_PATTERNS - printf("\n"); - #endif - if (mask) - numnotes++; - #ifdef DEBUG_PATTERNS - rest(1000); - #endif - } - } - if (insoffs) - free(insoffs); - if (samoffs) - free(samoffs); - if (patoffs) - free(patoffs); - - return j; -} diff --git a/dumb/src/tools/it/modulus.h b/dumb/src/tools/it/modulus.h deleted file mode 100644 index b17d6ff6d2..0000000000 --- a/dumb/src/tools/it/modulus.h +++ /dev/null @@ -1,193 +0,0 @@ - -#define MUSIC_IT AL_ID('I','M','P','M') - -typedef struct MODULUS_MUSIC_INFO { - char Name[29]; - int Type; -} MODULUS_MUSIC_INFO; - -#define ENVELOPE_ON 1 -#define ENVELOPE_LOOP_ON 2 -#define ENVELOPE_SUSTAINLOOP 4 - -typedef struct MODULUS_ENVELOPE { - unsigned char Flag, - NumNodes, - LoopBegin, LoopEnd, SustainLoopBegin, SustainLoopEnd; //in nodes. - char NodeY[25]; - short NodeTick[25]; -} MODULUS_ENVELOPE; - -typedef struct MODULUS_VENVELOPE { - char CurNode; - unsigned char CurTick; - char End; - //float CVolume; - MODULUS_ENVELOPE *Envelope; -} MODULUS_VENVELOPE; - -#define NNA_NOTECUT 1 -#define NNA_NOTECONTINUE 2 -#define NNA_NOTEOFF 3 -#define NNA_NOTEFADE 4 - -#define DCT_OFF 0 -#define DCT_NOTE 1 -#define DCT_SAMPLE 2 -#define DCT_INSTRUMENT 3 - -#define DCA_CUT 0 -#define DCA_NOTEOFF 1 -#define DCA_NOTEFADE 2 - -typedef struct MOULUS_INSTRUMENT { - unsigned char Flag; - char VolumeLoopNodeStart, VolumeLoopNodeEnd; - char SustainLoopNodeStart, SustainLoopNodeEnd; - char DuplicateCheckType; - char DuplicateCheckAction; - char NewNoteAction; - int FadeOut; - - unsigned char PitchPanSeperation, //0->64, Bit7: Don't use - PitchPanCenter; //Note, from C-0 to B-9 - unsigned char GlobalVolume, //0->128 - DefaultPan; //0->64, Bit7: Don't use - - - unsigned char NoteSample[120]; - unsigned char NoteNote[120]; - - MODULUS_ENVELOPE VolumeEnvelope, PanningEnvelope, PitchEnvelope; -} MODULUS_INSTRUMENT; - -#define SAMPLE_HASSAMPLE 1 -#define SAMPLE_16BIT 2 -#define SAMPLE_STEREO 4 -#define SAMPLE_USELOOP 16 -#define SAMPLE_USESUSTAINLOOP 32 -#define SAMPLE_PINGPONGLOOP 64 -#define SAMPLE_PINGPONGSUSTAINLOOP 128 - -#define VIBRATO_SINE 0 -#define VIBRATO_RAMPDOWN 1 -#define VIBRATO_SQUARE 2 -#define VIBRATO_RANDOM 3 - -typedef struct MODULUS_SAMPLE { - unsigned char GlobalVolume; //0->64 - unsigned char Flag; - unsigned char Volume; - int SampleLength; //in samples, not bytes ! - int LoopBegin, LoopEnd; //in samples - int SustainLoopBegin, SustainLoopEnd; - int C5Speed; //Number of bytes/sec for C-5 - - SAMPLE *Sample; - - char VibratoSpeed; //0->64 - char VibratoDepth; //0->64 - char VibratoWaveForm; - char VibratoRate; //0->64 -} MODULUS_SAMPLE; - -typedef struct MODULUS_NOTE { - char Mask; //If Bit0: Note, Bit1: Instrument, Bit2: Volume, Bit3: Panning, Bit4: Command - char Channel; //if -1, then end of row. - unsigned char Note; - char Instrument; - unsigned char Volume, Panning; - unsigned char Command, CommandValue; -} MODULUS_NOTE; - -typedef struct MODULUS_PATTERN { - int NumRows; - int NumNotes; - MODULUS_NOTE *Note; -} MODULUS_PATTERN; - -typedef struct MODULUS_VCHANNEL { - MODULUS_SAMPLE *Sample; //NULL is unused - char voice; - char ChannelVolume; - char NoteOn; - char NNA; - short FadeOutCount, FadeOut; - float MixVolume, MixPan; - MODULUS_VENVELOPE *VVolumeEnvelope, *VPanningEnvelope, *VPitchEnvelope; - MODULUS_VCHANNEL *next, *prev; -} MODULUS_VCHANNEL; - -typedef struct MODULUS_CHANNEL { - unsigned char Volume; //0->64 - unsigned char Pan; //0->32->64, 100 = surround, Bit7: Disable - char LastNote, LastInstrument, LastSample; - MODULUS_VCHANNEL *VChannel; -} MODULUS_CHANNEL; - -#define FLAG_STEREO 1 -#define FLAG_USEINSTRUMENTS 4 -#define FLAG_LINEARSLIDES 8 -#define FLAG_OLDEFFECT 16 - -typedef struct MODULUS { - MODULUS_INSTRUMENT *Instrument; - MODULUS_SAMPLE *Sample; - MODULUS_PATTERN *Pattern; - - int NumOrders; - int NumInstruments; - int NumSamples; - int NumPatterns; - int Flags; - short Version; - char GlobalVolume; - char MixVolume; - unsigned char Speed, Tempo; - char PanningSeperation; - - unsigned char *Order; - - MODULUS_CHANNEL Channel[64]; - -} MODULUS; - -#define COMMAND_SET_SONG_SPEED 1 -#define COMMAND_JUMP_TO_ORDER 2 -#define COMMAND_PATTERN_BREAK_TO_ROW 3 -#define COMMAND_SET_CHANNEL_VOLUME 13 -#define COMMAND_SET_SONG_TEMPO 20 -#define COMMAND_SET_GLOBAL_VOLUME 22 - -typedef struct MODULUS_PLAY { - MODULUS *Music; - int Loop, Tick; - int CurOrder, CurPattern, CurPos; - int Command, CommandVal0, CommandVal1, CommandVal2; - int pos; -} MODULUS_PLAY; -extern MODULUS_PLAY *song; - -extern int IT_Play_Method; - -MODULUS *load_it(char*); -int get_module_size(MODULUS *); - -int play_it(MODULUS *j, int loop); -void install_modulus(); -void set_mix_volume(int i); - -void stop_it(); -int is_music_done(); -void destroy_it(MODULUS *j); - -//Should be internal: -extern MODULUS_PLAY *song; -extern int note_freq[120]; - -extern void MOD_Interrupt(...); -extern int MOD_Poller(void*); - -#define IT_TIMER 0 -#define IT_POLL 1 - diff --git a/dumb/src/tools/it/typedef.hpp b/dumb/src/tools/it/typedef.hpp deleted file mode 100644 index 6d4eefeef0..0000000000 --- a/dumb/src/tools/it/typedef.hpp +++ /dev/null @@ -1,3 +0,0 @@ -typedef unsigned char byte; -typedef unsigned short word; -typedef unsigned int dword; diff --git a/dumb/todo.txt b/dumb/todo.txt deleted file mode 100644 index d624a8d47a..0000000000 --- a/dumb/todo.txt +++ /dev/null @@ -1,141 +0,0 @@ -al_duh_get_volume() - -* [23:25:12] I prefer an API datagram :) - -* Create a glossary of terms like 'render', 'sigrenderer', etc.? - -* Consider the order in which stuff appears in dumb.h, and dumb.txt? - - -PROPOSED CHANGE OF TERMINOLOGY: - -Current situation: - - A DUH comprises a number of "signals". A signal is an entity capable of - producing a stream of audio. When a signal is called upon to generate - sound, it may in turn call upon any other signals in the DUH and use the - sound from those in generating its own. - - There are a number of "sigtypes", including 'SAMP' (a sample) and 'SEQU' - (a sequence). Every signal in a DUH must be of one of these known types. - Every sigtype is characterised by a four-byte identifier and the - following function prototypes: - - typedef void signal_t; - typedef void sampinfo_t; - - signal_t *load_signal(DUH *duh, DUMBFILE *file); - sampinfo_t *start_samples(DUH *duh, signal_t *signal, int n_channels, long pos); - void set_parameter(sampinfo_t *sampinfo, unsigned char id, long value); - long render_samples(sampinfo_t *sampinfo, float volume, float delta, long size, sample_t **samples); - void end_samples(sampinfo_t *sampinfo); - void unload_signal(signal_t *signal); - - When a signal in a DUH needs to be loaded, DUMB's core first checks the - identifier. If it is unknown, load_duh() fails. Each known sigtype will - have pointers to the above functions, so DUMB's core will then call the - load_signal() function. This loads the "signal", which could consist of - sample data, or sequence data (like the patterns in a music module). - (There's ambiguity here; we use the word "signal" for the whole entity - and also for the specific data that distinguish it from other signals of - the same sigtype.) - - Once a signal is in memory, it can be used to generate sound. Its - start_samples() function is called for that, and a "sampinfo" block is - returned; this will contain the current position and any necessary state - information. render_samples() generates sound, and end_samples() destroys - the sampinfo block. - - DUMB's support for existing file formats is implemented as follows. First - a signal_t is constructed manually by reading the file. Then the special - make_duh() function is called. This creates a DUH struct with just one - signal in it, the one we just created. We provide all the above - functions, except load_signal(), since that has been bypassed. DUMB's - core now has our start_samples() etc. function for generating the sound, - and it has our unload_signal() function for getting the file out of - memory when we're done. - - It is possible with some sigtypes to adjust their sound using - "parameters". set_parameter() is called for this. An example would be - changing the cut-off frequency for a signal that acts as a filter. I plan - to add a second version of this function that takes a pointer. This would - be used when manipulating DUHs in code; an example is when installing a - callback function for a music module file. It couldn't be used by a file - on disk. - -This terminology is far from intuitive. Here are some proposals: - -- The things DUHs are made of can still be called "signals". -- The types of signal can still be called "sigtypes" ("signal types"). -- The signal-specific data can be called the "sigdata" ("signal data"). -- The sampinfo block can be renamed to a "sigrenderer" ("signal renderer"). -- The parameters can be called "sigparams" ("signal parameters"). - -This way we have some consistency between different parts of the library; -the API for rendering a DUH as a whole uses the term "renderer". We also -have a full name and an abbreviation for each term. - -Any advances on this? - ---- - -Todo/Wishlist: - -* MOD/XM loading - change the effect memory system; it isn't robust when it - comes to remembering stuff from one pattern to the next. -* --- IMPORTANT --- Put link to IT in docs: http://www.noisemusic.org/it/ -* --- IMPORTANT --- Twist the sample decompression algorithm around, since - it was derived from a GPL'd algorithm. We don't want - to have to put it under GPL! :) ... or, find out that it - wasn't originally written under the GPL and then credit - the bloke who wrote it :) -* MMX resamplers and downsamplers -* Ability to load *.it, *.xm directly into DUH structs (IT done) -* Ability to embed IT compressed samples... no, it's copyrighted. Let's do - our own :) -* Ability to embed ITs themselves (? not sure how useful that is) -* Remove cit.c -* Check all return values. I think the Winamp plug-in needs looking at... -* resample.c - it seems x*y is safe if 0<=x<=65535 and -32768<=y<=32768 or - vice versa. Check this is true on all compilers. If so, make - use of it to gain more accuracy. -* DUMB_IDs should always be long or always be int... -* Decide whether the load_signal function really needs the DUH parameter... -* Allow for DUH modularity; different pieces share samples etc. - -* Fix makefile so it can manage without alld - or put note in the FAQ that - ppl must build alld -* Arrange to detect file types by extension (probably not by content though) -* Change aldmbd to aldmd in makefiles to maintain 8.3 compatibility -* Put dumb_resampling_quality and dumb_it_max_to_mix in howto.txt -* More info in howto.txt, in particular that install_sound() is needed... -* Add a sanity check for restart_position? -* Note in docs to let entheh know if you release a game using DUMB - - -STUFF TO FIX FOR THE FIRST RELEASE -================================== - -General -------- -* Naming is a bit confusing sometimes... -* What to do about ASSERT() and TRACE() - they were hacked in when - the lib was split from Allegro, and they need replacing. -* Add some constants to dumb.h (DUMB_VERSION_STR etc.) - -entheh ------- -* Update docs, write more docs (a lot to do here!) -* Go through, eliminate warnings, resolve some "/** WARNING" comments - (they used to be #warning but Bob complained :) -* Program it to calculate the length of IT and S3M files (currently - always set to 10 minutes IIRC) - -Bob ---- -* dumb_resample() now has a volume parameter, so there are some extra - floating-point multiply ops that could possibly be optimised. - -tjaden ------- -* Test on Linux when it's all ready plz :) diff --git a/dumb/vc6/dumb/.gitignore b/dumb/vc6/dumb/.gitignore new file mode 100644 index 0000000000..32cff875e0 --- /dev/null +++ b/dumb/vc6/dumb/.gitignore @@ -0,0 +1,3 @@ +*.user +Debug +Release \ No newline at end of file diff --git a/dumb/vc6/dumb/dumb.vcproj b/dumb/vc6/dumb/dumb.vcproj new file mode 100644 index 0000000000..525bc56fc5 --- /dev/null +++ b/dumb/vc6/dumb/dumb.vcproj @@ -0,0 +1,2007 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dumb/vc6/dumb/dumb.vcxproj b/dumb/vc6/dumb/dumb.vcxproj new file mode 100644 index 0000000000..6e49557cff --- /dev/null +++ b/dumb/vc6/dumb/dumb.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {612D360C-A51B-4B34-8F49-33F42A2957F5} + dumb + + + + + + + + + + + + StaticLibrary + true + v120_xp + + + StaticLibrary + v120_xp + + + + + + + + + + + + + <_ProjectFileVersion>10.0.21006.1 + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + _USE_SSE;RESAMPLER_DECORATE=dumb;BARRAY_DECORATE=dumb;_DEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;DEBUGMODE=1;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Level3 + true + EditAndContinue + Default + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + MaxSpeed + AnySuitable + ../../include;%(AdditionalIncludeDirectories) + _USE_SSE;RESAMPLER_DECORATE=dumb;BARRAY_DECORATE=dumb;NDEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;%(PreprocessorDefinitions) + true + MultiThreaded + true + Level3 + true + ProgramDatabase + Default + Fast + NoExtensions + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Document + true + true + + + Document + true + true + + + Document + true + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dumb/vc6/dumb/dumb.vcxproj.filters b/dumb/vc6/dumb/dumb.vcxproj.filters new file mode 100644 index 0000000000..167393748f --- /dev/null +++ b/dumb/vc6/dumb/dumb.vcxproj.filters @@ -0,0 +1,332 @@ + + + + + {419c5e1f-2bf4-473a-b2e5-2e531285aa62} + + + {44b333b3-1607-4820-82bc-e4c21a40e31a} + + + {0b122556-3781-4ef3-87fe-ffa5fb50b493} + + + {e961cd19-26f6-4df0-b895-e099d3e81db9} + + + {82e35139-08ff-4e99-a3ce-2254d7427ec4} + + + {5f7fc0f6-4008-4166-83ad-e5d914718bd0} + + + {0fd0715e-5824-4419-aa5b-2d4272d222ce} + + + {b9e26fe7-6056-4580-b2c6-10e6116d4129} + + + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\core + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\helpers + + + src\it\loaders + + + src\it\loaders + + + src\it + + + src\it + + + src\it\readers + + + src\it\readers + + + src\it + + + src\it + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it\readers + + + src\it + + + src\it\readers + + + src\it\readers + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\loaders + + + src\it\readers + + + src\it\readers + + + src\helpers + + + src\helpers + + + + + include + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + include\internal + + + + + src\helpers + + + src\helpers + + + src\helpers + + + \ No newline at end of file diff --git a/dumb/vc6/dumb_static/dumb_static.vcproj b/dumb/vc6/dumb_static/dumb_static.vcproj index 3f1373cc31..301a0fb82c 100644 --- a/dumb/vc6/dumb_static/dumb_static.vcproj +++ b/dumb/vc6/dumb_static/dumb_static.vcproj @@ -1,2004 +1,2073 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/sound/music_dumb.cpp b/src/sound/music_dumb.cpp index 8405228a3c..3a1651012f 100644 --- a/src/sound/music_dumb.cpp +++ b/src/sound/music_dumb.cpp @@ -122,8 +122,8 @@ typedef struct MODMIDICFG CVAR(Bool, mod_dumb, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Int, mod_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR(Int, mod_volramp, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR(Int, mod_interp, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Int, mod_volramp, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Int, mod_interp, DUMB_LQ_CUBIC, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Bool, mod_autochip, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Int, mod_autochip_size_force, 100, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); CVAR(Int, mod_autochip_size_scan, 500, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); @@ -462,7 +462,7 @@ typedef struct tdumbfile_mem_status unsigned int offset, size; } dumbfile_mem_status; -static int dumbfile_mem_skip(void *f, int32 n) +static int DUMBCALLBACK dumbfile_mem_skip(void *f, long n) { dumbfile_mem_status * s = (dumbfile_mem_status *) f; s->offset += n; @@ -471,11 +471,10 @@ static int dumbfile_mem_skip(void *f, int32 n) s->offset = s->size; return 1; } - return 0; } -static int dumbfile_mem_getc(void *f) +static int DUMBCALLBACK dumbfile_mem_getc(void *f) { dumbfile_mem_status * s = (dumbfile_mem_status *) f; if (s->offset < s->size) @@ -485,7 +484,7 @@ static int dumbfile_mem_getc(void *f) return -1; } -static int32 dumbfile_mem_getnc(char *ptr, int32 n, void *f) +static int32 DUMBCALLBACK dumbfile_mem_getnc(char *ptr, int32 n, void *f) { dumbfile_mem_status * s = (dumbfile_mem_status *) f; long max = s->size - s->offset; @@ -498,12 +497,32 @@ static int32 dumbfile_mem_getnc(char *ptr, int32 n, void *f) return max; } +static int DUMBCALLBACK dumbfile_mem_seek(void *f, long n) +{ + dumbfile_mem_status * s = (dumbfile_mem_status *) f; + s->offset = n; + if (s->offset > s->size) + { + s->offset = s->size; + return 1; + } + return 0; +} + +static int32 DUMBCALLBACK dumbfile_mem_get_size(void *f) +{ + dumbfile_mem_status * s = (dumbfile_mem_status *) f; + return s->size; +} + static DUMBFILE_SYSTEM mem_dfs = { NULL, // open &dumbfile_mem_skip, &dumbfile_mem_getc, &dumbfile_mem_getnc, - NULL // close + NULL, // close + &dumbfile_mem_seek, + &dumbfile_mem_get_size }; //========================================================================== @@ -539,128 +558,6 @@ DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, BYTE *start, FILE *f return dumbfile_open_ex(filestate, &mem_dfs); } -//========================================================================== -// -// MOD_SetRampMode -// -//========================================================================== - -void MOD_SetRampMode(DUH *duh) -{ - int ramp_mode = mod_volramp; - - DUMB_IT_SIGDATA * itsd = duh_get_it_sigdata(duh); - if (itsd) - { - if (ramp_mode > 2) - { - if ( ( itsd->flags & ( IT_WAS_AN_XM | IT_WAS_A_MOD ) ) == IT_WAS_AN_XM ) - ramp_mode = 2; - else - ramp_mode = 1; - } - for (int i = 0, j = itsd->n_samples; i < j; i++) - { - IT_SAMPLE * sample = &itsd->sample[i]; - if ( sample->flags & IT_SAMPLE_EXISTS && !( sample->flags & IT_SAMPLE_LOOP ) ) - { - double rate = 1. / double( sample->C5_speed ); - double length = double( sample->length ) * rate; - if ( length >= .1 ) - { - int k, l = sample->length; - if ( ramp_mode == 1 && ( ( rate * 16. ) < .01 ) ) - { - if (sample->flags & IT_SAMPLE_16BIT) - { - k = l - 15; - signed short * data = (signed short *) sample->data; - if (sample->flags & IT_SAMPLE_STEREO) - { - for (int shift = 1; k < l; k++, shift++) - { - data [k * 2] >>= shift; - data [k * 2 + 1] >>= shift; - } - } - else - { - for (int shift = 1; k < l; k++, shift++) - { - data [k] >>= shift; - } - } - } - else - { - k = l - 7; - signed char * data = (signed char *) sample->data; - if (sample->flags & IT_SAMPLE_STEREO) - { - for (int shift = 1; k < l; k++, shift++) - { - data [k * 2] >>= shift; - data [k * 2 + 1] >>= shift; - } - } - else - { - for (int shift = 1; k < l; k++, shift++) - { - data [k] >>= shift; - } - } - } - } - else - { - int m = int( .01 * double( sample->C5_speed ) + .5 ); - k = l - m; - if (sample->flags & IT_SAMPLE_16BIT) - { - signed short * data = (signed short *) sample->data; - if (sample->flags & IT_SAMPLE_STEREO) - { - for (; k < l; k++) - { - data [k * 2] = Scale( data [k * 2], l - k, m ); - data [k * 2 + 1] = Scale( data [k * 2 + 1], l - k, m ); - } - } - else - { - for (; k < l; k++) - { - data [k] = Scale( data [k], l - k, m ); - } - } - } - else - { - signed char * data = (signed char *) sample->data; - if (sample->flags & IT_SAMPLE_STEREO) - { - for (; k < l; k++) - { - data [k * 2] = Scale( data [k * 2], l - k, m ); - data [k * 2 + 1] = Scale( data [k * 2 + 1], l - k, m ); - } - } - else - { - for (; k < l; k++) - { - data [k] = Scale( data [k], l - k, m ); - } - } - } - } - } - } - } - } -} - //========================================================================== // // MOD_SetAutoChip @@ -1028,12 +925,6 @@ MusInfo *MOD_OpenSong(FILE *file, BYTE *musiccache, int size) } if ( duh ) { - // XXX test - if (mod_volramp) - { - MOD_SetRampMode(duh); - } - if (mod_autochip) { MOD_SetAutoChip(duh); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index f84c3ceffa..07f841545a 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1541,21 +1541,24 @@ OptionValue ModReplayers } -OptionValue ModInterpolations +OptionValue ModQuality { - 0.0, "None" + 0.0, "Aliasing" 1.0, "Linear" 2.0, "Cubic" + 3.0, "Band-limited step" // BLEP + 4.0, "Linear (Slower)" + 5.0, "Band-limited linear" // BLAM + 6.0, "Cubic (Slower)" + 7.0, "Sinc" } OptionValue ModVolumeRamps { 0.0, "None" - 1.0, "Logarithmic" - 2.0, "Linear" - 3.0, "XM=lin, else none" - 4.0, "XM=lin, else log" + 1.0, "Note on/off only" + 2.0, "Full ramping" } @@ -1565,7 +1568,7 @@ OptionMenu ModReplayerOptions Option "Replayer engine", "mod_dumb", "ModReplayers" StaticText " " Option "Sample rate", "mod_samplerate", "SampleRates", "mod_dumb" - Option "Interpolation", "mod_interp", "ModInterpolations", "mod_dumb" + Option "Quality", "mod_interp", "ModQuality", "mod_dumb" Option "Volume ramping", "mod_volramp", "ModVolumeRamps", "mod_dumb" StaticText " " Option "Chip-o-matic", "mod_autochip", "OnOff", "mod_dumb"