From 15b9bb96cde815b849514edbeb9dfd789e67db71 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Wed, 27 Jan 2021 23:45:25 -0600 Subject: [PATCH] Update nyquist to SVN r331 (r3.16+) ------------------------------------------------------------------------ r331 | rbd | 2020-10-13 12:40:12 -0500 (Tue, 13 Oct 2020) | 2 lines Also forgot to install NyquistWords.txt ------------------------------------------------------------------------ r330 | rbd | 2020-10-13 12:34:06 -0500 (Tue, 13 Oct 2020) | 2 lines Forgot to move nyquistman.pdf from docsrc/s2h to release ------------------------------------------------------------------------ r329 | rbd | 2020-10-13 11:32:33 -0500 (Tue, 13 Oct 2020) | 2 lines Updated some version numbers for 3.16. ------------------------------------------------------------------------ r328 | rbd | 2020-10-13 11:20:52 -0500 (Tue, 13 Oct 2020) | 2 lines Fixed NyquistIDE antialiasing for plot text, fix format of message. ------------------------------------------------------------------------ r327 | rbd | 2020-10-12 21:01:53 -0500 (Mon, 12 Oct 2020) | 2 lines Fixed a couple of format problems in manual. This version of Nyquist has been tested wtih macOS, Linux, 32&64-bit Windows. ------------------------------------------------------------------------ r326 | rbd | 2020-10-12 20:21:38 -0500 (Mon, 12 Oct 2020) | 1 line Modified WIN32 32-bit XLisp to use 64-bit FIXNUMs. This allows XLisp and Nyquist to handle big sounds even on 32-bit machines. Probably at some cost, but inner loops are mostly float and int32, and the Nyquist release is 64-bit anyway. Maybe we'll have to run some benchmarks on Audacity, which is still 32-bit on Windows. ------------------------------------------------------------------------ r325 | rbd | 2020-10-12 13:16:57 -0500 (Mon, 12 Oct 2020) | 1 line Win64 passes bigfiletest.lsp now. This version should work on all 64-bit systems now. These changes untested on Linux and macOS. ------------------------------------------------------------------------ r324 | rbd | 2020-10-11 21:31:53 -0500 (Sun, 11 Oct 2020) | 2 lines I couldn't free enough space on my linux box, so I adjusted the bigfiletest to write 8-bit ulaw. It's still >4GB and >4G samples. Works on Linux. ------------------------------------------------------------------------ r323 | rbd | 2020-10-11 19:41:25 -0500 (Sun, 11 Oct 2020) | 2 lines Missing file from last commit. ------------------------------------------------------------------------ r322 | rbd | 2020-10-11 19:36:08 -0500 (Sun, 11 Oct 2020) | 1 line Found another case where WIN64 needs int64_t instead of long for sample count. ------------------------------------------------------------------------ r321 | rbd | 2020-10-11 19:33:25 -0500 (Sun, 11 Oct 2020) | 3 lines Fixed s-save to handle optional and keyword parameters (which should never have been mixed in the first place). Documentation cleanup - should be final for this version. ------------------------------------------------------------------------ r320 | rbd | 2020-10-11 14:44:37 -0500 (Sun, 11 Oct 2020) | 2 lines Fixes to handle IRCAM sound format and tests for big file io working on macOS. ------------------------------------------------------------------------ r319 | rbd | 2020-10-10 21:31:58 -0500 (Sat, 10 Oct 2020) | 2 lines Changes for linux and to avoid compiler warnings on linux. ------------------------------------------------------------------------ r318 | rbd | 2020-10-10 20:50:23 -0500 (Sat, 10 Oct 2020) | 1 line This is the test used for Win64 version. ------------------------------------------------------------------------ r317 | rbd | 2020-10-10 20:34:34 -0500 (Sat, 10 Oct 2020) | 1 line This version works on Win64. Need to test changes on macOS and linux. ------------------------------------------------------------------------ r316 | rbd | 2020-10-10 19:59:15 -0500 (Sat, 10 Oct 2020) | 2 lines PWL changes to avoid compiler warning. ------------------------------------------------------------------------ r315 | rbd | 2020-10-10 19:34:04 -0500 (Sat, 10 Oct 2020) | 2 lines A few more changes for 64-bit sample counts on Win64 ------------------------------------------------------------------------ r314 | rbd | 2020-10-10 13:19:42 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed int64_t declaration in gate.alg ------------------------------------------------------------------------ r313 | rbd | 2020-10-10 12:07:40 -0500 (Sat, 10 Oct 2020) | 2 lines Fixes to gate for long sounds ------------------------------------------------------------------------ r312 | rbd | 2020-10-10 11:47:29 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed sound_save types for intgen ------------------------------------------------------------------------ r311 | rbd | 2020-10-10 11:09:01 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed a 64-bit sample count problem in siosc.alg ------------------------------------------------------------------------ r310 | rbd | 2020-10-10 11:03:12 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed sndmax to handle 64-bit sample counts. ------------------------------------------------------------------------ r309 | rbd | 2020-10-10 10:57:04 -0500 (Sat, 10 Oct 2020) | 2 lines Forgot to re-translate all tran/*.alg files with fix for int64 cast to int32. This version compiles on macOS and ready for test on Win64. ------------------------------------------------------------------------ r308 | rbd | 2020-10-10 10:16:05 -0500 (Sat, 10 Oct 2020) | 2 lines Everything seems to compile and run on macOS now. Moving changes to Windows for test. ------------------------------------------------------------------------ r307 | rbd | 2020-10-10 09:23:45 -0500 (Sat, 10 Oct 2020) | 1 line Added casts to avoid compiler warnings and to review changes to support 64-bit sample counts on Windows. Still not complete, and waiting to regenerate and compile tran directory code after updates to translation code that will insert more casts. ------------------------------------------------------------------------ r306 | rbd | 2020-10-09 21:55:15 -0500 (Fri, 09 Oct 2020) | 2 lines Rebuilt seqfnint.c from header files. ------------------------------------------------------------------------ r305 | rbd | 2020-10-09 21:53:33 -0500 (Fri, 09 Oct 2020) | 1 line Changed some FIXNUMS to LONG to avoid compiler warnings in seqfnint.c ------------------------------------------------------------------------ r304 | rbd | 2020-10-09 21:44:03 -0500 (Fri, 09 Oct 2020) | 2 lines I discovered forgotten regression-test.lsp and added test that requires 64-bit sample counts to pass. Fixed a few bugs revealed by running the type-checking regression tests. ------------------------------------------------------------------------ r303 | rbd | 2020-10-09 12:28:58 -0500 (Fri, 09 Oct 2020) | 2 lines Changes for 64-bit sample counts broke mult-channel s-save. Fixed in the commit for macOS. ------------------------------------------------------------------------ r302 | rbd | 2020-10-09 10:03:39 -0500 (Fri, 09 Oct 2020) | 2 lines Changed snd-play to return samples computed and used that to make a test for computing long sounds that would overflow 32-bit length counts. ------------------------------------------------------------------------ r301 | rbd | 2020-10-09 09:11:26 -0500 (Fri, 09 Oct 2020) | 2 lines corrected mistake in delaycv.alg and re-translated ------------------------------------------------------------------------ r300 | rbd | 2020-10-09 09:09:06 -0500 (Fri, 09 Oct 2020) | 2 lines Fix to delaycv.alg -- "s" changed to "input" to avoid matching "s" in "sample_type". ------------------------------------------------------------------------ r299 | rbd | 2020-10-09 09:03:33 -0500 (Fri, 09 Oct 2020) | 4 lines To avoid compiler warnings, XLisp interfaces to C int and long are now specified as LONG rather than FIXNUM, and the stubs that call the C functions cast FIXNUMs from XLisp into longs before calling C functions. ------------------------------------------------------------------------ r298 | rbd | 2020-10-08 22:20:26 -0500 (Thu, 08 Oct 2020) | 2 lines This commit has many more fixes to handle long (64-bit) sounds, including a lot of fixes for warnings by Visual Studio assigning int64_t to long (works on macOS, doesn't work on VS). This was compiled and tested on macOS, and even computed a 27.1-hour sound using OSC, LP, SUM and MULT (haven't tested I/O yet). ------------------------------------------------------------------------ r297 | rbd | 2020-10-07 13:04:02 -0500 (Wed, 07 Oct 2020) | 2 lines This is a major cleanup. It started with the goal of changing long to int64_t for sample counts so that on 64-bit windows, where long is only 32-bits, the sample counts would nevertheless be 64-bit allowing long sounds, which was a limitation for long recordings in Audacity. Since I was using compiler warnings to track possible loss-of-precision conversions from 64-bit sample counts, and there were *many* warnings, I started cleaning up *all* the warnings and ended up with a very large set of changes, including "modernizing" C declarations that date back to XLisp and CMU MIDI Toolkit code and were never changed. This version runs all the examples.sal code on macOS, but will surely have problems on Windows and Linux given the number of changes. ------------------------------------------------------------------------ r296 | rbd | 2020-10-06 13:34:20 -0500 (Tue, 06 Oct 2020) | 2 lines More changes from long to int64_t for sample counts. ------------------------------------------------------------------------ r295 | rbd | 2020-10-06 11:53:49 -0500 (Tue, 06 Oct 2020) | 2 lines More work on using 64-bit sample counts. Changed MAX_STOP from 32-bit to 64-bit limit. ------------------------------------------------------------------------ r294 | rbd | 2020-10-06 11:48:05 -0500 (Tue, 06 Oct 2020) | 2 lines Made some changes so that sample counts are int64_t (for windows) instead of long to support sample counts above 31 bits. ------------------------------------------------------------------------ r293 | rbd | 2020-10-04 21:30:55 -0500 (Sun, 04 Oct 2020) | 2 lines Fixed a few minor things for Linux and tested on Linux. ------------------------------------------------------------------------ r292 | rbd | 2020-10-04 21:00:28 -0500 (Sun, 04 Oct 2020) | 2 lines Update extensions: all are minor changes. ------------------------------------------------------------------------ r291 | rbd | 2020-09-24 13:59:31 -0500 (Thu, 24 Sep 2020) | 2 lines New implementation of seq and seqrep, added get-real-time, documented get-real-time, fixed examples.sal and examples.lsp which are now in lib rather than extensions (so they are now back in the basic installation), other cleanup. ------------------------------------------------------------------------ r290 | rbd | 2020-08-16 16:24:52 -0500 (Sun, 16 Aug 2020) | 2 lines Fixed bug in snd-gate, revised GATE and NOISE-GATE to handle multi-channel sound. RMS now handles multi-channel input. S-AVG added to take multichannel input (but not used, because RMS could not be written without making SND-SRATE convert multichannel sound to vector of floats. That seems to be going toward a fully vectorized model. Not going there for now. ------------------------------------------------------------------------ r289 | rbd | 2020-07-09 16:27:45 -0500 (Thu, 09 Jul 2020) | 2 lines Added GET-REAL-TIME function to XLISP. May not work yet on Windows. Various fixes for compiler warnings. I noticed FLAC doesn't work (I guess it never did) and I cannot figure out how this even links because flac_min seems to be undefined. Something to look at later. --- lib-src/libnyquist/nyquist/Readme.txt | 9 +- lib-src/libnyquist/nyquist/cmt/cext.h | 11 +- lib-src/libnyquist/nyquist/cmt/cmdline.c | 29 +- lib-src/libnyquist/nyquist/cmt/cmtcmd.c | 28 +- lib-src/libnyquist/nyquist/cmt/cmtcmd.h | 8 +- lib-src/libnyquist/nyquist/cmt/cmtio.h | 4 +- lib-src/libnyquist/nyquist/cmt/hashrout.h | 74 +- lib-src/libnyquist/nyquist/cmt/midifile.c | 7 +- lib-src/libnyquist/nyquist/cmt/midifns.c | 45 +- lib-src/libnyquist/nyquist/cmt/midifns.h | 2 +- lib-src/libnyquist/nyquist/cmt/moxc.c | 18 +- lib-src/libnyquist/nyquist/cmt/record.c | 62 +- lib-src/libnyquist/nyquist/cmt/seq.c | 27 +- lib-src/libnyquist/nyquist/cmt/seq.h | 25 +- lib-src/libnyquist/nyquist/cmt/seqmread.c | 8 +- lib-src/libnyquist/nyquist/cmt/seqmwrite.c | 40 +- lib-src/libnyquist/nyquist/cmt/seqread.c | 181 +- lib-src/libnyquist/nyquist/cmt/seqwrite.c | 29 +- lib-src/libnyquist/nyquist/cmt/tempomap.c | 6 +- lib-src/libnyquist/nyquist/cmt/timebase.c | 9 +- lib-src/libnyquist/nyquist/cmt/timebase.h | 2 +- lib-src/libnyquist/nyquist/cmt/userio.c | 19 +- lib-src/libnyquist/nyquist/cmt/userio.h | 4 +- lib-src/libnyquist/nyquist/cmupv/src/cmupv.c | 18 +- lib-src/libnyquist/nyquist/ffts/src/fftext.c | 7 +- lib-src/libnyquist/nyquist/ffts/src/fftext.h | 2 +- lib-src/libnyquist/nyquist/ffts/src/fftlib.c | 32 +- lib-src/libnyquist/nyquist/nyqsrc/add.c | 109 +- lib-src/libnyquist/nyquist/nyqsrc/add.h | 8 +- lib-src/libnyquist/nyquist/nyqsrc/avg.c | 40 +- lib-src/libnyquist/nyquist/nyqsrc/avg.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/compose.c | 27 +- lib-src/libnyquist/nyquist/nyqsrc/convolve.c | 44 +- lib-src/libnyquist/nyquist/nyqsrc/debug.c | 6 +- lib-src/libnyquist/nyquist/nyqsrc/debug.h | 2 - .../libnyquist/nyquist/nyqsrc/downsample.c | 25 +- .../libnyquist/nyquist/nyqsrc/downsample.h | 4 +- lib-src/libnyquist/nyquist/nyqsrc/f0.cpp | 2 +- lib-src/libnyquist/nyquist/nyqsrc/falloc.c | 6 +- lib-src/libnyquist/nyquist/nyqsrc/falloc.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/fft.c | 26 +- lib-src/libnyquist/nyquist/nyqsrc/fft.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/handlers.c | 2 +- lib-src/libnyquist/nyquist/nyqsrc/inverse.c | 16 +- lib-src/libnyquist/nyquist/nyqsrc/localdefs.h | 9 + lib-src/libnyquist/nyquist/nyqsrc/lpanal.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/multiread.c | 10 +- lib-src/libnyquist/nyquist/nyqsrc/multiseq.c | 13 +- lib-src/libnyquist/nyquist/nyqsrc/multiseq.h | 2 +- .../libnyquist/nyquist/nyqsrc/nfilterkit.h | 4 +- .../nyquist/nyqsrc/nyq-osc-server.c | 6 +- .../nyquist/nyqsrc/nyq-osc-server.h | 6 +- lib-src/libnyquist/nyquist/nyqsrc/nyx.c | 753 ++++-- .../libnyquist/nyquist/nyqsrc/phasevocoder.c | 44 +- .../libnyquist/nyquist/nyqsrc/phasevocoder.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/pvshell.c | 2 +- lib-src/libnyquist/nyquist/nyqsrc/pvshell.h | 6 +- lib-src/libnyquist/nyquist/nyqsrc/resamp.c | 20 +- lib-src/libnyquist/nyquist/nyqsrc/resampv.c | 8 +- lib-src/libnyquist/nyquist/nyqsrc/samples.c | 43 +- lib-src/libnyquist/nyquist/nyqsrc/samples.h | 8 +- lib-src/libnyquist/nyquist/nyqsrc/seqext.c | 7 +- lib-src/libnyquist/nyquist/nyqsrc/seqext.h | 6 +- lib-src/libnyquist/nyquist/nyqsrc/seqfnint.c | 67 +- lib-src/libnyquist/nyquist/nyqsrc/seqinterf.c | 4 +- lib-src/libnyquist/nyquist/nyqsrc/seqinterf.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/sndfmt.h | 4 +- lib-src/libnyquist/nyquist/nyqsrc/sndfnint.c | 135 +- .../libnyquist/nyquist/nyqsrc/sndfnint.lsp | 2 + lib-src/libnyquist/nyquist/nyqsrc/sndmax.c | 6 +- lib-src/libnyquist/nyquist/nyqsrc/sndmax.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/sndread.c | 29 +- lib-src/libnyquist/nyquist/nyqsrc/sndread.h | 10 +- lib-src/libnyquist/nyquist/nyqsrc/sndseq.c | 218 +- lib-src/libnyquist/nyquist/nyqsrc/sndseq.h | 5 +- .../libnyquist/nyquist/nyqsrc/sndsliders.c | 8 +- .../libnyquist/nyquist/nyqsrc/sndsliders.h | 3 +- lib-src/libnyquist/nyquist/nyqsrc/sndwrite.c | 4 +- lib-src/libnyquist/nyquist/nyqsrc/sndwrite.h | 17 +- .../libnyquist/nyquist/nyqsrc/sndwritepa.c | 170 +- lib-src/libnyquist/nyquist/nyqsrc/sound.c | 263 ++- lib-src/libnyquist/nyquist/nyqsrc/sound.h | 97 +- .../libnyquist/nyquist/nyqsrc/stoponzero.c | 15 +- lib-src/libnyquist/nyquist/nyqsrc/trigger.c | 20 +- lib-src/libnyquist/nyquist/nyqsrc/trigger.h | 4 +- lib-src/libnyquist/nyquist/nyqsrc/yin.c | 29 +- lib-src/libnyquist/nyquist/nyqsrc/yin.h | 2 +- .../libnyquist/nyquist/nyqstk/src/Delay.cpp | 15 +- lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp | 6 +- lib-src/libnyquist/nyquist/sys/unix/io.c | 6 +- lib-src/libnyquist/nyquist/sys/unix/osstuff.c | 76 +- .../libnyquist/nyquist/sys/unix/switches.h | 2 + lib-src/libnyquist/nyquist/sys/unix/term.c | 20 +- lib-src/libnyquist/nyquist/sys/unix/term.h | 12 +- .../nyquist/sys/win/msvc/winstuff.c | 17 +- lib-src/libnyquist/nyquist/tran/README.txt | 1 + lib-src/libnyquist/nyquist/tran/abs.c | 118 +- lib-src/libnyquist/nyquist/tran/allpoles.c | 132 +- lib-src/libnyquist/nyquist/tran/alpass.c | 74 +- lib-src/libnyquist/nyquist/tran/alpasscv.alg | 4 +- lib-src/libnyquist/nyquist/tran/alpasscv.c | 380 ++-- lib-src/libnyquist/nyquist/tran/alpassvc.alg | 2 +- lib-src/libnyquist/nyquist/tran/alpassvc.c | 323 +-- lib-src/libnyquist/nyquist/tran/alpassvv.c | 1496 ++++++------ lib-src/libnyquist/nyquist/tran/amosc.c | 410 ++-- lib-src/libnyquist/nyquist/tran/areson.c | 132 +- lib-src/libnyquist/nyquist/tran/areson.h | 2 +- lib-src/libnyquist/nyquist/tran/aresoncv.c | 542 ++--- lib-src/libnyquist/nyquist/tran/aresoncv.h | 2 +- lib-src/libnyquist/nyquist/tran/aresonvc.c | 498 ++-- lib-src/libnyquist/nyquist/tran/aresonvc.h | 2 +- lib-src/libnyquist/nyquist/tran/aresonvv.c | 2012 ++++++++--------- lib-src/libnyquist/nyquist/tran/aresonvv.h | 2 +- lib-src/libnyquist/nyquist/tran/atone.c | 234 +- lib-src/libnyquist/nyquist/tran/atonev.c | 458 ++-- lib-src/libnyquist/nyquist/tran/biquadfilt.c | 136 +- lib-src/libnyquist/nyquist/tran/buzz.alg | 2 +- lib-src/libnyquist/nyquist/tran/buzz.c | 398 ++-- lib-src/libnyquist/nyquist/tran/buzz.h | 2 +- lib-src/libnyquist/nyquist/tran/chase.c | 246 +- lib-src/libnyquist/nyquist/tran/clip.c | 230 +- lib-src/libnyquist/nyquist/tran/congen.c | 134 +- lib-src/libnyquist/nyquist/tran/const.c | 42 +- lib-src/libnyquist/nyquist/tran/coterm.alg | 2 +- lib-src/libnyquist/nyquist/tran/coterm.c | 439 ++-- lib-src/libnyquist/nyquist/tran/delaycc.c | 74 +- lib-src/libnyquist/nyquist/tran/delaycv.alg | 14 +- lib-src/libnyquist/nyquist/tran/delaycv.c | 924 ++++---- lib-src/libnyquist/nyquist/tran/delaycv.h | 4 +- lib-src/libnyquist/nyquist/tran/eqbandvvv.c | 824 +++---- lib-src/libnyquist/nyquist/tran/exp.c | 118 +- lib-src/libnyquist/nyquist/tran/fmfb.alg | 2 +- lib-src/libnyquist/nyquist/tran/fmfb.c | 60 +- lib-src/libnyquist/nyquist/tran/fmfbv.alg | 4 +- lib-src/libnyquist/nyquist/tran/fmfbv.c | 536 ++--- lib-src/libnyquist/nyquist/tran/fmosc.c | 396 ++-- lib-src/libnyquist/nyquist/tran/follow.c | 90 +- lib-src/libnyquist/nyquist/tran/follow.h | 2 +- .../libnyquist/nyquist/tran/fromarraystream.c | 30 +- lib-src/libnyquist/nyquist/tran/fromobject.c | 32 +- lib-src/libnyquist/nyquist/tran/gate.alg | 79 +- lib-src/libnyquist/nyquist/tran/gate.c | 174 +- lib-src/libnyquist/nyquist/tran/ifft.c | 47 +- lib-src/libnyquist/nyquist/tran/ifft.h | 2 +- lib-src/libnyquist/nyquist/tran/innerloop.lsp | 130 +- lib-src/libnyquist/nyquist/tran/instrbanded.c | 72 +- lib-src/libnyquist/nyquist/tran/instrbanded.h | 2 +- lib-src/libnyquist/nyquist/tran/instrbow.c | 72 +- .../libnyquist/nyquist/tran/instrbowedfreq.c | 96 +- lib-src/libnyquist/nyquist/tran/instrclar.c | 72 +- .../libnyquist/nyquist/tran/instrclarall.c | 144 +- .../libnyquist/nyquist/tran/instrclarfreq.c | 96 +- lib-src/libnyquist/nyquist/tran/instrflute.c | 72 +- .../libnyquist/nyquist/tran/instrfluteall.c | 144 +- .../libnyquist/nyquist/tran/instrflutefreq.c | 96 +- .../libnyquist/nyquist/tran/instrmandolin.c | 44 +- .../libnyquist/nyquist/tran/instrmodalbar.c | 44 +- .../libnyquist/nyquist/tran/instrmodalbar.h | 2 +- lib-src/libnyquist/nyquist/tran/instrsax.c | 74 +- lib-src/libnyquist/nyquist/tran/instrsaxall.c | 192 +- .../libnyquist/nyquist/tran/instrsaxfreq.c | 96 +- lib-src/libnyquist/nyquist/tran/instrsitar.c | 44 +- lib-src/libnyquist/nyquist/tran/integrate.c | 122 +- lib-src/libnyquist/nyquist/tran/log.c | 118 +- lib-src/libnyquist/nyquist/tran/lpreson.c | 142 +- lib-src/libnyquist/nyquist/tran/maxv.c | 956 ++++---- lib-src/libnyquist/nyquist/tran/offset.c | 226 +- lib-src/libnyquist/nyquist/tran/oneshot.alg | 4 +- lib-src/libnyquist/nyquist/tran/oneshot.c | 240 +- lib-src/libnyquist/nyquist/tran/osc.c | 50 +- lib-src/libnyquist/nyquist/tran/partial.alg | 2 +- lib-src/libnyquist/nyquist/tran/partial.c | 516 ++--- lib-src/libnyquist/nyquist/tran/pluck.alg | 2 +- lib-src/libnyquist/nyquist/tran/pluck.c | 70 +- lib-src/libnyquist/nyquist/tran/prod.alg | 2 +- lib-src/libnyquist/nyquist/tran/prod.c | 438 ++-- lib-src/libnyquist/nyquist/tran/pwl.alg | 10 +- lib-src/libnyquist/nyquist/tran/pwl.c | 40 +- lib-src/libnyquist/nyquist/tran/quantize.alg | 14 +- lib-src/libnyquist/nyquist/tran/quantize.c | 136 +- lib-src/libnyquist/nyquist/tran/quantize.h | 2 +- lib-src/libnyquist/nyquist/tran/recip.c | 120 +- lib-src/libnyquist/nyquist/tran/reson.c | 250 +- lib-src/libnyquist/nyquist/tran/reson.h | 2 +- lib-src/libnyquist/nyquist/tran/resoncv.c | 548 ++--- lib-src/libnyquist/nyquist/tran/resoncv.h | 2 +- lib-src/libnyquist/nyquist/tran/resonvc.c | 504 ++--- lib-src/libnyquist/nyquist/tran/resonvc.h | 2 +- lib-src/libnyquist/nyquist/tran/resonvv.c | 1992 ++++++++-------- lib-src/libnyquist/nyquist/tran/resonvv.h | 2 +- lib-src/libnyquist/nyquist/tran/sampler.c | 402 ++-- lib-src/libnyquist/nyquist/tran/sampler.h | 2 +- lib-src/libnyquist/nyquist/tran/scale.c | 120 +- lib-src/libnyquist/nyquist/tran/shape.c | 128 +- lib-src/libnyquist/nyquist/tran/sine.c | 46 +- lib-src/libnyquist/nyquist/tran/siosc.alg | 17 +- lib-src/libnyquist/nyquist/tran/siosc.c | 489 ++-- lib-src/libnyquist/nyquist/tran/slope.c | 124 +- lib-src/libnyquist/nyquist/tran/sqrt.c | 118 +- lib-src/libnyquist/nyquist/tran/stkchorus.c | 122 +- lib-src/libnyquist/nyquist/tran/stkpitshift.c | 122 +- lib-src/libnyquist/nyquist/tran/stkrev.c | 122 +- lib-src/libnyquist/nyquist/tran/stkrev.h | 2 +- lib-src/libnyquist/nyquist/tran/tapf.c | 934 ++++---- lib-src/libnyquist/nyquist/tran/tapv.c | 934 ++++---- lib-src/libnyquist/nyquist/tran/tone.c | 126 +- lib-src/libnyquist/nyquist/tran/tonev.c | 478 ++-- lib-src/libnyquist/nyquist/tran/translate.lsp | 196 +- lib-src/libnyquist/nyquist/tran/upsample.c | 380 ++-- lib-src/libnyquist/nyquist/tran/white.c | 40 +- lib-src/libnyquist/nyquist/tran/writemake.lsp | 231 +- lib-src/libnyquist/nyquist/tran/writesusp.lsp | 423 ++-- lib-src/libnyquist/nyquist/tran/writetoss.lsp | 27 +- lib-src/libnyquist/nyquist/xlisp/extern.c | 3 +- lib-src/libnyquist/nyquist/xlisp/path.c | 2 +- lib-src/libnyquist/nyquist/xlisp/security.c | 5 +- lib-src/libnyquist/nyquist/xlisp/xlbfun.c | 6 +- lib-src/libnyquist/nyquist/xlisp/xlcont.c | 2 +- lib-src/libnyquist/nyquist/xlisp/xldmem.c | 33 +- lib-src/libnyquist/nyquist/xlisp/xlfio.c | 12 +- lib-src/libnyquist/nyquist/xlisp/xlftab.c | 113 +- lib-src/libnyquist/nyquist/xlisp/xlimage.c | 2 +- lib-src/libnyquist/nyquist/xlisp/xlinit.c | 4 +- lib-src/libnyquist/nyquist/xlisp/xlisp.c | 4 +- lib-src/libnyquist/nyquist/xlisp/xlisp.h | 77 +- lib-src/libnyquist/nyquist/xlisp/xllist.c | 6 - lib-src/libnyquist/nyquist/xlisp/xlmath.c | 2 +- lib-src/libnyquist/nyquist/xlisp/xlobj.c | 2 +- lib-src/libnyquist/nyquist/xlisp/xlprin.c | 10 +- lib-src/libnyquist/nyquist/xlisp/xlread.c | 31 +- lib-src/libnyquist/nyquist/xlisp/xlstr.c | 6 +- lib-src/libnyquist/nyquist/xlisp/xlsys.c | 16 +- 232 files changed, 14750 insertions(+), 14290 deletions(-) create mode 100644 lib-src/libnyquist/nyquist/tran/README.txt diff --git a/lib-src/libnyquist/nyquist/Readme.txt b/lib-src/libnyquist/nyquist/Readme.txt index 185bb71e8..1a18b8a5b 100644 --- a/lib-src/libnyquist/nyquist/Readme.txt +++ b/lib-src/libnyquist/nyquist/Readme.txt @@ -1,5 +1,5 @@ -README file for Nyquist Version 3.15 -11 Sep 2018 +README file for Nyquist Version 3.16 +13 Oct 2020 Roger B. Dannenberg LICENSE: see license.txt @@ -27,6 +27,11 @@ and other versions of Unix. For details, see one of these files: IMPLEMENTATION STATUS ===================== +Version 3.16 provides: + Long sounds: sample counts are consistently 64-bit. + Details in documentation on avoiding accumulating computed samples in memory + some fixes in code to eliminate the same. + Win32 32-bit implementation makes Nyquist FIXNUMs 64-bit. Version 3.15 provides: Fix to retain selected nyquist directory Fix for NyquistIDE in paths with spaces diff --git a/lib-src/libnyquist/nyquist/cmt/cext.h b/lib-src/libnyquist/nyquist/cmt/cext.h index 8ae668c24..8d75bfab0 100644 --- a/lib-src/libnyquist/nyquist/cmt/cext.h +++ b/lib-src/libnyquist/nyquist/cmt/cext.h @@ -182,17 +182,10 @@ MALLOC is not defined! #endif #define ROUND32(x) ((int) ((x) + 0.5)) -// on 32-bit machines, ROUNDBIG rounds to int32_t -// on 64-bit architectures, ROUNDBIG rounds to int64_t -#define ROUNDBIG(x) ((intptr_t) ((x) + 0.5)) -/* obsolete: ROUND is needed for both ints, e.g. sample rates, - and big ints, e.g. sample counts, so we have two ROUND - functions. We use intptr_t for ROUNDBIG because long on - Windows is only 32 bits, while intptr_t is 64 bits. - With the addition of these 2 functions, we never +#define ROUNDBIG(x) ((int64_t) ((x) + 0.5)) +/* With the addition of these 2 functions, we never "NEED_ROUND" and trying to use round will cause an error. */ -/* for compatibility */ #ifdef NEED_ROUND // #define round ROUND #define round you should not use round diff --git a/lib-src/libnyquist/nyquist/cmt/cmdline.c b/lib-src/libnyquist/nyquist/cmt/cmdline.c index 2c7d38394..21c68a1a3 100644 --- a/lib-src/libnyquist/nyquist/cmt/cmdline.c +++ b/lib-src/libnyquist/nyquist/cmt/cmdline.c @@ -112,10 +112,10 @@ private boolean cl_rdy = FALSE; /* set to TRUE when initialized */ /***************************************************************************** * Routines local to this module *****************************************************************************/ -private char *cl_search(); -private int find_string(); +private char *cl_search(char *name, int opt_sw, int n); +private int find_string(char *s, boolean *abbr); private void indirect_command(char *filename, char *oldarg0); -private void ready_check(); +private void ready_check(void); /**************************************************************** * cl_arg @@ -194,9 +194,7 @@ void cl_help() * TRUE if syntax checks OK, otherwise false *****************************************************************************/ -boolean cl_init(av, ac) - char *av[]; - int ac; +boolean cl_init(char *av[], int ac) { argv = av; argc = ac; @@ -257,10 +255,7 @@ long cl_int_option(name, deflt) * not start with "-" *****************************************************************/ -private char *cl_search(name, opt_sw, n) - char *name; - int opt_sw; - int n; /* if opt_sw is cl_ARG, n > 0 tells which one */ +private char *cl_search(char *name, int opt_sw, int n) { register int i = 1; /* index into command line */ boolean abbr; @@ -365,9 +360,7 @@ boolean cl_syntax(char *s) * 0 = FALSE = not found, 1 = cl_OPT = option, 2 = cl_SW = switch *****************************************************************/ -private int find_string(s, abbr) - char *s; - boolean *abbr; +private int find_string(char *s, boolean *abbr) { int found_it = FALSE; int i; @@ -425,9 +418,7 @@ private int find_string(s, abbr) /* get_arg -- get an argument from a file */ /**/ -boolean get_arg(file, arg) - FILE *file; - char *arg; +boolean get_arg(FILE *file, char *arg) { int c; while ((c = getc(file)) != EOF && isspace(c)) ; @@ -443,9 +434,7 @@ boolean get_arg(file, arg) /* indirect_command -- get argv, argc from a file */ /**/ -private void indirect_command(filename, oldarg0) - char *filename; - char *oldarg0; +private void indirect_command(char *filename, char *oldarg0) { FILE *argfile = NULL; if (ok_to_open(filename, "r")) @@ -478,7 +467,7 @@ private void indirect_command(filename, oldarg0) * Effect: * Halt program if cl_rdy is not true. *****************************************************************/ -private void ready_check() +private void ready_check(void) { if (!cl_rdy) { gprintf(ERROR, diff --git a/lib-src/libnyquist/nyquist/cmt/cmtcmd.c b/lib-src/libnyquist/nyquist/cmt/cmtcmd.c index 311a5876a..9fdf4cebb 100644 --- a/lib-src/libnyquist/nyquist/cmt/cmtcmd.c +++ b/lib-src/libnyquist/nyquist/cmt/cmtcmd.c @@ -6,45 +6,43 @@ #include "exec/types.h" #include "exec/exec.h" #endif -#include "cmtcmd.h" #include "cext.h" +#include "midifns.h" +#include "timebase.h" +#include "moxc.h" +#include "seq.h" +#include "cmtcmd.h" #include "userio.h" #include "string.h" #define HASHELEM(p) ((p).symbol_name) #define HASHVAL 50 #define HASHENTRIES 50 -#define HASHENTER hash_lookup +#define HASHENTER lookup #define HASHNOCOPY #include "hashrout.h" -void defvar(name, addr) - char *name; - int *addr; +void defvar(char *name, int *addr) + { - int i = hash_lookup(name); + intptr_t i = lookup(name); HASHENTRY(i).symb_type = var_symb_type; HASHENTRY(i).ptr.intptr = addr; } -void defun(name, addr) - char *name; - int (*addr)(); +void defun(char *name, seq_cmd_fn addr) { - int i = hash_lookup(name); + intptr_t i = lookup(name); HASHENTRY(i).symb_type = fn_symb_type; HASHENTRY(i).ptr.routine = addr; } -void defvec(name, addr, size) - char *name; - int *addr; - int size; +void defvec(char *name, int *addr, int size) { - int i = hash_lookup(name); + intptr_t i = lookup(name); HASHENTRY(i).symb_type = vec_symb_type; HASHENTRY(i).size = size; HASHENTRY(i).ptr.intptr = addr; diff --git a/lib-src/libnyquist/nyquist/cmt/cmtcmd.h b/lib-src/libnyquist/nyquist/cmt/cmtcmd.h index 22a64620a..2a2fab581 100644 --- a/lib-src/libnyquist/nyquist/cmt/cmtcmd.h +++ b/lib-src/libnyquist/nyquist/cmt/cmtcmd.h @@ -21,15 +21,15 @@ typedef struct symb_descr { int size; /* for array bounds checking */ union { int *intptr; - int (*routine)(); + seq_cmd_fn routine; } ptr; } symb_descr_node; -int hash_lookup(char *s); +intptr_t lookup(char *s); void defvar(char *name, int *addr); void defvec(char *name, int *addr, int size); -typedef int (*defun_type)(); -void defun(char *name, defun_type addr); +/* former defun_type replaced by seq_cmd_fn */ +void defun(char *name, seq_cmd_fn addr); #define HASHTYPE symb_descr_node #include "hash.h" diff --git a/lib-src/libnyquist/nyquist/cmt/cmtio.h b/lib-src/libnyquist/nyquist/cmt/cmtio.h index 232862b50..3e50ad957 100644 --- a/lib-src/libnyquist/nyquist/cmt/cmtio.h +++ b/lib-src/libnyquist/nyquist/cmt/cmtio.h @@ -1,7 +1,7 @@ #define NOCHAR -2 -extern int IOinputfd; -extern int IOnochar; +int IOinputfd; +int IOnochar; int IOsetup(int inputfd); int IOcleanup(void); diff --git a/lib-src/libnyquist/nyquist/cmt/hashrout.h b/lib-src/libnyquist/nyquist/cmt/hashrout.h index a566b9f8e..ddbc589d3 100644 --- a/lib-src/libnyquist/nyquist/cmt/hashrout.h +++ b/lib-src/libnyquist/nyquist/cmt/hashrout.h @@ -144,7 +144,7 @@ extern COUNTER; #ifdef HASHPOINT HASHTYPE * #else -int +intptr_t #endif HASHENTER (s) char *s; @@ -158,63 +158,63 @@ char *s; * I haven't bothered. */ -for(i = 0, hash = 0; s[i] != '\0' && i < 15; i++) - hash += (i + 1) * s[i]; -hash %= HASHVAL; + for (i = 0, hash = 0; s[i] != '\0' && i < 15; i++) + hash += (i + 1) * s[i]; + hash %= HASHVAL; -/* - * search for s in the table + /* + * search for s in the table */ -for(elem = hashtab[hash]; elem != NULL; elem = elem->h_next) - if(strcmp(s, HASHELEM((elem->h_elem))) == 0) { /* found it */ + for (elem = hashtab[hash]; elem != NULL; elem = elem->h_next) + if (strcmp(s, HASHELEM((elem->h_elem))) == 0) { /* found it */ #ifdef HASHPOINT - return(&elem->h_elem); + return &elem->h_elem; #else - return(elem - hashfirstchunk); + return (int) (elem - hashfirstchunk); #endif - } + } -if(hashindex >= HASHENTRIES) { + if (hashindex >= HASHENTRIES) { #ifdef HASHPOINT - char *calloc(); + char *calloc(); - hashindex = 0; - hashchunk = (hashelem *) calloc(HASHENTRIES, sizeof(hashelem)); - if(hashchunk == NULL) { - gprintf(FATAL, "No mem for hash symbol table\n"); - EXIT(1); + hashindex = 0; + hashchunk = (hashelem *) calloc(HASHENTRIES, sizeof(hashelem)); + if (hashchunk == NULL) { + gprintf(FATAL, "No mem for hash symbol table\n"); + EXIT(1); #ifdef COUNTER - COUNTER++; /* optional symbol counter */ + COUNTER++; /* optional symbol counter */ +#endif + } +#else + gprintf(FATAL, "No hash table space, increase HASHENTRIES\n"); + EXIT(1); #endif } -#else - gprintf(FATAL, "No hash table space, increase HASHENTRIES\n"); - EXIT(1); -#endif -} -/* - * Splice a new entry into the list and fill in the string field + /* + * Splice a new entry into the list and fill in the string field */ -elem = &hashchunk[hashindex++]; -elem->h_next = hashtab[hash]; -hashtab[hash] = elem; + elem = &hashchunk[hashindex++]; + elem->h_next = hashtab[hash]; + hashtab[hash] = elem; #ifdef HASHNOCOPY -HASHELEM((elem->h_elem)) = s; + HASHELEM((elem->h_elem)) = s; #else -{ - char *strcpy(); - HASHELEM((elem->h_elem)) = memget((strlen(s) + 1)); - strcpy(HASHELEM((elem->h_elem)), s); -} + { + char *strcpy(); + HASHELEM((elem->h_elem)) = memget((strlen(s) + 1)); + strcpy(HASHELEM((elem->h_elem)), s); + } #endif #ifdef HASHPOINT -return(&elem->h_elem); + return &elem->h_elem; #else -return(elem - hashfirstchunk); + return (int) (elem - hashfirstchunk); #endif } diff --git a/lib-src/libnyquist/nyquist/cmt/midifile.c b/lib-src/libnyquist/nyquist/cmt/midifile.c index 0ec113749..878441a59 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifile.c +++ b/lib-src/libnyquist/nyquist/cmt/midifile.c @@ -379,7 +379,7 @@ int c; } static void -metaevent(type) +metaevent(int type) { int leng = msgleng(); char *m = msg(); @@ -509,7 +509,7 @@ readvarinum() } static long -to32bit(c1,c2,c3,c4) +to32bit(int c1, int c2, int c3, int c4) { long value = 0L; @@ -521,8 +521,7 @@ to32bit(c1,c2,c3,c4) } static int -to16bit(c1,c2) -int c1, c2; +to16bit(int c1, int c2) { return ((c1 & 0xff ) << 8) + (c2 & 0xff); } diff --git a/lib-src/libnyquist/nyquist/cmt/midifns.c b/lib-src/libnyquist/nyquist/cmt/midifns.c index 78ee06b1f..a524f723e 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifns.c +++ b/lib-src/libnyquist/nyquist/cmt/midifns.c @@ -331,10 +331,10 @@ private ulong ticksAtStart = 0L; * ****************************************************************************/ -private void fixup(); -private void midi_init(); -extern boolean check_ascii(); /*userio.c*/ -private void musicterm(); +private void fixup(void); +private void midi_init(void); +extern boolean check_ascii(void); /*userio.c*/ +private void musicterm(void); /**************************************************************************** @@ -347,7 +347,7 @@ private void musicterm(); #define ALL_NOTES_OFF 0x7B /*DMH: from macmidi.c*/ -void alloff() +void alloff(void) { int c; @@ -371,8 +371,7 @@ void alloff() ***************************************************************/ #ifdef UNIX_ITC -void eventwait(timeout) - long timeout; +void eventwait(long timeout) { struct timeval unix_timeout; struct timeval *waitspec = NULL; @@ -422,8 +421,7 @@ void eventwait(timeout) } #else #ifdef BUFFERED_SYNCHRONOUS_INPUT -void eventwait(timeout) - long timeout; +void eventwait(long timeout) { struct timeval unix_timeout; struct timeval *waitspec = NULL; @@ -433,10 +431,11 @@ void eventwait(timeout) timeout -= gettime(); /* convert to millisecond delay */ unix_timeout.tv_sec = timeout / 1000; /* remainder become microsecs: */ - unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000; + unix_timeout.tv_usec = (int) + (timeout - (unix_timeout.tv_sec * 1000)) * 1000; waitspec = &unix_timeout; getrlimit(RLIMIT_NOFILE, &file_limit); - select(file_limit.rlim_max+1, 0, 0, 0, waitspec); + select((int) (file_limit.rlim_max+1), 0, 0, 0, waitspec); } else { int c = getc(stdin); ungetc(c, stdin); @@ -444,8 +443,7 @@ void eventwait(timeout) return; } #else -void eventwait(timeout) - long timeout; +void eventwait(long timeout) { struct timeval unix_timeout; struct timeval *waitspec = NULL; @@ -473,8 +471,7 @@ void eventwait(timeout) #else #ifndef UNIX /* since I couldn't use an else above, have to check UNIX here */ #ifdef WINDOWS -void eventwait(timeout) - long timeout; +void eventwait(long timeout) { if (timeout >= 0) { gprintf(TRANS, "eventwait: not implemented\n"); @@ -528,7 +525,7 @@ void exclusive(boolean onflag) * Print error message and call musicinit ****************************************************************************/ -private void fixup() +private void fixup(void) { gprintf(ERROR, "You forgot to call musicinit. I'll do it for you.\n"); musicinit(); @@ -730,7 +727,7 @@ private void setup_sysex(MDevent *event, u_char *buffer) sysex_n = event->msglen; } -private void flush_sysex() +private void flush_sysex(void) { mdFree(sysex_p); sysex_p = 0; @@ -740,7 +737,7 @@ private void flush_sysex() #ifdef MACINTOSH_OR_DOS #ifndef WINDOWS -public boolean check_midi() +public boolean check_midi(void) { if (buffhead == bufftail) return FALSE; else return TRUE; @@ -808,7 +805,7 @@ short getkey(boolean waitflag) * fakes it ****************************************************************************/ -ulong gettime() /*DMH: ulong is from mpu->midifns conversion, for Mac*/ +ulong gettime(void) /*DMH: ulong is from mpu->midifns conversion, for Mac*/ { #if HAS_GETTIMEOFDAY struct timeval timeval; @@ -864,8 +861,7 @@ ulong gettime() /*DMH: ulong is from mpu->midifns conversion, for Mac*/ * Waits until the amount of time specified has lapsed ****************************************************************************/ -void l_rest(time) -long time; +void l_rest(long time) { if (!initialized) fixup(); l_restuntil(time + gettime()); @@ -879,8 +875,7 @@ long time; * Waits until the specified time has been reached (absolute time) ****************************************************************************/ -void l_restuntil(time) -long time; +void l_restuntil(long time) { #ifdef MACINTOSH ulong now = gettime(); @@ -1598,7 +1593,7 @@ void musicinit() * Miscellaneous cleanup of things done by musicinit. ****************************************************************************/ -private void musicterm() +private void musicterm(void) { if (musictrace) gprintf(TRANS, "musicterm()\n"); initialized = FALSE; @@ -1778,7 +1773,7 @@ private int atox(char *t) #endif /* def DOS */ -private void midi_init() +private void midi_init(void) { #ifdef UNIX_IRIX_MIDIFNS #define PBUFLEN 4 diff --git a/lib-src/libnyquist/nyquist/cmt/midifns.h b/lib-src/libnyquist/nyquist/cmt/midifns.h index 99042d3a6..1bac6bf96 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifns.h +++ b/lib-src/libnyquist/nyquist/cmt/midifns.h @@ -106,7 +106,7 @@ void midi_clock(void); void midi_cont(boolean onflag); void midi_ctrl(int channel, int control, int value); void midi_exclusive(unsigned char *msg); -void midi_flush(); +void midi_flush(void); void midi_note(int channel, int pitch, int velocity); void midi_program(int channel, int program); void midi_real(boolean onflag); diff --git a/lib-src/libnyquist/nyquist/cmt/moxc.c b/lib-src/libnyquist/nyquist/cmt/moxc.c index 11f94e704..fd74d35bd 100644 --- a/lib-src/libnyquist/nyquist/cmt/moxc.c +++ b/lib-src/libnyquist/nyquist/cmt/moxc.c @@ -112,9 +112,9 @@ struct MsgPort pub_port; * Routines local to this module *****************************************************************************/ -private void callrun(); -private void decode(); -private void moxcterm(); +private void callrun(void); +private void decode(void); +private void moxcterm(void); /**************************************************************************** * callallcancel @@ -127,7 +127,7 @@ private void moxcterm(); * (not necessarily the timebase) and repeat. ****************************************************************************/ -void callallcancel() +void callallcancel(void) { if (moxcdebug) gprintf(GDEBUG, "cancel all calls\n"); while (timebase_queue) { @@ -142,7 +142,7 @@ void callallcancel() /* catchup -- bring current timebase up to date by running its calls */ /**/ -void catchup() +void catchup(void) { register call_type call; /* Remember where we're going in virtual time because setting the @@ -310,7 +310,7 @@ void causepri(delay_type delay, int pri, void (*routine)(call_args_type args), c * executes the previously scheduled call call and deallocates it ****************************************************************************/ -private void callrun() +private void callrun(void) { call_type call; if (moxcdebug) { @@ -326,7 +326,7 @@ private void callrun() /* remove first call from timebase */ call = remove_call(timebase); - if (debug) gprintf(TRANS, "callrun call %lx\n", (ulong)call); + if (debug) gprintf(TRANS, "callrun call %p\n", call); insert_base(timebase); virttime = call->u.e.time; /* virtual time of the call */ if (moxcdebug) callshow(call); @@ -461,7 +461,7 @@ void moxcwait(dateoftimeout) * Effect: dispatch on user inputs, cause calls ****************************************************************************/ -private void decode() +private void decode(void) { /* It is important that midi_data is on a word boundary because we copy to it by doing a word transfer. @@ -658,7 +658,7 @@ void moxcrun() /* moxcterm -- clean up after moxcinit */ /**/ -private void moxcterm() +private void moxcterm(void) { #ifdef AMIGA FreeSignal((long) pub_port_signal); diff --git a/lib-src/libnyquist/nyquist/cmt/record.c b/lib-src/libnyquist/nyquist/cmt/record.c index 07cb18f9c..c59b31b76 100644 --- a/lib-src/libnyquist/nyquist/cmt/record.c +++ b/lib-src/libnyquist/nyquist/cmt/record.c @@ -81,15 +81,15 @@ private boolean fixed_octave; /* used to avoid many error messages */ /**************************************************************************** * Routines local to this module ****************************************************************************/ -private void bend_filter(); -private void byteorder(); -private void ctrl_filter(); -private int event_bend(); -private void filter(); -private long getdur(); -private long getnext(); -private char map_ctrl(); -private void output(); +private void bend_filter(note_type note, note_type last, long now); +private void byteorder(void); +private void ctrl_filter(note_type note, note_type last, long now); +private int event_bend(note_type note); +private void filter(note_type last); +private long getdur(int i, note_type last, int ped, long now); +private long getnext(int i, note_type last, long now); +private char map_ctrl(int control); +private void output(FILE *fp, note_type last, boolean absflag); /**************************************************************************** * bend_filter @@ -105,10 +105,7 @@ private void output(); * the time. ****************************************************************************/ -private void bend_filter(note, last, now) -note_type note; /* current note */ -note_type last; /* the last recorded event */ -long now; /* the current time */ +private void bend_filter(note_type note, note_type last, long now) { /* first see if there is another bend in this time * slot. @@ -132,7 +129,7 @@ long now; /* the current time */ * check out assumptions about byte order and placement ****************************************************************************/ -private void byteorder() +private void byteorder(void) { note_node test_event; if ((sizeof(test_event) != 4) || @@ -166,10 +163,7 @@ private void byteorder() * the time. ****************************************************************************/ -private void ctrl_filter(note, last, now) -note_type note; /* the current note */ -note_type last; /* the last recorded event */ -long now; /* the current time */ +private void ctrl_filter(note_type note, note_type last, long now) { /* see if there is another control change in this time * slot. @@ -196,8 +190,7 @@ long now; /* the current time */ * returns int: an 8 bit pitch bend number ****************************************************************************/ -private int event_bend(note) -note_type note; +private int event_bend(note_type note) { return((int) (((note->n[1]) >> 6) + ((note->n[2]) << 1))); } @@ -212,8 +205,7 @@ note_type note; * noop data (the current time is used as a noop) ****************************************************************************/ -private void filter(last) -note_type last; +private void filter(note_type last) { note_type note; /* loop control variable */ long now=0; /* last time seen */ @@ -263,11 +255,7 @@ note_type last; * pressed (this event will also start another note). ****************************************************************************/ -private long getdur(i, last, ped, now) -int i; -note_type last; -int ped; -long now; +private long getdur(int i, note_type last, int ped, long now) { int key = TRUE; /* flag that says if note is on */ long start = now; @@ -316,10 +304,7 @@ long now; * (returns time of last event if nothing else is found) ****************************************************************************/ -private long getnext(i, last, now) -int i; /* the index of the current note */ -note_type last; /* pointer to last valid data */ -long now; /* the current time */ +private long getnext(int i, note_type last, long now) { i++; /* advance to next item */ for (; event_buff + i < last; i++) { @@ -352,8 +337,7 @@ long now; /* the current time */ * MODWHEEL, FOOT ****************************************************************************/ -private char map_ctrl(control) -int control; +private char map_ctrl(int control) { switch (control) { /* 'J' is no longer code for PORTARATE @@ -389,10 +373,7 @@ int control; * clock tick for each continuous change parameter ****************************************************************************/ -private void output(fp, last, absflag) -FILE *fp; -note_type last; -boolean absflag; +private void output(FILE *fp, note_type last, boolean absflag) { int i; /* loop counter */ int command; /* the current command */ @@ -400,7 +381,8 @@ boolean absflag; int last_velocity = -1; /* used to filter repeated Lnn attributes */ int last_voice = 0; /* the default adagio channel (1) */ int ped = FALSE; /* flag maintains state of pedal */ - int how_many = last - event_buff; + /* size of event_buff is seems to be about 20000 events */ + int how_many = (int) (last - event_buff); long now=0; /* the time of the next event */ if (fp == NULL) { @@ -583,7 +565,7 @@ boolean rec_init(boolean bender) MIN((biggestChunk - SPACE_FOR_PLAY), ENOUGH_ROOM); /* leave SPACE_FOR_PLAY contiguous bytes of memory */ } - max_notes = spaceForRecord / sizeof(note_node); + max_notes = (long) (spaceForRecord / sizeof(note_node)); /* gprintf(GDEBUG,"max_notes = %d\n", max_notes);*/ event_buff = (note_type) MALLOC(spaceForRecord); if (event_buff == NULL) { @@ -650,4 +632,4 @@ overflow: return FALSE; } -#endif \ No newline at end of file +#endif diff --git a/lib-src/libnyquist/nyquist/cmt/seq.c b/lib-src/libnyquist/nyquist/cmt/seq.c index 3de2e5b25..bb04a5b38 100644 --- a/lib-src/libnyquist/nyquist/cmt/seq.c +++ b/lib-src/libnyquist/nyquist/cmt/seq.c @@ -106,7 +106,8 @@ chunk_type chunk_create(boolean first_flag) private void clock_tick(call_args_type args) { seq_type seq = (seq_type) args->arg[0]; - time_type fraction = (time_type) args->arg[1]; + // double cast to avoid pointer-to-long truncation on WIN64 + time_type fraction = (time_type) ((intptr_t) args->arg[1]); int delay; fraction += clock_ticksize; delay = fraction >> 16; @@ -171,14 +172,8 @@ private event_type event_create(seq, size, etime, eline) /* insert_call -- add a call event to the seq */ /**/ -event_type insert_call(seq, ctime, cline, voice, addr, value, n) - seq_type seq; - time_type ctime; - int cline; - int voice; - int (*addr)(); - long value[SEQ_MAX_PARMS]; - int n; +event_type insert_call(seq_type seq, time_type ctime, int cline, int voice, + int (*addr)(seq_arg_t args), long value[SEQ_MAX_PARMS], int n) { int i; register event_type event = event_create(seq, callsize, ctime, cline); @@ -227,13 +222,8 @@ event_type insert_clock(seq, ctime, cline, ticksize) /* insert_ctrl -- add a control to the seq */ /**/ -event_type insert_ctrl(seq, ctime, cline, ctrl, voice, value) - seq_type seq; - time_type ctime; - int cline; - int ctrl; - int voice; - int value; +event_type insert_ctrl(seq_type seq, time_type ctime, + int cline, int ctrl, int voice, int value) { register event_type event = event_create(seq, ctrlsize, ctime, cline); if (seq_print) { @@ -299,7 +289,7 @@ def_type insert_def(seq, symbol, definition, deflen) { int i; def_type defn = (def_type) chunk_alloc(seq, sizeof(def_node)); - defn->symbol = chunk_alloc(seq, strlen(symbol) + 1); + defn->symbol = chunk_alloc(seq, (int) strlen(symbol) + 1); defn->definition = (unsigned char *) chunk_alloc(seq, deflen); strcpy(defn->symbol, symbol); for (i = 0; i < deflen; i++) { @@ -718,7 +708,8 @@ private void ramp_event(call_args_type args) unsigned int to_value = (unsigned int) ((size_t) args->arg[3]); /* increment is also a fixed-point fraction, so int is fine */ int increment = (int) ((size_t) args->arg[4]); - time_type step = (time_type) args->arg[5];; + /* double cast to avoid pointer to long truncation warning in WIN64: */ + time_type step = (time_type) ((intptr_t) args->arg[5]); /* n is the number of steps remaining. int is big enough. */ int n = (int) ((size_t) args->arg[6]); diff --git a/lib-src/libnyquist/nyquist/cmt/seq.h b/lib-src/libnyquist/nyquist/cmt/seq.h index 85548b2e3..4cba97414 100644 --- a/lib-src/libnyquist/nyquist/cmt/seq.h +++ b/lib-src/libnyquist/nyquist/cmt/seq.h @@ -71,12 +71,17 @@ struct seti_struct { #define SEQ_MAX_PARMS 8 + +typedef struct seq_arg_struct { + long a[SEQ_MAX_PARMS]; +} seq_arg_t; + +typedef int (*seq_cmd_fn)(seq_arg_t args); + struct cause_struct { - int (*routine)(); + seq_cmd_fn routine; /* make a structure so we can copy by value */ - struct seq_arg_struct { - long a[SEQ_MAX_PARMS]; - } args; + seq_arg_t args; }; @@ -228,16 +233,16 @@ chunk_type chunk_create(boolean first_flag); extern boolean seq_print; /* debugging switch */ void seq_extensions(void); /* to be defined outside of seq -- user dependent */ -event_type insert_call(seq_type seq, time_type ctime, int cline, - int voice, int (*addr)(), long value[], int n); +event_type insert_call(seq_type seq, time_type ctime, int cline, int voice, + int (*addr)(seq_arg_t args), long value[SEQ_MAX_PARMS], int n); event_type insert_clock(seq_type seq, time_type ctime, int cline, time_type ticksize); event_type insert_ctrl(seq_type seq, time_type ctime, int cline, int ctrl, int voice, int value); - /* LISP: (SEQ-INSERT-CTRL SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */ + /* LISP: (SEQ-INSERT-CTRL SEQ LONG LONG LONG LONG LONG) */ event_type insert_ctrlramp(seq_type seq, time_type rtime, int rline, int voice, time_type step, time_type dur, int ctrl, int v1, int v2); - /* LISP: (SEQ-INSERT-RAMP SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */ + /* LISP: (SEQ-INSERT-RAMP SEQ LONG LONG LONG LONG LONG LONG LONG LONG) */ def_type insert_def(seq_type seq, char *symbol, unsigned char *definition, int deflen); event_type insert_deframp(seq_type seq, time_type rtime, int rline, int voice, @@ -245,12 +250,12 @@ event_type insert_deframp(seq_type seq, time_type rtime, int rline, int voice, int nparms, short parms[], int parm_num, int to_value); event_type insert_macctrl(seq_type seq, time_type ctime, int cline, int ctrl, int voice, int value); - /* LISP: (SEQ-INSERT-MACCTRL SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */ + /* LISP: (SEQ-INSERT-MACCTRL SEQ LONG LONG LONG LONG LONG) */ event_type insert_macro(seq_type seq, time_type ctime, int cline, def_type def, int voice, int nparms, short *parms); event_type insert_note(seq_type seq, time_type ntime, int nline, int voice, int pitch, time_type dur, int loud); - /* LISP: (SEQ-INSERT-NOTE SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */ + /* LISP: (SEQ-INSERT-NOTE SEQ LONG LONG LONG LONG LONG LONG) */ event_type insert_seti(seq_type seq, time_type stime, int sline, int voice, int *addr, int value); void noop(seq_type seq); diff --git a/lib-src/libnyquist/nyquist/cmt/seqmread.c b/lib-src/libnyquist/nyquist/cmt/seqmread.c index c9dcd49a3..d43ac9e95 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqmread.c +++ b/lib-src/libnyquist/nyquist/cmt/seqmread.c @@ -31,10 +31,10 @@ #include "midifile.h" #include "tempomap.h" -int filegetc(); -void initfuncs(); -void prtime(); -void snding_free(); +int filegetc(void); +void initfuncs(void); +void prtime(void); +void snding_free(void); typedef struct snding_struct { struct snding_struct *next; diff --git a/lib-src/libnyquist/nyquist/cmt/seqmwrite.c b/lib-src/libnyquist/nyquist/cmt/seqmwrite.c index 026859546..f7bc4bde9 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqmwrite.c +++ b/lib-src/libnyquist/nyquist/cmt/seqmwrite.c @@ -43,20 +43,21 @@ extern time_type clock_ticksize; /* millisec per tick shifted 16 bits */ extern boolean clock_running; /* TRUE if clock is running */ extern boolean use_midi_clock; -private void smfw_bend(); +private void smfw_bend(seq_type seq, int voice, int value); private void smfw_cause_noteoff(seq_type seq, time_type delay, int voice, int pitch); -private void smfw_ctrl(); -private void smfw_deltatime(); -private void smfw_dotrack(); -private void smfw_exclusive(); +private void smfw_ctrl(seq_type seq, int voice, int ctrl_name, int value); +private void smfw_deltatime(void); +private void smfw_dotrack(seq_type seq); +private void smfw_exclusive(int length, unsigned char *msg); private void smfw_noteoff(call_args_type args); -private void smfw_noteon(); +private void smfw_noteon(seq_type seq, int voice, int pitch, int vel); private void smfw_process_event(call_args_type args); private void smfw_ramp_event(call_args_type args); -private void smfw_send_macro(); +private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[], + int parm_num, int value); private void smfw_touch(seq_type seq, int voice, int value); -private void writevarlen(); +private void writevarlen(long value); /* smfw_bend -- write a pitch bend to a midi file */ @@ -97,8 +98,8 @@ private void smfw_cause_noteoff(seq_type seq, time_type delay, int voice, private void smfw_clock_event(call_args_type args) { - time_type old_ticksize = (time_type)(args->arg[0]); - time_type new_ticksize = (time_type)(args->arg[1]); + time_type old_ticksize = (time_type) ((intptr_t) args->arg[0]); + time_type new_ticksize = (time_type)((intptr_t) args->arg[1]); time_type temp_ticksize = new_ticksize; new_ticksize = scale(new_ticksize, 375L, 1024L); /* (new_ticksize >> 16) * 24000 ms/clock becomes us/midiquarter */ @@ -362,7 +363,7 @@ private void smfw_process_event(call_args_type args) break; case ESC_CTRL: switch (event->value) { - time_type this_event; + /* called routine will write to midifile in execution: */ case CALL_VALUE: sequence = seq; @@ -388,7 +389,7 @@ private void smfw_process_event(call_args_type args) /* set new ticksize: */ last_tick_size = clock_ticksize; } else { /*not on tempo track*/ - this_event = ((virttime - last_clock_event) * + long this_event = ((virttime - last_clock_event) * ((2500L << 16) / last_tick_size)) / 100; if (debug) gprintf(TRANS, "track != 0: Lastev: %ld Thisev: %ld NewLast: %ld\n", @@ -519,14 +520,10 @@ private void smfw_ramp_event(call_args_type args) /* smfw_send_macro -- write msg to midi file from a seq "macro" event */ /**/ -private void smfw_send_macro(ptr, voice, parameter, parm_num, value) - register unsigned char *ptr; - int voice; - short parameter[]; - int parm_num; - int value; +private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[], + int parm_num, int value) { - register unsigned char code, *loc; + unsigned char code, *loc; while ((code = *ptr++)) { loc = ptr + *ptr; ptr++; @@ -682,9 +679,8 @@ void seq_write_smf(seq, outfile) /* writevarlen -- write a variable length integer to midi file */ /**/ -private void writevarlen(value) - register long value; -{ +private void writevarlen(long value) +{ register ulong buffer; if (debug) gprintf(TRANS, "variable length quantity..."); diff --git a/lib-src/libnyquist/nyquist/cmt/seqread.c b/lib-src/libnyquist/nyquist/cmt/seqread.c index ab785f392..55f0c770c 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqread.c +++ b/lib-src/libnyquist/nyquist/cmt/seqread.c @@ -116,40 +116,40 @@ extern int abort_flag; /**************************************************************************** * Routines local to this module: ****************************************************************************/ -private void do_a_rest(); -private time_type doabsdur(); -private int doabspitch(); -private void doclock(); -private void docomment(); -private void doctrl(); -private void dodef(); -private time_type dodur(); -private void doerror(); -private int doloud(); -void domacro(); -private void donextdur(); -private int dopitch(); -private void doprogram(); -private void dorate(); -private void doset(); -private void dospecial(); -private time_type dosymdur(); -private void dotempo(); -private void dotime(); -private void dovoice(); -private void fferror(); -private void init(); -private int issymbol(); -private void marker(); -private void parseend(); -private void parsefield(); -private boolean parsenote(); -private boolean parseparm(); -private int scan(); -private int scan1(); -private long scanint(); -private void scansymb(); -private long scansgnint(); +private void do_a_rest(void); +private time_type doabsdur(void); +private int doabspitch(void); +private void doclock(void); +private void docomment(void); +private void doctrl(int n); +private void dodef(void); +private time_type dodur(void); +private void doerror(void); +private int doloud(void); +void domacro(void); +private void donextdur(void); +private int dopitch(void); +private void doprogram(void); +private void dorate(void); +private void doset(boolean vecflag); +private void dospecial(void); +private time_type dosymdur(void); +private void dotempo(void); +private void dotime(void); +private void dovoice(void); +private void fferror(char *s); +private void init(void); +private int issymbol(void); +private void marker(int count); +private void parseend(void); +private void parsefield(void); +private boolean parsenote(void); +private boolean parseparm(long *valptr); +private int scan(void); +private int scan1(char *start); +private long scanint(void); +private void scansymb(char *); +private long scansgnint(void); /**************************************************************************** * data structures for parser lookup tables @@ -313,10 +313,7 @@ private seq_type the_score; /* this is the score we are parsing */ * where the parameter should be substituted * and length is the number of data bytes */ -boolean def_append(def, nparms, data) - unsigned char def[]; - int nparms; - int data; +boolean def_append(unsigned char def[], int nparms, int data) { int base = (nparms << 1) + 1; /* this byte is the length */ /* first parameter has to be able to reference last byte: */ @@ -329,8 +326,7 @@ boolean def_append(def, nparms, data) } -def_type def_lookup(symbol) - char *symbol; +def_type def_lookup(char *symbol) { def_type defn = seq_dictionary(the_score); while (defn) { @@ -343,10 +339,7 @@ def_type def_lookup(symbol) } -void def_parm(def, nparms, code) - unsigned char def[]; - int nparms; - int code; +void def_parm(unsigned char def[], int nparms, int code) { int i, j; /* in order to insert a 2-byte parameter descriptor, the offsets from @@ -373,7 +366,7 @@ void def_parm(def, nparms, code) * Effect: parses a rest (R) command ****************************************************************************/ -private void do_a_rest() +private void do_a_rest(void) { if (token[fieldx]) fferror("Nothing expected after rest"); @@ -385,7 +378,7 @@ private void do_a_rest() * Effect: parses an absolute dur (U) command ****************************************************************************/ -private time_type doabsdur() +private time_type doabsdur(void) { time_type result=1000L; register char c; @@ -405,7 +398,7 @@ private time_type doabsdur() * Effect: parses an absolute pitch (P) command ****************************************************************************/ -private int doabspitch() +private int doabspitch(void) { int result = 60; int startx = fieldx; @@ -441,7 +434,7 @@ private int doabspitch() is applied to the final computed duration after all other scaling is applied. */ -private void doartic() +private void doartic(void) { if (isdigit(token[fieldx])) { artic = (int) scanint(); @@ -453,7 +446,7 @@ private void doartic() /* docall -- parse a call in the form !CALL fn(p1,p2,p3) */ /**/ -private void docall() +private void docall(void) { boolean error_flag = TRUE; ndurp = FALSE; @@ -471,7 +464,7 @@ private void docall() if (fieldx == 1) fferror("Routine name expected"); else if (token[fieldx] != '(') fferror("Open paren expected"); else { - desc = &HASHENTRY(hash_lookup(symbol)); + desc = &HASHENTRY(lookup(symbol)); if (!desc->symb_type) { fieldx = 0; fferror("Function not defined"); @@ -538,9 +531,9 @@ private void docall() * ticksize = (beattime / 24) = ((60sec/tempo)/24) = * ((60000ms/tempo)/24) = (60000/24)/tempo = 2500/tempo */ -private void doclock() +private void doclock(void) { - int oldticksize = ticksize; + long oldticksize = ticksize; ticksize = (2500L << 16) / tempo; insert_clock(the_score, seqround(thetime) - (oldticksize >> 17), lineno, ticksize); @@ -552,7 +545,7 @@ private void doclock() * Effect: parses a comment (*) command ****************************************************************************/ -private void docomment() +private void docomment(void) { line[linex] = '\n'; /* force end of line to skip comment line */ line[linex+1] = EOS; @@ -565,8 +558,7 @@ private void docomment() * Effect: parses a control (K, M, O, X, or Y) command ****************************************************************************/ -private void doctrl(n) -int n; +private void doctrl(int n) { ctrlval[n] = (int) scanint(); if (token[fieldx]) { @@ -578,7 +570,7 @@ int n; } -private void dodef() +private void dodef(void) { /* maximum def size is 256 + 9 parms * 2 + 2 = 276 */ unsigned char def[280]; @@ -667,7 +659,7 @@ private void dodef() * * Returns: duration in "precise" units ****************************************************************************/ -private time_type dodur() +private time_type dodur(void) { time_type result = 0L; symbolic_dur_flag = TRUE; @@ -689,7 +681,7 @@ private time_type dodur() * Effect: parse an unrecognized field by reporting an error ****************************************************************************/ -private void doerror() +private void doerror(void) { fieldx = 0; fferror("Bad field"); @@ -700,8 +692,9 @@ private void doerror() * Effect: parse a loudness (L) command ****************************************************************************/ -private int doloud() +private int doloud(void) { + size_t ii; int i, j; int result; int oldfieldx = fieldx; @@ -732,13 +725,13 @@ private int doloud() } scansymb(symbol); newfieldx = fieldx; - if ((i = strlen(symbol)) > 3 ) { /* maximum is 3, e.g. "ppp" */ + if ((ii = strlen(symbol)) > 3 ) { /* maximum is 3, e.g. "ppp" */ fieldx = oldfieldx; fferror("Loudness field too long"); fieldx = newfieldx; return 100; } - symbol[i + 1] = '\0'; /* pad short symbols with 0 */ + symbol[ii + 1] = '\0'; /* pad short symbols with 0 */ /* e.g. "p\0" -> "p\0\0" */ for (i = 0; i <= 7; i++) { /* loop through possibilities */ for (j = 0; j <= 2; j++) { /* test 3 characters */ @@ -756,7 +749,7 @@ private int doloud() } -void domacro() +void domacro(void) { int control_num; int value; @@ -827,7 +820,7 @@ void domacro() * The form N is parsed directly with scanint(). ****************************************************************************/ -private void donextdur() +private void donextdur(void) { ndurp = TRUE; /* flag that N was given */ if (isdigit(token[fieldx])) { @@ -846,7 +839,7 @@ private void donextdur() * Effect: parses a pitch command ****************************************************************************/ -private int dopitch() +private int dopitch(void) { int p, octave=0; int octflag = FALSE; /* set if octave is specified */ @@ -893,7 +886,7 @@ private int dopitch() * Effect: parses a program change (Z) command ****************************************************************************/ -private void doprogram() +private void doprogram(void) { register int program = (int) scanint(); ctrlflag[PROGRAM_CTRL] = ctrlflag[0] = TRUE; @@ -912,7 +905,7 @@ private void doprogram() } -private void doramp() +private void doramp(void) { int values[2]; time_type stepsize = 100L; /* default 10 per second */ @@ -1008,7 +1001,7 @@ private void doramp() * Effect: parses a !rate command ****************************************************************************/ -private void dorate() +private void dorate(void) { linex += scan(); if (!token[0]) @@ -1031,14 +1024,13 @@ private void dorate() } -private void doset(vec_flag) - boolean vec_flag; +private void doset(boolean vec_flag) { ndurp = FALSE; linex += scan(); if (!token[0]) fferror("Variable name expected"); else { - struct symb_descr *desc = &HASHENTRY(hash_lookup(token)); + struct symb_descr *desc = &HASHENTRY(lookup(token)); if (!desc->symb_type) fferror("Called function not defined"); else if (vec_flag && (desc->symb_type != vec_symb_type)) { fferror("This is not an array"); @@ -1079,7 +1071,7 @@ private void doset(vec_flag) default: fieldx++; if (i < numargs) { - value[i++] = seqround(dodur()); + value[i++] = (int) seqround(dodur()); } else fferror(too_many_error); break; } @@ -1110,7 +1102,7 @@ private void doset(vec_flag) * Effect: parses special (those starting with "!") commands ****************************************************************************/ -private void dospecial() +private void dospecial(void) { switch (issymbol()) { case sym_tempo: @@ -1160,7 +1152,7 @@ private void dospecial() * Effect: parses a duration (^, %, S, I, Q, H, or W) command ****************************************************************************/ -private time_type dosymdur() +private time_type dosymdur(void) { int i, dotcnt = 0; long dotfactor; @@ -1213,7 +1205,7 @@ private time_type dosymdur() * Effect: parses a !tempo command ****************************************************************************/ -private void dotempo() +private void dotempo(void) { linex += scan(); if (!token[0]) @@ -1243,7 +1235,7 @@ private void dotempo() * Implementation: see implementation of donextdur() ****************************************************************************/ -private void dotime() +private void dotime(void) { if (isdigit(token[fieldx])) { thetime = precise(scanint()); @@ -1262,7 +1254,7 @@ private void dotime() * Effect: parse a voice (V) command (the voice is the MIDI channel) ****************************************************************************/ -private void dovoice() +private void dovoice(void) { if (isdigit(token[fieldx])) { voice = (int) scanint(); @@ -1296,11 +1288,10 @@ private void dovoice() * carat will point to the first character in the field. ****************************************************************************/ -private void fferror(s) - char *s; +private void fferror(char *s) { gprintf(ERROR, "%3d | %s", lineno, line); - marker(linex-strlen(token)+fieldx+1+6); + marker((int) (linex - strlen(token) + fieldx + 1 + 6)); gprintf(ERROR, "Error: %s.\n", s); } @@ -1310,7 +1301,7 @@ private void fferror(s) * initializes the state variables ****************************************************************************/ -private void init() +private void init(void) { int i; @@ -1354,7 +1345,7 @@ private void init() * with note-ons. ****************************************************************************/ -private boolean ins_a_note() +private boolean ins_a_note(void) { long the_dur = (trunc(dur) * artic + 50) / 100; int the_pitch = pitch; @@ -1377,7 +1368,7 @@ private boolean ins_a_note() * insert one control change for each ctrlflag[i] that is TRUE ****************************************************************************/ -private boolean ins_ctrls() +private boolean ins_ctrls(void) { int i; event_type ctrl; @@ -1400,7 +1391,7 @@ private boolean ins_ctrls() * Assumes: token[1] has the symbol to look up (token[0] == '!') ****************************************************************************/ -private int issymbol() +private int issymbol(void) { int i, symb_num; char *sym; @@ -1426,8 +1417,7 @@ private int issymbol() * prints a carat (^) at the position specified on file stderr ****************************************************************************/ -private void marker(count) -int count; +private void marker(int count) { int i; char s[128]; @@ -1444,7 +1434,7 @@ int count; * ****************************************************************/ -private void parseend() +private void parseend(void) { boolean done = FALSE; while (!done) { @@ -1477,7 +1467,7 @@ private void parseend() * ****************************************************************************/ -private void parsefield() +private void parsefield(void) { fieldx = 1; switch (token[0]) { @@ -1566,7 +1556,7 @@ private void parsefield() * line contains a string to be parsed ****************************************************************************/ -private boolean parsenote() +private boolean parsenote(void) { boolean out_of_memory = FALSE; int i; @@ -1629,8 +1619,7 @@ private boolean parsenote() } -private boolean parseparm(valptr) - long *valptr; +private boolean parseparm(long *valptr) { register char c = token[fieldx]; if (isdigit(c) || c == '-') { @@ -1717,7 +1706,7 @@ public time_type scale(x, n, d) * scanning stops on delimiter: one of space, tab, newline, semicolon ****************************************************************************/ -private int scan() +private int scan(void) { char *start = line + linex; register char c; @@ -1755,8 +1744,7 @@ private int scan() * copies one char from start into token, converting to upper case ****************************************************************************/ -private int scan1(start) -char *start; +private int scan1(char *start) { int i = 0; @@ -1780,7 +1768,7 @@ char *start; * fieldx is incremented to end of the integer ****************************************************************************/ -private long scanint() +private long scanint(void) { long i = 0; char c; @@ -1793,7 +1781,7 @@ private long scanint() return i; } -private long scansgnint() +private long scansgnint(void) { if (token[fieldx] == '-') { fieldx++; @@ -1809,8 +1797,7 @@ private long scansgnint() /* scansymb -- scan a symbol from the token */ /**/ -private void scansymb(str) - char *str; +private void scansymb(char *str) { char c; while ((c = token[fieldx])) { diff --git a/lib-src/libnyquist/nyquist/cmt/seqwrite.c b/lib-src/libnyquist/nyquist/cmt/seqwrite.c index fde07469e..05de9a77b 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqwrite.c +++ b/lib-src/libnyquist/nyquist/cmt/seqwrite.c @@ -20,12 +20,13 @@ #include "userio.h" #include "record.h" -private boolean next_event_time(); -private void write_event(); +private boolean next_event_time(event_type event, time_type *next_time); +private void write_event(seq_type seq, event_type event, FILE *f, + boolean abs_flag); private void write_velocity(FILE *f, int velocity); -private void write_voice(); +private void write_voice(FILE *f, int voice); private void write_rest(FILE *f, event_type ev, boolean abs_flag); -private void write_time(); +private void write_time(FILE *f, event_type event, boolean abs_flag); private boolean clock_started; private long clock_half_tick; @@ -46,9 +47,7 @@ private int last_voice = seq_dflt_voice; /* * NOTE: clock events are ignored (unless this is the first clock event) */ -private boolean next_event_time(event, next_time) - event_type event; - time_type *next_time; +private boolean next_event_time(event_type event, time_type *next_time) { while (event) { if (vc_ctrl(event->nvoice) == ESC_CTRL && @@ -101,11 +100,8 @@ private char ctrl_letter[] = "?KMOXYZ"; /* write_event -- write a single event to a file */ /**/ -private void write_event(seq, event, f, abs_flag) - seq_type seq; - event_type event; - FILE *f; - boolean abs_flag; +private void write_event(seq_type seq, event_type event, FILE *f, + boolean abs_flag) { int voice = vc_voice(event->nvoice); @@ -231,10 +227,7 @@ private void write_rest(FILE *f, event_type ev, boolean abs_flag) /* write_time -- write the final field on the line with N or T command */ /**/ -private void write_time(f, event, abs_flag) - FILE *f; - event_type event; - boolean abs_flag; +private void write_time(FILE *f, event_type event, boolean abs_flag) { time_type next_time; @@ -271,9 +264,7 @@ private void write_velocity(FILE *f, int velocity) /* write_voice -- write the voice field */ /**/ -private void write_voice(f, voice) - FILE *f; - int voice; +private void write_voice(FILE *f, int voice) { if (last_voice != voice) { last_voice = voice; diff --git a/lib-src/libnyquist/nyquist/cmt/tempomap.c b/lib-src/libnyquist/nyquist/cmt/tempomap.c index e56b9bf0e..b5e713691 100644 --- a/lib-src/libnyquist/nyquist/cmt/tempomap.c +++ b/lib-src/libnyquist/nyquist/cmt/tempomap.c @@ -13,7 +13,7 @@ #include "seq.h" #include "tempomap.h" -static time_type elapsed_time(); +static time_type elapsed_time(long tempo, long beat); /* tempomap_create -- create a tempomap */ /**/ @@ -116,9 +116,7 @@ time_type tempomap_lookup(tempomap, beat) /* * the time returned is in units of 4us. */ -static time_type elapsed_time(tempo, beat) - long tempo; - long beat; +static time_type elapsed_time(long tempo, long beat) { return (time_type)((tempo * beat) >> 2); } diff --git a/lib-src/libnyquist/nyquist/cmt/timebase.c b/lib-src/libnyquist/nyquist/cmt/timebase.c index 65e04a737..947b64130 100644 --- a/lib-src/libnyquist/nyquist/cmt/timebase.c +++ b/lib-src/libnyquist/nyquist/cmt/timebase.c @@ -21,7 +21,7 @@ timebase_type timebase_queue = NULL; /* waiting to run timebase queue */ call_type callfree = NULL; /* free list */ -private void fatal(); +private void fatal(const char *msg); /**************************************************************************** @@ -124,9 +124,9 @@ void callshow(call) call_type call; { int i; - gprintf(TRANS,"address: %lx\n", (ulong)call); + gprintf(TRANS,"address: %p\n", call); gprintf(TRANS,"time: %ld\n", call->u.e.time); - gprintf(TRANS,"routine: %lx\n", (ulong)call->u.e.routine); + gprintf(TRANS,"routine: %p\n", call->u.e.routine); gprintf(TRANS,"parameters:"); for (i = 0; i < MAX_CALL_ARGS; i++) { gprintf(TRANS, " %p", call->u.e.p.arg[i]); @@ -141,8 +141,7 @@ void callshow(call) * Effect: print message and exit program ***************************************************************/ -private void fatal(msg) - char *msg; +private void fatal(const char *msg) { gprintf(FATAL, msg); EXIT(1); diff --git a/lib-src/libnyquist/nyquist/cmt/timebase.h b/lib-src/libnyquist/nyquist/cmt/timebase.h index c154171cd..cd67b379c 100644 --- a/lib-src/libnyquist/nyquist/cmt/timebase.h +++ b/lib-src/libnyquist/nyquist/cmt/timebase.h @@ -16,7 +16,7 @@ typedef struct call { struct { time_type time; /* virtual time of this call */ int priority; /* an 8-bit the priority, low priority first */ - void (*routine)(); /* who to call */ + void (*routine)(call_args_type args); /* who to call */ call_args_node p; /* what to pass */ } e; struct call *p; /* used to link free calls */ diff --git a/lib-src/libnyquist/nyquist/cmt/userio.c b/lib-src/libnyquist/nyquist/cmt/userio.c index 0c7e9972d..a5fe1b480 100644 --- a/lib-src/libnyquist/nyquist/cmt/userio.c +++ b/lib-src/libnyquist/nyquist/cmt/userio.c @@ -153,10 +153,6 @@ extern int debug; #include "xlisp.h" #endif -int IOinputfd; /* input file descriptor (usually 0) */ - -int IOnochar; /* Value to be returned by IOgetchar() - where there is no input to be had */ /**************************************************************************** * @@ -164,8 +160,8 @@ int IOnochar; /* Value to be returned by IOgetchar() * ****************************************************************************/ -int GetReadFileName(); -int GetWriteFileName(); +int GetReadFileName(void); +int GetWriteFileName(void); #ifdef MACINTOSH private void PtoC_StrCopy(char *p1, char *p2); @@ -192,7 +188,7 @@ public int abort_flag; /* control C or control G equivalent */ public int redirect_flag; /* check whether the I/O has been redirected-- Added by Ning Hu Apr.2001*/ /* extern void musicterm(); */ /*DMH: from macmidi.c, to allow abort_check*/ -public boolean ascii_input(); +public boolean ascii_input(char *c); /**************************************************************************** * @@ -811,7 +807,7 @@ void readln(fp) #ifdef DOTS_FOR_ARGS /* define with ... in arg list and use vsnprintf to get temp1 */ -public void gprintf(long where, char *format, ...) +public void gprintf(long where, const char *format, ...) { char temp1[GPRINTF_MESSAGE_LEN]; #ifdef AMIGA @@ -1106,8 +1102,7 @@ char *c; #endif #ifdef UNIX -public boolean ascii_input(c) -char *c; +public boolean ascii_input(char *c) { #ifdef UNIX_MACH /* @@ -1159,7 +1154,7 @@ public void unget_ascii(char c) } -public boolean check_ascii() +public boolean check_ascii(void) { char c; @@ -1249,7 +1244,7 @@ public int wait_ascii() FD_SET(IOinputfd, &readfds); gflush(); getrlimit(RLIMIT_NOFILE, &file_limit); - select(file_limit.rlim_max+1, &readfds, 0, 0, NULL); + select((int) (file_limit.rlim_max+1), &readfds, 0, 0, NULL); #endif /* !__APPLE__ */ #endif /* ifdef UNIX */ } diff --git a/lib-src/libnyquist/nyquist/cmt/userio.h b/lib-src/libnyquist/nyquist/cmt/userio.h index 7c05e96c3..86850b19e 100644 --- a/lib-src/libnyquist/nyquist/cmt/userio.h +++ b/lib-src/libnyquist/nyquist/cmt/userio.h @@ -52,7 +52,7 @@ extern int redirect_flag; /* added by Ning Hu, Apr 2001 */ boolean get_ascii(char *c); /* polls for an ascii character */ #ifdef DOTS_FOR_ARGS /* was (defined(ITC_MACH) && defined(__STDC__)) || defined(MACINTOSH) || defined(AZTEC) || (defined(AMIGA) && defined(LATTICE)) || defined(UNIX_ITC) */ -void gprintf(long where, char *format, ...); /* general printf */ +void gprintf(long where, const char *format, ...); /* general printf */ #else void gprintf(); #endif @@ -70,7 +70,7 @@ FILE *fileopen(char *deflt, char *extension, char *mode, char *prompt); void readln(FILE *fp); void gflush(void); int gputchar(int c); -int ggetchar(); +int ggetchar(void); char *ggets(char *str); boolean ascii_input(char *c); void unget_ascii(char c); diff --git a/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c b/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c index 1e81e6b25..43c4e336c 100644 --- a/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c +++ b/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c @@ -430,7 +430,10 @@ void pv_initialize(Phase_vocoder x) pv->pos_buffer_rear = pv->pos_buffer; } // make sure tables are constructed before we start real-time processing - int fft_error_sign = fftInit(pv->log2_fft); // target fftInit +#ifndef NDEBUG + int fft_error_sign = +#endif + fftInit(pv->log2_fft); // target fftInit assert(!fft_error_sign); pv->phase = PV_START; @@ -550,7 +553,8 @@ int pv_get_input_count(Phase_vocoder x) return need; } - +#pragma warning(disable: 4715 4068) // return type and unknown pragma +#pragma clang diagnostic ignored "-Wreturn-type" double pv_get_effective_pos(Phase_vocoder x) { PV *pv = (PV*)x; @@ -594,9 +598,8 @@ double pv_get_effective_pos(Phase_vocoder x) assert(pv->first_time); assert(pv->output_total == 0); return -(pv->ratio * pv->fftsize / 2.0); - } else { // I can't think of any other case. - assert(FALSE); - } + } // I can't think of any other case. + assert(FALSE); } @@ -972,15 +975,16 @@ float *pv_get_output(Phase_vocoder x) { PV *pv = (PV *)x; assert(pv->phase == PV_GOT_INPUT); - +#ifndef NDEBUG long blocksize = pv->blocksize; + float *out_next = pv->out_next; +#endif int fftsize = pv->fftsize; int frames_to_compute = pv->frames_to_compute; int syn_hopsize = pv->syn_hopsize; float *ana_win = pv->ana_win; float ratio = pv->ratio; float *input_head = pv->input_head; - float *out_next = pv->out_next; float *ana_frame = pv->ana_frame; float *ana_center; diff --git a/lib-src/libnyquist/nyquist/ffts/src/fftext.c b/lib-src/libnyquist/nyquist/ffts/src/fftext.c index a39911ca6..49d9dbcea 100644 --- a/lib-src/libnyquist/nyquist/ffts/src/fftext.c +++ b/lib-src/libnyquist/nyquist/ffts/src/fftext.c @@ -8,6 +8,7 @@ fftInit every time you call ffts. For example you could have someting like: #define FFT(a,n) if(!fftInit(roundtol(LOG2(n)))) ffts(a,roundtol(LOG2(n)),1);else printf("fft error\n"); *******************************************************************/ +#include #include #include "fftlib.h" #include "matlib.h" @@ -39,7 +40,8 @@ if ((M >= 0) && (M < 8*sizeof(long))){ } if (M > 1){ if (BRLowArray[M/2] == 0){ // init bit reversed table for cmplx fft - BRLowArray[M/2] = (short *) malloc( POW2(M/2-1)*sizeof(short) ); + // coercion avoids compiler warning about 32-bit shift: + BRLowArray[M/2] = (short *) malloc( (int64_t) POW2(M/2-1)*sizeof(short) ); if (BRLowArray[M/2] == 0) theError = 2; else{ @@ -49,7 +51,8 @@ if ((M >= 0) && (M < 8*sizeof(long))){ } if (M > 2){ if (BRLowArray[(M-1)/2] == 0){ // init bit reversed table for real fft - BRLowArray[(M-1)/2] = (short *) malloc( POW2((M-1)/2-1)*sizeof(short) ); + // coercion avoids compiler warning about 32-bit shift: + BRLowArray[(M-1)/2] = (short *) malloc( (int64_t) POW2((M-1)/2-1)*sizeof(short) ); if (BRLowArray[(M-1)/2] == 0) theError = 2; else{ diff --git a/lib-src/libnyquist/nyquist/ffts/src/fftext.h b/lib-src/libnyquist/nyquist/ffts/src/fftext.h index 15d8a6b46..1db007464 100644 --- a/lib-src/libnyquist/nyquist/ffts/src/fftext.h +++ b/lib-src/libnyquist/nyquist/ffts/src/fftext.h @@ -16,7 +16,7 @@ int fftInit(long M); /* OUTPUTS */ /* private cosine and bit reversed tables */ -void fftFree(); +void fftFree(void); // release storage for all private cosine and bit reversed tables void ffts(float *data, long M, long Rows); diff --git a/lib-src/libnyquist/nyquist/ffts/src/fftlib.c b/lib-src/libnyquist/nyquist/ffts/src/fftlib.c index 95f2ce67d..5a4c0e8c7 100644 --- a/lib-src/libnyquist/nyquist/ffts/src/fftlib.c +++ b/lib-src/libnyquist/nyquist/ffts/src/fftlib.c @@ -3,6 +3,8 @@ lower level fft stuff including routines called in fftext.c and fft2d.c *******************************************************************/ /* inline declarations modified by RBD for C99 compiler */ + +#include #include "fftlib.h" #include #define MCACHE (11-(sizeof(float)/8)) // fft's with M bigger than this bust primary cache @@ -107,7 +109,7 @@ posB = posA + 2; posBi = posB + 1; iolimit = ioptr + Nrems2; -for (; ioptr < iolimit; ioptr += POW2(M/2+1)){ +for (; ioptr < iolimit; ioptr += (int64_t) POW2(M/2+1)){ for (Colstart = Nroot_1; Colstart >= 0; Colstart--){ iCol = Nroot_1; p0r = ioptr+ Nroot_1_ColInc + BRLow[Colstart]*4; @@ -420,7 +422,7 @@ float *p0r, *p1r, *p2r, *p3r; float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i; float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i; -const float Two = 2.0; +/* UNUSED: const float Two = 2.0; */ pinc = NDiffU * 2; // 2 floats per complex pnext = pinc * 4; @@ -528,7 +530,7 @@ unsigned long SameUCnt; float *pstrt; float *p0r, *p1r, *p2r, *p3r; -float w1r = 1.0/MYROOT2; /* cos(pi/4) */ +float w1r = 1.0F/MYROOT2; /* cos(pi/4) */ float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i; float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i; float t1r, t1i; @@ -981,7 +983,7 @@ for (; StageCnt > 0 ; StageCnt--){ w1r = *u1r; w1i = *u1i; - if (DiffUCnt <= NDiffU/2) + if ((long) DiffUCnt <= NDiffU/2) w0r = -w0r; t0r = f0r - f4r * w2r - f4i * w2i; @@ -1171,7 +1173,7 @@ posB = posA + 2; posBi = posB + 1; iolimit = ioptr + Nrems2; -for (; ioptr < iolimit; ioptr += POW2(M/2+1)){ +for (; ioptr < iolimit; ioptr += (int64_t) POW2(M/2+1)){ for (Colstart = Nroot_1; Colstart >= 0; Colstart--){ iCol = Nroot_1; p0r = ioptr+ Nroot_1_ColInc + BRLow[Colstart]*4; @@ -1352,7 +1354,7 @@ ioptr[7] = scale*f3i; //inline void ifft8pt(float *ioptr, float scale); static inline void ifft8pt(float *ioptr, float scale){ /*** RADIX 8 ifft ***/ -float w0r = 1.0/MYROOT2; /* cos(pi/4) */ +float w0r = 1.0F/MYROOT2; /* cos(pi/4) */ float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i; float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i; float t0r, t0i, t1r, t1i; @@ -1484,7 +1486,7 @@ float *p0r, *p1r, *p2r, *p3r; float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i; float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i; -const float Two = 2.0; +/* UNUSED: const float Two = 2.0; */ pinc = NDiffU * 2; // 2 floats per complex pnext = pinc * 4; @@ -1592,7 +1594,7 @@ unsigned long SameUCnt; float *pstrt; float *p0r, *p1r, *p2r, *p3r; -float w1r = 1.0/MYROOT2; /* cos(pi/4) */ +float w1r = 1.0F/MYROOT2; /* cos(pi/4) */ float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i; float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i; float t1r, t1i; @@ -2048,7 +2050,7 @@ for (; StageCnt > 0 ; StageCnt--){ w1r = *u1r; w1i = *u1i; - if (DiffUCnt <= NDiffU/2) + if ((long) DiffUCnt <= NDiffU/2) w0r = -w0r; t0r = f0r - f4r * w2r + f4i * w2i; @@ -2501,9 +2503,9 @@ posi = pos + 1; p0r = ioptr; p1r = ioptr + pos/2; -u0r = Utbl + POW2(M-3); +u0r = Utbl + (int) POW2(M-3); -w0r = *u0r, +w0r = *u0r; f0r = *(p0r); f0i = *(p0r + 1); @@ -2541,7 +2543,7 @@ f5i = *(p1r + posi); u0r = Utbl + 1; u0i = Utbl + (POW2(M-2)-1); -w0r = *u0r, +w0r = *u0r; w0i = *u0i; p0r = (ioptr + 2); @@ -2992,9 +2994,9 @@ posi = pos + 1; p0r = ioptr; p1r = ioptr + pos/2; -u0r = Utbl + POW2(M-3); +u0r = Utbl + (int) POW2(M-3); -w0r = *u0r, +w0r = *u0r; f0r = *(p0r); f0i = *(p0r + 1); @@ -3032,7 +3034,7 @@ f5i = *(p1r + posi); u0r = Utbl + 1; u0i = Utbl + (POW2(M-2)-1); -w0r = *u0r, +w0r = *u0r; w0i = *u0i; p0r = (ioptr + 2); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/add.c b/lib-src/libnyquist/nyquist/nyqsrc/add.c index a443c242a..075a7746f 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/add.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/add.c @@ -46,15 +46,17 @@ factor, ADD will create a rescaling of the operand. #include "add.h" #include "assert.h" +#pragma warning(disable: 4068) // unknown pragma (MSVS) +#pragma clang diagnostic ignored "-Wunreachable-code" #define debugA 0 #define A if (debugA) /* I don't know how these debug switches (A and D) differ: */ -#define D A +#define D if (debugA) /* switch B is/was to look for a particular zero block length bug */ -#define debugB 0 -#define B if (debugB | debugA) +#define debugB debugA +#define B if (debugB) /* #define GC_DEBUG 1 */ @@ -79,7 +81,7 @@ void add_s1_s2_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) falloc_sample_block(out, "add_s1_s2_nn_fetch"); snd_list->block = out; out_ptr = out->samples; -A nyquist_printf("add[%p,%p] (s1_s2_nn) %p new block %p\n", +A nyquist_printf("add[%p,%p] (s1_s2_nn) %p new block %p\n", susp->s1, susp->s2, susp, out); /* fill up the new block */ @@ -95,7 +97,7 @@ A nyquist_printf("add[%p,%p] (s1_s2_nn) %p starting outer loop, cnt %d\n", A nyquist_printf("add[%p,%p]: look for samples (for s1) \n", susp->s1, susp->s2); /* if (!susp->s1->list->block) watch_susp(susp->s1->list->u.susp); */ susp_check_term_log_block_samples(s1, s1_bptr, s1_ptr, s1_cnt, 1, 3); -A nyquist_printf("add[%p,%p]: found samples (for s1) s1_cnt=%d\n", +A nyquist_printf("add[%p,%p]: found samples (for s1) s1_cnt=%d\n", susp->s1, susp->s2, (int)susp->s1_cnt); togo = MIN(togo, susp->s1_cnt); if (susp->terminate_bits & 1) { @@ -104,12 +106,12 @@ A nyquist_printf("add[%p,%p]: terminate bits on (for s1) togo=%d\n", } /* don't run past the s2 input sample block: */ -A nyquist_printf("add[%p,%p]: look for samples (for s2) \n", susp->s1, susp->s2); +A nyquist_printf("add[%p,%p]: look for samples (for s2) \n", susp->s1, susp->s2); susp_check_term_log_block_samples(s2, s2_bptr, s2_ptr, s2_cnt, 2, 3); -A nyquist_printf("add[%p,%p]: found samples (for s2) s2_cnt=%d\n", +A nyquist_printf("add[%p,%p]: found samples (for s2) s2_cnt=%d\n", susp->s1, susp->s2, (int)susp->s2_cnt); togo = MIN(togo, susp->s2_cnt); -A if (susp->terminate_bits & 2) { +A if (susp->terminate_bits & 2) { nyquist_printf("add[%p,%p]: terminate bits on (for s2) togo=%d\n", susp->s1, susp->s2, togo); } @@ -117,16 +119,18 @@ A if (susp->terminate_bits & 2) { /* don't run past logical stop time (need to check this even * if a sound has terminated) */ -A nyquist_printf( - "add[%p,%p] (s1_s2_nn) %p: logically_stopped %d, logical_stop_cnt %d, s1 logical_stop_cnt %ld, s2 logical_stop_cnt %ld \n", - susp->s1, susp->s2, susp, susp->logically_stopped, - (int) susp->susp.log_stop_cnt, - susp->s1->logical_stop_cnt, - susp->s2->logical_stop_cnt); +A nyquist_printf("add[%p,%p] (s1_s2_nn) %p: logically_stopped %d, " + "logical_stop_cnt %d, s1 logical_stop_cnt %" PRId64 + ", s2 logical_stop_cnt %" PRId64 "\n", + susp->s1, susp->s2, susp, susp->logically_stopped, + (int) susp->susp.log_stop_cnt, + susp->s1->logical_stop_cnt, susp->s2->logical_stop_cnt); if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && (susp->logical_stop_bits == 3)) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); -A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2, to_stop); + int to_stop = (int) (susp->susp.log_stop_cnt - + (susp->susp.current + cnt)); +A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2, + to_stop); /* logical stops have to be indicated on block boundaries */ if (to_stop < togo) { if (to_stop == 0) { @@ -152,7 +156,8 @@ A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2, to_stop); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - + (susp->susp.current + cnt)); D nyquist_printf("add[%p,%p]: togo = %d\n", susp->s1, susp->s2, togo); if (togo == 0) break; } @@ -263,7 +268,8 @@ void add_s1_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) { add_susp_type susp = (add_susp_type) a_susp; /* expansion of add_s_nn_fetch(snd_list,s1,s2,1); follows: */ - int togo, s2_start=0; + int togo; + int64_t s2_start = 0; int n; sample_block_type out; register sample_block_values_type out_ptr; @@ -292,9 +298,9 @@ B if (togo == 0) stdputstr("togo is zero at checkpoint 1\n"); /* if (susp->s1_ptr == zero_block->samples) { -sep21 RBD*/ if (susp->terminate_bits & 1) { if (susp->s2) { - s2_start = (long) ((susp->s2->t0 - susp->susp.t0) * - susp->s2->sr + 0.5); -D nyquist_printf("add_s_nn_fetch: s2_start %d\n", s2_start); + s2_start = (int64_t) ((susp->s2->t0 - susp->susp.t0) * + susp->s2->sr + 0.5); +D nyquist_printf("add_s_nn_fetch: s2_start %" PRId64 "\n", s2_start); } togo = 0; B if (togo == 0) stdputstr("togo is zero at checkpoint 2\n"); @@ -331,14 +337,15 @@ D nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp); /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && susp->logical_stop_bits == 3) { - int to_stop = susp->susp.log_stop_cnt - susp->susp.current; + int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current; if (to_stop < togo) { if (to_stop == 0) { susp->logically_stopped = true; - } else togo = to_stop; + } else togo = (int) to_stop; } B if (togo == 0) stdputstr("togo is zero at checkpoint 3\n"); -D nyquist_printf("add_s1_nn_fetch: to_stop %d togo %d\n", to_stop, togo); +D nyquist_printf("add_s1_nn_fetch: to_stop %" PRId64 " togo %d\n", + to_stop, togo); } /* consider other signal? don't run past its start time... */ @@ -346,7 +353,7 @@ D nyquist_printf("add_s1_nn_fetch: to_stop %d togo %d\n", to_stop, togo); s2_start = ROUND32((susp->s2->t0 - susp->susp.t0) * susp->s2->sr); if (s2_start < susp->susp.current + togo) - togo = MIN(togo, s2_start - susp->susp.current); + togo = (int) MIN(togo, s2_start - susp->susp.current); B if (togo == 0) stdputstr("togo is zero at checkpoint 4\n"); } @@ -427,12 +434,15 @@ D sound_print_tree(susp->s1); falloc_sample_block(out, "add_s1_nn_fetch"); snd_list->block = out; out_ptr = out->samples; -B nyquist_printf("add[%p,%p] (s1_nn) %p new block %p, s1_ptr %p block %p s1_cnt %d togo %d\n", susp->s1, susp->s2, susp, out, susp->s1_ptr, susp->s1_bptr->samples, (int)susp->s1_cnt, togo); +B nyquist_printf("add[%p,%p] (s1_nn) %p new block %p, s1_ptr %p " + "block %p s1_cnt %d togo %d\n", susp->s1, susp->s2, + susp, out, susp->s1_ptr, susp->s1_bptr->samples, + (int)susp->s1_cnt, togo); n = togo; B if (togo == 0) stdputstr("togo is zero at checkpoint 5\n"); -B if (togo == 0) nyquist_printf( - "add[%p,%p] (s%d_nn) %p starting copy loop, togo %d\n", - susp->s1, susp->s2, 1, susp, togo); +B if (togo == 0) nyquist_printf( + "add[%p,%p] (s%d_nn) %p starting copy loop, togo %d\n", + susp->s1, susp->s2, 1, susp, togo); while (n--) { /* the inner sample computation loop */ /* scale? */ *out_ptr++ = *(susp->s1_ptr++); @@ -460,9 +470,10 @@ D stdputstr("add_s_nn_fetch: add_s1_s2_fetch installed\n"); /* s2 finished and s1 stops */ /* go to terminal state */ susp->s1 = NULL; -D nyquist_printf("add_s_nn_fetch: go to terminal state. susp->s2 %p, \ - susp->susp.current %d, s2_start %d, susp->s1->list %p, \ - zero_snd_list %p\n", susp->s2, (int)susp->susp.current, +D nyquist_printf("add_s_nn_fetch: go to terminal state. susp->s2 %p, " + "susp->susp.current %" PRId64 ", s2_start %" PRId64 + ", susp->s1->list %p, zero_snd_list %p\n", + susp->s2, susp->susp.current, s2_start, susp->s1->list, zero_snd_list); /* !!! free resources and set up pointers to terminal snd_list */ /* !!! logically stopped? */ @@ -555,10 +566,10 @@ D nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp); /* check if we've seen the logical stop from s2. If so then log_stop_cnt is max of s1 and s2 stop times */ (susp->logical_stop_bits & 2)) { - int to_stop; -D nyquist_printf("add_s2_nn_fetch: susp->susp.log_stop_cnt %ld\n", + int64_t to_stop; +D nyquist_printf("add_s2_nn_fetch: susp->susp.log_stop_cnt %" PRId64 "\n", susp->susp.log_stop_cnt); -D nyquist_printf("add_s2_nn_fetch: susp->susp.current %ld\n", +D nyquist_printf("add_s2_nn_fetch: susp->susp.current %" PRId64 "\n", susp->susp.current); to_stop = susp->susp.log_stop_cnt - susp->susp.current; // to_stop can be less than zero if we've been adding in sounds with @@ -578,10 +589,11 @@ D nyquist_printf("add_s2_nn_fetch: susp->susp.current %ld\n", if (to_stop < togo) { if (to_stop == 0) { susp->logically_stopped = true; - } else togo = to_stop; + } else togo = (int) to_stop; } B if (togo == 0) stdputstr("togo is zero at checkpoint 3\n"); -D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo); +D nyquist_printf("add_s2_nn_fetch: to_stop %" PRId64 " togo %d\n", + to_stop, togo); } /* consider other signal? don't run past its start time... */ @@ -589,7 +601,7 @@ D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo); s1_start = ROUND32((susp->s1->t0 - susp->susp.t0) * susp->s1->sr); if (s1_start < susp->susp.current + togo) - togo = MIN(togo, s1_start - susp->susp.current); + togo = (int) MIN(togo, s1_start - susp->susp.current); assert(togo > 0); } @@ -614,12 +626,12 @@ D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo); */ /* just fetch and pass blocks on */ -D nyquist_printf("add[%p,%p] (s%d_nn) %p starting uncopy, togo %d\n", susp->s2, susp->s1, - 2, susp, togo); +D nyquist_printf("add[%p,%p] (s%d_nn) %p starting uncopy, togo %d\n", + susp->s2, susp->s1, 2, susp, togo); snd_list->block = susp->s2_bptr; (susp->s2_bptr->refcnt)++; -D nyquist_printf("add[%p,%p] (s%d_nn) %p shared block %p zero_block %p\n",susp->s2, susp->s1, - 2, susp, susp->s2_bptr, zero_block); +D nyquist_printf("add[%p,%p] (s%d_nn) %p shared block %p zero_block %p\n", + susp->s2, susp->s1, 2, susp, susp->s2_bptr, zero_block); susp_took(s2_cnt, togo); snd_list->block_len = togo; @@ -657,7 +669,7 @@ D sound_print_tree(susp->s2); snd_list->u.next = addend_list; return; } else { -D nyquist_printf("s1 == NULL, but no collapse, lsc %ld\n", +D nyquist_printf("s1 == NULL, but no collapse, lsc %" PRId64 "\n", susp->s2->logical_stop_cnt); } } else { @@ -694,7 +706,7 @@ B nyquist_printf( /* add a new snd_list for the susp */ susp->susp.current += togo; - if (0) stdputstr("testing..."); + if (/* DISABLES CODE */ (0)) stdputstr("testing..."); /* * test for termination or change of state, * note s1_start computed earlier @@ -728,7 +740,7 @@ D stdputstr("add_s_nn_fetch: snd_list->logically_stopped\n"); D stdputstr("add_s_nn_fetch: susp->logically_stopped\n"); susp->logically_stopped = true; } - if (0) { + if (/* DISABLES CODE */ (0)) { if (susp->logically_stopped || snd_list->logically_stopped) stdputstr("STOPPED\n"); else @@ -748,18 +760,19 @@ void add_zero_fill_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) #endif togo = max_sample_block_len; - if (0) fprintf(STDERR, "add_zero_fill_nn_fetch, susp.current %d\n", + if (/* DISABLES CODE */ (0)) fprintf(STDERR, + "add_zero_fill_nn_fetch, susp.current %d\n", (int)susp->susp.current); /* don't run past start time ... */ if (susp->s1) { s_start = ROUND32((susp->s1->t0 - susp->susp.t0) * susp->s1->sr); if (s_start < susp->susp.current + togo) { - togo = s_start - susp->susp.current; + togo = (int) (s_start - susp->susp.current); } } else if (susp->s2) { s_start = ROUND32((susp->s2->t0 - susp->susp.t0) * susp->s2->sr); if (s_start < susp->susp.current + togo) { - togo = s_start - susp->susp.current; + togo = (int) (s_start - susp->susp.current); } } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/add.h b/lib-src/libnyquist/nyquist/nyqsrc/add.h index 673796051..840abf260 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/add.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/add.h @@ -4,15 +4,15 @@ typedef struct add_susp_struct { snd_susp_node susp; boolean started; int terminate_bits; - long terminate_cnt; + int64_t terminate_cnt; int logical_stop_bits; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_type s1_bptr; /* block pointer */ sample_block_values_type s1_ptr; sound_type s2; - long s2_cnt; + int s2_cnt; sample_block_type s2_bptr; /* block pointer */ sample_block_values_type s2_ptr; @@ -27,7 +27,7 @@ typedef struct add_susp_struct { #endif /* pointer used to synchronize adds in multiseq */ struct multiseq_struct *multiseq; - long s1_prepend; /* offset to susp.current */ + int64_t s1_prepend; /* offset to susp.current */ } add_susp_node, *add_susp_type; sound_type snd_make_add(sound_type s1, sound_type s2); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/avg.c b/lib-src/libnyquist/nyquist/nyqsrc/avg.c index 321bd3048..b24d559a5 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/avg.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/avg.c @@ -15,16 +15,18 @@ */ -void avg_free(); +void avg_free(snd_susp_type a_susp); -typedef sample_type (*process_block_type)(/* struct avg_susp_struct *susp */); +struct avg_susp_struct; + +typedef sample_type (*process_block_type)(struct avg_susp_struct *susp); typedef struct avg_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; /* blocksize is how many input samples to process for an output sample */ long blocksize; @@ -77,7 +79,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) { avg_susp_type susp = (avg_susp_type) a_susp; int cnt = 0; /* how many samples computed */ - int togo = 0; + int64_t togo = 0; int n; sample_block_type out; register sample_block_values_type out_ptr; @@ -109,7 +111,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). @@ -131,7 +133,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) } } - n = togo; + n = (int) togo; s_ptr_reg = susp->s_ptr; fillptr_reg = susp->fillptr; if (n) do { /* the inner sample computation loop */ @@ -146,7 +148,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* using s_ptr_reg is a bad idea on RS/6000: */ susp->s_ptr += togo; susp->fillptr = fillptr_reg; - susp_took(s_cnt, togo); + susp_took(s_cnt, (int) togo); } /* outer loop */ /* test for termination */ @@ -168,23 +170,23 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) void avg_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) { avg_susp_type susp = (avg_susp_type) a_susp; - long final_count = MIN(susp->susp.current + max_sample_block_len, - susp->susp.toss_cnt); + int64_t final_count = MIN(susp->susp.current + max_sample_block_len, + susp->susp.toss_cnt); time_type final_time = susp->susp.t0 + final_count / susp->susp.sr; - long n; + int64_t n; /* fetch samples from s up to final_time for this block of zeros */ - while (((long) ((final_time - susp->s->t0) * susp->s->sr + 0.5)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= + susp->s->current) + susp_get_samples(s, s_ptr, s_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ if (final_count == susp->susp.toss_cnt) { - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - - (susp->s->current - susp->s_cnt)); - susp->s_ptr += n; - susp_took(s_cnt, n); - susp->susp.fetch = susp->susp.keep_fetch; + n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + (susp->s->current - susp->s_cnt)); + susp->s_ptr += n; + susp_took(s_cnt, (int) n); + susp->susp.fetch = susp->susp.keep_fetch; } snd_list->block_len = (short) (final_count - susp->susp.current); susp->susp.current = final_count; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/avg.h b/lib-src/libnyquist/nyquist/nyqsrc/avg.h index 4c21cc368..bafe0506f 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/avg.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/avg.h @@ -1,6 +1,6 @@ sound_type snd_make_avg(sound_type s, long blocksize, long stepsize, long op); sound_type snd_avg(sound_type s, long blocksize, long stepsize, long op); - /* LISP: (snd-avg SOUND FIXNUM FIXNUM FIXNUM) */ + /* LISP: (snd-avg SOUND LONG LONG LONG) */ #define op_average 1 #define op_peak 2 /* LISP-SRC: (setf OP-AVERAGE 1) (setf OP-PEAK 2) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/compose.c b/lib-src/libnyquist/nyquist/nyqsrc/compose.c index 0dd7641dd..d75c87442 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/compose.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/compose.c @@ -14,22 +14,22 @@ * 28Apr03 dm changes for portability and fix compiler warnings */ -void compose_free(); +void compose_free(snd_susp_type a_susp); typedef struct compose_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type f; - long f_cnt; + int f_cnt; sample_block_values_type f_ptr; sample_type f_prev; double f_time; double f_time_increment; boolean started; sound_type g; - long g_cnt; + int g_cnt; sample_block_values_type g_ptr; } compose_susp_node, *compose_susp_type; @@ -110,14 +110,15 @@ void compose_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - if (to_stop < togo && ((togo = to_stop) == 0)) break; + int64_t to_stop = susp->susp.log_stop_cnt - + (susp->susp.current + cnt); + if (to_stop < togo && ((togo = (int) to_stop) == 0)) break; } n = togo; @@ -177,8 +178,8 @@ f_out_of_samples: void compose_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) { compose_susp_type susp = (compose_susp_type) a_susp; - long final_count = MIN(susp->susp.current + max_sample_block_len, - susp->susp.toss_cnt); + long final_count = (long) MIN(susp->susp.current + max_sample_block_len, + susp->susp.toss_cnt); time_type final_time = susp->susp.t0 + final_count / susp->susp.sr; long n; @@ -193,12 +194,12 @@ void compose_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ if (final_count == susp->susp.toss_cnt) { - n = ROUNDBIG((final_time - susp->f->t0) * susp->f->sr - - (susp->f->current - susp->f_cnt)); + n = ROUND32((final_time - susp->f->t0) * susp->f->sr - + (susp->f->current - susp->f_cnt)); susp->f_ptr += n; susp_took(f_cnt, n); - n = ROUNDBIG((final_time - susp->g->t0) * susp->g->sr - - (susp->g->current - susp->g_cnt)); + n = ROUND32((final_time - susp->g->t0) * susp->g->sr - + (susp->g->current - susp->g_cnt)); susp->g_ptr += n; susp_took(g_cnt, n); susp->susp.fetch = susp->susp.keep_fetch; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/convolve.c b/lib-src/libnyquist/nyquist/nyqsrc/convolve.c index 3b37ee074..3e2fe91e2 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/convolve.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/convolve.c @@ -83,16 +83,16 @@ #include "fftext.h" #include "convolve.h" -void convolve_free(); +void convolve_free(snd_susp_type a_susp); typedef struct convolve_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean know_end_of_x; boolean logically_stopped; sound_type x_snd; - long x_snd_cnt; + int x_snd_cnt; sample_block_values_type x_snd_ptr; sample_type *X; // the FFTs of x_snd @@ -228,12 +228,12 @@ void convolve_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* can't use more than what's left in R. R_current is the next sample of R, so what's left is N - (R - R_current) */ R_current = susp->R_current; - togo = min(togo, N - (R_current - R)); + togo = (int) min(togo, N - (R_current - R)); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo == 0) break; } @@ -241,9 +241,9 @@ void convolve_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && susp->susp.log_stop_cnt <= susp->susp.current + cnt + togo) { - togo = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - D printf("susp->susp.log_stop_cnt is set to %ld\n", - susp->susp.log_stop_cnt); + togo = (int) (susp->susp.log_stop_cnt - (susp->susp.current + cnt)); + D printf("susp->susp.log_stop_cnt is set to %" PRId64 "\n", + susp->susp.log_stop_cnt); if (togo == 0) break; } @@ -287,8 +287,8 @@ void convolve_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - - (susp->x_snd->current - susp->x_snd_cnt)); + n = (long) ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - + (susp->x_snd->current - susp->x_snd_cnt)); susp->x_snd_ptr += n; susp_took(x_snd_cnt, n); susp->susp.fetch = susp->susp.keep_fetch; @@ -333,12 +333,14 @@ void fill_with_samples(sample_type *x, sound_type s, long n) int i; for (i = 0; i < n; i++) { if (!s->extra) { /* this is the first call, so fix up s */ - s->extra = (long *) malloc(sizeof(long) * FIELDS); - s->extra[0] = sizeof(long) * FIELDS; + s->extra = (int64_t *) malloc(sizeof(s->extra[0]) * FIELDS); + s->extra[0] = sizeof(s->extra[0]) * FIELDS; s->CNT = s->INDEX = 0; } - if (s->CNT == s->INDEX) { - sound_get_next(s, &(s->CNT)); + int icnt = (int) s->CNT; /* need this to be int type */ + if (icnt == s->INDEX) { + sound_get_next(s, &icnt); + s->CNT = icnt; /* save the count back into s->extra */ s->INDEX = 0; } x[i] = s->SAMPLES[s->INDEX++] * s->scale; @@ -353,7 +355,7 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd) time_type t0 = x_snd->t0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - long h_len; + int64_t h_len; int i; // assume fft_size is maximal. We fix this later if it is wrong long fft_size = 1 << MAX_LOG_FFT_SIZE; @@ -372,8 +374,8 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd) * the FFT size is at least double that */ if (h_len <= fft_size / 4) { /* compute log-base-2(h_len): */; - double log_len = log(h_len) / M_LN2; - int log_len_int = log_len; + double log_len = log((double) h_len) / M_LN2; + int log_len_int = (int) log_len; if (log_len_int != log_len) log_len_int++; /* round up to power of 2 */ susp->M = log_len_int + 1; } else { @@ -383,11 +385,11 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd) D printf("fft_size %ld\n", fft_size); susp->N = fft_size / 2; // round h_len up to multiple of susp->N and multiply by 2 - susp->h_snd_len = h_len; + susp->h_snd_len = (int) h_len; h_len = ((h_len + susp->N - 1) / susp->N) * susp->N * 2; - susp->L = h_len / fft_size; + susp->L = (int) (h_len / fft_size); // allocate memory - susp->H = (sample_type *) calloc(h_len, sizeof(susp->H[0])); + susp->H = (sample_type *) calloc((size_t) h_len, sizeof(susp->H[0])); if (!susp->H) { xlfail("memory allocation failure in convolve"); } @@ -413,7 +415,7 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd) for (i = 0; i < susp->L; i++) { rffts(susp->H + i * susp->N * 2, susp->M, 1); } - susp->X = (sample_type *) calloc(h_len, sizeof(susp->X[0])); + susp->X = (sample_type *) calloc((size_t) h_len, sizeof(susp->X[0])); susp->R = (sample_type *) calloc(fft_size, sizeof(susp->R[0])); susp->Y = (sample_type *) calloc(fft_size, sizeof(susp->Y[0])); if (!susp->X || !susp->R || !susp->Y) { diff --git a/lib-src/libnyquist/nyquist/nyqsrc/debug.c b/lib-src/libnyquist/nyquist/nyqsrc/debug.c index 74a77f5b4..b2b5f0457 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/debug.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/debug.c @@ -151,10 +151,10 @@ void print_sound_type(sound_type s) nyquist_printf("\t(0x%p:0x%p)->", list, list->block); while (list->block) { list = list->u.next; - if (blockcount < 5) { - nyquist_printf("(0x%p:0x%p)->", list, list->block); + if (blockcount < 50) { + nyquist_printf("(0x%p block 0x%p)->", list, list->block); } - else if (blockcount == 5) { + else { stdputstr(" ... "); break; } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/debug.h b/lib-src/libnyquist/nyquist/nyqsrc/debug.h index 6874ed251..f4a755c68 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/debug.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/debug.h @@ -28,7 +28,6 @@ typedef struct partial_susp_struct { #endif extern sound_type watch_table_sound; -extern int table_ptr_check_enable; void print_sound_type(sound_type s); void print_sample_block_type(char *label, @@ -40,7 +39,6 @@ void watch_snd_list(snd_list_type s); void dbg_mem_allocated(void *p, char *who); void dbg_mem_freed(void *p, char *who); void dbg_mem_print(char *msg, void *p); -void table_ptr_check(); /* #define TRACESNDGC */ #define DEBUG_H diff --git a/lib-src/libnyquist/nyquist/nyqsrc/downsample.c b/lib-src/libnyquist/nyquist/nyqsrc/downsample.c index ca1e9c786..82ed2c9fb 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/downsample.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/downsample.c @@ -23,10 +23,10 @@ void down_free(snd_susp_type a_susp); typedef struct down_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; /* support for interpolation of s */ @@ -35,8 +35,9 @@ typedef struct down_susp_struct { double s_pHaSe_iNcR; /* support for ramp between samples of s */ + /*can we delete these? double output_per_s; - long s_n; + long s_n; */ } down_susp_node, *down_susp_type; @@ -78,7 +79,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo <= 0) { togo = 0; break; @@ -87,7 +88,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). @@ -105,7 +106,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) } else /* limit togo so we can start a new * block at the LST */ - togo = to_stop; + togo = (int) to_stop; } } @@ -197,8 +198,8 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) void down_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) { down_susp_type susp = (down_susp_type) a_susp; - long final_count = MIN(susp->susp.current + max_sample_block_len, - susp->susp.toss_cnt); + int64_t final_count = MIN(susp->susp.current + max_sample_block_len, + susp->susp.toss_cnt); time_type final_time = susp->susp.t0 + final_count / susp->susp.sr; long n; @@ -209,8 +210,8 @@ void down_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ if (final_count == susp->susp.toss_cnt) { - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - - (susp->s->current - susp->s_cnt)); + n = (long) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); susp->susp.fetch = susp->susp.keep_fetch; @@ -289,8 +290,8 @@ sound_type snd_make_down(rate_type sr, sound_type s) susp->s_cnt = 0; susp->s_pHaSe = 0.0; susp->s_pHaSe_iNcR = s->sr / sr; - susp->s_n = 0; - susp->output_per_s = sr / s->sr; + //susp->s_n = 0; + //susp->output_per_s = sr / s->sr; return sound_create((snd_susp_type)susp, t0, sr, scale_factor); } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/downsample.h b/lib-src/libnyquist/nyquist/nyqsrc/downsample.h index 1435a7300..55a61fe6e 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/downsample.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/downsample.h @@ -1,3 +1,3 @@ -sound_type snd_make_down(); -sound_type snd_down(); +sound_type snd_make_down(rate_type sr, sound_type s); +sound_type snd_down(rate_type sr, sound_type s); /* LISP: (snd-down ANYNUM SOUND) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp b/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp index 1a032bc40..e46d81ac6 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp +++ b/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp @@ -134,6 +134,6 @@ float best_f0(float *samples, int n, int m, float threshold, int Tmax) best_f0=f0; } } - delete[] results; + delete[](results); return best_f0; } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/falloc.c b/lib-src/libnyquist/nyquist/nyqsrc/falloc.c index 7656f4cc1..372b796cf 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/falloc.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/falloc.c @@ -45,8 +45,7 @@ int npools = 0; CQUE *pools = NULL; #endif -void sound_already_free_test(s) - sound_type s; +void sound_already_free_test(sound_type s) { sound_type sp; for (sp = (sound_type) sound_free; sp; sp = (sound_type) ((CQUE *) sp)->qnext) { @@ -235,7 +234,8 @@ void falloc_gc() tlist = tsave; /* Maintain stats */ - sample_block_total -= (tsiz / round_size(sizeof(sample_block_node))); + sample_block_total -= (int) + (tsiz / round_size(sizeof(sample_block_node))); npools--; /* If this is the active pool, then reset current pointers */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/falloc.h b/lib-src/libnyquist/nyquist/nyqsrc/falloc.h index a863a5423..0d5cade64 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/falloc.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/falloc.h @@ -92,7 +92,7 @@ extern int sample_blocks_since_gc; #if defined(TRACK_POOLS) && TRACK_POOLS // extern CQUE *pools; -void falloc_gc(); +void falloc_gc(void); #endif void falloc_init(void); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/fft.c b/lib-src/libnyquist/nyquist/nyqsrc/fft.c index 8b190c467..e9f32357e 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/fft.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/fft.c @@ -82,7 +82,7 @@ void fft_shift(float *x, int len) void n_samples_from_sound(sound_type s, long n, float *table) { - long blocklen; + int blocklen; sample_type scale_factor = s->scale; s = sound_copy(s); while (n > 0) { @@ -112,7 +112,7 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) if (!s->extra) { /* this is the first call, so fix up s */ sound_type w = NULL; - long bytes = sizeof(long) * OFFSET + sizeof(float) * 3 * len; + long bytes = sizeof(s->extra[0]) * OFFSET + sizeof(float) * 3 * len; if (winval) { if (soundp(winval)) { w = getsound(winval); @@ -137,7 +137,7 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) * really necessary). */ - s->extra = (long *) malloc(bytes); + s->extra = (int64_t *) malloc(bytes); s->extra[0] = bytes; s->CNT = s->INDEX = s->FILLCNT = 0; s->TERMCNT = -1; @@ -152,7 +152,8 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) n_samples_from_sound(w, len, window); } } else { - maxlen = (s->extra[0] - sizeof(long) * OFFSET) / (sizeof(float) * 3); + maxlen = (long) ((s->extra[0] - sizeof(s->extra[0]) * OFFSET) / + (sizeof(float) * 3)); if (maxlen != len) xlfail("len changed from initial value"); float_base = (float *) &(s->extra[OFFSET]); } @@ -161,10 +162,12 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) // this code computes window location window = float_base + 2 * len; /* step 1: refill buffer with samples */ - fillptr = s->FILLCNT; + fillptr = (long) s->FILLCNT; while (fillptr < maxlen) { - if (s->INDEX == s->CNT) { - sound_get_next(s, &(s->CNT)); + int icnt = (int) s->CNT; /* need this to be type int */ + if (s->INDEX == icnt) { + sound_get_next(s, &icnt); + s->CNT = icnt; /* save the count back to s->extra */ if (s->SAMPLES == zero_block->samples) { if (s->TERMCNT < 0) s->TERMCNT = fillptr; } @@ -197,6 +200,9 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) } /* perform the fft: */ m = ROUND32(log(len) / M_LN2); /* compute log-base-2(len) */ + if (m > 27) { /* 27 comes from fftext.c and seems big enough */ + xlfail("FFT len greater than 2^27"); + } if (1 << m != len) { xlfail("FFT len is not a power of two"); } @@ -231,13 +237,15 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval) */ skip = step - maxlen; while (skip > 0) { - long remaining = s->CNT - s->INDEX; + long remaining = (long) (s->CNT - s->INDEX); if (remaining >= skip) { s->INDEX += skip; skip = 0; } else { skip -= remaining; - sound_get_next(s, &(s->CNT)); + int icnt = (int) s->CNT; /* need this to be type int */ + sound_get_next(s, &icnt); + s->CNT = icnt; /* save count back into s->extra */ s->INDEX = 0; } } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/fft.h b/lib-src/libnyquist/nyquist/nyqsrc/fft.h index 0278be8dc..48e73653d 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/fft.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/fft.h @@ -3,4 +3,4 @@ void fft_shift(float *x, int len); LVAL snd_fft(sound_type s, long len, long step, LVAL w); - /* LISP: (SND-FFT SOUND FIXNUM FIXNUM ANY) */ + /* LISP: (SND-FFT SOUND LONG LONG ANY) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/handlers.c b/lib-src/libnyquist/nyquist/nyqsrc/handlers.c index a57691c2d..28dc8e238 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/handlers.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/handlers.c @@ -6,7 +6,7 @@ char *app_syntax = ""; /* note -- a simple way to make a midi note on channel 1 */ /**/ -void note(pitch, dur) +void note(int pitch, int dur) { } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/inverse.c b/lib-src/libnyquist/nyquist/nyqsrc/inverse.c index 572bb1707..0ad19911a 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/inverse.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/inverse.c @@ -17,15 +17,15 @@ #include "falloc.h" #include "inverse.h" -void inverse_free(); +void inverse_free(snd_susp_type a_susp); typedef struct inverse_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; double s_prev; double s_time; @@ -93,7 +93,7 @@ void inverse_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp->terminate_cnt <= susp->susp.current + out_cnt) { /* pretend like we computed the correct number of samples */ togo = 0; - out_cnt = susp->terminate_cnt - susp->susp.current; + out_cnt = (long) (susp->terminate_cnt - susp->susp.current); /* exit the loop to complete the termination */ break; } @@ -132,8 +132,8 @@ void inverse_fetch(snd_susp_type a_susp, snd_list_type snd_list) void inverse_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) { inverse_susp_type susp = (inverse_susp_type) a_susp; - long final_count = MIN(susp->susp.current + max_sample_block_len, - susp->susp.toss_cnt); + int64_t final_count = MIN(susp->susp.current + max_sample_block_len, + susp->susp.toss_cnt); time_type final_time = susp->susp.t0 + final_count / susp->susp.sr; long n; @@ -144,8 +144,8 @@ void inverse_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ if (final_count == susp->susp.toss_cnt) { - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - - (susp->s->current - susp->s_cnt)); + n = (long) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); susp->susp.fetch = susp->susp.keep_fetch; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/localdefs.h b/lib-src/libnyquist/nyquist/nyqsrc/localdefs.h index b227c2fb7..014f4b6df 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/localdefs.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/localdefs.h @@ -1,3 +1,12 @@ +// localdefs.h -- additional declarations needed for XLisp extensions +// this file is for Nyquist + /* include actual local file headers: */ #include "sndfnintdefs.h" #include "seqfnintdefs.h" + +/* from sndsliders.c */ + +LVAL xslider_read(void); + + diff --git a/lib-src/libnyquist/nyquist/nyqsrc/lpanal.h b/lib-src/libnyquist/nyquist/nyqsrc/lpanal.h index 87af9c023..f12fe2dba 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/lpanal.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/lpanal.h @@ -1,4 +1,4 @@ /* lpanal.h -- LPC analysis */ LVAL snd_lpanal(LVAL v, long P); - /* LISP: (SND-LPANAL ANY FIXNUM) */ + /* LISP: (SND-LPANAL ANY LONG) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/multiread.c b/lib-src/libnyquist/nyquist/nyqsrc/multiread.c index d42a404fd..397a12114 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/multiread.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/multiread.c @@ -139,20 +139,20 @@ void multiread_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (true) { /* compute how many frames to read to fill sample blocks */ - long frame_count = max_sample_block_len - frames_read; - long actual; /* how many frames actually read */ + int frame_count = max_sample_block_len - frames_read; + int actual; /* how many frames actually read */ /* make sure frames will fit in buffer */ if (frame_count * file_frame_size > input_buffer_samps) { frame_count = input_buffer_samps / file_frame_size; } - actual = sf_readf_float(susp->sndfile, input_buffer, frame_count); + actual = (int) sf_readf_float(susp->sndfile, input_buffer, frame_count); n = actual; /* don't read too many */ if (n > (susp->cnt - susp->susp.current)) { - n = susp->cnt - susp->susp.current; + n = (int) (susp->cnt - susp->susp.current); } /* process one channel at a time, multiple passes through input */ @@ -268,7 +268,7 @@ void multiread_free(snd_susp_type a_susp) } if (!active) { /* stdputstr("all channels freed, freeing susp now\n"); */ - read_free(susp); + read_free(a_susp); } } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c index ff8b5390f..d86d2b5c7 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c @@ -19,6 +19,7 @@ #include "scale.h" #include "extern.h" #include "cext.h" +#include "sndseq.h" /* #define MULTISEQ_GC_DEBUG */ #ifdef MULTISEQ_GC_DEBUG @@ -344,7 +345,7 @@ void multiseq_convert(multiseq_type ms) for (i = 0; i < ms->nchans; i++) { snd_list_type snd_list = ms->chans[i]; add_susp_type susp = (add_susp_type) snd_list->u.susp; - long sother_start; + int64_t sother_start; /* remove backpointer to ms */ susp->multiseq = NULL; @@ -361,8 +362,8 @@ void multiseq_convert(multiseq_type ms) } sother_start = ROUNDBIG((susp->s2->t0 - susp->susp.t0) * susp->s2->sr); -D nyquist_printf("sother_start computed for %p: %d\n", - susp, (int)sother_start); +D nyquist_printf("sother_start computed for %p: %" PRId64 "\n", + susp, sother_start); if (sother_start > susp->susp.current) { D nyquist_printf("susp %p using add_s1_nn_fetch\n", susp); susp->susp.fetch = add_s1_nn_fetch; @@ -605,7 +606,11 @@ D nyquist_printf("ms->t0 == %g\n", ms->t0); } -/* note: snd_multiseq is a noop, just call snd_make_multiseq */ +LVAL snd_multiseq(LVAL snd, LVAL closure) +{ + return snd_make_multiseq(sound_array_copy(snd), closure); +} + void multiseq_free(snd_susp_type a_susp) { diff --git a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.h b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.h index 921ba24c7..ef217cd1b 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.h @@ -15,5 +15,5 @@ typedef struct multiseq_struct { -LVAL snd_make_multiseq(LVAL s1, LVAL closure); +LVAL snd_multiseq(LVAL s1, LVAL closure); /* LISP: (SND-MULTISEQ ANY ANY) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/nfilterkit.h b/lib-src/libnyquist/nyquist/nyqsrc/nfilterkit.h index ce1ae5ff3..b7343e584 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/nfilterkit.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/nfilterkit.h @@ -11,10 +11,10 @@ typedef unsigned int UWORD; #ifdef DEBUG #define INLINE -#else /* DEBUG */ +#else DEBUG /* #define INLINE inline */ #define INLINE -#endif /* DEBUG */ +#endif DEBUG /* * FilterUp() - Applies a filter to a given sample when up-converting. diff --git a/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.c b/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.c index d14f2220a..780f837d1 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.c @@ -74,7 +74,11 @@ int nosc_init() lo_server_add_method(the_server, "/slider", "if", slider_handler, NULL); lo_server_add_method(the_server, "/wii/orientation", "ff", wii_orientation_handler, NULL); - lo_fd = lo_server_get_socket_fd(the_server); + /* On Win64 this is technically incorrect because socket_type is 64 bits, + but *currently* the high-order WIN64 handle bits are zero and this + works. It is likely to continue working because changing it would cause + many failures. */ + lo_fd = (int) lo_server_get_socket_fd(the_server); nosc_enabled = true; } return 0; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.h b/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.h index df1dd9f9a..7f4c1ce0d 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/nyq-osc-server.h @@ -5,6 +5,6 @@ * Created by Roger Dannenberg */ -int nosc_init(); -int nosc_poll(); -void nosc_finish(); +int nosc_init(void); +int nosc_poll(void); +void nosc_finish(void); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/nyx.c b/lib-src/libnyquist/nyquist/nyqsrc/nyx.c index 4cc1fea75..95c6b7dfc 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/nyx.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/nyx.c @@ -17,6 +17,9 @@ #ifndef WIN32 #include +#else +#include +#include #endif /* nyx includes */ @@ -71,6 +74,8 @@ LOCAL XLCONTEXT nyx_cntxt; LOCAL int nyx_first_time = 1; LOCAL LVAL nyx_obarray; LOCAL FLOTYPE nyx_warp_stretch; +LOCAL long nyx_input_length = 0; +LOCAL char *nyx_audio_name = NULL; /* Suspension node */ typedef struct nyx_susp_struct { @@ -82,7 +87,7 @@ typedef struct nyx_susp_struct { } nyx_susp_node, *nyx_susp_type; #if defined(NYX_DEBUG_COPY) && NYX_DEBUG_COPY -static const char *_types_[] = +static const char *_types_[] = { "FREE_NODE", "SUBR", @@ -253,7 +258,8 @@ LOCAL LVAL nyx_dup_value(LVAL val) break; case CONS: - nval = cons(nyx_dup_value(car(val)), nyx_dup_value(cdr(val))); + nval = nyx_dup_value(cdr(val)); + nval = cons(nyx_dup_value(car(val)), nval); break; case SUBR: @@ -327,6 +333,11 @@ LOCAL void nyx_save_obarray() continue; } + // Ignore *SCRATCH* since it's allowed to be updated + if (strcmp(name, "*SCRATCH*") == 0) { + continue; + } + // Duplicate the symbol's values setvalue(nsym, nyx_dup_value(getvalue(syma))); setplist(nsym, nyx_dup_value(getplist(syma))); @@ -344,6 +355,7 @@ LOCAL void nyx_save_obarray() LOCAL void nyx_restore_obarray() { LVAL obvec = getvalue(obarray); + LVAL sscratch = xlenter("*SCRATCH*"); // one-time lookup int i; // Scan all obarray vectors @@ -351,6 +363,7 @@ LOCAL void nyx_restore_obarray() LVAL last = NULL; LVAL dcon; + // Scan all elements for (dcon = getelement(obvec, i); dcon; dcon = cdr(dcon)) { LVAL dsym = car(dcon); char *name = (char *)getstring(getpname(dsym)); @@ -362,6 +375,11 @@ LOCAL void nyx_restore_obarray() continue; } + // Ignore *SCRATCH* since it's allowed to be updated + if (strcmp(name, "*SCRATCH*") == 0) { + continue; + } + // Find the symbol in the original obarray. for (scon = getelement(nyx_obarray, hash(name, HSIZE)); scon; scon = cdr(scon)) { LVAL ssym = car(scon); @@ -375,15 +393,21 @@ LOCAL void nyx_restore_obarray() } } - // If we didn't find the symbol in the original obarray, then it must've - // been added since and must be removed from the current obarray. + // If we didn't find the symbol in the original obarray, then it + // must've been added and must be removed from the current obarray. + // Exception: if the new symbol is a property symbol of *scratch*, + // then allow the symbol to stay; otherwise, property lookups will + // fail. if (scon == NULL) { - if (last) { - rplacd(last, cdr(dcon)); - } - else { - setelement(obvec, i, cdr(dcon)); - } + // check property list of scratch + if (findprop(sscratch, dsym) == NIL) { + if (last) { + rplacd(last, cdr(dcon)); + } + else { + setelement(obvec, i, cdr(dcon)); + } + } // otherwise, keep new property symbol } // Must track the last dcon for symbol removal @@ -396,7 +420,6 @@ LOCAL void nyx_restore_obarray() LOCAL LVAL copylist(LVAL from) { - LVAL nsym; if (from == NULL) { return NULL; } @@ -432,9 +455,10 @@ void nyx_init() argv[0] = "nyquist"; xlisp_main_init(1, argv); + nyx_audio_name = NULL; nyx_os_cb = NULL; nyx_output_cb = NULL; - + nyx_first_time = 0; #if defined(NYX_FULL_COPY) && NYX_FULL_COPY @@ -443,7 +467,7 @@ void nyx_init() #else // Permanently protect the original obarray value. This is needed since // it would be unreferenced in the new obarray and would be garbage - // collected. We want to keep it around so we can make copies of it to + // collected. We want to keep it around so we can make copies of it to // refresh the execution state. xlprot1(nyx_obarray); nyx_obarray = getvalue(obarray); @@ -483,22 +507,38 @@ void nyx_cleanup() // Make sure the sound nodes can be garbage-collected. Sounds are EXTERN // nodes whose value does not get copied during a full copy of the obarray. - setvalue(xlenter("S"), NIL); + setvalue(xlenter(nyx_get_audio_name()), NIL); // Free excess memory segments - does a gc() freesegs(); + // Free unused memory pools + falloc_gc(); + // No longer need the callbacks nyx_output_cb = NULL; nyx_os_cb = NULL; + // Reset vars + nyx_input_length = 0; + + if (nyx_audio_name) { + free(nyx_audio_name); + nyx_audio_name = NULL; + } + #if defined(NYX_MEMORY_STATS) && NYX_MEMORY_STATS printf("\nnyx_cleanup\n"); xmem(); #endif } -LOCAL void nyx_susp_fetch(register nyx_susp_type susp, snd_list_type snd_list) +void nyx_set_xlisp_path(const char *path) +{ + set_xlisp_path(path); +} + +LOCAL void nyx_susp_fetch(nyx_susp_type susp, snd_list_type snd_list) { sample_block_type out; sample_block_values_type out_ptr; @@ -510,11 +550,12 @@ LOCAL void nyx_susp_fetch(register nyx_susp_type susp, snd_list_type snd_list) snd_list->block = out; n = max_sample_block_len; - if (susp->susp.current + n > susp->len) + if (susp->susp.current + n > susp->len) { n = susp->len - susp->susp.current; + } err = susp->callback(out_ptr, susp->channel, - susp->susp.current, n, 0, susp->userdata); + susp->susp.current, n, 0, susp->userdata); if (err) { // The user canceled or some other error occurred, so we use // xlsignal() to jump back to our error handler. @@ -553,25 +594,58 @@ void nyx_capture_output(nyx_output_callback callback, void *userdata) nyx_output_ud = userdata; } +char *nyx_get_audio_name() +{ + if (!nyx_audio_name) { + nyx_audio_name = strdup("S"); + } + + return nyx_audio_name; +} + +void nyx_set_audio_name(const char *name) +{ + if (nyx_audio_name) { + free(nyx_audio_name); + nyx_audio_name = NULL; + } + + nyx_audio_name = strdup(name); +} + void nyx_set_audio_params(double rate, long len) { - double stretch_len = (len > 0 ? len / rate : 1.0); - LVAL warp; + LVAL flo; + LVAL con; + + xlstkcheck(2); + xlsave(flo); + xlsave(con); /* Bind the sample rate to the "*sound-srate*" global */ - setvalue(xlenter("*SOUND-SRATE*"), cvflonum(rate)); + flo = cvflonum(rate); + setvalue(xlenter("*DEFAULT-SOUND-SRATE*"), flo); + setvalue(xlenter("*SOUND-SRATE*"), flo); + + /* Bind the control sample rate to "*control-srate*" globals */ + flo = cvflonum((double) rate / 20.0); + setvalue(xlenter("*DEFAULT-CONTROL-SRATE*"), flo); + setvalue(xlenter("*CONTROL-SRATE*"), flo); /* Bind selection len to "len" global */ - setvalue(xlenter("LEN"), cvflonum(len)); + nyx_input_length = len; + flo = cvflonum(len); + setvalue(xlenter("LEN"), flo); /* Set the "*warp*" global based on the length of the audio */ - xlprot1(warp); - warp = cons(cvflonum(0), /* time offset */ - cons(cvflonum(stretch_len), /* time stretch */ - cons(NULL, /* cont. time warp */ - NULL))); - setvalue(xlenter("*WARP*"), warp); - xlpop(); + con = cons(NULL, NULL); + flo = cvflonum(len > 0 ? (double) len / rate : 1.0); + con = cons(flo, con); + flo = cvflonum(0); + con = cons(flo, con); + setvalue(xlenter("*WARP*"), con); + + xlpopn(2); } void nyx_set_input_audio(nyx_audio_callback callback, @@ -579,54 +653,52 @@ void nyx_set_input_audio(nyx_audio_callback callback, int num_channels, long len, double rate) { - sample_type scale_factor = 1.0; - time_type t0 = 0.0; - nyx_susp_type *susp; - sound_type *snd; - int ch; + LVAL val; + int ch; nyx_set_audio_params(rate, len); - susp = (nyx_susp_type *)malloc(num_channels * sizeof(nyx_susp_type)); - snd = (sound_type *)malloc(num_channels * sizeof(sound_type)); - - for(ch=0; ch < num_channels; ch++) { - falloc_generic(susp[ch], nyx_susp_node, "nyx_set_input_audio"); - - susp[ch]->callback = callback; - susp[ch]->userdata = userdata; - susp[ch]->len = len; - susp[ch]->channel = ch; - - susp[ch]->susp.fetch = nyx_susp_fetch; - susp[ch]->susp.keep_fetch = NULL; - susp[ch]->susp.free = nyx_susp_free; - susp[ch]->susp.mark = NULL; - susp[ch]->susp.print_tree = nyx_susp_print_tree; - susp[ch]->susp.name = "nyx"; - susp[ch]->susp.toss_cnt = 0; - susp[ch]->susp.current = 0; - susp[ch]->susp.sr = rate; - susp[ch]->susp.t0 = t0; - susp[ch]->susp.log_stop_cnt = 0; - - snd[ch] = sound_create((snd_susp_type)susp[ch], t0, - rate, - scale_factor); - } - if (num_channels > 1) { - LVAL array = newvector(num_channels); - for(ch=0; chcallback = callback; + susp->userdata = userdata; + susp->len = len; + susp->channel = ch; + + susp->susp.fetch = (snd_fetch_fn)nyx_susp_fetch; + susp->susp.keep_fetch = NULL; + susp->susp.free = (snd_free_fn)nyx_susp_free; + susp->susp.mark = NULL; + susp->susp.print_tree = (snd_print_tree_fn)nyx_susp_print_tree; + susp->susp.name = "nyx"; + susp->susp.toss_cnt = 0; + susp->susp.current = 0; + susp->susp.sr = rate; + susp->susp.t0 = 0.0; + susp->susp.log_stop_cnt = 0; + + snd = sound_create((snd_susp_type) susp, 0.0, rate, 1.0); + if (num_channels > 1) { + setelement(val, ch, cvsound(snd)); + } + else { + val = cvsound(snd); + } } + + setvalue(xlenter(nyx_get_audio_name()), val); + + xlpop(); } LOCAL int nyx_is_labels(LVAL expr) @@ -644,33 +716,41 @@ LOCAL int nyx_is_labels(LVAL expr) } while (expr != NULL) { - if (!consp(expr)) + if (!consp(expr)) { return 0; + } label = car(expr); - if (!consp(label)) + if (!consp(label)) { return 0; + } first = car(label); - if (!(floatp(first) || fixp(first))) + if (!(floatp(first) || fixp(first))) { return 0; + } - if (!consp(cdr(label))) + if (!consp(cdr(label))) { return 0; + } second = car(cdr(label)); if (floatp(second) || fixp(second)) { - if (!consp(cdr(cdr(label)))) + if (!consp(cdr(cdr(label)))) { return 0; + } third = car(cdr(cdr(label))); - if (!(stringp(third))) + if (!(stringp(third))) { return 0; + } } - else - if (!(stringp(second))) + else { + if (!(stringp(second))) { return 0; + } + } expr = cdr(expr); } @@ -686,16 +766,16 @@ nyx_rval nyx_get_type(LVAL expr) nyx_result_type = nyx_error; - if (expr==NULL) { + if (expr == NULL) { return nyx_result_type; } - switch(ntype(expr)) + switch (ntype(expr)) { case FIXNUM: nyx_result_type = nyx_int; break; - + case FLONUM: nyx_result_type = nyx_double; break; @@ -709,7 +789,7 @@ nyx_rval nyx_get_type(LVAL expr) /* make sure it's a vector of sounds */ int i; nyx_result_type = nyx_audio; - for(i=0; istop); + if (nyx_input_length == 0) { + LVAL val = getvalue(xlenter("LEN")); + if (val != s_unbound) { + if (ntype(val) == FLONUM) { + nyx_input_length = (long) getflonum(val); + } + else if (ntype(val) == FIXNUM) { + nyx_input_length = (long) getfixnum(val); + } + } } - while(result==0) { - for(ch=0; chget_next(snd, &cnt); + block = sound_get_next(snd, &cnt); if (block == zero_block || cnt == 0) { + success = TRUE; result = -1; break; } - /* copy the data to a temporary buffer and scale it - by the appropriate scale factor */ - - if (cnt > bufferlen) { - if (buffer) - free(buffer); - - buffer = (float *)malloc(cnt * sizeof(float)); - if (buffer == NULL) { - goto finish; - } - - bufferlen = cnt; + // Copy and scale the samples + for (i = 0; i < cnt; i++) { + buffer[i] = block->samples[i] * snd->scale; } - memcpy(buffer, block->samples, cnt * sizeof(float)); - - for(i=0; iscale; - - result = callback(buffer, ch, - totals[ch], cnt, lens[ch], userdata); + result = callback((float *)buffer, ch, + totals[ch], cnt, lens[ch] ? lens[ch] : cnt, userdata); if (result != 0) { - // The user canceled or some other error occurred, so we use - // xlsignal() to jump back to our error handler. - xlsignal(NULL, NULL); - // never get here. + result = -1; + break; } totals[ch] += cnt; } } - success = TRUE; - - xltoplevel(); + // This will unwind the xlisp context and restore internals to a point just + // before we issued our xlbegin() above. This is important since the internal + // xlisp stacks will contain pointers to invalid objects otherwise. + // + // Also note that execution will jump back up to the statement following the + // _setjmp() above. + xljump(&nyx_cntxt, CF_TOPLEVEL, NIL); + // Never reached finish: - gc(); - if (buffer) { free(buffer); } @@ -940,6 +1062,8 @@ int nyx_get_audio(nyx_audio_callback callback, void *userdata) free(snds); } + gc(); + #if defined(NYX_MEMORY_STATS) && NYX_MEMORY_STATS printf("\nnyx_get_audio after\n"); xmem(); @@ -950,39 +1074,42 @@ int nyx_get_audio(nyx_audio_callback callback, void *userdata) int nyx_get_int() { - if (nyx_get_type(nyx_result) != nyx_int) + if (nyx_get_type(nyx_result) != nyx_int) { return -1; + } return getfixnum(nyx_result); } double nyx_get_double() { - if (nyx_get_type(nyx_result) != nyx_double) + if (nyx_get_type(nyx_result) != nyx_double) { return -1.0; + } return getflonum(nyx_result); } const char *nyx_get_string() { - if (nyx_get_type(nyx_result) != nyx_string) + if (nyx_get_type(nyx_result) != nyx_string) { return NULL; + } return (const char *)getstring(nyx_result); } unsigned int nyx_get_num_labels() { - LVAL s = nyx_result; + LVAL s; int count = 0; - if (nyx_get_type(nyx_result) != nyx_labels) + if (nyx_get_type(nyx_result) != nyx_labels) { return 0; + } - while(s) { + for (s = nyx_result; s; s = cdr(s)) { count++; - s = cdr(s); } return count; @@ -999,10 +1126,11 @@ void nyx_get_label(unsigned int index, LVAL t1_expr; LVAL str_expr; - if (nyx_get_type(nyx_result) != nyx_labels) + if (nyx_get_type(nyx_result) != nyx_labels) { return; + } - while(index) { + while (index) { index--; s = cdr(s); if (s == NULL) { @@ -1020,18 +1148,23 @@ void nyx_get_label(unsigned int index, str_expr = t1_expr; t1_expr = t0_expr; } - else + else { str_expr = car(cdr(cdr(label_expr))); + } - if (floatp(t0_expr)) + if (floatp(t0_expr)) { *start_time = getflonum(t0_expr); - else if (fixp(t0_expr)) + } + else if (fixp(t0_expr)) { *start_time = (double)getfixnum(t0_expr); + } - if (floatp(t1_expr)) + if (floatp(t1_expr)) { *end_time = getflonum(t1_expr); - else if (fixp(t1_expr)) + } + else if (fixp(t1_expr)) { *end_time = (double)getfixnum(t1_expr); + } *label = (const char *)getstring(str_expr); } @@ -1077,24 +1210,24 @@ int ostgetc() nyx_expr_pos++; return '\n'; } - else - return EOF; + + return EOF; } /* osinit - initialize */ -void osinit(char *banner) +void osinit(const char *banner) { } /* osfinish - clean up before returning to the operating system */ -void osfinish(void) +void osfinish(void) { } /* oserror - print an error message */ -void oserror(char *msg) +void oserror(const char *msg) { - printf("nyx error: %s\n", msg); + errputstr(msg); } long osrand(long n) @@ -1104,79 +1237,77 @@ long osrand(long n) /* cd .. open - open an ascii file */ -FILE *osaopen(name,mode) char *name,*mode; +FILE *osaopen(const char *name, const char *mode) { - FILE *fp; - fp = fopen(name,mode); - return fp; + return fopen(name, mode); } /* osbopen - open a binary file */ -FILE *osbopen(char *name, char *mode) +FILE *osbopen(const char *name, const char *mode) { char bmode[10]; - FILE *fp; - + strncpy(bmode, mode, 8); - strcat(bmode,"b"); - fp = fopen(name,bmode); - return fp; + strcat(bmode, "b"); + + return fopen(name,bmode); } /* osclose - close a file */ int osclose(FILE *fp) { - return (fclose(fp)); + return fclose(fp); } /* osagetc - get a character from an ascii file */ int osagetc(FILE *fp) { - return (getc(fp)); + return getc(fp); } /* osaputc - put a character to an ascii file */ int osaputc(int ch, FILE *fp) { - return (putc(ch,fp)); + return putc(ch,fp); } /* osoutflush - flush output to a file */ -void osoutflush(FILE *fp) { fflush(fp); } - -extern int dbgflg; +void osoutflush(FILE *fp) +{ + fflush(fp); +} /* osbgetc - get a character from a binary file */ -/* int osbgetc(fp) FILE *fp; {return (getc(fp));} */ -#ifndef WIN32 // duplicated in winfun.c, per James Crook, 7/4/2003 - int osbgetc(FILE *fp) - { - return (getc(fp)); - } -#endif +int osbgetc(FILE *fp) +{ + return getc(fp); +} /* osbputc - put a character to a binary file */ int osbputc(int ch, FILE *fp) { - return (putc(ch,fp)); + return putc(ch, fp); } /* ostputc - put a character to the terminal */ void ostputc(int ch) -{ +{ oscheck(); /* check for control characters */ - - if (nyx_output_cb) + + if (nyx_output_cb) { nyx_output_cb(ch, nyx_output_ud); - else - putchar(((char) ch)); + } + else { + putchar((char) ch); + } } /* ostoutflush - flush output buffer */ void ostoutflush() { - if (!nyx_output_cb) + if (!nyx_output_cb) { fflush(stdout); + } } /* osflush - flush the terminal input buffer */ @@ -1196,7 +1327,6 @@ void oscheck(void) } /* xsystem - execute a system command */ -#ifndef WIN32 // duplicated in winfun.c, per James Crook, 7/4/2003 LVAL xsystem() { if (moreargs()) { @@ -1206,82 +1336,218 @@ LVAL xsystem() } return s_true; } -#endif -#ifndef WIN32 /* xsetdir -- set current directory of the process */ LVAL xsetdir() { char *dir = (char *)getstring(xlgastring()); int result; LVAL cwd = NULL; + int verbose = TRUE; + + if (moreargs()) { + verbose = (xlgetarg() != NIL); + } + xllastarg(); + result = chdir(dir); if (result) { - perror("SETDIR"); + /* perror("SETDIR"); -- Nyquist uses SETDIR to search for directories + * at startup, so failures are normal, and seeing error messages + * could be confusing, so don't print them. The NULL return indicates + * an error, but doesn't tell which one it is. + * But now, SETDIR has a second verbose parameter that is nil when + * searching for directories. -RBD + */ + if (verbose) perror("Directory Setting Error"); + return NULL; } + dir = getcwd(NULL, 1000); if (dir) { - cwd = cvstring(dir); - free(dir); - } + cwd = cvstring(dir); + free(dir); + } + return cwd; } -#endif /* xgetkey - get a key from the keyboard */ -#ifndef WIN32 // duplicated in winfun.c, per James Crook, 7/4/2003 - LVAL xgetkey() {xllastarg(); return (cvfixnum((FIXTYPE)getchar()));} -#endif +LVAL xgetkey() +{ + xllastarg(); + return (cvfixnum((FIXTYPE)getchar())); +} /* ossymbols - enter os specific symbols */ -#ifndef WIN32 // duplicated in winfun.c, per James Crook, 7/4/2003 - void ossymbols(void) {} -#endif +void ossymbols(void) +{ +} /* xsetupconsole -- used to configure window in Win32 version */ -#ifndef WIN32 // duplicated in winfun.c, per James Crook, 7/4/2003 - LVAL xsetupconsole() { return NULL; } -#endif +LVAL xsetupconsole() +{ + return NULL; +} +#if defined(WIN32) +const char os_pathchar = '\\'; +const char os_sepchar = ','; +#else const char os_pathchar = '/'; const char os_sepchar = ':'; +#endif /* control-C handling */ -void ctcinit() {} +void ctcinit() +{ +} /* xechoenabled -- set/clear echo_enabled flag (unix only) */ -LVAL xechoenabled() { return NULL; } +LVAL xechoenabled() +{ + return NULL; +} -/* osdir_list_start -- open a directory listing */ -int osdir_list_start(char *path) { return FALSE; } +#if defined(WIN32) + +static WIN32_FIND_DATA FindFileData; +static HANDLE hFind = INVALID_HANDLE_VALUE; +#define OSDIR_LIST_READY 0 +#define OSDIR_LIST_STARTED 1 +#define OSDIR_LIST_DONE 2 +static int osdir_list_status = OSDIR_LIST_READY; +#define OSDIR_MAX_PATH 256 +static char osdir_path[OSDIR_MAX_PATH]; + +// osdir_list_start -- prepare to list a directory +int osdir_list_start(const char *path) +{ + if (strlen(path) >= OSDIR_MAX_PATH - 2) { + xlcerror("LISTDIR path too big", "return nil", NULL); + return FALSE; + } + strcpy(osdir_path, path); + strcat(osdir_path, "/*"); // make a pattern to match all files + + if (osdir_list_status != OSDIR_LIST_READY) { + osdir_list_finish(); // close previously interrupted listing + } + + hFind = FindFirstFile(osdir_path, &FindFileData); // get the "." + if (hFind == INVALID_HANDLE_VALUE) { + return FALSE; + } + if (FindNextFile(hFind, &FindFileData) == 0) { + return FALSE; // get the ".." + } + + osdir_list_status = OSDIR_LIST_STARTED; + + return TRUE; +} /* osdir_list_next -- read the next entry from a directory */ -char *osdir_list_next() { return NULL; } +const char *osdir_list_next() +{ + if (FindNextFile(hFind, &FindFileData) == 0) { + osdir_list_status = OSDIR_LIST_DONE; + return NULL; + } + return FindFileData.cFileName; +} /* osdir_list_finish -- close an open directory */ -void osdir_list_finish() { return; } +void osdir_list_finish() +{ + if (osdir_list_status != OSDIR_LIST_READY) { + FindClose(hFind); + } + osdir_list_status = OSDIR_LIST_READY; +} + +#else + +#include +#define OSDIR_LIST_READY 0 +#define OSDIR_LIST_STARTED 1 +#define OSDIR_LIST_DONE 2 +static int osdir_list_status = OSDIR_LIST_READY; +static DIR *osdir_dir; + +/* osdir_list_start -- open a directory listing */ +int osdir_list_start(const char *path) +{ + if (osdir_list_status != OSDIR_LIST_READY) { + osdir_list_finish(); /* close current listing */ + } + osdir_dir = opendir(path); + if (!osdir_dir) { + return FALSE; + } + osdir_list_status = OSDIR_LIST_STARTED; + return TRUE; +} + +/* osdir_list_next -- read the next entry from a directory */ +const char *osdir_list_next() +{ + struct dirent *entry; + + if (osdir_list_status != OSDIR_LIST_STARTED) { + return NULL; + } + + entry = readdir(osdir_dir); + if (!entry) { + osdir_list_status = OSDIR_LIST_DONE; + return NULL; + } + return entry->d_name; +} + +/* osdir_list_finish -- close an open directory */ +void osdir_list_finish() +{ + if (osdir_list_status != OSDIR_LIST_READY) { + closedir(osdir_dir); + } + osdir_list_status = OSDIR_LIST_READY; +} + +#endif -#ifndef WIN32 /* xget_temp_path -- get a path to create temp files */ LVAL xget_temp_path() { - char *tmp = getenv("TMPDIR"); + char *tmp; + +#if defined(WINDOWS) + tmp = getenv("TEMP"); +#else + tmp = getenv("TMPDIR"); +#endif + if (!tmp || !*tmp) { tmp = getenv("TMP"); if (!tmp || !*tmp) { +#if defined(WINDOWS) + tmp = "/"; +#else tmp = "/tmp/"; +#endif } } + return cvstring(tmp); } -#endif -#ifndef WIN32 /* xget_user -- get a string identifying the user, for use in file names */ LVAL xget_user() { char *user = getenv("USER"); + if (!user || !*user) { user = getenv("USERNAME"); if (!user || !*user) { @@ -1289,6 +1555,23 @@ LVAL xget_user() user = "nyquist"; } } + return cvstring(user); } + +#if defined(WINDOWS) +/* get_xlisp_path -- return path to xlisp */ +void get_xlisp_path(char *p, long p_max) +{ + char *paths = getenv("XLISPPATH"); + + if (!paths || !*paths) { + *p = 0; + return; + } + + strncpy(p, paths, p_max); + p[p_max-1] = 0; +} #endif + diff --git a/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.c b/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.c index 0627d998a..7b1588c4e 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.c @@ -169,17 +169,17 @@ what do we do? #include "cmupv.h" typedef struct pvstate_struct { - long f_count; /* how many samples have we taken from f? */ - long g_count; /* how many samples have we taken from g? */ + int64_t f_count; /* how many samples have we taken from f? */ + int64_t g_count; /* how many samples have we taken from g? */ double g_prev; /* the previous value of g (at g_count - 2) */ double g_next; /* the current value of g (at g_count - 1) */ - long sample_count; /* how many total samples computed, specifically + int64_t sample_count; /* how many total samples computed, specifically * the number of samples copied into Nyquist * sample blocks via *out++ = pvs->output[index++]; */ Phase_vocoder *pv; /* the phase vocoder object */ sample_type *input; /* a frame of samples to go into fft */ - long input_count; /* sample number of first sample in input */ + int64_t input_count; /* sample number of first sample in input */ sample_type *output; /* output from phase vocoder */ long output_count; /* since we deliver samples on demand, output_count keeps track of how much is left in output. @@ -188,17 +188,17 @@ typedef struct pvstate_struct { int hopsize; /* the hopsize -- not used */ int mode; /* the mode -- see cmupv.h */ /* data to compute logical stop time */ - long t0; /* output sample count of previous frame */ + int64_t t0; /* output sample count of previous frame */ double g0; /* input time of previous frame center */ /* data to detect termination */ long f_terminated; /* set when f terminates */ - long f_terminate_count; /* sample count of f when it terminates */ + int64_t f_terminate_count; /* sample count of f when it terminates */ long g_terminated; /* set when g terminates */ - long g_terminate_count; /* sample count of g when it terminates */ + int64_t g_terminate_count; /* sample count of g when it terminates */ /* return values from pv_callback */ long flags; /* logical stop and terminate flags */ - long logical_stop_count; /* sample count of output logical stop */ - long terminate_count; /* sample count of output terminate time */ + int64_t logical_stop_count; /* sample count of output logical stop */ + int64_t terminate_count; /* sample count of output terminate time */ } pvstate_node, *pvstate_type; #define OUTPUT_SIZE 256 @@ -216,7 +216,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock) * interpolation math work right */ double g_count = out_time * susp->g->sr + 1.0; double g; /* the value of g at g_count which is at the time of out_count */ - long f_start; /* the start sample of input f for the next frame */ + int64_t f_start; /* the start sample of input f for the next frame */ int hop; /* the hopsize from the previous frame to this frame, thus the offset into input buffer of the data we want to keep */ int got_from_f; /* samples already in input */ @@ -224,7 +224,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock) sample_type *input = pvs->input; int i; int f_logically_stopped = FALSE; - long f_logical_stop_count; + int64_t f_logical_stop_count; pvs->flags = 0; /* before loop: * pvs->g_count <= g_count, @@ -257,7 +257,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock) /* f_start is now the first sample position of the window */ /* (4) shift INPUT */ - hop = f_start - pvs->input_count; + hop = (int) (f_start - pvs->input_count); if (hop < 0) { hop = 0; } @@ -311,7 +311,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock) /* new window is all zero, so output terminates soon ... */ pvs->flags |= PVSHELL_FLAG_TERMINATE; pvs->terminate_count = out_count - hop + pvs->fftsize / 2; - printf("pv_callback terminated by f at %ld\n", pvs->terminate_count); + /* printf("pv_callback terminated by f at %ld\n", pvs->terminate_count); */ } pvs->t0 = out_count; pvs->g0 = g; @@ -335,12 +335,12 @@ int pv_callback(long out_count, float *samples, int len, void *rock) (See comments at top of file for more about the computation here.) */ if (f_logically_stopped && !pvs->g_terminated) { - pvs->logical_stop_count = pvs->t0 + (out_count - pvs->t0) * - ((f_logical_stop_count / susp->f->sr - pvs->g0) / (g - pvs->g0)); + pvs->logical_stop_count = (int64_t) (pvs->t0 + (out_count - pvs->t0) * + ((f_logical_stop_count / susp->f->sr - pvs->g0) / (g - pvs->g0))); } if (pvs->g_terminated) { - long term_cnt_from_g = ROUNDBIG((pvs->g_terminate_count / susp->g->sr) * - susp->f->sr); + int64_t term_cnt_from_g = + ROUNDBIG((pvs->g_terminate_count / susp->g->sr) * susp->f->sr); if (f_logically_stopped) { /* take min of g and f log. stop cnt */ pvs->logical_stop_count = MIN(pvs->logical_stop_count, term_cnt_from_g); @@ -377,7 +377,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock) */ long pv_fetch(pvshell_type susp, sample_block_values_type out, long *n, - long sample_count) + int64_t sample_count) { pvstate_type pvs = (pvstate_type) susp->state; int i; @@ -408,8 +408,8 @@ long pv_fetch(pvshell_type susp, if (take > remaining) take = remaining; if (pvs->flags) { if (pvs->flags & PVSHELL_FLAG_TERMINATE) { - int to_term = pvs->terminate_count - sample_count; - if (to_term < take) take = to_term; + int64_t to_term = pvs->terminate_count - sample_count; + if (to_term < take) take = (int) to_term; if (take == 0) { /* we want to set the terminate flag at the beginning of the sample block, i.e. only if count == 0; if @@ -422,7 +422,7 @@ long pv_fetch(pvshell_type susp, } } if (pvs->flags & PVSHELL_FLAG_LOGICAL_STOP) { - int to_stop = pvs->logical_stop_count - sample_count; + int64_t to_stop = pvs->logical_stop_count - sample_count; /* if we're exactly at the logical stop block, then set the logical stop flag and compute the block as normal. Otherwise, if we have not reached the logical @@ -433,7 +433,7 @@ long pv_fetch(pvshell_type susp, if (to_stop == 0 && count == 0) { flags |= PVSHELL_FLAG_LOGICAL_STOP; } else if (to_stop > 0 && to_stop < take) { - take = to_stop; + take = (int) to_stop; } } } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.h b/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.h index 6e564ded9..791545239 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/phasevocoder.h @@ -3,4 +3,4 @@ */ sound_type snd_phasevocoder(sound_type f, sound_type g, long fftsize, long hopsize, long mode); - /* LISP: (snd-phasevocoder SOUND SOUND FIXNUM FIXNUM FIXNUM) */ + /* LISP: (snd-phasevocoder SOUND SOUND LONG LONG LONG) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/pvshell.c b/lib-src/libnyquist/nyquist/nyqsrc/pvshell.c index 38435c47f..1b3c3a1e7 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/pvshell.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/pvshell.c @@ -28,7 +28,7 @@ * 28Apr03 dm changes for portability and fix compiler warnings */ -void pvshell_free(); +void pvshell_free(snd_susp_type a_susp); typedef struct pvshell_susp_struct { diff --git a/lib-src/libnyquist/nyquist/nyqsrc/pvshell.h b/lib-src/libnyquist/nyquist/nyqsrc/pvshell.h index 5ecd16e7c..f3985bdf0 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/pvshell.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/pvshell.h @@ -28,16 +28,16 @@ struct pvshell_struct; typedef long (*h_fn_type)(struct pvshell_struct *susp, sample_block_values_type out, long *n, - long sample_count); + int64_t sample_count); typedef void (*pvs_free_fn_type)(struct pvshell_struct *susp); typedef struct pvshell_struct { sound_type f; - long f_cnt; + int f_cnt; sample_block_values_type f_ptr; sound_type g; - long g_cnt; + int g_cnt; sample_block_values_type g_ptr; long flags; /* for terminated and logically stopped flags */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/resamp.c b/lib-src/libnyquist/nyquist/nyqsrc/resamp.c index a877d7765..a8e60c899 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/resamp.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/resamp.c @@ -63,14 +63,14 @@ samples). When downsampling, the filter is stretched by 1/factor */ -void resample_free(); +void resample_free(snd_susp_type a_susp); typedef struct resample_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; float *X; long Xsize; @@ -118,7 +118,7 @@ static int SrcUp(float X[], float Y[], double factor, double *Time, *Y++ = (float) v; *Time += dt; /* Move to next sample by time increment */ } - return (Y - Ystart); /* Return the number of output samples */ + return (int) (Y - Ystart); /* Return the number of output samples */ } @@ -152,7 +152,7 @@ static int SrcUD(float X[], float Y[], double factor, double *Time, *Y++ = (float) v; *Time += dt; /* Move to next sample by time increment */ } - return (Y - Ystart); /* Return the number of output samples */ + return (int) (Y - Ystart); /* Return the number of output samples */ } @@ -199,13 +199,13 @@ samples need to be shifted from the end of X to the beginning. while (susp->Xp < susp->Xsize) { /* outer loop */ /* read samples from susp->s into X */ - togo = susp->Xsize - susp->Xp; + togo = (int) (susp->Xsize - susp->Xp); /* don't run past the s input sample block. If termination or * logical stop info become available, translate to susp->terminate_cnt * and susp->log_stop_cnt. */ susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = MIN(togo, susp->s_cnt); + togo = (int) MIN(togo, susp->s_cnt); memcpy(susp->X + susp->Xp, susp->s_ptr, togo * sizeof(sample_type)); susp->s_ptr += togo; @@ -221,15 +221,15 @@ samples need to be shifted from the end of X to the beginning. togo = max_sample_block_len; if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + max_sample_block_len) { - togo = susp->terminate_cnt - susp->susp.current; + togo = (int) (susp->terminate_cnt - susp->susp.current); } if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - susp->susp.current; + int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current; assert(to_stop >= 0); if (to_stop < togo) { if (to_stop == 0) susp->logically_stopped = true; - else togo = to_stop; + else togo = (int) to_stop; } } if (togo == 0) { diff --git a/lib-src/libnyquist/nyquist/nyqsrc/resampv.c b/lib-src/libnyquist/nyquist/nyqsrc/resampv.c index 01d88d723..6da3cdd79 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/resampv.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/resampv.c @@ -60,14 +60,14 @@ typedef struct resamplev_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type f; - long f_cnt; + int f_cnt; sample_block_values_type f_ptr; sound_type g; - long g_cnt; + int g_cnt; sample_block_values_type g_ptr; double prev_g; /* data for interpolation: */ double next_g; @@ -97,7 +97,7 @@ typedef struct resamplev_susp_struct { int Xoff; /* number of extra samples at beginning and end of X */ } resamplev_susp_node, *resamplev_susp_type; -void resamplev_free(); +void resamplev_free(snd_susp_type a_susp); void resampv_refill(resamplev_susp_type susp); /* Sampling rate conversion subroutine diff --git a/lib-src/libnyquist/nyquist/nyqsrc/samples.c b/lib-src/libnyquist/nyquist/nyqsrc/samples.c index e841f67b3..e426c31a0 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/samples.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/samples.c @@ -18,7 +18,7 @@ LVAL s_next = NULL; LVAL s_send; -void samples_symbols() +void samples_symbols(void) { s_next = xlenter(":NEXT"); s_send = xlenter("SEND"); @@ -64,10 +64,10 @@ sound_type snd_from_array(double t0, double sr, LVAL array) /* snd_length -- count how many samples are in a sound */ /**/ -long snd_length(sound_type s, long len) +int64_t snd_length(sound_type s, int64_t len) { - long total = 0; - long blocklen; + int64_t total = 0; + int blocklen; s = sound_copy(s); if (len > s->stop) len = s->stop; @@ -87,7 +87,7 @@ long snd_length(sound_type s, long len) double snd_maxsamp(sound_type s) { sample_type result = 0.0F; - long blocklen; + int blocklen; s = sound_copy(s); while (true) { @@ -113,9 +113,9 @@ LVAL snd_samples(sound_type s, long len) { LVAL v; long vx = 0; - long blocklen; + int blocklen; register double scale_factor = s->scale; - len = snd_length(s, len); + len = (long) snd_length(s, len); s = sound_copy(s); xlsave1(v); @@ -155,14 +155,16 @@ LVAL snd_samples(sound_type s, long len) LVAL snd_fetch(sound_type s) { if (!s->extra) { /* this is the first call, so fix up s */ - s->extra = (long *) malloc(sizeof(long) * FIELDS); - s->extra[0] = sizeof(long) * FIELDS; + s->extra = (int64_t *) malloc(sizeof(s->extra[0]) * FIELDS); + s->extra[0] = sizeof(s->extra[0]) * FIELDS; s->CNT = s->INDEX = 0; - } else if (s->extra[0] != sizeof(long) * FIELDS) { + } else if (s->extra[0] != sizeof(s->extra[0]) * FIELDS) { xlfail("sound in use by another iterator"); } - if (s->CNT == s->INDEX) { - sound_get_next(s, &(s->CNT)); + int icnt = (int) s->CNT; /* need this to be type int */ + if (icnt == s->INDEX) { + sound_get_next(s, &icnt); + s->CNT = icnt; /* save the count back to s->extra */ s->INDEX = 0; } if (s->SAMPLES == zero_block->samples) { @@ -205,6 +207,7 @@ LVAL snd_fetch(sound_type s) #define TERMCNT extra[4] #define OFFSET 5 +/* array size is limited by 32-bit len (on Windows) */ LVAL snd_fetch_array(sound_type s, long len, long step) { long i, maxlen, skip, fillptr; @@ -217,23 +220,25 @@ LVAL snd_fetch_array(sound_type s, long len, long step) if (len < 1) xlfail("len < 1"); if (!s->extra) { /* this is the first call, so fix up s */ - s->extra = (long *) malloc(sizeof(long) * (len + OFFSET)); + s->extra = (int64_t *) malloc(sizeof(int64_t) * (len + OFFSET)); s->extra[0] = sizeof(long) * (len + OFFSET); s->CNT = s->INDEX = s->FILLCNT = 0; s->TERMCNT = -1; maxlen = len; } else { - maxlen = (s->extra[0] / sizeof(long)) - OFFSET; + maxlen = (long) ((s->extra[0] / sizeof(long)) - OFFSET); if (maxlen < 1) xlfail("sound in use by another iterator"); if (maxlen < len) xlfail("len grew"); } samples = (float *) &(s->extra[OFFSET]); /* step 1: refill buffer with samples */ - fillptr = s->FILLCNT; + fillptr = (long) s->FILLCNT; /* cast is for Win64 where long is 32-bit */ while (fillptr < maxlen) { + int icnt = (int) s->CNT; /* need this to be type int */ if (s->INDEX == s->CNT) { - sound_get_next(s, &(s->CNT)); + sound_get_next(s, &icnt); + s->CNT = icnt; /* save count back to s->extra */ if (s->SAMPLES == zero_block->samples) { setvalue(rslt_symbol, cvfixnum(fillptr)); if (s->TERMCNT < 0) s->TERMCNT = fillptr; @@ -283,13 +288,15 @@ LVAL snd_fetch_array(sound_type s, long len, long step) */ skip = step - maxlen; while (skip > 0) { - long remaining = s->CNT - s->INDEX; + int remaining = (int) (s->CNT - s->INDEX); if (remaining >= skip) { s->INDEX += skip; skip = 0; } else { skip -= remaining; - sound_get_next(s, &(s->CNT)); + int icnt = (int) s->CNT; /* need to have type int */ + sound_get_next(s, &icnt); + s->CNT = icnt; /* save count back in s->extra */ s->INDEX = 0; } } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/samples.h b/lib-src/libnyquist/nyquist/nyqsrc/samples.h index 890724188..1d57af443 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/samples.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/samples.h @@ -4,17 +4,17 @@ extern LVAL s_next; extern LVAL s_send; -void samples_symbols(); +void samples_symbols(void); sound_type snd_from_array(double t0, double sr, LVAL array); /* LISP: (SND-FROM-ARRAY ANYNUM ANYNUM ANY) */ -LVAL snd_samples(sound_type s, long len); /* LISP: (SND-SAMPLES SOUND FIXNUM) */ -long snd_length(sound_type s, long len); /* LISP: (SND-LENGTH SOUND FIXNUM) */ +LVAL snd_samples(sound_type s, long len); /* LISP: (SND-SAMPLES SOUND LONG) */ +int64_t snd_length(sound_type s, int64_t len); /* LISP: (SND-LENGTH SOUND FIXNUM) */ double snd_maxsamp(sound_type s); /* LISP: (SND-MAXSAMP SOUND) */ LVAL snd_fetch(sound_type s); /* LISP: (SND-FETCH SOUND) */ LVAL snd_fetch_array(sound_type s, long len, long step); - /* LISP: (SND-FETCH-ARRAY SOUND FIXNUM FIXNUM) */ + /* LISP: (SND-FETCH-ARRAY SOUND LONG LONG) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/seqext.c b/lib-src/libnyquist/nyquist/nyqsrc/seqext.c index f8165c80e..8eb21c15d 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/seqext.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/seqext.c @@ -31,12 +31,11 @@ LVAL s_seq; xtype_desc seq_desc; -static void xlseq_print(); +static void xlseq_print(LVAL fptr, void *sequence); -void nop() {} +void nop(void) {} -boolean seqp(s) - LVAL s; +boolean seqp(LVAL s) { return exttypep(s, s_seq); } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/seqext.h b/lib-src/libnyquist/nyquist/nyqsrc/seqext.h index 0727e77c0..52db3c753 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/seqext.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/seqext.h @@ -1,9 +1,9 @@ /* seqext.h -- header for seq extensions for xlisp */ -void seqext_init(); -void seqext_symbols(); -boolean seqp(); +void seqext_init(void); +void seqext_symbols(void); +boolean seqp(LVAL s); extern xtype_desc seq_desc; extern LVAL s_seq; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/seqfnint.c b/lib-src/libnyquist/nyquist/nyqsrc/seqfnint.c index 8781cfc24..0c3047bd4 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/seqfnint.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/seqfnint.c @@ -18,7 +18,6 @@ extern LVAL s_true; extern LVAL RSLT_sym; - #include "seqdecls.h" #include "seqext.h" @@ -42,11 +41,11 @@ LVAL xlc_seq_reset(void) LVAL xlc_seq_insert_ctrl(void) { seq_type arg1 = getseq(xlgaseq()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); xllastarg(); insert_ctrl(arg1, arg2, arg3, arg4, arg5, arg6); @@ -59,14 +58,14 @@ LVAL xlc_seq_insert_ctrl(void) LVAL xlc_seq_insert_ramp(void) { seq_type arg1 = getseq(xlgaseq()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); - long arg7 = getfixnum(xlgafixnum()); - long arg8 = getfixnum(xlgafixnum()); - long arg9 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); + long arg7 = (long) getfixnum(xlgafixnum()); + long arg8 = (long) getfixnum(xlgafixnum()); + long arg9 = (long) getfixnum(xlgafixnum()); xllastarg(); insert_ctrlramp(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); @@ -79,11 +78,11 @@ LVAL xlc_seq_insert_ramp(void) LVAL xlc_seq_insert_macctrl(void) { seq_type arg1 = getseq(xlgaseq()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); xllastarg(); insert_macctrl(arg1, arg2, arg3, arg4, arg5, arg6); @@ -96,12 +95,12 @@ LVAL xlc_seq_insert_macctrl(void) LVAL xlc_seq_insert_note(void) { seq_type arg1 = getseq(xlgaseq()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); - long arg7 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); + long arg7 = (long) getfixnum(xlgafixnum()); xllastarg(); insert_note(arg1, arg2, arg3, arg4, arg5, arg6, arg7); @@ -154,13 +153,13 @@ LVAL xlc_seq_next(void) LVAL xlc_seq_get(void) { seq_type arg1 = getseq(xlgaseq()); - long arg2 = 0; - long arg3 = 0; - long arg4 = 0; - long arg5 = 0; - long arg6 = 0; - long arg7 = 0; - long arg8 = 0; + long arg2 = (long) 0; + long arg3 = (long) 0; + long arg4 = (long) 0; + long arg5 = (long) 0; + long arg6 = (long) 0; + long arg7 = (long) 0; + long arg8 = (long) 0; LVAL result; xllastarg(); @@ -186,8 +185,6 @@ LVAL xlc_seq_get(void) } -#include "seqmwrite.h" - /* xlc_seq_write_smf -- interface to C routine seq_xlwrite_smf */ /**/ LVAL xlc_seq_write_smf(void) @@ -216,6 +213,8 @@ LVAL xlc_seq_read_smf(void) } +#include "seqmwrite.h" + #include "seqread.h" /* xlc_seq_read -- interface to C routine seq_read */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.c b/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.c index 9d8d030a4..416e70832 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.c @@ -25,8 +25,8 @@ boolean seq_next(seq_type seq) /* seq_get -- get event data for the current event */ /**/ -void seq_get(seq_type seq, long *eventtype, long *ntime, long *line, long *chan, - long *value1, long *value2, long *dur) +void seq_get(seq_type seq, long *eventtype, long *ntime, long *line, long *chan, + long *value1, long *value2, long *dur) { event_type ev = seq->current; if (!ev) *eventtype = SEQ_DONE; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.h b/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.h index 5db091f44..0919b44e0 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/seqinterf.h @@ -3,7 +3,7 @@ boolean seq_next(seq_type seq); /* LISP: (SEQ-NEXT SEQ) */ void seq_get(seq_type seq, long *eventtype, long *time, long *line, long *chan, long *value1, long *value2, long *dur); - /* LISP: (SEQ-GET SEQ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^) */ + /* LISP: (SEQ-GET SEQ LONG^ LONG^ LONG^ LONG^ LONG^ LONG^ LONG^) */ /* LISP-SRC: (setfn seq-tag first) (setfn seq-time second) diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndfmt.h b/lib-src/libnyquist/nyquist/nyqsrc/sndfmt.h index 3f8f235da..ed43a4334 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndfmt.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndfmt.h @@ -56,7 +56,9 @@ error here /* LISP-SRC: (setf snd-head-raw 20) */ #define SND_HEAD_OGG 21 /* LISP-SRC: (setf snd-head-OGG 21) */ -#define SND_NUM_HEADS 22 +#define SND_HEAD_WAVEX 22 +/* LISP-SRC: (setf snd-head-WAVEX 22) */ +#define SND_NUM_HEADS 23 /* bitfields for soundheaders */ #define SND_HEAD_CHANNELS (1<<0) diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.c b/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.c index 285e3632c..4cd838af3 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.c @@ -54,7 +54,6 @@ extern LVAL s_true; extern LVAL RSLT_sym; - #include "sndfile.h" #include "sound.h" @@ -63,8 +62,8 @@ extern LVAL RSLT_sym; /**/ LVAL xlc_snd_set_max_audio_mem(void) { - long arg1 = getfixnum(xlgafixnum()); - long result; + int64_t arg1 = getfixnum(xlgafixnum()); + int64_t result; xllastarg(); result = snd_set_max_audio_mem(arg1); @@ -239,7 +238,7 @@ LVAL xlc_snd_xform(void) /**/ LVAL xlc_block_watch(void) { - long arg1 = getfixnum(xlgafixnum()); + int64_t arg1 = getfixnum(xlgafixnum()); xllastarg(); block_watch(arg1); @@ -252,8 +251,8 @@ LVAL xlc_block_watch(void) LVAL xlc_sound_nth_block(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); - long result; + long arg2 = (long) getfixnum(xlgafixnum()); + int64_t result; xllastarg(); result = sound_nth_block(arg1, arg2); @@ -279,7 +278,7 @@ LVAL xlc_snd_copy(void) LVAL xlc_snd_print(void) { LVAL arg1 = xlgetarg(); - long arg2 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); xllastarg(); sound_print(arg1, arg2); @@ -292,10 +291,11 @@ LVAL xlc_snd_print(void) LVAL xlc_snd_play(void) { LVAL arg1 = xlgetarg(); + int64_t result; xllastarg(); - sound_play(arg1); - return NIL; + result = sound_play(arg1); + return cvfixnum(result); } @@ -386,9 +386,9 @@ LVAL xlc_snd_add(void) LVAL xlc_snd_avg(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -452,8 +452,8 @@ LVAL xlc_snd_down(void) LVAL xlc_snd_fft(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); LVAL arg4 = xlgetarg(); LVAL result; @@ -487,7 +487,7 @@ LVAL xlc_snd_inverse(void) LVAL xlc_snd_lpanal(void) { LVAL arg1 = xlgetarg(); - long arg2 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); LVAL result; xllastarg(); @@ -498,7 +498,7 @@ LVAL xlc_snd_lpanal(void) #include "multiseq.h" -/* xlc_snd_multiseq -- interface to C routine snd_make_multiseq */ +/* xlc_snd_multiseq -- interface to C routine snd_multiseq */ /**/ LVAL xlc_snd_multiseq(void) { @@ -507,7 +507,7 @@ LVAL xlc_snd_multiseq(void) LVAL result; xllastarg(); - result = snd_make_multiseq(arg1, arg2); + result = snd_multiseq(arg1, arg2); return (result); } @@ -522,9 +522,9 @@ LVAL xlc_snd_phasevocoder(void) { sound_type arg1 = getsound(xlgasound()); sound_type arg2 = getsound(xlgasound()); - long arg3 = getfixnum(xlgafixnum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -588,7 +588,7 @@ LVAL xlc_snd_from_array(void) LVAL xlc_snd_samples(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); LVAL result; xllastarg(); @@ -602,8 +602,8 @@ LVAL xlc_snd_samples(void) LVAL xlc_snd_length(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); - long result; + int64_t arg2 = getfixnum(xlgafixnum()); + int64_t result; xllastarg(); result = snd_length(arg1, arg2); @@ -642,8 +642,8 @@ LVAL xlc_snd_fetch(void) LVAL xlc_snd_fetch_array(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); - long arg3 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); LVAL result; xllastarg(); @@ -661,7 +661,7 @@ LVAL xlc_snd_fetch_array(void) LVAL xlc_snd_max(void) { LVAL arg1 = xlgetarg(); - long arg2 = getfixnum(xlgafixnum()); + int64_t arg2 = getfixnum(xlgafixnum()); double result; xllastarg(); @@ -679,20 +679,19 @@ LVAL xlc_snd_read(void) unsigned char * arg1 = getstring(xlgastring()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); - long arg7 = getfixnum(xlgafixnum()); - long arg8 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); + long arg7 = (long) getfixnum(xlgafixnum()); + long arg8 = (long) getfixnum(xlgafixnum()); double arg9 = testarg2(xlgaanynum()); double arg10 = testarg2(xlgaanynum()); - long arg11 = 0; - long arg12 = 0; + long arg11 = (long) 0; LVAL result; xllastarg(); xlprot1(result); - result = snd_make_read(arg1, arg2, arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11, &arg12); + result = snd_make_read(arg1, arg2, arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11); { LVAL *next = &getvalue(RSLT_sym); *next = cons(NIL, NIL); car(*next) = cvfixnum(arg4); next = &cdr(*next); @@ -709,9 +708,7 @@ LVAL xlc_snd_read(void) *next = cons(NIL, NIL); car(*next) = cvflonum(arg10); next = &cdr(*next); *next = cons(NIL, NIL); - car(*next) = cvfixnum(arg11); next = &cdr(*next); - *next = cons(NIL, NIL); - car(*next) = cvfixnum(arg12); + car(*next) = cvfixnum(arg11); } xlpop(); return (result); @@ -740,7 +737,7 @@ LVAL xlc_snd_seq(void) /**/ LVAL xlc_snd_slider(void) { - long arg1 = getfixnum(xlgafixnum()); + long arg1 = (long) getfixnum(xlgafixnum()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); double arg4 = testarg2(xlgaanynum()); @@ -792,7 +789,7 @@ LVAL xlc_snd_yin(void) sound_type arg1 = getsound(xlgasound()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); LVAL result; xllastarg(); @@ -933,7 +930,7 @@ LVAL xlc_snd_areson(void) sound_type arg1 = getsound(xlgasound()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -951,7 +948,7 @@ LVAL xlc_snd_aresoncv(void) sound_type arg1 = getsound(xlgasound()); double arg2 = testarg2(xlgaanynum()); sound_type arg3 = getsound(xlgasound()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -969,7 +966,7 @@ LVAL xlc_snd_aresonvc(void) sound_type arg1 = getsound(xlgasound()); sound_type arg2 = getsound(xlgasound()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -987,7 +984,7 @@ LVAL xlc_snd_aresonvv(void) sound_type arg1 = getsound(xlgasound()); sound_type arg2 = getsound(xlgasound()); sound_type arg3 = getsound(xlgasound()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1056,7 +1053,7 @@ LVAL xlc_snd_biquad(void) /**/ LVAL xlc_snd_buzz(void) { - long arg1 = getfixnum(xlgafixnum()); + long arg1 = (long) getfixnum(xlgafixnum()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); double arg4 = testarg2(xlgaanynum()); @@ -1288,7 +1285,7 @@ LVAL xlc_snd_follow(void) double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); double arg4 = testarg2(xlgaanynum()); - long arg5 = getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1360,7 +1357,7 @@ LVAL xlc_snd_ifft(void) double arg1 = testarg2(xlgaanynum()); double arg2 = testarg2(xlgaanynum()); LVAL arg3 = xlgetarg(); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); LVAL arg5 = xlgetarg(); sound_type result; @@ -1378,7 +1375,7 @@ LVAL xlc_snd_bandedwg(void) { double arg1 = testarg2(xlgaanynum()); sound_type arg2 = getsound(xlgasound()); - long arg3 = getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); double arg4 = testarg2(xlgaanynum()); sound_type result; @@ -1565,7 +1562,7 @@ LVAL xlc_snd_modalbar(void) { double arg1 = testarg2(xlgaanynum()); double arg2 = testarg2(xlgaanynum()); - long arg3 = getfixnum(xlgafixnum()); + long arg3 = (long) getfixnum(xlgafixnum()); double arg4 = testarg2(xlgaanynum()); double arg5 = testarg2(xlgaanynum()); sound_type result; @@ -1846,7 +1843,7 @@ LVAL xlc_snd_pwl(void) LVAL xlc_snd_quantize(void) { sound_type arg1 = getsound(xlgasound()); - long arg2 = getfixnum(xlgafixnum()); + long arg2 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1879,7 +1876,7 @@ LVAL xlc_snd_reson(void) sound_type arg1 = getsound(xlgasound()); double arg2 = testarg2(xlgaanynum()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1897,7 +1894,7 @@ LVAL xlc_snd_resoncv(void) sound_type arg1 = getsound(xlgasound()); double arg2 = testarg2(xlgaanynum()); sound_type arg3 = getsound(xlgasound()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1915,7 +1912,7 @@ LVAL xlc_snd_resonvc(void) sound_type arg1 = getsound(xlgasound()); sound_type arg2 = getsound(xlgasound()); double arg3 = testarg2(xlgaanynum()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1933,7 +1930,7 @@ LVAL xlc_snd_resonvv(void) sound_type arg1 = getsound(xlgasound()); sound_type arg2 = getsound(xlgasound()); sound_type arg3 = getsound(xlgasound()); - long arg4 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -1955,7 +1952,7 @@ LVAL xlc_snd_sampler(void) double arg5 = testarg2(xlgaanynum()); double arg6 = testarg2(xlgaanynum()); sound_type arg7 = getsound(xlgasound()); - long arg8 = getfixnum(xlgafixnum()); + long arg8 = (long) getfixnum(xlgafixnum()); sound_type result; xllastarg(); @@ -2187,7 +2184,7 @@ LVAL xlc_snd_stkpitshift(void) /**/ LVAL xlc_snd_stkrev(void) { - long arg1 = getfixnum(xlgafixnum()); + long arg1 = (long) getfixnum(xlgafixnum()); sound_type arg2 = getsound(xlgasound()); double arg3 = testarg2(xlgaanynum()); double arg4 = testarg2(xlgaanynum()); @@ -2227,20 +2224,21 @@ LVAL xlc_snd_stkchorus(void) LVAL xlc_snd_save(void) { LVAL arg1 = xlgetarg(); - long arg2 = getfixnum(xlgafixnum()); + int64_t arg2 = getfixnum(xlgafixnum()); unsigned char * arg3 = getstring(xlgastring()); - long arg4 = getfixnum(xlgafixnum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); - long arg7 = getfixnum(xlgafixnum()); + long arg4 = (long) getfixnum(xlgafixnum()); + long arg5 = (long) getfixnum(xlgafixnum()); + long arg6 = (long) getfixnum(xlgafixnum()); + long arg7 = (long) getfixnum(xlgafixnum()); double arg8 = 0.0; - long arg9 = 0; + long arg9 = (long) 0; double arg10 = 0.0; LVAL arg11 = xlgetarg(); + int64_t arg12 = getfixnum(xlgafixnum()); double result; xllastarg(); - result = sound_save(arg1, arg2, arg3, arg4, arg5, arg6, arg7, &arg8, &arg9, &arg10, arg11); + result = sound_save(arg1, arg2, arg3, arg4, arg5, arg6, arg7, &arg8, &arg9, &arg10, arg11, arg12); { LVAL *next = &getvalue(RSLT_sym); *next = cons(NIL, NIL); car(*next) = cvflonum(arg8); next = &cdr(*next); @@ -2258,21 +2256,18 @@ LVAL xlc_snd_save(void) LVAL xlc_snd_overwrite(void) { LVAL arg1 = xlgetarg(); - long arg2 = getfixnum(xlgafixnum()); + int64_t arg2 = getfixnum(xlgafixnum()); unsigned char * arg3 = getstring(xlgastring()); double arg4 = testarg2(xlgaanynum()); - long arg5 = getfixnum(xlgafixnum()); - long arg6 = getfixnum(xlgafixnum()); - long arg7 = getfixnum(xlgafixnum()); - long arg8 = getfixnum(xlgafixnum()); - double arg9 = 0.0; + double arg5 = 0.0; + int64_t arg6 = getfixnum(xlgafixnum()); double result; xllastarg(); - result = sound_overwrite(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, &arg9); + result = sound_overwrite(arg1, arg2, arg3, arg4, &arg5, arg6); { LVAL *next = &getvalue(RSLT_sym); *next = cons(NIL, NIL); - car(*next) = cvflonum(arg9); + car(*next) = cvflonum(arg5); } return cvflonum(result); } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.lsp b/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.lsp index c3354bf37..015191b24 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.lsp +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndfnint.lsp @@ -48,6 +48,8 @@ (setf snd-head-OGG 21) + (setf snd-head-WAVEX 22) + (setf snd-head-channels 1) (setf snd-head-mode 2) diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndmax.c b/lib-src/libnyquist/nyquist/nyqsrc/sndmax.c index a91297b05..6995aa3cf 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndmax.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndmax.c @@ -18,11 +18,11 @@ #include "sndmax.h" #include "extern.h" -double sound_max(LVAL snd_expr, long n) +double sound_max(LVAL snd_expr, int64_t n) { LVAL s_as_lval; sound_type s = NULL; - long blocklen; + int blocklen; sample_block_values_type sbufp; register double maximum = 0; @@ -53,7 +53,7 @@ double sound_max(LVAL snd_expr, long n) if (sampblock == zero_block || blocklen == 0) { break; } - togo = MIN(blocklen, n); + togo = (long) MIN(blocklen, n); sbufp = sampblock->samples; for (j = 0; j < togo; j++) { register double samp = *sbufp++; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndmax.h b/lib-src/libnyquist/nyquist/nyqsrc/sndmax.h index b18f29429..68f667769 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndmax.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndmax.h @@ -1,4 +1,4 @@ /* sndmax.h -- header to write sounds to files */ -double sound_max(LVAL snd_expr, long n); +double sound_max(LVAL snd_expr, int64_t n); /* LISP: (SND-MAX ANY FIXNUM) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndread.c b/lib-src/libnyquist/nyquist/nyqsrc/sndread.c index 04c7aa45f..6a38e0bdc 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndread.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndread.c @@ -60,13 +60,14 @@ void read__fetch(snd_susp_type a_susp, snd_list_type snd_list) out_ptr = out->samples; snd_list->block = out; - in_count = sf_readf_float(susp->sndfile, out_ptr, max_sample_block_len); + in_count = (long) sf_readf_float(susp->sndfile, out_ptr, + max_sample_block_len); n = in_count; /* don't read too many */ if (n > (susp->cnt - susp->susp.current)) { - n = susp->cnt - susp->susp.current; + n = (long) (susp->cnt - susp->susp.current); } snd_list->block_len = (short) n; @@ -110,8 +111,7 @@ LVAL snd_make_read( long *swap, /* swap bytes */ double *srate, /* srate: sample rate */ double *dur, /* duration (in seconds) to read */ - long *flags, /* which parameters have been set */ - long *byte_offset) /* byte offset in file of first sample */ + long *flags) /* which parameters have been set */ { register read_susp_type susp; /* srate specified as input parameter */ @@ -161,11 +161,12 @@ LVAL snd_make_read( /* write the code so it will only compile if one and only one ENDIAN setting is defined */ #ifdef XL_LITTLE_ENDIAN - susp->sf_info.format |= SF_ENDIAN_BIG; + long format = SF_ENDIAN_BIG; #endif #ifdef XL_BIG_ENDIAN - susp->sf_info.format |= SF_ENDIAN_LITTLE; + long format = SF_ENDIAN_LITTLE; #endif + susp->sf_info.format |= format; } susp->sndfile = NULL; @@ -175,8 +176,8 @@ LVAL snd_make_read( if (!susp->sndfile) { char error[240]; - snprintf(error, 240, "SND-READ: Cannot open file '%s' because of %s", filename, - sf_strerror(susp->sndfile)); + snprintf(error, 240, "SND-READ: Cannot open file '%s' because of %s", + filename, sf_strerror(susp->sndfile)); xlfail(error); } if (susp->sf_info.channels < 1) { @@ -191,7 +192,7 @@ LVAL snd_make_read( *srate = susp->sf_info.samplerate; } /* compute dur */ - frames = sf_seek(susp->sndfile, 0, SEEK_END); + frames = susp->sf_info.frames; actual_dur = ((double) frames) / *srate; if (offset < 0) offset = 0; /* round offset to an integer frame count */ @@ -205,7 +206,6 @@ LVAL snd_make_read( if (actual_dur < *dur) *dur = actual_dur; sf_seek(susp->sndfile, frames, SEEK_SET); /* return to read loc in file */ - /* initialize susp state */ susp->susp.sr = *srate; susp->susp.t0 = t0; @@ -215,16 +215,16 @@ LVAL snd_make_read( susp->susp.log_stop_cnt = UNKNOWN; /* watch for overflow */ if (*dur * *srate + 0.5 > (unsigned long) 0xFFFFFFFF) { - susp->cnt = 0x7FFFFFFF; + susp->cnt = 0x7FFFFFFFFFFFFFFF; } else { susp->cnt = ROUNDBIG((*dur) * *srate); } switch (susp->sf_info.format & SF_FORMAT_TYPEMASK) { - case SF_FORMAT_WAV: *format = SND_HEAD_WAVE; break; case SF_FORMAT_AIFF: *format = SND_HEAD_AIFF; break; + case SF_FORMAT_IRCAM: *format = SND_HEAD_IRCAM; break; case SF_FORMAT_AU: *format = SND_HEAD_NEXT; break; - case SF_FORMAT_RAW: *format = SND_HEAD_RAW; break; + case SF_FORMAT_WAV: *format = SND_HEAD_WAVE; break; case SF_FORMAT_PAF: *format = SND_HEAD_PAF; break; case SF_FORMAT_SVX: *format = SND_HEAD_SVX; break; case SF_FORMAT_NIST: *format = SND_HEAD_NIST; break; @@ -237,11 +237,12 @@ LVAL snd_make_read( case SF_FORMAT_HTK: *mode = SND_HEAD_HTK; break; case SF_FORMAT_SDS: *mode = SND_HEAD_SDS; break; case SF_FORMAT_AVR: *mode = SND_HEAD_AVR; break; - case SF_FORMAT_WAVEX: *format = SND_HEAD_WAVE; break; case SF_FORMAT_SD2: *format = SND_HEAD_SD2; break; case SF_FORMAT_FLAC: *format = SND_HEAD_FLAC; break; case SF_FORMAT_CAF: *format = SND_HEAD_CAF; break; + case SF_FORMAT_RAW: *format = SND_HEAD_RAW; break; case SF_FORMAT_OGG: *format = SND_HEAD_OGG; break; + case SF_FORMAT_WAVEX: *format = SND_HEAD_WAVEX; break; default: *format = SND_HEAD_NONE; break; } *channels = susp->sf_info.channels; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndread.h b/lib-src/libnyquist/nyquist/nyqsrc/sndread.h index 73dd7fd7d..db580cc33 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndread.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndread.h @@ -7,14 +7,14 @@ typedef struct read_susp_struct { snd_susp_node susp; SNDFILE *sndfile; SF_INFO sf_info; - snd_list_type *chan; /* array of back pointers */ - long cnt; /* how many sample frames to read */ + snd_list_type *chan; /* array of back pointers */ + int64_t cnt; /* how many sample frames to read */ } read_susp_node, *read_susp_type; LVAL snd_make_read(unsigned char *filename, time_type offset, time_type t0, long *format, long *channels, long *mode, long *bits, long *swap, - double *srate, double *dur, long *flags, long *byte_offset); -/* LISP: (SND-READ STRING ANYNUM ANYNUM FIXNUM* FIXNUM* FIXNUM* FIXNUM* FIXNUM* ANYNUM* ANYNUM* FIXNUM^ FIXNUM^) */ + double *srate, double *dur, long *flags); +/* LISP: (SND-READ STRING ANYNUM ANYNUM LONG* LONG* LONG* LONG* LONG* ANYNUM* ANYNUM* LONG^) */ -void read_free(); +void read_free(snd_susp_type a_susp); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndseq.c b/lib-src/libnyquist/nyquist/nyqsrc/sndseq.c index d5ec7348e..92dea5cd4 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndseq.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndseq.c @@ -19,6 +19,7 @@ #include "extern.h" #include "cext.h" #include "assert.h" +#include "sndseq.h" #define SNDSEQDBG 0 #define D if (SNDSEQDBG) @@ -30,20 +31,20 @@ (sndseq_free) or else we'll leak memory. */ typedef struct sndseq_susp_struct { - snd_susp_node susp; - boolean started; + snd_susp_node susp; + boolean started; int terminate_bits; - long terminate_cnt; + int64_t terminate_cnt; int logical_stop_bits; - boolean logically_stopped; - sound_type s1; - long s1_cnt; - sample_block_type s1_bptr; /* block pointer */ - sample_block_values_type s1_ptr; - sound_type s2; - long s2_cnt; - sample_block_type s2_bptr; /* block pointer */ - sample_block_values_type s2_ptr; + boolean logically_stopped; + sound_type s1; + int s1_cnt; + sample_block_type s1_bptr; /* block pointer */ + sample_block_values_type s1_ptr; + sound_type s2; + int s2_cnt; + sample_block_type s2_bptr; /* block pointer */ + sample_block_values_type s2_ptr; /* support for interpolation of s2 */ sample_type s2_x1_sample; @@ -65,11 +66,106 @@ void sndseq_free(snd_susp_type susp); extern LVAL s_stdout; +void print_closure(LVAL val); + +#ifdef SNDSEQDBG + +LVAL print_stack[100]; +int print_stack_index = 0; + +#define ps_push(x) print_stack[print_stack_index++] = x +#define ps_pop(x) print_stack_index-- + +int in_cycle(LVAL x) +{ + for (int i = 0; i < print_stack_index; i++) { + if (print_stack[i] == x) { + return TRUE; + } + } + return FALSE; +} + +/* print_closure -- show everything for debugging */ +void print_lval(LVAL x) +{ + LVAL next; + if (!x) { + printf("NIL"); + return; + } + if (in_cycle(x)) { + printf(""); + return; + } + ps_push(x); + switch (ntype(x)) { + case CONS: + printf("("); + for (LVAL nptr = x; nptr != NIL; nptr = next) { + print_lval(car(nptr)); + if ((next = cdr(nptr))) { + if (consp(next)) printf(" "); + else { + printf(" . "); + print_lval(next); + break; + } + } + } + printf(")"); + break; + case SYMBOL: + printf("%s", getstring(getpname(x))); + break; + case FIXNUM: + printf(IFMT, getfixnum(x)); + break; + case FLONUM: + printf("%g", getflonum(x)); + break; + case EXTERN: + printf("<%s:%p>", getdesc(x)->type_name, getinst(x)); + break; + case CLOSURE: + printf("\n", x); + print_closure(x); + break; + default: + printf("", ntype(x)); + break; + } + ps_pop(x); +} + +void print_closure(LVAL val) +{ + printf("Name: "); print_lval(getname(val)); + printf("\nType: "); print_lval(gettype(val)); + printf("\nLambda: "); print_lval(getlambda(val)); + printf("\nArgs: "); print_lval(getargs(val)); + printf("\nOargs: "); print_lval(getoargs(val)); + printf("\nRest: "); print_lval(getrest(val)); + printf("\nKargs: "); print_lval(getkargs(val)); + printf("\nAargs: "); print_lval(getaargs(val)); + printf("\nBody: "); print_lval(getbody(val)); + printf("\nEnv: "); print_lval(closure_getenv(val)); + printf("\nFenv: "); print_lval(getfenv(val)); + printf("\n"); +} + +#endif + void sndseq_mark(snd_susp_type a_susp) { +D nyquist_printf("sndseq_mark: marking susp %p\n", a_susp); sndseq_susp_type susp = (sndseq_susp_type) a_susp; sound_xlmark(susp->s1); - if (susp->closure) mark(susp->closure); + if (susp->closure) { +D nyquist_printf("sndseq_mark: marking closure %p\n", susp->closure); +D print_closure(susp->closure); + mark(susp->closure); + } } @@ -100,7 +196,7 @@ void sndseq_fetch(snd_susp_type a_susp, snd_list_type snd_list) if (susp->s1_ptr == zero_block->samples) { susp->terminate_bits = 1; /* mark s1 as terminated */ } -/* nyquist_printf("sndseq_fetch: s1-lsc %d, current %d cnt %d\n", +/* nyquist_printf("sndseq_fetch: s1-lsc %d, current %d cnt %d\n", susp->s1->logical_stop_cnt, susp->s1->current, susp->s1_cnt); */ } @@ -109,14 +205,19 @@ void sndseq_fetch(snd_susp_type a_susp, snd_list_type snd_list) time_type now = susp->susp.t0 + susp->susp.current / susp->susp.sr; /* note: cons args are protected from GC: */ LVAL result; - long delay; /* sample delay to s2 */ -/* stats();gc();stats();*/ + int64_t delay; /* sample delay to s2 */ +/* stats();gc();stats();*/ xlsave1(result); -D nyquist_printf("sndseq_fetch: about to eval closure at %g, " - "susp->susp.t0 %g, susp.current %d:\n", - now, susp->susp.t0, (int)susp->susp.current); +D nyquist_printf("::::sndseq_fetch: about to eval closure at %g, " + "susp->susp.t0 %g, susp.current %d:\n", + now, susp->susp.t0, (int)susp->susp.current); +D nyquist_printf(" susp@%p(%s)\n", susp, susp->susp.name); +D (*susp->susp.print_tree)((snd_susp_type) susp, 4); +D nyquist_printf(" EVALUATE CLOSURE: "); +D print_lval(susp->closure); +D printf("\n"); result = xleval(cons(susp->closure, consa(cvflonum(now)))); susp->logical_stop_bits = 1; /* mark s1 as logically stopped */ @@ -157,9 +258,9 @@ D nyquist_printf("in sndseq: logically stopped; " } else { susp->susp.fetch = add_s2_nn_fetch; susp->susp.name = "sndseq:add_s2_nn_fetch"; - } + } } else if (delay > 0) { /* fill hole between s1 and s2 */ -D stdputstr("using add_s1_nn_fetch\n"); +D stdputstr("using add_s1_nn_fetch\n"); susp->susp.fetch = add_s1_nn_fetch; susp->susp.name = "sndseq:add_s1_nn_fetch"; } else { @@ -173,7 +274,7 @@ D stdputstr("using add_s1_nn_fetch\n"); D stdputstr("in sndseq: calling add's fetch\n"); (*(susp->susp.fetch))(a_susp, snd_list); D stdputstr("in sndseq: returned from add's fetch\n"); -/* gc();*/ +/* gc();*/ xlpop(); return; } @@ -185,13 +286,13 @@ D stdputstr("in sndseq: returned from add's fetch\n"); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + togo) { - togo = susp->terminate_cnt - susp->susp.current; + togo = (int) (susp->terminate_cnt - susp->susp.current); } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - susp->susp.current; - togo = MIN(togo, to_stop); + int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current; + togo = (int) MIN(togo, to_stop); } assert(togo >= 0); @@ -216,7 +317,7 @@ D stdputstr("in sndseq: returned from add's fetch\n"); */ /* just fetch and pass blocks on */ -/* nyquist_printf("sndseq (s1_nn) %x starting uncopy, togo %d\n", susp, togo); */ +/* nyquist_printf("sndseq (s1_nn) %x starting uncopy, togo %d\n", susp, togo); */ snd_list->block = susp->s1_bptr; /* the zero_block indicates termination, don't copy it! Use * internal_zero_block instead. It is also filled with zeros, @@ -227,7 +328,7 @@ D stdputstr("in sndseq: returned from add's fetch\n"); if (snd_list->block == zero_block) snd_list->block = internal_zero_block; (snd_list->block->refcnt)++; -/* nyquist_printf("sndseq (s1_nn) %x shared block %x\n", susp, susp->s1_bptr);*/ +/* nyquist_printf("sndseq (s1_nn) %x shared block %x\n", susp, susp->s1_bptr);*/ susp_took(s1_cnt, togo); snd_list->block_len = togo; @@ -274,11 +375,21 @@ void sndseq_print_tree(snd_susp_type a_susp, int n) indent(n); stdputstr("s1:"); sound_print_tree_1(susp->s1, n); - +D { indent(n); + nyquist_printf("closure %p stored at %p\n", + susp->closure, &susp->closure); + } +D if (susp->closure && closurep(susp->closure)) { + LVAL body = getbody(susp->closure); + LVAL lambda = getlambda(susp->closure); + LVAL args = getargs(susp->closure); + nyquist_printf(" closure args@%p: ", args); stdprint(args); + nyquist_printf(" closure lambda@%p: ", lambda); stdprint(lambda); + nyquist_printf(" closure body@%p: ", body); stdprint(body); + } indent(n); stdputstr("closure:"); stdprint(susp->closure); - indent(n); stdputstr("s2:"); sound_print_tree_1(susp->s2, n); @@ -287,11 +398,9 @@ void sndseq_print_tree(snd_susp_type a_susp, int n) -sound_type snd_make_sndseq(s1, closure) - sound_type s1; - LVAL closure; +sound_type snd_make_sndseq(sound_type s1, LVAL closure) { - register sndseq_susp_type susp; + sndseq_susp_type susp; /* t0 specified as input parameter */ sample_type scale_factor = 1.0F; sound_type result; @@ -329,20 +438,45 @@ sound_type snd_make_sndseq(s1, closure) susp->s2 = NULL; susp->s2_cnt = 0; susp->s2_phase = 0.0; -/* susp->s2_phase_incr = ?? - susp->output_per_s2 = ?? */ susp->closure = closure; - result = sound_create((snd_susp_type)susp, susp->susp.t0, susp->susp.sr, scale_factor); + result = sound_create((snd_susp_type)susp, susp->susp.t0, + susp->susp.sr, scale_factor); +D nyquist_printf("Created sndseq: "); +D sound_print_tree_1(result, 2); xlpopn(1); return result; } -sound_type snd_sndseq(s1, closure) - sound_type s1; - LVAL closure; +/* This was going to support a new construct, SEQV, but it was just a bad idea. +void change_seqclosure(LVAL snd, LVAL vars, LVAL closure) { - sound_type s1_copy; - s1_copy = sound_copy(s1); - return snd_make_sndseq(s1_copy, closure); + if (listp(vars)) { // modify the closure + LVAL newenv; + LVAL binding; + LVAL envsublist; // don't save, always points into env + xlstkcheck(2); + xlsave(newenv); // initially just ((var . val) ...) + xlsave(binding); + while (vars) { // for each var in environment + LVAL var = car(vars); + // get value of sym in env: + binding = cons(var, xlgetvalue(var)); + newenv = cons(binding, newenv); + vars = cdr(vars); + } + + newenv = consa(newenv); + if (null(snd)) { // first sound gets to see all local variables + cdr(newenv) = closure_getenv(closure); + } + setenv(closure, newenv); + xlpopn(2); + } +} +*/ + +sound_type snd_sndseq(sound_type snd, LVAL closure) +{ + return snd_make_sndseq(sound_copy(snd), closure); } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndseq.h b/lib-src/libnyquist/nyquist/nyqsrc/sndseq.h index 03fdd1157..ca5307700 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndseq.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndseq.h @@ -1,3 +1,4 @@ -sound_type snd_make_sndseq(); -sound_type snd_sndseq(); +sound_type snd_make_sndseq(sound_type s1, LVAL closure); +sound_type snd_sndseq(sound_type s1, LVAL closure); /* LISP: (SND-SEQ SOUND ANY) */ + diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.c b/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.c index 24a4f16db..2cf5f36b9 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.c @@ -14,7 +14,7 @@ LVAL xslider_read(void) { LVAL arg = xlgafixnum(); - int index = getfixnum(arg); + int index = (int) getfixnum(arg); xllastarg(); if (index >= 0 && index < SLIDERS_MAX) { return cvflonum(slider_array[index]); @@ -46,12 +46,12 @@ LVAL xosc_enable(void) } -void slider_free(); +void slider_free(snd_susp_type a_susp); typedef struct slider_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; int index; } slider_susp_node, *slider_susp_type; @@ -86,7 +86,7 @@ void slider__fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo == 0) break; } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.h b/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.h index ae96523a2..cbe05336c 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndsliders.h @@ -3,8 +3,7 @@ * Jan 2013 */ - /* access from Nyquist unit generators to shared data */ sound_type snd_make_slider(int index, time_type t0, rate_type sr, time_type d); sound_type snd_slider(int index, time_type t0, rate_type sr, time_type d); - /* LISP: (SND-SLIDER FIXNUM ANYNUM ANYNUM ANYNUM) */ + /* LISP: (SND-SLIDER LONG ANYNUM ANYNUM ANYNUM) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.c b/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.c index 07a69c77d..2b1187233 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.c @@ -375,7 +375,7 @@ cvtfn_type find_cvt_to_fn(snd_type snd, char *buf) sample_type sound_save_sound(LVAL s_as_lval, long n, snd_type snd, char *buf, long *ntotal, snd_type player) { - long blocklen; + int blocklen; long buflen; sound_type s; long debug_unit; /* print messages at intervals of this many samples */ @@ -634,7 +634,7 @@ D nyquist_printf("save scale factor %d = %g\n", (int)i, state[i].scale); * would be a bug.) */ free(state); - xlpop(); + xlpopn(2); return max_sample; } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.h b/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.h index 192317e8d..d88e48077 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndwrite.h @@ -1,12 +1,11 @@ /* sndwrite.h -- header to write sounds to files */ -double sound_save(LVAL snd_expr, long n, - unsigned char *filename, long format, - long mode, long bits, long swap, double *sr, long *nchans, - double *duration, LVAL play); -/* LISP: (SND-SAVE ANY FIXNUM STRING FIXNUM FIXNUM FIXNUM FIXNUM ANYNUM^ FIXNUM^ ANYNUM^ ANY) */ +double sound_save(LVAL snd_expr, int64_t n, + unsigned char *filename, long format, + long mode, long bits, long swap, double *sr, long *nchans, + double *duration, LVAL play, int64_t progress); +/* LISP: (SND-SAVE ANY FIXNUM STRING LONG LONG LONG LONG ANYNUM^ LONG^ ANYNUM^ ANY FIXNUM) */ -double sound_overwrite(LVAL snd_expr, long n, - unsigned char *filename, double offset_secs, long format, - long mode, long bits, long swap, double *duration); -/* LISP: (SND-OVERWRITE ANY FIXNUM STRING ANYNUM FIXNUM FIXNUM FIXNUM FIXNUM ANYNUM^) */ +double sound_overwrite(LVAL snd_expr, int64_t n, unsigned char *filename, + double offset_secs, double *duration, int64_t progress); +/* LISP: (SND-OVERWRITE ANY FIXNUM STRING ANYNUM ANYNUM^ FIXNUM) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndwritepa.c b/lib-src/libnyquist/nyquist/nyqsrc/sndwritepa.c index b59a58a85..dad1d812d 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndwritepa.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndwritepa.c @@ -61,19 +61,19 @@ if (s > threshold) { \ if (s > max_sample) { \ max_sample = s; \ - threshold = min(1.0, s); \ + threshold = min(1.0F, s); \ } \ if (s > 1.0) { \ - s = (sample_type) (fmod(s + 1.0, 2.0) - 1.0); \ + s = (sample_type) (fmodf(s + 1.0F, 2.0F) - 1.0F); \ (x) = s; \ } \ } else if (s < -threshold) { \ if (s < -max_sample) { \ max_sample = -s; \ - threshold = min(1.0, -s); \ + threshold = min(1.0F, -s); \ } \ if (s < -1.0) { \ - s = (sample_type) -(fmod(-s + 1.0, 2.0) - 1.0); \ + s = (sample_type) -(fmodf(-s + 1.0F, 2.0F) - 1.0F); \ (x) = s; \ } \ } @@ -114,18 +114,22 @@ void portaudio_exit() } -sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, - SNDFILE *snd_file, float *buf, long *ntotal); +// sound_save_sound - implements s-save for mono sounds +sample_type sound_save_sound(LVAL s_as_lval, int64_t n, SF_INFO *sf_info, + SNDFILE *snd_file, float *buf, int64_t *ntotal, + int64_t progress); -sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info, - SNDFILE *snd_file, float *buf, long *ntotal); +// sound_save_array - implements s-save for multi-channel sounds +sample_type sound_save_array(LVAL sa, int64_t n, SF_INFO *sf_info, + SNDFILE *snd_file, float *buf, int64_t *ntotal, + int64_t progress); unsigned char st_linear_to_ulaw(int sample);/* jlh not used anywhere */ typedef struct { sound_type sound; - long cnt; + int cnt; sample_block_values_type ptr; double scale; int terminated; @@ -176,7 +180,7 @@ LVAL prepare_audio(LVAL play, SF_INFO *sf_info) pref = getvalue(pref); if (pref == s_unbound) pref = NULL; if (stringp(pref)) pref_string = getstring(pref); - else if (fixp(pref)) pref_num = getfixnum(pref); + else if (fixp(pref)) pref_num = (int) getfixnum(pref); if (!portaudio_initialized) { if (portaudio_error(Pa_Initialize(), @@ -250,7 +254,7 @@ LVAL prepare_audio(LVAL play, SF_INFO *sf_info) /* finish_audio -- flush the remaining samples, then close */ /**/ -void finish_audio() +void finish_audio(void) { /* portaudio_error(Pa_StopStream(audio_stream), "could not stop stream"); */ /* write Latency frames of audio to make sure all samples are played */ @@ -292,16 +296,17 @@ long lookup_format(long format, long mode, long bits, long swap) case SND_HEAD_SD2: sf_format = SF_FORMAT_SD2; break; case SND_HEAD_FLAC: sf_format = SF_FORMAT_FLAC; break; case SND_HEAD_CAF: sf_format = SF_FORMAT_CAF; break; - case SND_HEAD_OGG: sf_format = SF_FORMAT_OGG; mode = SND_MODE_VORBIS; break; /* ZEYU */ case SND_HEAD_RAW: sf_format = SF_FORMAT_RAW; #ifdef XL_BIG_ENDIAN sf_format |= (swap ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG); #endif #ifdef XL_LITTLE_ENDIAN - sf_format |= (swap ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE); + sf_format |= (swap ? SF_ENDIAN_LITTLE : SF_ENDIAN_LITTLE); #endif break; + case SND_HEAD_OGG: sf_format = SF_FORMAT_OGG; mode = SND_MODE_VORBIS; break; + case SND_HEAD_WAVEX: sf_format = SF_FORMAT_WAVEX; break; default: sf_format = SF_FORMAT_WAV; nyquist_printf("s-save: unrecognized format, using SND_HEAD_WAVE\n"); @@ -362,22 +367,15 @@ long lookup_format(long format, long mode, long bits, long swap) } -double sound_save( - LVAL snd_expr, - long n, - unsigned char *filename, - long format, - long mode, - long bits, - long swap, - double *sr, - long *nchans, - double *duration, - LVAL play) +// sound_save - implements s-save. As files are written, the sample count +// is printed at intervals of progress. Typically every 10s of sound. +double sound_save(LVAL snd_expr, int64_t n, unsigned char *filename, + long format, long mode, long bits, long swap, double *sr, + long *nchans, double *duration, LVAL play, int64_t progress) { LVAL result; float *buf = NULL; - long ntotal; + int64_t ntotal; double max_sample; SNDFILE *sndfile = NULL; SF_INFO sf_info; @@ -388,7 +386,9 @@ double sound_save( memset(&sf_info, 0, sizeof(sf_info)); sf_info.format = lookup_format(format, mode, bits, swap); + // printf("in sound_save: calling xleval on %p\n", snd_expr); result = xleval(snd_expr); + // printf("in sound_save: got result of xleval %p\n", result); /* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */ if (vectorp(result)) { /* make sure all elements are of type a_sound */ @@ -397,7 +397,7 @@ double sound_save( while (i > 0) { i--; if (!exttypep(getelement(result, i), a_sound)) { - xlerror("sound_save: array has non-sound element", + xlerror("S-SAVE: array has non-sound element", result); } } @@ -426,7 +426,7 @@ double sound_save( } max_sample = sound_save_array(result, n, &sf_info, sndfile, - buf, &ntotal); + buf, &ntotal, progress); *duration = ntotal / *sr; if (sndfile) sf_close(sndfile); if (play != NIL) finish_audio(); @@ -459,13 +459,15 @@ double sound_save( } max_sample = sound_save_sound(result, n, &sf_info, sndfile, - buf, &ntotal); + buf, &ntotal, progress); *duration = ntotal / *sr; if (sndfile) sf_close(sndfile); if (play != NIL) finish_audio(); } else { + xlprot1(result); xlerror("sound_save: expression did not return a sound", result); + xlpop(); max_sample = 0.0; } if (buf) free(buf); @@ -475,13 +477,12 @@ double sound_save( /* open_for_write -- helper function for sound_overwrite */ /* - * if the format is RAW, then fill in sf_info according to - * sound sample rate and channels. Otherwise, open the file - * and see if the sample rate and channele match. + * open the file and prepare to read it if it matches the expected + * sample rate and number of channels */ SNDFILE *open_for_write(unsigned char *filename, long direction, - long format, SF_INFO *sf_info, int channels, - long srate, double offset, float **buf) + SF_INFO *sf_info, int channels, int srate, + double offset, float **buf) /* channels and srate are based on the sound we're writing to the file */ { SNDFILE *sndfile; @@ -489,18 +490,13 @@ SNDFILE *open_for_write(unsigned char *filename, long direction, char error[140]; // error messages are formatted here sf_count_t rslt; // frame count returned from sf_seek - if (format == SND_HEAD_RAW) { - sf_info->channels = channels; - sf_info->samplerate = srate; - } else { - sf_info->format = 0; - } sndfile = NULL; if (ok_to_open((char *) filename, "w")) sndfile = sf_open((const char *) filename, direction, sf_info); if (!sndfile) { - snprintf(error, sizeof(error), "snd_overwrite: cannot open file %s", filename); + snprintf(error, sizeof(error), "snd_overwrite: cannot open file %s", + filename); xlabort(error); } /* use proper scale factor: 8000 vs 7FFF */ @@ -515,7 +511,7 @@ SNDFILE *open_for_write(unsigned char *filename, long direction, xlabort(error); } if (sf_info->channels != channels) { - snprintf(error, sizeof(error), "%s%d%s%d%s", + snprintf(error, sizeof(error), "%s%d%s%d%s", "snd_overwrite: number of channels in sound (", channels, ") does not match\n number of channels in file (", @@ -523,19 +519,17 @@ SNDFILE *open_for_write(unsigned char *filename, long direction, sf_close(sndfile); xlabort(error); } - if (sf_info->samplerate != srate) { - snprintf(error, sizeof(error), "%s%ld%s%d%s", + snprintf(error, sizeof(error), "%s%d%s%d%s", "snd_overwrite: sample rate in sound (", srate, ") does not match\n sample rate in file (", sf_info->samplerate, - ")"); + ")"); sf_close(sndfile); xlabort(error); } - - if ((*buf = (float *) malloc(max_sample_block_len * channels * + if ((*buf = (float *) malloc(max_sample_block_len * sf_info->channels * sizeof(float))) == NULL) { xlabort("snd_overwrite: couldn't allocate memory"); } @@ -543,21 +537,13 @@ SNDFILE *open_for_write(unsigned char *filename, long direction, } -double sound_overwrite( - LVAL snd_expr, - long n, - unsigned char *filename, - double offset_secs, - long format, - long mode, - long bits, - long swap, - double *duration) +double sound_overwrite(LVAL snd_expr, int64_t n, unsigned char *filename, + double offset_secs, double *duration, int64_t progress) { LVAL result; // the SOUND to be evaluated SF_INFO sf_info; // info about the sound file double max_sample; // return value - long ntotal; // how many samples were overwritten + int64_t ntotal; // how many samples were overwritten /* long flags; */ @@ -573,7 +559,6 @@ double sound_overwrite( fclose(file); } memset(&sf_info, 0, sizeof(sf_info)); - sf_info.format = lookup_format(format, mode, bits, swap); result = xleval(snd_expr); /* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */ if (vectorp(result)) { @@ -589,23 +574,23 @@ double sound_overwrite( result); } } - sndfile = open_for_write(filename, SFM_RDWR, format, &sf_info, channels, + sndfile = open_for_write(filename, SFM_RDWR, &sf_info, channels, ROUND32(getsound(getelement(result, 0))->sr), offset_secs, &buf); max_sample = sound_save_array(result, n, &sf_info, sndfile, - buf, &ntotal); + buf, &ntotal, progress); *duration = ntotal / (double) sf_info.samplerate; free(buf); sf_close(sndfile); } else if (exttypep(result, a_sound)) { SNDFILE *sndfile; // opened sound file float *buf; // buffer for samples read in from sound file - sndfile = open_for_write(filename, SFM_RDWR, format, &sf_info, 1, + sndfile = open_for_write(filename, SFM_RDWR, &sf_info, 1, ROUND32(getsound(result)->sr), offset_secs, &buf); max_sample = sound_save_sound(result, n, &sf_info, sndfile, buf, - &ntotal); + &ntotal, progress); *duration = ntotal / (double) sf_info.samplerate; free(buf); sf_close(sndfile); @@ -625,15 +610,16 @@ int is_pcm(SF_INFO *sf_info) } -sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, - SNDFILE *sndfile, float *buf, long *ntotal) +sample_type sound_save_sound(LVAL s_as_lval, int64_t n, SF_INFO *sf_info, + SNDFILE *sndfile, float *buf, int64_t *ntotal, + int64_t progress) { - long blocklen; + int blocklen; sound_type s; int i; sample_type *samps; - long debug_unit; /* print messages at intervals of this many samples */ - long debug_count; /* next point at which to print a message */ + int64_t debug_unit; /* print messages at intervals of this many samples */ + int64_t debug_count; /* next point at which to print a message */ sample_type max_sample = 0.0F; sample_type threshold = 0.0F; double sound_srate; @@ -659,8 +645,11 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, /* for debugging */ /* printing_this_sound = s;*/ - - debug_unit = debug_count = (long) max(sf_info->samplerate, 10000.0); + if (progress < 10000) { + progress = 10000; + } + debug_unit = debug_count = + (int64_t) max(10 * sf_info->samplerate, progress); sound_frames = 0; sound_srate = sf_info->samplerate; @@ -681,7 +670,7 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, if (sampblock == zero_block || blocklen == 0) { break; } - togo = min(blocklen, n); + togo = (int) min(blocklen, n); if (s->scale != 1) { /* copy/scale samples into buf */ for (i = 0; i < togo; i++) { buf[i] = s->scale * sampblock->samples[i]; @@ -713,7 +702,7 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, n -= togo; *ntotal += togo; if (*ntotal > debug_count) { - gprintf(TRANS, " %ld ", *ntotal); + gprintf(TRANS, " %" PRId64 " ", *ntotal); fflush(stdout); debug_count += debug_unit; } @@ -725,16 +714,17 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info, } -sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info, - SNDFILE *sndfile, float *buf, long *ntotal) +sample_type sound_save_array(LVAL sa, int64_t n, SF_INFO *sf_info, + SNDFILE *sndfile, float *buf, int64_t *ntotal, + int64_t progress) { long i, chans; float *float_bufp; sound_state_type state; double start_time = HUGE_VAL; LVAL sa_copy; - long debug_unit; /* print messages at intervals of this many samples */ - long debug_count; /* next point at which to print a message */ + int64_t debug_unit; /* print messages at intervals of this many samples */ + int64_t debug_count; /* next point at which to print a message */ sample_type max_sample = 0.0F; sample_type threshold = 0.0F; double sound_srate; @@ -764,6 +754,7 @@ sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info, free(buf); sf_close(sndfile); } + // printf("DEBUG: xlstack on entry to sound_save_array: %p\n", xlstack); xlprot1(sa); sa_copy = newvector(chans); xlprot1(sa_copy); @@ -795,7 +786,11 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); sound_prepend_zeros(state[i].sound, start_time); } - debug_unit = debug_count = (long) max(sf_info->samplerate, 10000.0); + if (progress < 10000) { + progress = 10000; + } + debug_unit = debug_count = + (int64_t) max(10 * sf_info->samplerate, progress); sound_frames = 0; sound_srate = sf_info->samplerate; @@ -809,7 +804,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); loop if all sounds have terminated */ int terminated = true; - int togo = n; + int64_t togo = n; /* because of this, togo must be int64_t here */ int j; oscheck(); @@ -817,14 +812,16 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); for (i = 0; i < chans; i++) { if (state[i].cnt == 0) { if (sndwrite_trace) { - nyquist_printf("CALLING SOUND_GET_NEXT ON CHANNEL %ld (%p)\n", - i, state[i].sound); /* jlh 64 bit issue */ - sound_print_tree(state[i].sound); + nyquist_printf("CALLING SOUND_GET_NEXT ON " + "CHANNEL %ld (%p)\n", + i, state[i].sound); /* jlh 64 bit issue */ + sound_print_tree(state[i].sound); } state[i].ptr = sound_get_next(state[i].sound, &(state[i].cnt))->samples; if (sndwrite_trace) { - nyquist_printf("RETURNED FROM CALL TO SOUND_GET_NEXT ON CHANNEL %ld\n", i); + nyquist_printf("RETURNED FROM CALL TO SOUND_GET_NEXT " + "ON CHANNEL %ld\n", i); } if (state[i].ptr == zero_block->samples) { state[i].terminated = true; @@ -833,6 +830,8 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); if (!state[i].terminated) terminated = false; togo = min(togo, state[i].cnt); } + /* note that now, togo is well within range of int because it is the + min of state[i].cnt */ if (terminated) break; @@ -857,7 +856,8 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); /* Here we have interleaved floats. Before converting to the sound file format, call PortAudio to play them. */ if (audio_stream) { - PaError err = Pa_WriteStream(audio_stream, buf, togo); + PaError err = Pa_WriteStream(audio_stream, buf, + (unsigned long) togo); if (err) { printf("Pa_WriteStream error %d\n", err); } @@ -867,7 +867,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); n -= togo; for (i = 0; i < chans; i++) { - state[i].cnt -= togo; + state[i].cnt -= (int) togo; } *ntotal += togo; if (*ntotal > debug_count) { @@ -885,7 +885,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale); * would be a bug.) */ free(state); - xlpop(); + xlpopn(2); return max_sample; } diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sound.c b/lib-src/libnyquist/nyquist/nyqsrc/sound.c index 0ef3fb992..0a9e9f3eb 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sound.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sound.c @@ -6,6 +6,7 @@ */ /* define size_t: */ +#include #ifdef UNIX #include "sys/types.h" #endif @@ -53,7 +54,7 @@ static void sound_xlsave(FILE *fp, void *s); static unsigned char *sound_xlrestore(FILE *); void sound_print_array(LVAL sa, long n); -void sound_print_sound(sound_type s, long n); +void sound_print_sound(LVAL s_as_lval, long n); void sample_block_unref(sample_block_type sam); #ifdef SNAPSHOTS @@ -65,10 +66,13 @@ int nosc_enabled = false; #endif /* m is in bytes */ -long snd_set_max_audio_mem(long m) +int64_t snd_set_max_audio_mem(int64_t m) { - long r = max_sample_blocks; - max_sample_blocks = m / (max_sample_block_len * sizeof(float)); + int64_t r = max_sample_blocks; + // avoid overflow since max_sample_blocks is long + int64_t msb = m / (max_sample_block_len * sizeof(float)); + if (msb > LONG_MAX) msb = LONG_MAX; + max_sample_blocks = (long) msb; return r * max_sample_block_len * sizeof(float); } @@ -76,7 +80,7 @@ long snd_set_max_audio_mem(long m) double sound_latency = 0.3; /* default value */ /* these are used so get times for *AUDIO-MARKERS* */ double sound_srate = 44100.0; -long sound_frames = 0; +int64_t sound_frames = 0; double snd_set_latency(double latency) { @@ -86,7 +90,7 @@ double snd_set_latency(double latency) } -long check_terminate_cnt(long tc) +int64_t check_terminate_cnt(int64_t tc) { if (tc < 0) { xlfail("duration is less than 0 samples"); @@ -150,7 +154,7 @@ snd_list_type gcbug_snd_list = 0; long blocks_to_watch_len = 0; sample_block_type blocks_to_watch[blocks_to_watch_max]; -void block_watch(long sample_block) +void block_watch(int64_t sample_block) { if (blocks_to_watch_len >= blocks_to_watch_max) { stdputstr("block_watch - no more space to save pointers\n"); @@ -174,13 +178,14 @@ void block_watch(long sample_block) void fetch_zeros(snd_susp_type susp, snd_list_type snd_list) { - int len = MIN(susp->log_stop_cnt - susp->current, - max_sample_block_len); + int64_t len = MIN(susp->log_stop_cnt - susp->current, + max_sample_block_len); /* nyquist_printf("fetch_zeros, lsc %d current %d len %d\n", susp->log_stop_cnt, susp->current, len); */ if (len < 0) { char error[80]; - sprintf(error, "fetch_zeros susp %p (%s) len %d", susp, susp->name, len); + sprintf(error, "fetch_zeros susp %p (%s) len %" PRId64, + susp, susp->name, len); xlabort(error); } if (len == 0) { /* we've reached the logical stop time */ @@ -188,7 +193,7 @@ void fetch_zeros(snd_susp_type susp, snd_list_type snd_list) susp->name, susp->log_stop_cnt); */ snd_list_terminate(snd_list); } else { - snd_list->block_len = len; + snd_list->block_len = (short) len; susp->current += len; } } @@ -199,7 +204,7 @@ void fetch_zeros(snd_susp_type susp, snd_list_type snd_list) * NOTE: intended to be called from lisp. Lisp can then call block_watch * to keep an eye on the block. */ -long sound_nth_block(sound_type snd, long n) +int64_t sound_nth_block(sound_type snd, long n) { long i; snd_list_type snd_list = snd->list; @@ -211,7 +216,7 @@ long sound_nth_block(sound_type snd, long n) if (!snd_list->block) return 0; snd_list = snd_list->u.next; } - if (snd_list->block) return (long) snd_list->block; + if (snd_list->block) return (int64_t) snd_list->block; else return 0; } @@ -279,7 +284,7 @@ sound_type sound_create( { sound_type sound; falloc_sound(sound, "sound_create"); - if (((long) sound) & 3) errputstr("sound not word aligned\n"); + if (((intptr_t) sound) & 3) errputstr("sound not word aligned\n"); last_sound = sound; /* debug */ if (t0 < 0) xlfail("attempt to create a sound with negative starting time"); /* nyquist_printf("sound_create %p gets %g\n", sound, t0); */ @@ -333,7 +338,7 @@ sound_type sound_create( */ void sound_prepend_zeros(sound_type snd, time_type t0) { - long n; + int64_t n; /* first, see if we're already prepending some zeros */ if (snd->get_next != SND_get_zeros) { @@ -348,7 +353,7 @@ void sound_prepend_zeros(sound_type snd, time_type t0) snd->get_next = SND_get_zeros; } - n = (long) (((snd->true_t0 - t0) * snd->sr) + 0.5); /* how many samples to prepend */ + n = ROUNDBIG((snd->true_t0 - t0) * snd->sr); /* how many samples to prepend */ /* add to prepend_cnt so first sample will correspond to new t0 */ snd->prepend_cnt += n; @@ -406,9 +411,9 @@ sound_type sound_copy(sound_type snd) /**/ table_type sound_to_table(sound_type s) { - long len = snd_length(s, max_table_len); + long len = (long) snd_length(s, max_table_len); long tx = 0; /* table index */ - long blocklen; + int blocklen; register double scale_factor = s->scale; sound_type original_s = s; table_type table; /* the new table */ @@ -501,12 +506,11 @@ void snd_list_ref(snd_list_type list) } -void snd_list_terminate(snd_list) - snd_list_type snd_list; +void snd_list_terminate(snd_list_type snd_list) { snd_susp_type susp = snd_list->u.next->u.susp; - long lsc = susp->log_stop_cnt; - long current = susp->current; + int64_t lsc = susp->log_stop_cnt; + int64_t current = susp->current; /* unreference the empty sample block that was allocated: */ sample_block_unref(snd_list->block); /* use zero_block instead */ @@ -541,7 +545,6 @@ void snd_list_unref(snd_list_type list) break; // the rest of the list is shared, nothing more to free } - next = NULL; // list nodes either point to a block of samples or this is the // last list node (list->block == NULL) which points to a suspension // lists can also terminate at the zero_block, which is an infinite @@ -661,9 +664,9 @@ void snd_sort_2(sound_type *s1_ptr, sound_type *s2_ptr, rate_type sr) double snd_sref(sound_type s, time_type t) { double exact_cnt; /* how many fractional samples to scan */ - int cnt; /* how many samples to flush */ + int64_t cnt; /* how many samples to flush */ sample_block_type sampblock = NULL; - long blocklen; + int blocklen; sample_type x1, x2; /* interpolate between these samples */ /* changed true_t0 to just t0 based on comment that true_t0 is only @@ -673,7 +676,7 @@ double snd_sref(sound_type s, time_type t) if (exact_cnt < 0.0) return 0.0; s = sound_copy(s); /* don't modify s, create new reader */ - cnt = (long) exact_cnt; /* rounds down */ + cnt = (int64_t) exact_cnt; /* rounds down */ exact_cnt -= cnt; /* remember fractional remainder */ /* now flush cnt samples */ @@ -707,7 +710,7 @@ double snd_sref_inverse(sound_type s, double val) double exact_cnt; /* how many fractional samples to scan */ int i; sample_block_type sampblock; - long blocklen; + int blocklen; sample_type x1, x2; /* interpolate between these samples */ if (val < 0) { @@ -767,6 +770,14 @@ double snd_sref_inverse(sound_type s, double val) time_type snd_stop_time(sound_type s) { if (s->stop == MAX_STOP) return MAX_STOP_TIME; + /* I think placing the stop time 0.5 samples later than the last + is to avoid rounding errors somewhere. Sounds are supposed + to be open-ended on the right, and I would guess s->stop + should be one greater than the actual number of samples. + Therefore, it seems that 0.5 should be 0.0 so that + converting back to sample count will round to s->stop. + I'm not changing this because it has been this way for + a long time and Nyquist seems to get it right. -RBD */ else return s->t0 + (s->stop + 0.5) / s->sr; } @@ -805,7 +816,7 @@ sound_type snd_xform(sound_type snd, time_type stop_time, promoted_sample_type scale) { - long start_cnt, stop_cnt; /* clipping samples (sample 0 at new t0) */ + int64_t start_cnt, stop_cnt; /* clipping samples (sample 0 at new t0) */ /* start_cnt should reflect max of where the sound starts (t0) * and the new start_time. @@ -814,7 +825,7 @@ sound_type snd_xform(sound_type snd, start_cnt = 0; } else { double new_start_cnt = ((start_time - time) * sr) + 0.5; - start_cnt = ((new_start_cnt > 0) ? (long) new_start_cnt : 0); + start_cnt = ((new_start_cnt > 0) ? (int64_t) new_start_cnt : 0); } /* if (start_cnt < -(snd->current)) start_cnt = -(snd->current); */ @@ -826,7 +837,7 @@ sound_type snd_xform(sound_type snd, } else { double new_stop_cnt = ((stop_time - time) * sr) + 0.5; if (new_stop_cnt < MAX_STOP) { - stop_cnt = (long) new_stop_cnt; + stop_cnt = (int64_t) new_stop_cnt; } else { errputstr("Warning: stop count overflow in snd_xform\n"); stop_cnt = MAX_STOP; @@ -847,9 +858,8 @@ sound_type snd_xform(sound_type snd, */ ffree_snd_list(snd->list, "snd_xform"); snd->list = zero_snd_list; - nyquist_printf("snd_xform: (stop_time < t0 or start >= stop) " - "-> zero sound = %p\n", snd); - + /* nyquist_printf("snd_xform: (stop_time < t0 or start >= stop) " + "-> zero sound = %p\n", snd); */ } else { snd = sound_copy(snd); snd->t0 = time; @@ -883,9 +893,9 @@ sound_type snd_xform(sound_type snd, * non-real-time operation) and installs SND_get_next to return * blocks normally from then on. */ -sample_block_type SND_flush(sound_type snd, long * cnt) +sample_block_type SND_flush(sound_type snd, int *cnt) { - long mycnt; + int mycnt; sample_block_type block = SND_get_first(snd, &mycnt); /* changed from < to <= because we want to read at least the first sample */ while (snd->current <= 0) { @@ -896,11 +906,11 @@ sample_block_type SND_flush(sound_type snd, long * cnt) * is in the right place, we can do a minimal fixup and return: */ if (snd->current == snd->list->block_len) { - *cnt = snd->current; /* == snd->list->block_len */ + *cnt = (int) snd->current; /* == snd->list->block_len */ /* snd->get_next = SND_get_next; -- done by SND_get_first */ return block; } else /* snd->current < snd->list->block_len */ { - long i; + int64_t i; sample_block_values_type from_ptr; /* we have to return a partial block */ /* NOTE: if we had been smart, we would have had SND_get_next @@ -919,7 +929,7 @@ sample_block_type SND_flush(sound_type snd, long * cnt) } snd_list_unref(snd->list); snd->list = snd_list; - *cnt = snd->current; + *cnt = (int) snd->current; return snd_list->block; } } @@ -932,13 +942,13 @@ sample_block_type SND_flush(sound_type snd, long * cnt) * the normal (original) get_next function. * */ -sample_block_type SND_get_zeros(sound_type snd, long * cnt) +sample_block_type SND_get_zeros(sound_type snd, int *cnt) { - int len = MIN(snd->prepend_cnt, max_sample_block_len); + int64_t len = MIN(snd->prepend_cnt, max_sample_block_len); /* stdputstr("SND_get_zeros: "); */ if (len < 0) { char error[80]; - sprintf(error, "SND_get_zeros snd %p len %d", snd, len); + sprintf(error, "SND_get_zeros snd %p len %" PRId64, snd, len); xlabort(error); } if (len == 0) { /* we've finished prepending zeros */ @@ -946,7 +956,7 @@ sample_block_type SND_get_zeros(sound_type snd, long * cnt) /* stdputstr("done, calling sound_get_next\n"); fflush(stdout); */ return sound_get_next(snd, cnt); } else { - *cnt = len; + *cnt = (int) len; snd->current += len; snd->prepend_cnt -= len; /* nyquist_printf("returning internal_zero_block@%p\n", internal_zero_block); @@ -1056,14 +1066,15 @@ sample_block_type SND_get_zeros(sound_type snd, long * cnt) * generated. ****************************************************************************/ -void add_s1_s2_nn_fetch(); /* for debugging */ +/* for debugging */ +void add_s1_s2_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list); /* SND_get_first -- the standard fn to get a block, after returning * the first block, plug in SND_get_next for successive blocks */ -sample_block_type SND_get_first(sound_type snd, long * cnt) +sample_block_type SND_get_first(sound_type snd, int *cnt) { - register snd_list_type snd_list = snd->list; + snd_list_type snd_list = snd->list; /* * If there is not a block of samples, we need to generate one. */ @@ -1130,9 +1141,9 @@ sample_block_type SND_get_first(sound_type snd, long * cnt) } -sample_block_type SND_get_next(sound_type snd, long * cnt) +sample_block_type SND_get_next(sound_type snd, int *cnt) { - register snd_list_type snd_list = snd->list; + snd_list_type snd_list = snd->list; /* * SND_get_next is installed by SND_get_first, so we know * when we are called that we are done with the current block @@ -1191,10 +1202,10 @@ sample_block_type make_zero_block(void) * should be the MAX of logical stop times of arguments, so this routine * would not be used. */ -void min_cnt(long *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt) +void min_cnt(int64_t *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt) { - long c = (long) ((((sound->current - cnt) / sound->sr + sound->t0) - susp->t0) * - susp->sr + 0.5); + int64_t c = ROUNDBIG((((sound->current - cnt) / sound->sr + sound->t0) - susp->t0) * + susp->sr); /* if *cnt_ptr is uninitialized, just plug in c, otherwise compute min */ if ((*cnt_ptr == UNKNOWN) || (*cnt_ptr > c)) { /* nyquist_printf("min_cnt %p: new count is %d\n", susp, c);*/ @@ -1276,7 +1287,7 @@ void set_logical_stop_time(sound_type sound, time_type when) | | t0 when */ - long n = (long) ((when - sound->t0) * sound->sr + 0.5); + int64_t n = ROUNDBIG((when - sound->t0) * sound->sr); if (n < 0) { xlcerror("retain the current logical stop", "logical stop sample count is negative", NIL); @@ -1288,10 +1299,11 @@ void set_logical_stop_time(sound_type sound, time_type when) -/* for debugging */ +/* for debugging sound_type printing_this_sound = NULL; void ((**watch_me)()) = NULL; + void set_watch(where) void ((**where)()); { @@ -1300,84 +1312,128 @@ void set_watch(where) nyquist_printf("set_watch: watch_me = %p\n", watch_me); } } - +*/ /* * additional routines */ + +/* snd_list_len - for debugging: how many sample blocks held? */ +long snd_list_len(void *inst) +{ + int i = 0; + sound_type snd = (sound_type) inst; + snd_list_type list = snd->list; + while (list->block && list->block != zero_block && list->block_len != 0) { + i++; + list = list->u.next; + } + return i; +} + + +/* sound_print - implement SND-PRINT, based on sound_save in sndwritepa.c */ +/**/ void sound_print(snd_expr, n) LVAL snd_expr; long n; { LVAL result; - xlsave1(result); result = xleval(snd_expr); + /* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */ if (vectorp(result)) { /* make sure all elements are of type a_sound */ long i = getsize(result); while (i > 0) { i--; if (!exttypep(getelement(result, i), a_sound)) { - xlerror("sound_print: array has non-sound element", - result); + xlerror("SND-PRINT: array has non-sound element", + result); } } sound_print_array(result, n); - } else if (exttypep(result, a_sound)) { - sound_print_sound(getsound(result), n); + } else if (soundp(result)) { + sound_print_sound(result, n); } else { + xlprot1(result); xlerror("sound_print: expression did not return a sound", result); + xlpop(); } - xlpop(); } -void sound_print_sound(sound_type s, long n) +/* sound_print_sound - implements SND-PRINT for mono signal */ +/**/ +void sound_print_sound(LVAL s_as_lval, long n) { int ntotal = 0; - long blocklen; + sound_type s; + int blocklen; sample_block_type sampblock; - /* for debugging */ - printing_this_sound = s; + /* for debugging + printing_this_sound = s; + */ - nyquist_printf("sound_print: start at time %g\n", s->t0); + xlprot1(s_as_lval); + s = sound_copy(getsound(s_as_lval)); + s_as_lval = cvsound(s); /* destroys our reference to original */ + + nyquist_printf("SND-PRINT: start at time %g\n", s->t0); while (ntotal < n) { - if (s->logical_stop_cnt != UNKNOWN) - nyquist_printf("LST=%d ", (int)s->logical_stop_cnt); + if (s->logical_stop_cnt != UNKNOWN) { + nyquist_printf("logical stop time (in samples): %d ", + (int)s->logical_stop_cnt); + } sound_print_tree(s); sampblock = sound_get_next(s, &blocklen); if (sampblock == zero_block || blocklen == 0) { break; } - print_sample_block_type("sound_print", sampblock, + print_sample_block_type("SND-PRINT", sampblock, MIN(blocklen, n - ntotal)); ntotal += blocklen; } nyquist_printf("total samples: %d\n", ntotal); + xlpop(); } void sound_print_array(LVAL sa, long n) { - long blocklen; - long i, len; + int blocklen; + long i, chans; + LVAL sa_copy; long upper = 0; sample_block_type sampblock; time_type t0, tmax; - len = getsize(sa); - if (len == 0) { - stdputstr("sound_print: 0 channels!\n"); + chans = getsize(sa); + if (chans == 0) { + stdputstr("SND-PRINT: 0 channels!\n"); return; } + xlprot1(sa); + sa_copy = newvector(chans); + xlprot1(sa_copy); + + /* To be non-destructive, copy sounds from sa to sa_copy. */ + for (i = 0; i < chans; i++) { + sound_type s = getsound(getelement(sa, i)); + setelement(sa_copy, i, cvsound(sound_copy(s))); + } + /* If sa and sounds in sa are not accessible, we do not want to retain + * them because they will accumulate the computed samples. + */ + sa = sa_copy; /* destroy original reference to (maybe) allow GC */ + /* take care of prepending zeros if necessary */ t0 = tmax = (getsound(getelement(sa, 0)))->t0; - for (i = 1; i < len; i++) { + for (i = 1; i < chans; i++) { sound_type s = getsound(getelement(sa, i)); t0 = MIN(s->t0, t0); tmax = MAX(s->t0, tmax); @@ -1386,7 +1442,7 @@ void sound_print_array(LVAL sa, long n) /* if necessary, prepend zeros */ if (t0 != tmax) { stdputstr("prepending zeros to channels: "); - for (i = 0; i < len; i++) { + for (i = 0; i < chans; i++) { sound_type s = getsound(getelement(sa, i)); if (t0 < s->t0) { nyquist_printf(" %d ", (int)i); @@ -1396,31 +1452,32 @@ void sound_print_array(LVAL sa, long n) stdputstr("\n"); } - nyquist_printf("sound_print: start at time %g\n", t0); + nyquist_printf("SND-PRINT: start at time %g\n", t0); while (upper < n) { int i; boolean done = true; - for (i = 0; i < len; i++) { + for (i = 0; i < chans; i++) { sound_type s = getsound(getelement(sa, i)); - long current = -1; /* always get first block */ + int64_t current = -1; /* always get first block */ while (current < upper) { sampblock = sound_get_next(s, &blocklen); if (sampblock != zero_block && blocklen != 0) { - done = false; + done = false; } current = s->current - blocklen; nyquist_printf("chan %d current %d:\n", i, (int)current); - print_sample_block_type("sound_print", sampblock, - MIN(blocklen, n - current)); + print_sample_block_type("SND-PRINT", sampblock, + (int) MIN(blocklen, n - current)); current = s->current; - upper = MAX(upper, current); + upper = (long) MAX(upper, current); } } if (done) break; } nyquist_printf("total: %d samples x %d channels\n", - (int)upper, (int)len); + (int)upper, (int)chans); + xlpopn(2); // sa and sa_copy } @@ -1433,17 +1490,16 @@ void sound_print_array(LVAL sa, long n) * an expression that evaluates to the sound we want. The * expression is eval'd, the result copied (in case the * expression was a sound or a global variable and we really - * want to preserve the sound), and then a GC is run to + * want to preserve the sound), and then GC will * get rid of the original if there really are no other - * references. Finally, the copy is used to play the - * sounds. + * references. */ -void sound_play(snd_expr) +int64_t sound_play(snd_expr) LVAL snd_expr; { - int ntotal; - long blocklen; + int64_t ntotal; + int blocklen; sample_block_type sampblock; LVAL result; sound_type s; @@ -1451,24 +1507,21 @@ void sound_play(snd_expr) xlsave1(result); result = xleval(snd_expr); if (!exttypep(result, a_sound)) { - xlerror("sound_play: expression did not return a sound", + xlerror("SND-PLAY: expression did not return a sound", result); } ntotal = 0; - s = getsound(result); - xlpop(); - /* if snd_expr was simply a symbol, then s now points to + /* if snd_expr was simply a symbol, then result now points to a shared sound_node. If we read samples from it, then the sound bound to the symbol will be destroyed, so copy it first. If snd_expr was a real expression that computed a new value, then the next garbage collection - will reclaim the sound_node. We need to explicitly - free the copy since the garbage collector cannot find - it. + will reclaim the sound_node. */ - s = sound_copy(s); - gc(); + s = sound_copy(getsound(result)); + result = cvsound(s); + while (1) { #ifdef OSC if (nosc_enabled) nosc_poll(); @@ -1480,8 +1533,9 @@ void sound_play(snd_expr) /* print_sample_block_type("sound_play", sampblock, blocklen); */ ntotal += blocklen; } - nyquist_printf("total samples: %d\n", ntotal); - sound_unref(s); + nyquist_printf("total samples: %" PRId64 "\n", ntotal); + xlpop(); + return ntotal; } @@ -1549,7 +1603,6 @@ void sound_print_tree_1(snd, n) (int)snd_list->u.susp->log_stop_cnt, snd_list->u.susp->sr, snd_list->u.susp->t0, snd_list); -/* stdputstr("HI THERE AGAIN\n");*/ susp_print_tree(snd_list->u.susp, n + 4); return; } @@ -1662,8 +1715,8 @@ void sound_xlmark(void *a_sound) stdputstr("local variable or parameter that is being passed to\n"); stdputstr("SEQ or SEQREP. The garbage collector assumes that\n"); stdputstr("sounds are not recursive or circular, and follows\n"); - stdputstr("sounds to their end. After following a more nodes,\n"); - stdputstr("than can exist, I'm pretty sure that there is a\n"); + stdputstr("sounds to their end. After following 1M nodes,\n"); + stdputstr("I'm pretty sure that there is a\n"); stdputstr("cycle here, but since this is a bug, I cannot promise\n"); stdputstr("to recover. Prepare to crash. If you cannot locate\n"); stdputstr("the cause of this, contact the author -RBD.\n"); @@ -1697,8 +1750,7 @@ void sound_symbols() /* The SOUND Type: */ -boolean soundp(s) -LVAL s; +boolean soundp(LVAL s) { return (exttypep(s, a_sound)); } @@ -1725,8 +1777,7 @@ sound_type sound_zero(time_type t0,rate_type sr) } -LVAL cvsound(s) -sound_type s; +LVAL cvsound(sound_type s) { /* nyquist_printf("cvsound(%p)\n", s);*/ return (cvextern(sound_desc, (unsigned char *) s)); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sound.h b/lib-src/libnyquist/nyquist/nyqsrc/sound.h index 201b81612..9f406a965 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sound.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sound.h @@ -9,7 +9,7 @@ #include "stdefs.h" /* used for *AUDIO-MARKERS* */ -extern long sound_frames; +extern int64_t sound_frames; extern double sound_srate; extern long max_sample_blocks; @@ -25,7 +25,7 @@ extern int nosc_enabled; /* enable polling for OSC messages */ #define PERMS 0644 /* -rw-r--r-- */ /* default stop sample count (for clipping) */ -#define MAX_STOP 0x7FFFFFFF +#define MAX_STOP 0x7FFFFFFFFFFFFFFF /* default stop time (for clipping) */ #define MAX_STOP_TIME 10E20 @@ -228,7 +228,7 @@ extern int nosc_enabled; /* enable polling for OSC messages */ #define INTERP_SHIFT 2 LVAL snd_badsr(void); -long check_terminate_cnt(long tc); +int64_t check_terminate_cnt(int64_t tc); typedef double time_type; typedef double rate_type; @@ -248,8 +248,8 @@ typedef double promoted_sample_type; production */ /* leave a few words short of 1024 in case we allocate powers of 2 */ -#define max_sample_block_len 1020 -/* #define max_sample_block_len 4 */ +#define max_sample_block_len 1016 +// #define max_sample_block_len 4 /* longest allowed sample is basically 2^31 but a bit lower to allow for rounding */ @@ -274,25 +274,18 @@ typedef struct { /* forward declaration for circular type dependencies */ typedef struct snd_list_struct *snd_list_type; -struct snd_susp_struct; - -typedef void (*snd_fetch_fn)(struct snd_susp_struct *, snd_list_type snd_list); -typedef void (*snd_free_fn)(struct snd_susp_struct *); -typedef void (*snd_mark_fn)(struct snd_susp_struct *); /* marks LVAL nodes for GC */ -typedef void (*snd_print_tree_fn)(struct snd_susp_struct *, int); - typedef struct snd_susp_struct { - snd_fetch_fn fetch; + void (*fetch)(struct snd_susp_struct *, snd_list_type snd_list); void (*keep_fetch)(struct snd_susp_struct *, snd_list_type snd_list); - snd_free_fn free; - snd_mark_fn mark; - snd_print_tree_fn print_tree; /* debugging */ + void (*free)(struct snd_susp_struct *); + void (*mark)(struct snd_susp_struct *); /* marks LVAL nodes for GC */ + void (*print_tree)(struct snd_susp_struct *, int); /* debugging */ char *name; /* string name for debugging */ - long toss_cnt; /* return this many zeros, then compute */ - long current; /* current sample number */ + int64_t toss_cnt; /* return this many zeros, then compute */ + int64_t current; /* current sample number */ double sr; /* sample rate */ time_type t0; /* starting time */ - long log_stop_cnt; /* logical stop count */ + int64_t log_stop_cnt; /* logical stop count */ /* other susp dependent stuff will be here... */ } snd_susp_node, *snd_susp_type; @@ -325,26 +318,26 @@ typedef struct table_struct { #define UNKNOWN (-10-max_sample_block_len) typedef struct sound_struct { - sample_block_type (*get_next)(struct sound_struct *snd, long *cnt); + sample_block_type (*get_next)(struct sound_struct *snd, int *cnt); time_type time; /* logical starting time */ time_type t0; /* quantized time of first sample */ - long stop; /* stop (clipping) sample no. */ + int64_t stop; /* stop (clipping) sample no. */ time_type true_t0; /* exact time of first sample */ rate_type sr; /* sample rate */ - long current; /* current sample number, + int64_t current; /* current sample number, if negative, then the first -current samples must be dropped in order to find the first sample */ - long logical_stop_cnt; /* log stop sample no, -1=unknwn */ + int64_t logical_stop_cnt; /* log stop sample no, -1=unknwn */ snd_list_type list; /* sample block list, starting at curr. samp */ sample_type scale; /* scale factor for the result */ - long prepend_cnt; /* how many zeros to prepend */ + int64_t prepend_cnt; /* how many zeros to prepend */ /* function to use as get_next after prepended zeros are generated: */ sample_block_type (*after_prepend) - (struct sound_struct * snd, long * cnt); + (struct sound_struct * snd, int *cnt); table_type table; /* pointer to table-ized version of this sound */ - long *extra; /* used for extra state information, first word of extra - state should be the length of the extra state + int64_t *extra; /* used for extra state information, extra[0] + should be the length of the extra state (see sound_unref()) */ } sound_node, *sound_type; @@ -359,7 +352,7 @@ extern snd_list_type zero_snd_list; extern sound_type printing_this_sound; /* debugging global */ -long snd_set_max_audio_mem(long m); +int64_t snd_set_max_audio_mem(int64_t m); /* LISP: (SND-SET-MAX-AUDIO-MEM FIXNUM) */ extern double sound_latency; /* controls output latency */ @@ -379,10 +372,10 @@ void snd_list_unref(snd_list_type list); LVAL cvsound(sound_type); extern LVAL a_sound; -sample_block_type SND_get_next(sound_type snd, long * cnt); -sample_block_type SND_get_first(sound_type snd, long * cnt); -sample_block_type SND_get_zeros(sound_type snd, long * cnt); -sample_block_type SND_flush(sound_type snd, long * cnt); +sample_block_type SND_get_next(sound_type snd, int *cnt); +sample_block_type SND_get_first(sound_type snd, int *cnt); +sample_block_type SND_get_zeros(sound_type snd, int *cnt); +sample_block_type SND_flush(sound_type snd, int *cnt); double hz_to_step(double); /* LISP: (HZ-TO-STEP ANYNUM) */ int interp_style(sound_type s, rate_type sr); @@ -415,7 +408,7 @@ sound_type snd_xform(sound_type snd, rate_type sr, time_type time, sound_type sound_create(snd_susp_type susp, time_type t0, rate_type sr, promoted_sample_type scale); -void min_cnt(long *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt); +void min_cnt(int64_t *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt); void indent(int n); void sound_prepend_zeros(sound_type snd, time_type t0); @@ -426,18 +419,20 @@ void sound_prepend_zeros(sound_type snd, time_type t0); extern long blocks_to_watch_len; extern sample_block_type blocks_to_watch[blocks_to_watch_max]; -void block_watch(long sample_block); +void block_watch(int64_t sample_block); /* LISP: (BLOCK-WATCH FIXNUM) */ -long sound_nth_block(sound_type snd, long n); - /* LISP: (SOUND-NTH-BLOCK SOUND FIXNUM) */ +int64_t sound_nth_block(sound_type snd, long n); + /* LISP: (SOUND-NTH-BLOCK SOUND LONG) */ #endif +LVAL sound_array_copy(LVAL sa); + sound_type sound_copy(sound_type snd); /* LISP: (SND-COPY SOUND) */ void sound_xlmark(void *a_sound); void sound_print(LVAL snd_expr, long n); - /* LISP: (SND-PRINT ANY FIXNUM) */ -void sound_play(LVAL snd_expr); + /* LISP: (SND-PRINT ANY LONG) */ +int64_t sound_play(LVAL snd_expr); /* LISP: (SND-PLAY ANY) */ void stats(void); /* LISP: (STATS) */ @@ -545,32 +540,22 @@ double step_to_hz(double); */ #define susp_check_term_log_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt, bit, all) \ if (susp->sample_cnt == 0) { \ - susp_get_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt); \ -/*OLD if (susp->sound->logical_stop_cnt == \ - susp->sound->current - susp->sample_cnt) { \ -*/ \ + susp_get_block_samples(sound, sample_block_ptr, \ + sample_ptr, sample_cnt); \ if (susp->sound->logical_stop_cnt != UNKNOWN && \ !(susp->logical_stop_bits & bit)) { \ susp->logical_stop_bits |= bit; \ -/*OLD \ - if (susp->logical_stop_bits == all) { \ - susp->susp.log_stop_cnt = (long) \ - ((((susp->sound->current - susp->sample_cnt) / \ - susp->sound->sr + susp->sound->t0) - \ - susp->susp.t0) * susp->susp.sr + 0.5); \ - assert(susp->susp.log_stop_cnt >= 0); } } \ -*/ \ - susp->susp.log_stop_cnt = max(susp->susp.log_stop_cnt, \ + susp->susp.log_stop_cnt = (int64_t) max(susp->susp.log_stop_cnt, \ (((susp->sound->logical_stop_cnt / \ susp->sound->sr + susp->sound->t0) - \ susp->susp.t0) * susp->susp.sr + 0.5)); } \ if (susp->sample_ptr == zero_block->samples) { \ susp->terminate_bits |= bit; \ if (susp->terminate_bits == all) { \ - susp->terminate_cnt = (long) \ - ((((susp->sound->current - susp->sample_cnt) / \ - susp->sound->sr + susp->sound->t0) - \ - susp->susp.t0) * susp->susp.sr + 0.5); \ + susp->terminate_cnt = ROUNDBIG( \ + (((susp->sound->current - susp->sample_cnt) / \ + susp->sound->sr + susp->sound->t0) - \ + susp->susp.t0) * susp->susp.sr); \ } } } @@ -584,7 +569,7 @@ double step_to_hz(double); */ #define logical_stop_cnt_cvt(sound) \ (sound->logical_stop_cnt == UNKNOWN ? UNKNOWN : \ - ROUND32((sound->logical_stop_cnt / sound->sr) * susp->susp.sr)) + ROUNDBIG((sound->logical_stop_cnt / sound->sr) * susp->susp.sr)) /* logical_stop_test tests to see if sound has logically stopped; if so, diff --git a/lib-src/libnyquist/nyquist/nyqsrc/stoponzero.c b/lib-src/libnyquist/nyquist/nyqsrc/stoponzero.c index 92b95c1ff..836f9b903 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/stoponzero.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/stoponzero.c @@ -14,10 +14,10 @@ void stoponzero_free(snd_susp_type a_susp); typedef struct stoponzero_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; } stoponzero_susp_node, *stoponzero_susp_type; @@ -50,7 +50,7 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo < 0) togo = 0; /* avoids rounding errros */ if (togo == 0) break; } @@ -58,7 +58,8 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + int64_t to_stop = (susp->susp.log_stop_cnt - + (susp->susp.current + cnt)); /* break if to_stop == 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the * output block). @@ -77,7 +78,7 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) } else /* limit togo so we can start a new * block at the LST */ - togo = to_stop; + togo = (int) to_stop; } } @@ -132,8 +133,8 @@ void stoponzero_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - - (susp->s1->current - susp->s1_cnt)); + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); susp->susp.fetch = susp->susp.keep_fetch; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/trigger.c b/lib-src/libnyquist/nyquist/nyqsrc/trigger.c index 0f5daf1e3..e7bbb2bd1 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/trigger.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/trigger.c @@ -61,15 +61,15 @@ typedef struct trigger_susp_struct { snd_susp_node susp; boolean started; int terminate_bits; - long terminate_cnt; + int64_t terminate_cnt; int logical_stop_bits; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_type s1_bptr; /* block pointer */ sample_block_values_type s1_ptr; sound_type s2; - long s2_cnt; + int s2_cnt; sample_block_type s2_bptr; /* block pointer */ sample_block_values_type s2_ptr; @@ -81,7 +81,7 @@ typedef struct trigger_susp_struct { void trigger_fetch(snd_susp_type, snd_list_type); -void trigger_free(); +void trigger_free(snd_susp_type a_susp); extern LVAL s_stdout; @@ -122,7 +122,7 @@ void trigger_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); if (togo == 0) break; } @@ -135,7 +135,7 @@ void trigger_fetch(snd_susp_type a_susp, snd_list_type snd_list) trigger_susp_type new_trigger; sound_type new_trigger_snd; LVAL result; - long delay; /* sample delay to s2 */ + int64_t delay; /* sample delay to s2 */ time_type now; susp->previous = s; /* don't retrigger */ @@ -275,9 +275,7 @@ void trigger_print_tree(snd_susp_type a_susp, int n) -sound_type snd_make_trigger(s1, closure) - sound_type s1; - LVAL closure; +sound_type snd_make_trigger(sound_type s1, LVAL closure) { register trigger_susp_type susp; /* t0 specified as input parameter */ @@ -321,9 +319,7 @@ sound_type snd_make_trigger(s1, closure) } -sound_type snd_trigger(s1, closure) - sound_type s1; - LVAL closure; +sound_type snd_trigger(sound_type s1, LVAL closure) { sound_type s1_copy; s1_copy = sound_copy(s1); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/trigger.h b/lib-src/libnyquist/nyquist/nyqsrc/trigger.h index d300e92d7..f6a82447e 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/trigger.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/trigger.h @@ -1,3 +1,3 @@ -sound_type snd_make_trigger(); -sound_type snd_trigger(); +sound_type snd_make_trigger(sound_type s1, LVAL closure); +sound_type snd_trigger(sound_type s1, LVAL closure); /* LISP: (SND-TRIGGER SOUND ANY) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/yin.c b/lib-src/libnyquist/nyquist/nyqsrc/yin.c index 9796ba228..10350d59c 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/yin.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/yin.c @@ -12,17 +12,17 @@ #include "yin.h" -void yin_free(); +void yin_free(snd_susp_type a_susp); /* for multiple channel results, one susp is shared by all sounds */ /* the susp in turn must point back to all sound list tails */ typedef struct yin_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; long blocksize; long stepsize; @@ -31,9 +31,9 @@ typedef struct yin_susp_struct { sample_type *fillptr; sample_type *endptr; snd_list_type chan[2]; /* array of back pointers */ - long cnt; /* how many sample frames to read */ - long m; - long middle; + int cnt; /* how many sample frames to read */ + int m; + int middle; } yin_susp_node, *yin_susp_type; /* DEBUG CODE: @@ -392,18 +392,21 @@ void yin_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* don't run past the s input sample block */ susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + togo = (int) min(togo, susp->s_cnt); /* don't run past terminate time */ if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo/susp->stepsize) { - togo = (susp->terminate_cnt - (susp->susp.current + cnt)) * susp->stepsize; + susp->terminate_cnt <= + susp->susp.current + cnt + togo/susp->stepsize) { + togo = (int) ((susp->terminate_cnt - (susp->susp.current + cnt)) * + susp->stepsize); if (togo == 0) break; } /* don't run past logical stop time */ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + int64_t to_stop = susp->susp.log_stop_cnt - + (susp->susp.current + cnt); /* break if to_stop = 0 (we're at the logical stop) * AND cnt > 0 (we're not at the beginning of the output block) */ @@ -417,7 +420,7 @@ void yin_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ susp->logically_stopped = true; } else /* limit togo so we can start a new block a the LST */ - togo = to_stop * susp->stepsize; + togo = (int) (to_stop * susp->stepsize); } } n = togo; @@ -545,10 +548,10 @@ LVAL snd_make_yin(sound_type s, double low_step, double high_step, long stepsize susp->susp.current = 0; susp->s = s; susp->s_cnt = 0; - susp->m = (long) (sr / step_to_hz(high_step)); + susp->m = (int) (sr / step_to_hz(high_step)); if (susp->m < 2) susp->m = 2; /* add 1 to make sure we round up */ - susp->middle = (long) (sr / step_to_hz(low_step)) + 1; + susp->middle = (int) (sr / step_to_hz(low_step)) + 1; susp->blocksize = susp->middle * 2; susp->stepsize = stepsize; /* blocksize must be at least step size to implement stepping */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/yin.h b/lib-src/libnyquist/nyquist/nyqsrc/yin.h index 656aa81f0..bb656dfbe 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/yin.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/yin.h @@ -2,5 +2,5 @@ LVAL snd_yin(sound_type s, double low_step, double high_step, long stepsize); -/* LISP: (SND-YIN SOUND ANYNUM ANYNUM FIXNUM) */ +/* LISP: (SND-YIN SOUND ANYNUM ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp index 3749868a2..1b5a0e097 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp @@ -72,15 +72,12 @@ void Delay :: setMaximumDelay(unsigned long delay) { if ( delay < inputs_.size() ) return; -/* if ( delay < 0 ) { errorString_ << "Delay::setMaximumDelay: argument (" << delay << ") less than zero!\n"; handleError( StkError::WARNING ); return; } - else -*/ - if (delay < delay_ ) { + else if (delay < delay_ ) { errorString_ << "Delay::setMaximumDelay: argument (" << delay << ") less than current delay setting (" << delay_ << ")!\n"; handleError( StkError::WARNING ); return; @@ -100,7 +97,6 @@ void Delay :: setDelay(unsigned long delay) if ( outPoint_ == inputs_.size() ) outPoint_ = 0; delay_ = inputs_.size() - 1; } - /* else if ( delay < 0 ) { errorString_ << "Delay::setDelay: argument (" << delay << ") less than zero ... setting to zero!\n"; handleError( StkError::WARNING ); @@ -108,7 +104,6 @@ void Delay :: setDelay(unsigned long delay) outPoint_ = inPoint_; delay_ = 0; } - */ else { // read chases write if ( inPoint_ >= delay ) outPoint_ = inPoint_ - delay; else outPoint_ = inputs_.size() + inPoint_ - delay; @@ -124,19 +119,19 @@ unsigned long Delay :: getDelay(void) const StkFloat Delay :: energy(void) const { unsigned long i; - StkFloat e = 0; + register StkFloat e = 0; if (inPoint_ >= outPoint_) { for (i=outPoint_; i #include "cext.h" -extern int IOinputfd; /* input file descriptor (usually 0) */ +int IOinputfd; /* input file descriptor (usually 0) */ -extern int IOnochar; /* Value to be returned by IOgetchar() - where there is no input to be had */ +int IOnochar; /* Value to be returned by IOgetchar() + where there is no input to be had */ static struct sgttyb IOoldmodes, IOcurrentmodes; /* Initial and current tty modes */ diff --git a/lib-src/libnyquist/nyquist/sys/unix/osstuff.c b/lib-src/libnyquist/nyquist/sys/unix/osstuff.c index 2aa32b57f..50aecf5be 100644 --- a/lib-src/libnyquist/nyquist/sys/unix/osstuff.c +++ b/lib-src/libnyquist/nyquist/sys/unix/osstuff.c @@ -36,6 +36,8 @@ * advertised. * 28-OCT-05 Roger Dannenberg at CMU-SCS * added directory listing functions + * 9-JUL-2020 Roger Dannenberg + * added get-real-time lisp function */ #include "switches.h" @@ -44,6 +46,7 @@ #include #include #include +#include #include #include @@ -80,12 +83,19 @@ static char lbuf[LBSIZE]; static int lpos[LBSIZE]; #endif +#if USE_RAND +#if __APPLE__ +#else +#include +#endif +#endif + static int echo_enabled = 1; /* forward declarations */ -FORWARD LOCAL void xflush(); -FORWARD LOCAL int xcheck(); -FORWARD LOCAL void hidden_msg(); +FORWARD LOCAL void xflush(void); +FORWARD LOCAL int xcheck(void); +FORWARD LOCAL void hidden_msg(void); /*==========================================================================*/ /* control-c interrupt handling routines and variables. Uses B4.2 signal @@ -96,14 +106,13 @@ FORWARD LOCAL void hidden_msg(); #include static int ctc = FALSE; -static void control_c(int x) {ctc = TRUE;} -void ctcinit() {signal ( SIGINT, control_c );} -static void ctcreset() {signal ( SIGINT, control_c );} +static void control_c(int x) {ctc = TRUE;} +void ctcinit(void) {signal ( SIGINT, control_c );} +static void ctcreset(void) {signal ( SIGINT, control_c );} /*==========================================================================*/ - const char os_pathchar = '/'; const char os_sepchar = ':'; @@ -112,6 +121,10 @@ const char os_sepchar = ':'; void osinit(const char *banner) { printf("%s\n",banner); + if (max_sample_block_len < 64) { + printf("Warning: max_sample_block_len %d is small. Maybe you forgot" + " to reset it after debugging.\n", max_sample_block_len); + } /* start the random number generator. Older version was srand(1) seed of 1 makes the sequence repeatable. Random gives better pseudo randomness than does rand(). @@ -164,7 +177,8 @@ void oserror(const char *msg) {printf("error: %s\n",msg);} /* osaopen - open an ascii file */ -FILE *osaopen(name,mode) const char *name,*mode; { +FILE *osaopen(const char *name, const char *mode) +{ FILE *fp = NULL; if (ok_to_open(name, mode)) fp = fopen(name,mode); @@ -237,7 +251,7 @@ int osbputc(ch,fp) int ch; FILE *fp; {return (putc(ch,fp));} #ifdef OLDEST_OSTGETC /* ostgetc - get a character from the terminal */ -int ostgetc() +int ostgetc(void) { int ch; switch (ch = term_getchar()) { @@ -293,7 +307,7 @@ int ostgetc() #else #if OLD_OSTGETC /* ostgetc - get a character from the terminal */ -int ostgetc() +int ostgetc(void) { int ch; for (;;) { @@ -328,7 +342,7 @@ int readline_first = 1; extern int xldebug; -int ostgetc() +int ostgetc(void) { int rval; @@ -364,7 +378,7 @@ int ostgetc() #else /* no readline */ -void end_of_line_edit() +void end_of_line_edit(void) { line_edit = FALSE; if (tfp) { @@ -375,7 +389,7 @@ void end_of_line_edit() } /* THIS IS THE "REAL" ostgetc(): */ -LOCAL int rawtchar() +LOCAL int rawtchar(void) { int ch; if (typeahead_tail != typeahead_head) { @@ -392,7 +406,7 @@ LOCAL int rawtchar() return ch; } -int ostgetc() +int ostgetc(void) { /* * NOTE: lbuf[] accumulates characters as they are typed @@ -561,7 +575,7 @@ void ostputc(int ch) } /* ostoutflush - flush output buffer */ -void ostoutflush() +void ostoutflush(void) { if (tfp) fflush(tfp); fflush(stdout); @@ -585,7 +599,7 @@ void osflush(void) * * This function assumes that '\016' has been received already. */ -LOCAL void hidden_msg() +LOCAL void hidden_msg(void) { #define MSGBUF_MAX 64 char msgbuf[MSGBUF_MAX]; @@ -687,14 +701,14 @@ void oscheck(void) } /* xflush - flush the input line buffer and start a new line */ -LOCAL void xflush() +LOCAL void xflush(void) { osflush(); ostputc('\n'); } /* xsystem - execute a system command */ -LVAL xsystem() +LVAL xsystem(void) { /*LVAL strval;*/ unsigned char *cmd = NULL; if (SAFE_NYQUIST) return NULL; @@ -706,7 +720,7 @@ LVAL xsystem() /* xsetdir -- set current directory of the process */ -LVAL xsetdir() +LVAL xsetdir(void) { char *dir = (char *)getstring(xlgastring()); int result = -1; @@ -738,13 +752,13 @@ LVAL xsetdir() } /* xget_temp_path -- get a path to create temp files */ -LVAL xget_temp_path() +LVAL xget_temp_path(void) { return cvstring("/tmp/"); } /* xget_user -- get a string identifying the user, for use in file names */ -LVAL xget_user() +LVAL xget_user(void) { const char *user = getenv("USER"); if (!user || !*user) { @@ -756,7 +770,7 @@ LVAL xget_user() /* xechoenabled -- set/clear echo_enabled flag (unix only) */ -LVAL xechoenabled() +LVAL xechoenabled(void) { int flag = (xlgetarg() != NULL); xllastarg(); @@ -789,7 +803,7 @@ int osdir_list_start(const char *path) /* osdir_list_next -- read the next entry from a directory */ -const char *osdir_list_next() +const char *osdir_list_next(void) { if (osdir_list_status != OSDIR_LIST_STARTED) { return NULL; @@ -805,7 +819,7 @@ const char *osdir_list_next() /* osdir_list_finish -- close an open directory */ -void osdir_list_finish() +void osdir_list_finish(void) { if (osdir_list_status != OSDIR_LIST_READY) { closedir(osdir_dir); @@ -815,18 +829,26 @@ void osdir_list_finish() /* xcheck -- return a character if one is present */ -LOCAL int xcheck() +LOCAL int xcheck(void) { int ch = term_testchar(); return ch; } /* xgetkey - get a key from the keyboard */ -LVAL xgetkey() {xllastarg(); return (cvfixnum((FIXTYPE)term_getchar()));} +LVAL xgetkey(void) {xllastarg(); return (cvfixnum((FIXTYPE)term_getchar()));} /* ossymbols - enter os specific symbols */ void ossymbols(void) {} /* xsetupconsole -- used to configure window in Win32 version */ -LVAL xsetupconsole() { return NIL; } +LVAL xsetupconsole(void) { return NIL; } + +/* xgetrealtime - get current time in seconds */ +LVAL xgetrealtime(void) +{ + struct timeval te; + gettimeofday(&te, NULL); // get current time + return cvflonum((double) te.tv_sec + (te.tv_usec * 1e-6)); +} diff --git a/lib-src/libnyquist/nyquist/sys/unix/switches.h b/lib-src/libnyquist/nyquist/sys/unix/switches.h index ef9181b27..91e226359 100644 --- a/lib-src/libnyquist/nyquist/sys/unix/switches.h +++ b/lib-src/libnyquist/nyquist/sys/unix/switches.h @@ -191,7 +191,9 @@ /* NYQUIST tells some CMT code that we're really in * XLISP and NYQUIST */ +#ifndef NYQUIST #define NYQUIST 1 +#endif /* If SAFE_NYQUIST is defined, Nyquist will prevent: * - writes anywhere except in the directory tree diff --git a/lib-src/libnyquist/nyquist/sys/unix/term.c b/lib-src/libnyquist/nyquist/sys/unix/term.c index 2218febd5..df15c036e 100644 --- a/lib-src/libnyquist/nyquist/sys/unix/term.c +++ b/lib-src/libnyquist/nyquist/sys/unix/term.c @@ -19,7 +19,7 @@ #include #include -void ctcinit(); +void ctcinit(void); /* This will be used for new terminal settings. */ static struct termios current; @@ -34,14 +34,14 @@ void term_restore(void) } /* Clean up termianl; called on exit. */ -void term_exit() +void term_exit(void) { term_restore(); } /* Will be called when contrl-Z is pressed; * this correctly handles the terminal. */ -void term_ctrlz() +void term_ctrlz(int i) { signal(SIGTSTP, term_ctrlz); term_restore(); @@ -50,12 +50,18 @@ void term_ctrlz() /* Will be called when the application is continued * after having been stopped. */ -void term_cont() +void term_cont(int i) { signal(SIGCONT, term_cont); tcsetattr(0, TCSANOW, ¤t); } +/* callback for SIGQUIT is different type from atexit callback */ +void term_quit(int i) +{ + term_exit(); +} + /* Needs to be called to initialize the terminal. */ void term_init(void) { @@ -67,7 +73,7 @@ void term_init(void) /* We _must_ clean up when we exit. */ /* signal(SIGINT, term_exit); */ ctcinit(); /* XLisp wants to catch ctrl C */ - signal(SIGQUIT, term_exit); + signal(SIGQUIT, term_quit); /* Control-Z must also be handled. */ signal(SIGTSTP, term_ctrlz); signal(SIGCONT, term_cont); @@ -103,7 +109,7 @@ void term_line(void) * * if ready, return it, otherwise return -2 */ -int term_testchar() +int term_testchar(void) { int n; char c; @@ -124,7 +130,7 @@ int term_testchar() /* term_getchar -- get a character (block if necessary) */ /**/ -int term_getchar() +int term_getchar(void) { char c; int rslt = read(0, &c, 1); diff --git a/lib-src/libnyquist/nyquist/sys/unix/term.h b/lib-src/libnyquist/nyquist/sys/unix/term.h index 4a6ac4c7c..2e9c5d7fa 100644 --- a/lib-src/libnyquist/nyquist/sys/unix/term.h +++ b/lib-src/libnyquist/nyquist/sys/unix/term.h @@ -1,6 +1,6 @@ -void term_init(); -void term_exit(); -void ctcinit(); /* not implemented in term.h */ -int term_testchar(); -int term_getchar(); -void term_character(); +void term_init(void); +void term_exit(void); +void ctcinit(void); /* not implemented in term.h */ +int term_testchar(void); +int term_getchar(void); +void term_character(void); diff --git a/lib-src/libnyquist/nyquist/sys/win/msvc/winstuff.c b/lib-src/libnyquist/nyquist/sys/win/msvc/winstuff.c index a4babaead..3a5f61f4e 100644 --- a/lib-src/libnyquist/nyquist/sys/win/msvc/winstuff.c +++ b/lib-src/libnyquist/nyquist/sys/win/msvc/winstuff.c @@ -82,7 +82,7 @@ static char *linebuf = NULL, *lineptr; static int numChars; /* input thread */ -unsigned long input_thread_handle = -1; +static uintptr_t input_thread_handle = -1; #define NEED_INPUT if (input_thread_handle == -1) start_input_thread(); #define input_buffer_max 1024 #define input_buffer_mask (input_buffer_max - 1) @@ -425,3 +425,18 @@ LVAL xechoenabled() } +/* xgetrealtime - get current time in seconds */ +LVAL xgetrealtime() +{ + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = (uint64_t) file_time.dwLowDateTime; + time += ((uint64_t) file_time.dwHighDateTime) << 32; + time -= EPOCH; + time /= 10000000L; + return cvflonum((double) time + system_time.wMilliseconds * 0.001); +} \ No newline at end of file diff --git a/lib-src/libnyquist/nyquist/tran/README.txt b/lib-src/libnyquist/nyquist/tran/README.txt new file mode 100644 index 000000000..d3d9b43c2 --- /dev/null +++ b/lib-src/libnyquist/nyquist/tran/README.txt @@ -0,0 +1 @@ +Run command-line nyquist in this directory and type (m) to regenerate all .c and .h files. See translate.lsp for other commands to translate individual files or groups of files. diff --git a/lib-src/libnyquist/nyquist/tran/abs.c b/lib-src/libnyquist/nyquist/tran/abs.c index 14a2615dc..34d2c5329 100644 --- a/lib-src/libnyquist/nyquist/tran/abs.c +++ b/lib-src/libnyquist/nyquist/tran/abs.c @@ -14,10 +14,10 @@ void abs_free(snd_susp_type a_susp); typedef struct abs_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; } abs_susp_node, *abs_susp_type; @@ -39,94 +39,94 @@ void abs_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { sample_type s = *input_ptr_reg++; sample_type o = s; if (o < 0.0) o = -o; *out_ptr_reg++ = o; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* abs_n_fetch */ void abs_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ abs_susp_type susp = (abs_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/allpoles.c b/lib-src/libnyquist/nyquist/tran/allpoles.c index d1ed2516e..30853456a 100644 --- a/lib-src/libnyquist/nyquist/tran/allpoles.c +++ b/lib-src/libnyquist/nyquist/tran/allpoles.c @@ -14,10 +14,10 @@ void allpoles_free(snd_susp_type a_susp); typedef struct allpoles_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type x_snd; - long x_snd_cnt; + int x_snd_cnt; sample_block_values_type x_snd_ptr; long ak_len; @@ -52,47 +52,47 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the x_snd input sample block: */ - susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt); - togo = min(togo, susp->x_snd_cnt); + /* don't run past the x_snd input sample block: */ + susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt); + togo = min(togo, susp->x_snd_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } if (susp->ak_array == NULL) { @@ -120,15 +120,15 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) } - n = togo; - ak_len_reg = susp->ak_len; - gain_reg = susp->gain; - ak_coefs_reg = susp->ak_coefs; - zk_buf_reg = susp->zk_buf; - index_reg = susp->index; - x_snd_ptr_reg = susp->x_snd_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ak_len_reg = susp->ak_len; + gain_reg = susp->gain; + ak_coefs_reg = susp->ak_coefs; + zk_buf_reg = susp->zk_buf; + index_reg = susp->index; + x_snd_ptr_reg = susp->x_snd_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; long xi; long xj; z0 = (x_snd_scale_reg * *x_snd_ptr_reg++)*gain_reg; for (xi=0; xi < ak_len_reg ; xi++) { xj = index_reg + xi; if (xj >= ak_len_reg) xj -= ak_len_reg; @@ -137,46 +137,46 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) zk_buf_reg[index_reg] = z0; index_reg++; if (index_reg == ak_len_reg) index_reg = 0; *out_ptr_reg++ = (sample_type) z0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->zk_buf = zk_buf_reg; - susp->index = index_reg; - /* using x_snd_ptr_reg is a bad idea on RS/6000: */ - susp->x_snd_ptr += togo; - out_ptr += togo; - susp_took(x_snd_cnt, togo); - cnt += togo; + susp->zk_buf = zk_buf_reg; + susp->index = index_reg; + /* using x_snd_ptr_reg is a bad idea on RS/6000: */ + susp->x_snd_ptr += togo; + out_ptr += togo; + susp_took(x_snd_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* allpoles_s_fetch */ void allpoles_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ allpoles_susp_type susp = (allpoles_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from x_snd up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr)) >= - susp->x_snd->current) - susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt); + susp->x_snd->current) + susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - + n = (int) ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - (susp->x_snd->current - susp->x_snd_cnt)); susp->x_snd_ptr += n; susp_took(x_snd_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/alpass.c b/lib-src/libnyquist/nyquist/tran/alpass.c index 4d739c949..a4b9e4f81 100644 --- a/lib-src/libnyquist/nyquist/tran/alpass.c +++ b/lib-src/libnyquist/nyquist/tran/alpass.c @@ -14,9 +14,9 @@ void alpass_free(snd_susp_type a_susp); typedef struct alpass_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double feedback; @@ -47,67 +47,67 @@ void alpass_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - feedback_reg = susp->feedback; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + feedback_reg = susp->feedback; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z; y = *delayptr_reg; *delayptr_reg++ = z = (sample_type) (feedback_reg * y + *input_ptr_reg++); *out_ptr_reg++ = (sample_type) (y - feedback_reg * z); if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpass_n_fetch */ void alpass_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ alpass_susp_type susp = (alpass_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/alpasscv.alg b/lib-src/libnyquist/nyquist/tran/alpasscv.alg index f8114663e..2a7377d7f 100644 --- a/lib-src/libnyquist/nyquist/tran/alpasscv.alg +++ b/lib-src/libnyquist/nyquist/tran/alpasscv.alg @@ -14,8 +14,8 @@ (TERMINATE (MIN input)) (INNER-LOOP-LOCALS " register sample_type y, z, fb;\n") (INNER-LOOP "y = *delayptr; - *delayptr++ = z = (sample_type) - ((fb = feedback) * y + input); + *delayptr++ = z = + ((fb = (sample_type) feedback) * y + input); output = (sample_type) (y - fb * z); if (delayptr >= endptr) delayptr = susp->delaybuf") (FINALIZATION "free(susp->delaybuf);") diff --git a/lib-src/libnyquist/nyquist/tran/alpasscv.c b/lib-src/libnyquist/nyquist/tran/alpasscv.c index dbdd3b325..635c9a5f9 100644 --- a/lib-src/libnyquist/nyquist/tran/alpasscv.c +++ b/lib-src/libnyquist/nyquist/tran/alpasscv.c @@ -15,12 +15,12 @@ void alpasscv_free(snd_susp_type a_susp); typedef struct alpasscv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; sound_type feedback; - long feedback_cnt; + int feedback_cnt; sample_block_values_type feedback_ptr; /* support for interpolation of feedback */ @@ -30,7 +30,7 @@ typedef struct alpasscv_susp_struct { /* support for ramp between samples of feedback */ double output_per_feedback; - long feedback_n; + int64_t feedback_n; long delaylen; sample_type *delaybuf; @@ -59,58 +59,58 @@ void alpasscv_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, fb; y = *delayptr_reg; - *delayptr_reg++ = z = (sample_type) - ((fb = *feedback_ptr_reg++) * y + *input_ptr_reg++); + *delayptr_reg++ = z = + ((fb = (sample_type) *feedback_ptr_reg++) * y + *input_ptr_reg++); *out_ptr_reg++ = (sample_type) (y - fb * z); if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpasscv_nn_fetch */ @@ -136,58 +136,58 @@ void alpasscv_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, fb; y = *delayptr_reg; - *delayptr_reg++ = z = (sample_type) - ((fb = (feedback_scale_reg * *feedback_ptr_reg++)) * y + *input_ptr_reg++); + *delayptr_reg++ = z = + ((fb = (sample_type) (feedback_scale_reg * *feedback_ptr_reg++)) * y + *input_ptr_reg++); *out_ptr_reg++ = (sample_type) (y - fb * z); if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpasscv_ns_fetch */ @@ -216,74 +216,74 @@ void alpasscv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); + susp->started = true; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_pHaSe_ReG = susp->feedback_pHaSe; - feedback_x1_sample_reg = susp->feedback_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_pHaSe_ReG = susp->feedback_pHaSe; + feedback_x1_sample_reg = susp->feedback_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, fb; - if (feedback_pHaSe_ReG >= 1.0) { - feedback_x1_sample_reg = feedback_x2_sample; - /* pick up next sample as feedback_x2_sample: */ - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - feedback_pHaSe_ReG -= 1.0; - susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); - } + if (feedback_pHaSe_ReG >= 1.0) { + feedback_x1_sample_reg = feedback_x2_sample; + /* pick up next sample as feedback_x2_sample: */ + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + feedback_pHaSe_ReG -= 1.0; + susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); + } y = *delayptr_reg; - *delayptr_reg++ = z = (sample_type) - ((fb = - (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG)) * y + *input_ptr_reg++); + *delayptr_reg++ = z = + ((fb = (sample_type) + (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG)) * y + *input_ptr_reg++); *out_ptr_reg++ = (sample_type) (y - fb * z); if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->delayptr = delayptr_reg; - susp->feedback_pHaSe = feedback_pHaSe_ReG; - susp->feedback_x1_sample = feedback_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + togo -= n; + susp->delayptr = delayptr_reg; + susp->feedback_pHaSe = feedback_pHaSe_ReG; + susp->feedback_x1_sample = feedback_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpasscv_ni_fetch */ @@ -311,104 +311,104 @@ void alpasscv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->feedback_pHaSe = 1.0; + susp->started = true; + susp->feedback_pHaSe = 1.0; } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next feedback_x2_sample when phase goes past 1.0; */ - /* we use feedback_n (computed below) to avoid roundoff errors: */ - if (susp->feedback_n <= 0) { - susp->feedback_x1_sample = feedback_x2_sample; - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - susp->feedback_pHaSe -= 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); - /* feedback_n gets number of samples before phase exceeds 1.0: */ - susp->feedback_n = (long) ((1.0 - susp->feedback_pHaSe) * - susp->output_per_feedback); - } - togo = min(togo, susp->feedback_n); - feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); - feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + - feedback_x2_sample * susp->feedback_pHaSe); + /* grab next feedback_x2_sample when phase goes past 1.0; */ + /* we use feedback_n (computed below) to avoid roundoff errors: */ + if (susp->feedback_n <= 0) { + susp->feedback_x1_sample = feedback_x2_sample; + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + susp->feedback_pHaSe -= 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); + /* feedback_n gets number of samples before phase exceeds 1.0: */ + susp->feedback_n = (int64_t) ((1.0 - susp->feedback_pHaSe) * + susp->output_per_feedback); + } + togo = (int) min(togo, susp->feedback_n); + feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); + feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + + feedback_x2_sample * susp->feedback_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, fb; y = *delayptr_reg; - *delayptr_reg++ = z = (sample_type) - ((fb = feedback_val) * y + *input_ptr_reg++); + *delayptr_reg++ = z = + ((fb = (sample_type) feedback_val) * y + *input_ptr_reg++); *out_ptr_reg++ = (sample_type) (y - fb * z); if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - feedback_val += feedback_DeLtA; - } while (--n); /* inner loop */ + feedback_val += feedback_DeLtA; + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; - susp->feedback_n -= togo; - cnt += togo; + susp->delayptr = delayptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; + susp->feedback_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpasscv_nr_fetch */ void alpasscv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ alpasscv_susp_type susp = (alpasscv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* fetch samples from feedback up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr)) >= - susp->feedback->current) - susp_get_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback->current) + susp_get_samples(feedback, feedback_ptr, feedback_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); - n = ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - + n = (int) ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - (susp->feedback->current - susp->feedback_cnt)); susp->feedback_ptr += n; susp_took(feedback_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/alpassvc.alg b/lib-src/libnyquist/nyquist/tran/alpassvc.alg index 358da10be..957815417 100644 --- a/lib-src/libnyquist/nyquist/tran/alpassvc.alg +++ b/lib-src/libnyquist/nyquist/tran/alpassvc.alg @@ -32,7 +32,7 @@ * conver from seconds to samples. Note: don't use actual sound_type * names in comments! The translator isn't smart enough. */ - delaysamp = delaysnd * delay_scale_factor; + delaysamp = (sample_type) delaysnd * delay_scale_factor; delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr + buflen - (delayi + 1); diff --git a/lib-src/libnyquist/nyquist/tran/alpassvc.c b/lib-src/libnyquist/nyquist/tran/alpassvc.c index 63e97fd9b..efee182da 100644 --- a/lib-src/libnyquist/nyquist/tran/alpassvc.c +++ b/lib-src/libnyquist/nyquist/tran/alpassvc.c @@ -15,12 +15,12 @@ void alpassvc_free(snd_susp_type a_susp); typedef struct alpassvc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; sound_type delaysnd; - long delaysnd_cnt; + int delaysnd_cnt; sample_block_values_type delaysnd_ptr; /* support for interpolation of delaysnd */ @@ -30,7 +30,7 @@ typedef struct alpassvc_susp_struct { /* support for ramp between samples of delaysnd */ double output_per_delaysnd; - long delaysnd_n; + int64_t delaysnd_n; float delay_scale_factor; double feedback; @@ -64,36 +64,36 @@ void alpassvc_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the delaysnd input sample block: */ - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - togo = min(togo, susp->delaysnd_cnt); + /* don't run past the delaysnd input sample block: */ + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + togo = min(togo, susp->delaysnd_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - feedback_reg = susp->feedback; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - delaysnd_ptr_reg = susp->delaysnd_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + feedback_reg = susp->feedback; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + delaysnd_ptr_reg = susp->delaysnd_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -102,7 +102,7 @@ void alpassvc_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) * conver from seconds to samples. Note: don't use actual sound_type * names in comments! The translator isn't smart enough. */ - delaysamp = *delaysnd_ptr_reg++ * delay_scale_factor_reg; + delaysamp = (sample_type) *delaysnd_ptr_reg++ * delay_scale_factor_reg; delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -126,26 +126,26 @@ void alpassvc_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) *delayptr_reg++ = *endptr_reg; } *out_ptr_reg++ = (sample_type) (y - feedback_reg * z); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ - susp->delaysnd_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(delaysnd_cnt, togo); - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ + susp->delaysnd_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(delaysnd_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvc_nn_fetch */ @@ -177,60 +177,61 @@ void alpassvc_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - susp->delaysnd_x1_sample = (susp->delaysnd_cnt--, *(susp->delaysnd_ptr)); + susp->started = true; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd_cnt--; + susp->delaysnd_x1_sample = *(susp->delaysnd_ptr); } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - feedback_reg = susp->feedback; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; - delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + feedback_reg = susp->feedback; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; + delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (delaysnd_pHaSe_ReG >= 1.0) { - delaysnd_x1_sample_reg = delaysnd_x2_sample; - /* pick up next sample as delaysnd_x2_sample: */ - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - delaysnd_pHaSe_ReG -= 1.0; - susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); - } + if (delaysnd_pHaSe_ReG >= 1.0) { + delaysnd_x1_sample_reg = delaysnd_x2_sample; + /* pick up next sample as delaysnd_x2_sample: */ + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + delaysnd_pHaSe_ReG -= 1.0; + susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); + } /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, * conver from seconds to samples. Note: don't use actual sound_type * names in comments! The translator isn't smart enough. */ - delaysamp = - (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg; + delaysamp = (sample_type) + (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg; delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -254,27 +255,27 @@ void alpassvc_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) *delayptr_reg++ = *endptr_reg; } *out_ptr_reg++ = (sample_type) (y - feedback_reg * z); - delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; - susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; + susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvc_ni_fetch */ @@ -305,57 +306,57 @@ void alpassvc_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->delaysnd_pHaSe = 1.0; + susp->started = true; + susp->delaysnd_pHaSe = 1.0; } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next delaysnd_x2_sample when phase goes past 1.0; */ - /* we use delaysnd_n (computed below) to avoid roundoff errors: */ - if (susp->delaysnd_n <= 0) { - susp->delaysnd_x1_sample = delaysnd_x2_sample; - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - susp->delaysnd_pHaSe -= 1.0; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - delaysnd_x2_sample = *(susp->delaysnd_ptr); - /* delaysnd_n gets number of samples before phase exceeds 1.0: */ - susp->delaysnd_n = (long) ((1.0 - susp->delaysnd_pHaSe) * - susp->output_per_delaysnd); - } - togo = min(togo, susp->delaysnd_n); - delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); - delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + - delaysnd_x2_sample * susp->delaysnd_pHaSe); + /* grab next delaysnd_x2_sample when phase goes past 1.0; */ + /* we use delaysnd_n (computed below) to avoid roundoff errors: */ + if (susp->delaysnd_n <= 0) { + susp->delaysnd_x1_sample = delaysnd_x2_sample; + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + susp->delaysnd_pHaSe -= 1.0; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + delaysnd_x2_sample = *(susp->delaysnd_ptr); + /* delaysnd_n gets number of samples before phase exceeds 1.0: */ + susp->delaysnd_n = (int64_t) ((1.0 - susp->delaysnd_pHaSe) * + susp->output_per_delaysnd); + } + togo = (int) min(togo, susp->delaysnd_n); + delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); + delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + + delaysnd_x2_sample * susp->delaysnd_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - feedback_reg = susp->feedback; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + feedback_reg = susp->feedback; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -364,7 +365,7 @@ void alpassvc_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) * conver from seconds to samples. Note: don't use actual sound_type * names in comments! The translator isn't smart enough. */ - delaysamp = delaysnd_val * delay_scale_factor_reg; + delaysamp = (sample_type) delaysnd_val * delay_scale_factor_reg; delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -388,51 +389,51 @@ void alpassvc_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) *delayptr_reg++ = *endptr_reg; } *out_ptr_reg++ = (sample_type) (y - feedback_reg * z); - delaysnd_val += delaysnd_DeLtA; - } while (--n); /* inner loop */ + delaysnd_val += delaysnd_DeLtA; + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; - susp->delaysnd_n -= togo; - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; + susp->delaysnd_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvc_nr_fetch */ void alpassvc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ alpassvc_susp_type susp = (alpassvc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* fetch samples from delaysnd up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr)) >= - susp->delaysnd->current) - susp_get_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd->current) + susp_get_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); - n = ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr - + n = (int) ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr - (susp->delaysnd->current - susp->delaysnd_cnt)); susp->delaysnd_ptr += n; susp_took(delaysnd_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/alpassvv.c b/lib-src/libnyquist/nyquist/tran/alpassvv.c index 5347ccf92..bf2537a59 100644 --- a/lib-src/libnyquist/nyquist/tran/alpassvv.c +++ b/lib-src/libnyquist/nyquist/tran/alpassvv.c @@ -15,12 +15,12 @@ void alpassvv_free(snd_susp_type a_susp); typedef struct alpassvv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; sound_type delaysnd; - long delaysnd_cnt; + int delaysnd_cnt; sample_block_values_type delaysnd_ptr; /* support for interpolation of delaysnd */ @@ -30,9 +30,9 @@ typedef struct alpassvv_susp_struct { /* support for ramp between samples of delaysnd */ double output_per_delaysnd; - long delaysnd_n; + int64_t delaysnd_n; sound_type feedback; - long feedback_cnt; + int feedback_cnt; sample_block_values_type feedback_ptr; /* support for interpolation of feedback */ @@ -42,7 +42,7 @@ typedef struct alpassvv_susp_struct { /* support for ramp between samples of feedback */ double output_per_feedback; - long feedback_n; + int64_t feedback_n; float delay_scale_factor; long buflen; @@ -75,40 +75,40 @@ void alpassvv_nnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the delaysnd input sample block: */ - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - togo = min(togo, susp->delaysnd_cnt); + /* don't run past the delaysnd input sample block: */ + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + togo = min(togo, susp->delaysnd_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - delaysnd_ptr_reg = susp->delaysnd_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + delaysnd_ptr_reg = susp->delaysnd_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -144,29 +144,29 @@ void alpassvv_nnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ - susp->delaysnd_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(delaysnd_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ + susp->delaysnd_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(delaysnd_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nnn_fetch */ @@ -195,40 +195,40 @@ void alpassvv_nns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the delaysnd input sample block: */ - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - togo = min(togo, susp->delaysnd_cnt); + /* don't run past the delaysnd input sample block: */ + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + togo = min(togo, susp->delaysnd_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - delaysnd_ptr_reg = susp->delaysnd_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + delaysnd_ptr_reg = susp->delaysnd_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -264,29 +264,29 @@ void alpassvv_nns_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ - susp->delaysnd_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(delaysnd_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ + susp->delaysnd_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(delaysnd_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nns_fetch */ @@ -318,57 +318,57 @@ void alpassvv_nni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); + susp->started = true; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the delaysnd input sample block: */ - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - togo = min(togo, susp->delaysnd_cnt); + /* don't run past the delaysnd input sample block: */ + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + togo = min(togo, susp->delaysnd_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_pHaSe_ReG = susp->feedback_pHaSe; - feedback_x1_sample_reg = susp->feedback_x1_sample; - delaysnd_ptr_reg = susp->delaysnd_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_pHaSe_ReG = susp->feedback_pHaSe; + feedback_x1_sample_reg = susp->feedback_x1_sample; + delaysnd_ptr_reg = susp->delaysnd_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (feedback_pHaSe_ReG >= 1.0) { - feedback_x1_sample_reg = feedback_x2_sample; - /* pick up next sample as feedback_x2_sample: */ - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - feedback_pHaSe_ReG -= 1.0; - susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); - } + if (feedback_pHaSe_ReG >= 1.0) { + feedback_x1_sample_reg = feedback_x2_sample; + /* pick up next sample as feedback_x2_sample: */ + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + feedback_pHaSe_ReG -= 1.0; + susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -376,7 +376,7 @@ void alpassvv_nni_fetch(snd_susp_type a_susp, snd_list_type snd_list) * names in comments! The translator isn't smart enough. */ register sample_type fb = (sample_type) - (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); + (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); delaysamp = (sample_type) (*delaysnd_ptr_reg++ * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ @@ -402,30 +402,30 @@ void alpassvv_nni_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - susp->feedback_pHaSe = feedback_pHaSe_ReG; - susp->feedback_x1_sample = feedback_x1_sample_reg; - /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ - susp->delaysnd_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(delaysnd_cnt, togo); - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + susp->feedback_pHaSe = feedback_pHaSe_ReG; + susp->feedback_x1_sample = feedback_x1_sample_reg; + /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ + susp->delaysnd_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(delaysnd_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nni_fetch */ @@ -456,61 +456,61 @@ void alpassvv_nnr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->feedback_pHaSe = 1.0; + susp->started = true; + susp->feedback_pHaSe = 1.0; } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the delaysnd input sample block: */ - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - togo = min(togo, susp->delaysnd_cnt); + /* don't run past the delaysnd input sample block: */ + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + togo = min(togo, susp->delaysnd_cnt); - /* grab next feedback_x2_sample when phase goes past 1.0; */ - /* we use feedback_n (computed below) to avoid roundoff errors: */ - if (susp->feedback_n <= 0) { - susp->feedback_x1_sample = feedback_x2_sample; - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - susp->feedback_pHaSe -= 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); - /* feedback_n gets number of samples before phase exceeds 1.0: */ - susp->feedback_n = (long) ((1.0 - susp->feedback_pHaSe) * - susp->output_per_feedback); - } - togo = min(togo, susp->feedback_n); - feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); - feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + - feedback_x2_sample * susp->feedback_pHaSe); + /* grab next feedback_x2_sample when phase goes past 1.0; */ + /* we use feedback_n (computed below) to avoid roundoff errors: */ + if (susp->feedback_n <= 0) { + susp->feedback_x1_sample = feedback_x2_sample; + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + susp->feedback_pHaSe -= 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); + /* feedback_n gets number of samples before phase exceeds 1.0: */ + susp->feedback_n = (int64_t) ((1.0 - susp->feedback_pHaSe) * + susp->output_per_feedback); + } + togo = (int) min(togo, susp->feedback_n); + feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); + feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + + feedback_x2_sample * susp->feedback_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - delaysnd_ptr_reg = susp->delaysnd_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + delaysnd_ptr_reg = susp->delaysnd_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -546,29 +546,29 @@ void alpassvv_nnr_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - feedback_val += feedback_DeLtA; - } while (--n); /* inner loop */ + feedback_val += feedback_DeLtA; + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ - susp->delaysnd_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(delaysnd_cnt, togo); - susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; - susp->feedback_n -= togo; - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using delaysnd_ptr_reg is a bad idea on RS/6000: */ + susp->delaysnd_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(delaysnd_cnt, togo); + susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; + susp->feedback_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nnr_fetch */ @@ -600,57 +600,58 @@ void alpassvv_nin_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - susp->delaysnd_x1_sample = (susp->delaysnd_cnt--, *(susp->delaysnd_ptr)); + susp->started = true; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd_cnt--; + susp->delaysnd_x1_sample = *(susp->delaysnd_ptr); } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; - delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; + delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (delaysnd_pHaSe_ReG >= 1.0) { - delaysnd_x1_sample_reg = delaysnd_x2_sample; - /* pick up next sample as delaysnd_x2_sample: */ - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - delaysnd_pHaSe_ReG -= 1.0; - susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); - } + if (delaysnd_pHaSe_ReG >= 1.0) { + delaysnd_x1_sample_reg = delaysnd_x2_sample; + /* pick up next sample as delaysnd_x2_sample: */ + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + delaysnd_pHaSe_ReG -= 1.0; + susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -659,7 +660,7 @@ void alpassvv_nin_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ register sample_type fb = (sample_type) *feedback_ptr_reg++; delaysamp = (sample_type) ( - (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); + (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -684,30 +685,30 @@ void alpassvv_nin_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; - susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; + susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nin_fetch */ @@ -740,57 +741,58 @@ void alpassvv_nis_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - susp->delaysnd_x1_sample = (susp->delaysnd_cnt--, *(susp->delaysnd_ptr)); + susp->started = true; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd_cnt--; + susp->delaysnd_x1_sample = *(susp->delaysnd_ptr); } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; - delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; + delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (delaysnd_pHaSe_ReG >= 1.0) { - delaysnd_x1_sample_reg = delaysnd_x2_sample; - /* pick up next sample as delaysnd_x2_sample: */ - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - delaysnd_pHaSe_ReG -= 1.0; - susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); - } + if (delaysnd_pHaSe_ReG >= 1.0) { + delaysnd_x1_sample_reg = delaysnd_x2_sample; + /* pick up next sample as delaysnd_x2_sample: */ + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + delaysnd_pHaSe_ReG -= 1.0; + susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -799,7 +801,7 @@ void alpassvv_nis_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ register sample_type fb = (sample_type) (feedback_scale_reg * *feedback_ptr_reg++); delaysamp = (sample_type) ( - (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); + (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -824,30 +826,30 @@ void alpassvv_nis_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; - susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; + susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nis_fetch */ @@ -882,11 +884,12 @@ void alpassvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - susp->delaysnd_x1_sample = (susp->delaysnd_cnt--, *(susp->delaysnd_ptr)); - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); + susp->started = true; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd_cnt--; + susp->delaysnd_x1_sample = *(susp->delaysnd_ptr); + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); @@ -896,53 +899,53 @@ void alpassvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_pHaSe_ReG = susp->feedback_pHaSe; - feedback_x1_sample_reg = susp->feedback_x1_sample; - delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; - delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_pHaSe_ReG = susp->feedback_pHaSe; + feedback_x1_sample_reg = susp->feedback_x1_sample; + delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; + delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (delaysnd_pHaSe_ReG >= 1.0) { - delaysnd_x1_sample_reg = delaysnd_x2_sample; - /* pick up next sample as delaysnd_x2_sample: */ - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - delaysnd_pHaSe_ReG -= 1.0; - susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); - } - if (feedback_pHaSe_ReG >= 1.0) { - feedback_x1_sample_reg = feedback_x2_sample; - /* pick up next sample as feedback_x2_sample: */ - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - feedback_pHaSe_ReG -= 1.0; - susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); - } + if (delaysnd_pHaSe_ReG >= 1.0) { + delaysnd_x1_sample_reg = delaysnd_x2_sample; + /* pick up next sample as delaysnd_x2_sample: */ + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + delaysnd_pHaSe_ReG -= 1.0; + susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); + } + if (feedback_pHaSe_ReG >= 1.0) { + feedback_x1_sample_reg = feedback_x2_sample; + /* pick up next sample as feedback_x2_sample: */ + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + feedback_pHaSe_ReG -= 1.0; + susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -950,9 +953,9 @@ void alpassvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) * names in comments! The translator isn't smart enough. */ register sample_type fb = (sample_type) - (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); + (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); delaysamp = (sample_type) ( - (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); + (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -977,30 +980,30 @@ void alpassvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; - feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; + feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - susp->feedback_pHaSe = feedback_pHaSe_ReG; - susp->feedback_x1_sample = feedback_x1_sample_reg; - susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; - susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + susp->feedback_pHaSe = feedback_pHaSe_ReG; + susp->feedback_x1_sample = feedback_x1_sample_reg; + susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; + susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nii_fetch */ @@ -1034,10 +1037,11 @@ void alpassvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - susp->delaysnd_x1_sample = (susp->delaysnd_cnt--, *(susp->delaysnd_ptr)); - susp->feedback_pHaSe = 1.0; + susp->started = true; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd_cnt--; + susp->delaysnd_x1_sample = *(susp->delaysnd_ptr); + susp->feedback_pHaSe = 1.0; } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); @@ -1047,61 +1051,61 @@ void alpassvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next feedback_x2_sample when phase goes past 1.0; */ - /* we use feedback_n (computed below) to avoid roundoff errors: */ - if (susp->feedback_n <= 0) { - susp->feedback_x1_sample = feedback_x2_sample; - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - susp->feedback_pHaSe -= 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); - /* feedback_n gets number of samples before phase exceeds 1.0: */ - susp->feedback_n = (long) ((1.0 - susp->feedback_pHaSe) * - susp->output_per_feedback); - } - togo = min(togo, susp->feedback_n); - feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); - feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + - feedback_x2_sample * susp->feedback_pHaSe); + /* grab next feedback_x2_sample when phase goes past 1.0; */ + /* we use feedback_n (computed below) to avoid roundoff errors: */ + if (susp->feedback_n <= 0) { + susp->feedback_x1_sample = feedback_x2_sample; + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + susp->feedback_pHaSe -= 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); + /* feedback_n gets number of samples before phase exceeds 1.0: */ + susp->feedback_n = (int64_t) ((1.0 - susp->feedback_pHaSe) * + susp->output_per_feedback); + } + togo = (int) min(togo, susp->feedback_n); + feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); + feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + + feedback_x2_sample * susp->feedback_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; - delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + delaysnd_pHaSe_ReG = susp->delaysnd_pHaSe; + delaysnd_x1_sample_reg = susp->delaysnd_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (delaysnd_pHaSe_ReG >= 1.0) { - delaysnd_x1_sample_reg = delaysnd_x2_sample; - /* pick up next sample as delaysnd_x2_sample: */ - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - delaysnd_pHaSe_ReG -= 1.0; - susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); - } + if (delaysnd_pHaSe_ReG >= 1.0) { + delaysnd_x1_sample_reg = delaysnd_x2_sample; + /* pick up next sample as delaysnd_x2_sample: */ + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + delaysnd_pHaSe_ReG -= 1.0; + susp_check_samples_break(delaysnd, delaysnd_ptr, delaysnd_cnt, delaysnd_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -1110,7 +1114,7 @@ void alpassvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ register sample_type fb = (sample_type) feedback_val; delaysamp = (sample_type) ( - (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); + (delaysnd_x1_sample_reg * (1 - delaysnd_pHaSe_ReG) + delaysnd_x2_sample * delaysnd_pHaSe_ReG) * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ yptr = delayptr_reg + buflen_reg - (delayi + 1); @@ -1135,30 +1139,30 @@ void alpassvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; - feedback_val += feedback_DeLtA; - } while (--n); /* inner loop */ + delaysnd_pHaSe_ReG += delaysnd_pHaSe_iNcR_rEg; + feedback_val += feedback_DeLtA; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; - susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; - susp->feedback_n -= togo; - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + susp->delaysnd_pHaSe = delaysnd_pHaSe_ReG; + susp->delaysnd_x1_sample = delaysnd_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; + susp->feedback_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nir_fetch */ @@ -1189,61 +1193,61 @@ void alpassvv_nrn_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->delaysnd_pHaSe = 1.0; + susp->started = true; + susp->delaysnd_pHaSe = 1.0; } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next delaysnd_x2_sample when phase goes past 1.0; */ - /* we use delaysnd_n (computed below) to avoid roundoff errors: */ - if (susp->delaysnd_n <= 0) { - susp->delaysnd_x1_sample = delaysnd_x2_sample; - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - susp->delaysnd_pHaSe -= 1.0; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - delaysnd_x2_sample = *(susp->delaysnd_ptr); - /* delaysnd_n gets number of samples before phase exceeds 1.0: */ - susp->delaysnd_n = (long) ((1.0 - susp->delaysnd_pHaSe) * - susp->output_per_delaysnd); - } - togo = min(togo, susp->delaysnd_n); - delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); - delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + - delaysnd_x2_sample * susp->delaysnd_pHaSe); + /* grab next delaysnd_x2_sample when phase goes past 1.0; */ + /* we use delaysnd_n (computed below) to avoid roundoff errors: */ + if (susp->delaysnd_n <= 0) { + susp->delaysnd_x1_sample = delaysnd_x2_sample; + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + susp->delaysnd_pHaSe -= 1.0; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + delaysnd_x2_sample = *(susp->delaysnd_ptr); + /* delaysnd_n gets number of samples before phase exceeds 1.0: */ + susp->delaysnd_n = (int64_t) ((1.0 - susp->delaysnd_pHaSe) * + susp->output_per_delaysnd); + } + togo = (int) min(togo, susp->delaysnd_n); + delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); + delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + + delaysnd_x2_sample * susp->delaysnd_pHaSe); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -1279,29 +1283,29 @@ void alpassvv_nrn_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_val += delaysnd_DeLtA; - } while (--n); /* inner loop */ + delaysnd_val += delaysnd_DeLtA; + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; - susp->delaysnd_n -= togo; - susp_took(feedback_cnt, togo); - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; + susp->delaysnd_n -= togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nrn_fetch */ @@ -1333,61 +1337,61 @@ void alpassvv_nrs_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->delaysnd_pHaSe = 1.0; + susp->started = true; + susp->delaysnd_pHaSe = 1.0; } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); delaysnd_x2_sample = *(susp->delaysnd_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next delaysnd_x2_sample when phase goes past 1.0; */ - /* we use delaysnd_n (computed below) to avoid roundoff errors: */ - if (susp->delaysnd_n <= 0) { - susp->delaysnd_x1_sample = delaysnd_x2_sample; - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - susp->delaysnd_pHaSe -= 1.0; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - delaysnd_x2_sample = *(susp->delaysnd_ptr); - /* delaysnd_n gets number of samples before phase exceeds 1.0: */ - susp->delaysnd_n = (long) ((1.0 - susp->delaysnd_pHaSe) * - susp->output_per_delaysnd); - } - togo = min(togo, susp->delaysnd_n); - delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); - delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + - delaysnd_x2_sample * susp->delaysnd_pHaSe); + /* grab next delaysnd_x2_sample when phase goes past 1.0; */ + /* we use delaysnd_n (computed below) to avoid roundoff errors: */ + if (susp->delaysnd_n <= 0) { + susp->delaysnd_x1_sample = delaysnd_x2_sample; + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + susp->delaysnd_pHaSe -= 1.0; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + delaysnd_x2_sample = *(susp->delaysnd_ptr); + /* delaysnd_n gets number of samples before phase exceeds 1.0: */ + susp->delaysnd_n = (int64_t) ((1.0 - susp->delaysnd_pHaSe) * + susp->output_per_delaysnd); + } + togo = (int) min(togo, susp->delaysnd_n); + delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); + delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + + delaysnd_x2_sample * susp->delaysnd_pHaSe); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -1423,29 +1427,29 @@ void alpassvv_nrs_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_val += delaysnd_DeLtA; - } while (--n); /* inner loop */ + delaysnd_val += delaysnd_DeLtA; + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; - susp->delaysnd_n -= togo; - susp_took(feedback_cnt, togo); - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; + susp->delaysnd_n -= togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nrs_fetch */ @@ -1479,10 +1483,10 @@ void alpassvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->delaysnd_pHaSe = 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); + susp->started = true; + susp->delaysnd_pHaSe = 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); @@ -1492,61 +1496,61 @@ void alpassvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next delaysnd_x2_sample when phase goes past 1.0; */ - /* we use delaysnd_n (computed below) to avoid roundoff errors: */ - if (susp->delaysnd_n <= 0) { - susp->delaysnd_x1_sample = delaysnd_x2_sample; - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - susp->delaysnd_pHaSe -= 1.0; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - delaysnd_x2_sample = *(susp->delaysnd_ptr); - /* delaysnd_n gets number of samples before phase exceeds 1.0: */ - susp->delaysnd_n = (long) ((1.0 - susp->delaysnd_pHaSe) * - susp->output_per_delaysnd); - } - togo = min(togo, susp->delaysnd_n); - delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); - delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + - delaysnd_x2_sample * susp->delaysnd_pHaSe); + /* grab next delaysnd_x2_sample when phase goes past 1.0; */ + /* we use delaysnd_n (computed below) to avoid roundoff errors: */ + if (susp->delaysnd_n <= 0) { + susp->delaysnd_x1_sample = delaysnd_x2_sample; + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + susp->delaysnd_pHaSe -= 1.0; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + delaysnd_x2_sample = *(susp->delaysnd_ptr); + /* delaysnd_n gets number of samples before phase exceeds 1.0: */ + susp->delaysnd_n = (int64_t) ((1.0 - susp->delaysnd_pHaSe) * + susp->output_per_delaysnd); + } + togo = (int) min(togo, susp->delaysnd_n); + delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); + delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + + delaysnd_x2_sample * susp->delaysnd_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_pHaSe_ReG = susp->feedback_pHaSe; - feedback_x1_sample_reg = susp->feedback_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_pHaSe_ReG = susp->feedback_pHaSe; + feedback_x1_sample_reg = susp->feedback_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; - if (feedback_pHaSe_ReG >= 1.0) { - feedback_x1_sample_reg = feedback_x2_sample; - /* pick up next sample as feedback_x2_sample: */ - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - feedback_pHaSe_ReG -= 1.0; - susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); - } + if (feedback_pHaSe_ReG >= 1.0) { + feedback_x1_sample_reg = feedback_x2_sample; + /* pick up next sample as feedback_x2_sample: */ + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + feedback_pHaSe_ReG -= 1.0; + susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); + } { /* compute where to read y, we want y to be delay_snd samples * after delay_ptr, where we write the new sample. First, @@ -1554,7 +1558,7 @@ void alpassvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) * names in comments! The translator isn't smart enough. */ register sample_type fb = (sample_type) - (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); + (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG); delaysamp = (sample_type) (delaysnd_val * delay_scale_factor_reg); delayi = (int) delaysamp; /* get integer part */ delaysamp = delaysamp - delayi; /* get phase */ @@ -1580,30 +1584,30 @@ void alpassvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_val += delaysnd_DeLtA; - feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + delaysnd_val += delaysnd_DeLtA; + feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - susp->feedback_pHaSe = feedback_pHaSe_ReG; - susp->feedback_x1_sample = feedback_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; - susp->delaysnd_n -= togo; - cnt += togo; + togo -= n; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + susp->feedback_pHaSe = feedback_pHaSe_ReG; + susp->feedback_x1_sample = feedback_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; + susp->delaysnd_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nri_fetch */ @@ -1636,9 +1640,9 @@ void alpassvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->delaysnd_pHaSe = 1.0; - susp->feedback_pHaSe = 1.0; + susp->started = true; + susp->delaysnd_pHaSe = 1.0; + susp->feedback_pHaSe = 1.0; } susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); @@ -1648,66 +1652,66 @@ void alpassvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next delaysnd_x2_sample when phase goes past 1.0; */ - /* we use delaysnd_n (computed below) to avoid roundoff errors: */ - if (susp->delaysnd_n <= 0) { - susp->delaysnd_x1_sample = delaysnd_x2_sample; - susp->delaysnd_ptr++; - susp_took(delaysnd_cnt, 1); - susp->delaysnd_pHaSe -= 1.0; - susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); - delaysnd_x2_sample = *(susp->delaysnd_ptr); - /* delaysnd_n gets number of samples before phase exceeds 1.0: */ - susp->delaysnd_n = (long) ((1.0 - susp->delaysnd_pHaSe) * - susp->output_per_delaysnd); - } - togo = min(togo, susp->delaysnd_n); - delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); - delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + - delaysnd_x2_sample * susp->delaysnd_pHaSe); + /* grab next delaysnd_x2_sample when phase goes past 1.0; */ + /* we use delaysnd_n (computed below) to avoid roundoff errors: */ + if (susp->delaysnd_n <= 0) { + susp->delaysnd_x1_sample = delaysnd_x2_sample; + susp->delaysnd_ptr++; + susp_took(delaysnd_cnt, 1); + susp->delaysnd_pHaSe -= 1.0; + susp_check_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + delaysnd_x2_sample = *(susp->delaysnd_ptr); + /* delaysnd_n gets number of samples before phase exceeds 1.0: */ + susp->delaysnd_n = (int64_t) ((1.0 - susp->delaysnd_pHaSe) * + susp->output_per_delaysnd); + } + togo = (int) min(togo, susp->delaysnd_n); + delaysnd_DeLtA = (sample_type) ((delaysnd_x2_sample - susp->delaysnd_x1_sample) * susp->delaysnd_pHaSe_iNcR); + delaysnd_val = (sample_type) (susp->delaysnd_x1_sample * (1.0 - susp->delaysnd_pHaSe) + + delaysnd_x2_sample * susp->delaysnd_pHaSe); - /* grab next feedback_x2_sample when phase goes past 1.0; */ - /* we use feedback_n (computed below) to avoid roundoff errors: */ - if (susp->feedback_n <= 0) { - susp->feedback_x1_sample = feedback_x2_sample; - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - susp->feedback_pHaSe -= 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); - /* feedback_n gets number of samples before phase exceeds 1.0: */ - susp->feedback_n = (long) ((1.0 - susp->feedback_pHaSe) * - susp->output_per_feedback); - } - togo = min(togo, susp->feedback_n); - feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); - feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + - feedback_x2_sample * susp->feedback_pHaSe); + /* grab next feedback_x2_sample when phase goes past 1.0; */ + /* we use feedback_n (computed below) to avoid roundoff errors: */ + if (susp->feedback_n <= 0) { + susp->feedback_x1_sample = feedback_x2_sample; + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + susp->feedback_pHaSe -= 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); + /* feedback_n gets number of samples before phase exceeds 1.0: */ + susp->feedback_n = (int64_t) ((1.0 - susp->feedback_pHaSe) * + susp->output_per_feedback); + } + togo = (int) min(togo, susp->feedback_n); + feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); + feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + + feedback_x2_sample * susp->feedback_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delay_scale_factor_reg = susp->delay_scale_factor; - buflen_reg = susp->buflen; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delay_scale_factor_reg = susp->delay_scale_factor; + buflen_reg = susp->buflen; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register sample_type y, z, delaysamp; register int delayi; register sample_type *yptr; @@ -1743,62 +1747,62 @@ void alpassvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) (y - fb * z); }; - delaysnd_val += delaysnd_DeLtA; - feedback_val += feedback_DeLtA; - } while (--n); /* inner loop */ + delaysnd_val += delaysnd_DeLtA; + feedback_val += feedback_DeLtA; + } while (--n); /* inner loop */ - susp->buflen = buflen_reg; - susp->delayptr = delayptr_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; - susp->delaysnd_n -= togo; - susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; - susp->feedback_n -= togo; - cnt += togo; + susp->buflen = buflen_reg; + susp->delayptr = delayptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->delaysnd_pHaSe += togo * susp->delaysnd_pHaSe_iNcR; + susp->delaysnd_n -= togo; + susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; + susp->feedback_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* alpassvv_nrr_fetch */ void alpassvv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ alpassvv_susp_type susp = (alpassvv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* fetch samples from delaysnd up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr)) >= - susp->delaysnd->current) - susp_get_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); + susp->delaysnd->current) + susp_get_samples(delaysnd, delaysnd_ptr, delaysnd_cnt); /* fetch samples from feedback up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr)) >= - susp->feedback->current) - susp_get_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback->current) + susp_get_samples(feedback, feedback_ptr, feedback_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); - n = ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr - + n = (int) ROUNDBIG((final_time - susp->delaysnd->t0) * susp->delaysnd->sr - (susp->delaysnd->current - susp->delaysnd_cnt)); susp->delaysnd_ptr += n; susp_took(delaysnd_cnt, n); - n = ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - + n = (int) ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - (susp->feedback->current - susp->feedback_cnt)); susp->feedback_ptr += n; susp_took(feedback_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/amosc.c b/lib-src/libnyquist/nyquist/tran/amosc.c index 7a6054a88..06cda336f 100644 --- a/lib-src/libnyquist/nyquist/tran/amosc.c +++ b/lib-src/libnyquist/nyquist/tran/amosc.c @@ -15,10 +15,10 @@ void amosc_free(snd_susp_type a_susp); typedef struct amosc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type amod; - long amod_cnt; + int amod_cnt; sample_block_values_type amod_ptr; /* support for interpolation of amod */ @@ -28,7 +28,7 @@ typedef struct amosc_susp_struct { /* support for ramp between samples of amod */ double output_per_amod; - long amod_n; + int64_t amod_n; double ph_incr; table_type the_table; @@ -60,56 +60,56 @@ void amosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the amod input sample block: */ - susp_check_term_log_samples(amod, amod_ptr, amod_cnt); - togo = min(togo, susp->amod_cnt); + /* don't run past the amod input sample block: */ + susp_check_term_log_samples(amod, amod_ptr, amod_cnt); + togo = min(togo, susp->amod_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - amod_ptr_reg = susp->amod_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + amod_ptr_reg = susp->amod_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { long table_index = (long) phase_reg; double x1 = (double) (table_ptr_reg[table_index]); @@ -118,28 +118,28 @@ void amosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase_reg += ph_incr_reg; while (phase_reg > table_len_reg) phase_reg -= table_len_reg; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - /* using amod_ptr_reg is a bad idea on RS/6000: */ - susp->amod_ptr += togo; - out_ptr += togo; - susp_took(amod_cnt, togo); - cnt += togo; + susp->phase = phase_reg; + /* using amod_ptr_reg is a bad idea on RS/6000: */ + susp->amod_ptr += togo; + out_ptr += togo; + susp_took(amod_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* amosc_s_fetch */ @@ -169,102 +169,102 @@ void amosc_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(amod, amod_ptr, amod_cnt); - susp->amod_x1_sample = susp_fetch_sample(amod, amod_ptr, amod_cnt); + susp->started = true; + susp_check_term_log_samples(amod, amod_ptr, amod_cnt); + susp->amod_x1_sample = susp_fetch_sample(amod, amod_ptr, amod_cnt); } susp_check_term_log_samples(amod, amod_ptr, amod_cnt); amod_x2_sample = susp_current_sample(amod, amod_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - amod_pHaSe_ReG = susp->amod_pHaSe; - amod_x1_sample_reg = susp->amod_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (amod_pHaSe_ReG >= 1.0) { - amod_x1_sample_reg = amod_x2_sample; - /* pick up next sample as amod_x2_sample: */ - susp->amod_ptr++; - susp_took(amod_cnt, 1); - amod_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(amod, amod_ptr, amod_cnt, amod_x2_sample); - } + n = togo; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + amod_pHaSe_ReG = susp->amod_pHaSe; + amod_x1_sample_reg = susp->amod_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (amod_pHaSe_ReG >= 1.0) { + amod_x1_sample_reg = amod_x2_sample; + /* pick up next sample as amod_x2_sample: */ + susp->amod_ptr++; + susp_took(amod_cnt, 1); + amod_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(amod, amod_ptr, amod_cnt, amod_x2_sample); + } { long table_index = (long) phase_reg; double x1 = (double) (table_ptr_reg[table_index]); *out_ptr_reg++ = (sample_type) ((x1 + (phase_reg - table_index) * (table_ptr_reg[table_index + 1] - x1)) * - (amod_x1_sample_reg * (1 - amod_pHaSe_ReG) + amod_x2_sample * amod_pHaSe_ReG)); + (amod_x1_sample_reg * (1 - amod_pHaSe_ReG) + amod_x2_sample * amod_pHaSe_ReG)); phase_reg += ph_incr_reg; while (phase_reg > table_len_reg) phase_reg -= table_len_reg; }; - amod_pHaSe_ReG += amod_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + amod_pHaSe_ReG += amod_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = phase_reg; - susp->amod_pHaSe = amod_pHaSe_ReG; - susp->amod_x1_sample = amod_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = phase_reg; + susp->amod_pHaSe = amod_pHaSe_ReG; + susp->amod_x1_sample = amod_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* amosc_i_fetch */ @@ -293,77 +293,77 @@ void amosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->amod_pHaSe = 1.0; + susp->started = true; + susp->amod_pHaSe = 1.0; } susp_check_term_log_samples(amod, amod_ptr, amod_cnt); amod_x2_sample = susp_current_sample(amod, amod_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next amod_x2_sample when phase goes past 1.0; */ - /* we use amod_n (computed below) to avoid roundoff errors: */ - if (susp->amod_n <= 0) { - susp->amod_x1_sample = amod_x2_sample; - susp->amod_ptr++; - susp_took(amod_cnt, 1); - susp->amod_pHaSe -= 1.0; - susp_check_term_log_samples(amod, amod_ptr, amod_cnt); - amod_x2_sample = susp_current_sample(amod, amod_ptr); - /* amod_n gets number of samples before phase exceeds 1.0: */ - susp->amod_n = (long) ((1.0 - susp->amod_pHaSe) * - susp->output_per_amod); - } - togo = min(togo, susp->amod_n); - amod_DeLtA = (sample_type) ((amod_x2_sample - susp->amod_x1_sample) * susp->amod_pHaSe_iNcR); - amod_val = (sample_type) (susp->amod_x1_sample * (1.0 - susp->amod_pHaSe) + - amod_x2_sample * susp->amod_pHaSe); + /* grab next amod_x2_sample when phase goes past 1.0; */ + /* we use amod_n (computed below) to avoid roundoff errors: */ + if (susp->amod_n <= 0) { + susp->amod_x1_sample = amod_x2_sample; + susp->amod_ptr++; + susp_took(amod_cnt, 1); + susp->amod_pHaSe -= 1.0; + susp_check_term_log_samples(amod, amod_ptr, amod_cnt); + amod_x2_sample = susp_current_sample(amod, amod_ptr); + /* amod_n gets number of samples before phase exceeds 1.0: */ + susp->amod_n = (int64_t) ((1.0 - susp->amod_pHaSe) * + susp->output_per_amod); + } + togo = (int) min(togo, susp->amod_n); + amod_DeLtA = (sample_type) ((amod_x2_sample - susp->amod_x1_sample) * susp->amod_pHaSe_iNcR); + amod_val = (sample_type) (susp->amod_x1_sample * (1.0 - susp->amod_pHaSe) + + amod_x2_sample * susp->amod_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { long table_index = (long) phase_reg; double x1 = (double) (table_ptr_reg[table_index]); @@ -372,45 +372,45 @@ void amosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase_reg += ph_incr_reg; while (phase_reg > table_len_reg) phase_reg -= table_len_reg; }; - amod_val += amod_DeLtA; - } while (--n); /* inner loop */ + amod_val += amod_DeLtA; + } while (--n); /* inner loop */ - susp->phase = phase_reg; - out_ptr += togo; - susp->amod_pHaSe += togo * susp->amod_pHaSe_iNcR; - susp->amod_n -= togo; - cnt += togo; + susp->phase = phase_reg; + out_ptr += togo; + susp->amod_pHaSe += togo * susp->amod_pHaSe_iNcR; + susp->amod_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* amosc_r_fetch */ void amosc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ amosc_susp_type susp = (amosc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from amod up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->amod->t0) * susp->amod->sr)) >= - susp->amod->current) - susp_get_samples(amod, amod_ptr, amod_cnt); + susp->amod->current) + susp_get_samples(amod, amod_ptr, amod_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->amod->t0) * susp->amod->sr - + n = (int) ROUNDBIG((final_time - susp->amod->t0) * susp->amod->sr - (susp->amod->current - susp->amod_cnt)); susp->amod_ptr += n; susp_took(amod_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/areson.c b/lib-src/libnyquist/nyquist/tran/areson.c index ae87a3d07..6356f3b5b 100644 --- a/lib-src/libnyquist/nyquist/tran/areson.c +++ b/lib-src/libnyquist/nyquist/tran/areson.c @@ -14,10 +14,10 @@ void areson_free(snd_susp_type a_susp); typedef struct areson_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double c3; @@ -50,100 +50,100 @@ void areson_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3_reg = susp->c3; - c2_reg = susp->c2; - c1_reg = susp->c1; - y1_reg = susp->y1; - y2_reg = susp->y2; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3_reg = susp->c3; + c2_reg = susp->c2; + c1_reg = susp->c1; + y1_reg = susp->y1; + y2_reg = susp->y2; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; current = *input_ptr_reg++; *out_ptr_reg++ = (sample_type) (y0 = c1_reg * current + c2_reg * y1_reg - c3_reg * y2_reg); y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* areson_n_fetch */ void areson_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ areson_susp_type susp = (areson_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/areson.h b/lib-src/libnyquist/nyquist/tran/areson.h index fa7c94f63..882b20a2a 100644 --- a/lib-src/libnyquist/nyquist/tran/areson.h +++ b/lib-src/libnyquist/nyquist/tran/areson.h @@ -1,3 +1,3 @@ sound_type snd_make_areson(sound_type input, double hz, double bw, int normalization); sound_type snd_areson(sound_type input, double hz, double bw, int normalization); - /* LISP: (snd-areson SOUND ANYNUM ANYNUM FIXNUM) */ + /* LISP: (snd-areson SOUND ANYNUM ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/aresoncv.c b/lib-src/libnyquist/nyquist/tran/aresoncv.c index 041796733..cbc254b62 100644 --- a/lib-src/libnyquist/nyquist/tran/aresoncv.c +++ b/lib-src/libnyquist/nyquist/tran/aresoncv.c @@ -15,13 +15,13 @@ void aresoncv_free(snd_susp_type a_susp); typedef struct aresoncv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type bw; - long bw_cnt; + int bw_cnt; sample_block_values_type bw_ptr; /* support for interpolation of bw */ @@ -31,7 +31,7 @@ typedef struct aresoncv_susp_struct { /* support for ramp between samples of bw */ double output_per_bw; - long bw_n; + int64_t bw_n; double c3co; double coshz; @@ -69,105 +69,105 @@ void aresoncv_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - double c3p1; - double c3t4; - double omc3; - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1 = c3co_reg + 1.0; - c3t4 = c3co_reg * 4.0; - omc3 = 1.0 - c3co_reg; - c2_reg = c3t4 * coshz_reg / c3p1; - c1_reg = (normalization_reg == 0 ? 0.0 : + double c3p1; + double c3t4; + double omc3; + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1 = c3co_reg + 1.0; + c3t4 = c3co_reg * 4.0; + omc3 = 1.0 - c3co_reg; + c2_reg = c3t4 * coshz_reg / c3p1; + c1_reg = (normalization_reg == 0 ? 0.0 : (normalization_reg == 1 ? 1.0 - omc3 * sqrt(1.0 - c2_reg * c2_reg / c3t4) : 1.0 - sqrt(c3p1 * c3p1 - c2_reg * c2_reg) * omc3 / c3p1)); current = *s1_ptr_reg++; *out_ptr_reg++ = (float) (y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg); y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresoncv_ns_fetch */ @@ -200,129 +200,129 @@ void aresoncv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - double c3p1; - double c3t4; - double omc3; - susp->started = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - c3p1 = susp->c3co + 1.0; - c3t4 = susp->c3co * 4.0; - omc3 = 1.0 - susp->c3co; - susp->c2 = c3t4 * susp->coshz / c3p1; - susp->c1 = (susp->normalization == 0 ? 0.0 : + double c3p1; + double c3t4; + double omc3; + susp->started = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + c3p1 = susp->c3co + 1.0; + c3t4 = susp->c3co * 4.0; + omc3 = 1.0 - susp->c3co; + susp->c2 = c3t4 * susp->coshz / c3p1; + susp->c1 = (susp->normalization == 0 ? 0.0 : (susp->normalization == 1 ? 1.0 - omc3 * sqrt(1.0 - susp->c2 * susp->c2 / c3t4) : 1.0 - sqrt(c3p1 * c3p1 - susp->c2 * susp->c2) * omc3 / c3p1)); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (bw_pHaSe_ReG >= 1.0) { + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - double c3p1; - double c3t4; - double omc3; - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1 = c3co_reg + 1.0; - c3t4 = c3co_reg * 4.0; - omc3 = 1.0 - c3co_reg; - c2_reg = c3t4 * coshz_reg / c3p1; - c1_reg = (normalization_reg == 0 ? 0.0 : + double c3p1; + double c3t4; + double omc3; + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1 = c3co_reg + 1.0; + c3t4 = c3co_reg * 4.0; + omc3 = 1.0 - c3co_reg; + c2_reg = c3t4 * coshz_reg / c3p1; + c1_reg = (normalization_reg == 0 ? 0.0 : (normalization_reg == 1 ? 1.0 - omc3 * sqrt(1.0 - c2_reg * c2_reg / c3t4) : 1.0 - sqrt(c3p1 * c3p1 - c2_reg * c2_reg) * omc3 / c3p1)); - } + } current = *s1_ptr_reg++; *out_ptr_reg++ = (float) (y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg); y2_reg = y1_reg; y1_reg = y0 - current; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresoncv_ni_fetch */ @@ -353,143 +353,143 @@ void aresoncv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - double c3p1; - double c3t4; - double omc3; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - c3p1 = susp->c3co + 1.0; - c3t4 = susp->c3co * 4.0; - omc3 = 1.0 - susp->c3co; - susp->c2 = c3t4 * susp->coshz / c3p1; - susp->c1 = (susp->normalization == 0 ? 0.0 : + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + double c3p1; + double c3t4; + double omc3; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + c3p1 = susp->c3co + 1.0; + c3t4 = susp->c3co * 4.0; + omc3 = 1.0 - susp->c3co; + susp->c2 = c3t4 * susp->coshz / c3p1; + susp->c1 = (susp->normalization == 0 ? 0.0 : (susp->normalization == 1 ? 1.0 - omc3 * sqrt(1.0 - susp->c2 * susp->c2 / c3t4) : 1.0 - sqrt(c3p1 * c3p1 - susp->c2 * susp->c2) * omc3 / c3p1)); - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; current = *s1_ptr_reg++; *out_ptr_reg++ = (float) (y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg); y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresoncv_nr_fetch */ void aresoncv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ aresoncv_susp_type susp = (aresoncv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from bw up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr)) >= - susp->bw->current) - susp_get_samples(bw, bw_ptr, bw_cnt); + susp->bw->current) + susp_get_samples(bw, bw_ptr, bw_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - + n = (int) ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - (susp->bw->current - susp->bw_cnt)); susp->bw_ptr += n; susp_took(bw_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/aresoncv.h b/lib-src/libnyquist/nyquist/tran/aresoncv.h index 6cf9a0ae5..bb2499b10 100644 --- a/lib-src/libnyquist/nyquist/tran/aresoncv.h +++ b/lib-src/libnyquist/nyquist/tran/aresoncv.h @@ -1,3 +1,3 @@ sound_type snd_make_aresoncv(sound_type s1, double hz, sound_type bw, int normalization); sound_type snd_aresoncv(sound_type s1, double hz, sound_type bw, int normalization); - /* LISP: (snd-aresoncv SOUND ANYNUM SOUND FIXNUM) */ + /* LISP: (snd-aresoncv SOUND ANYNUM SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/aresonvc.c b/lib-src/libnyquist/nyquist/tran/aresonvc.c index 7f279c997..767f81d5c 100644 --- a/lib-src/libnyquist/nyquist/tran/aresonvc.c +++ b/lib-src/libnyquist/nyquist/tran/aresonvc.c @@ -15,13 +15,13 @@ void aresonvc_free(snd_susp_type a_susp); typedef struct aresonvc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz; - long hz_cnt; + int hz_cnt; sample_block_values_type hz_ptr; /* support for interpolation of hz */ @@ -31,7 +31,7 @@ typedef struct aresonvc_susp_struct { /* support for ramp between samples of hz */ double output_per_hz; - long hz_n; + int64_t hz_n; double c3co; double c3p1; @@ -73,100 +73,100 @@ void aresonvc_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz input sample block: */ - susp_check_term_samples(hz, hz_ptr, hz_cnt); - togo = min(togo, susp->hz_cnt); + /* don't run past the hz input sample block: */ + susp_check_term_samples(hz, hz_ptr, hz_cnt); + togo = min(togo, susp->hz_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz_ptr_reg = susp->hz_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - register double y0, current; c2_reg = c3t4_reg * cos((hz_scale_reg * *hz_ptr_reg++)) / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz_ptr_reg = susp->hz_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + register double y0, current; c2_reg = c3t4_reg * cos((hz_scale_reg * *hz_ptr_reg++)) / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : (normalization_reg == 1 ? 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)); current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using hz_ptr_reg is a bad idea on RS/6000: */ - susp->hz_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using hz_ptr_reg is a bad idea on RS/6000: */ + susp->hz_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvc_ns_fetch */ @@ -201,117 +201,117 @@ void aresonvc_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? 0.0 : + susp->started = true; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? 0.0 : (susp->normalization == 1 ? 1.0 - susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : 1.0 - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz_pHaSe_ReG = susp->hz_pHaSe; - hz_x1_sample_reg = susp->hz_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - register double y0, current; if (hz_pHaSe_ReG >= 1.0) { + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz_pHaSe_ReG = susp->hz_pHaSe; + hz_x1_sample_reg = susp->hz_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + register double y0, current; if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ - /* pick up next sample as hz_x1_sample: */ - susp->hz_ptr++; - susp_took(hz_cnt, 1); - hz_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); - hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); - c2_reg = c3t4_reg * cos(hz_x1_sample_reg) / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : + /* pick up next sample as hz_x1_sample: */ + susp->hz_ptr++; + susp_took(hz_cnt, 1); + hz_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); + hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); + c2_reg = c3t4_reg * cos(hz_x1_sample_reg) / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : (normalization_reg == 1 ? 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)); - } + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->hz_pHaSe = hz_pHaSe_ReG; - susp->hz_x1_sample = hz_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->hz_pHaSe = hz_pHaSe_ReG; + susp->hz_x1_sample = hz_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvc_ni_fetch */ @@ -344,138 +344,138 @@ void aresonvc_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz_pHaSe = 1.0; + susp->started = true; + susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz_x1_sample when phase goes past 1.0; */ - /* use hz_n (computed below) to avoid roundoff errors: */ - if (susp->hz_n <= 0) { - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->hz_pHaSe -= 1.0; - /* hz_n gets number of samples before phase exceeds 1.0: */ - susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * - susp->output_per_hz); - susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? 0.0 : + /* grab next hz_x1_sample when phase goes past 1.0; */ + /* use hz_n (computed below) to avoid roundoff errors: */ + if (susp->hz_n <= 0) { + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->hz_pHaSe -= 1.0; + /* hz_n gets number of samples before phase exceeds 1.0: */ + susp->hz_n = (int64_t) ((1.0 - susp->hz_pHaSe) * + susp->output_per_hz); + susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? 0.0 : (susp->normalization == 1 ? 1.0 - susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : 1.0 - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)); - } - togo = min(togo, susp->hz_n); - hz_val = susp->hz_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + } + togo = (int) min(togo, susp->hz_n); + hz_val = susp->hz_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; - susp->hz_n -= togo; - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; + susp->hz_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvc_nr_fetch */ void aresonvc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ aresonvc_susp_type susp = (aresonvc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr)) >= - susp->hz->current) - susp_get_samples(hz, hz_ptr, hz_cnt); + susp->hz->current) + susp_get_samples(hz, hz_ptr, hz_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - + n = (int) ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - (susp->hz->current - susp->hz_cnt)); susp->hz_ptr += n; susp_took(hz_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/aresonvc.h b/lib-src/libnyquist/nyquist/tran/aresonvc.h index 0783f667c..a4e31f47f 100644 --- a/lib-src/libnyquist/nyquist/tran/aresonvc.h +++ b/lib-src/libnyquist/nyquist/tran/aresonvc.h @@ -1,3 +1,3 @@ sound_type snd_make_aresonvc(sound_type s1, sound_type hz, double bw, int normalization); sound_type snd_aresonvc(sound_type s1, sound_type hz, double bw, int normalization); - /* LISP: (snd-aresonvc SOUND SOUND ANYNUM FIXNUM) */ + /* LISP: (snd-aresonvc SOUND SOUND ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/aresonvv.c b/lib-src/libnyquist/nyquist/tran/aresonvv.c index aeec995c2..8817dc5f1 100644 --- a/lib-src/libnyquist/nyquist/tran/aresonvv.c +++ b/lib-src/libnyquist/nyquist/tran/aresonvv.c @@ -15,13 +15,13 @@ void aresonvv_free(snd_susp_type a_susp); typedef struct aresonvv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz1; - long hz1_cnt; + int hz1_cnt; sample_block_values_type hz1_ptr; /* support for interpolation of hz1 */ @@ -31,9 +31,9 @@ typedef struct aresonvv_susp_struct { /* support for ramp between samples of hz1 */ double output_per_hz1; - long hz1_n; + int64_t hz1_n; sound_type bw; - long bw_cnt; + int bw_cnt; sample_block_values_type bw_ptr; /* support for interpolation of bw */ @@ -43,7 +43,7 @@ typedef struct aresonvv_susp_struct { /* support for ramp between samples of bw */ double output_per_bw; - long bw_n; + int64_t bw_n; double scale1; double c3co; @@ -92,124 +92,124 @@ void aresonvv_nss_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nss_fetch */ @@ -248,142 +248,142 @@ void aresonvv_nsi_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (bw_pHaSe_ReG >= 1.0) { + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nsi_fetch */ @@ -420,137 +420,137 @@ void aresonvv_nsr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nsr_fetch */ @@ -589,139 +589,139 @@ void aresonvv_nis_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (hz1_pHaSe_ReG >= 1.0) { + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nis_fetch */ @@ -761,152 +761,152 @@ void aresonvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (hz1_pHaSe_ReG >= 1.0) { + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - if (bw_pHaSe_ReG >= 1.0) { + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nii_fetch */ @@ -944,148 +944,148 @@ void aresonvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (hz1_pHaSe_ReG >= 1.0) { + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nir_fetch */ @@ -1122,137 +1122,137 @@ void aresonvv_nrs_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; + susp->started = true; + susp->hz1_pHaSe = 1.0; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - susp_took(bw_cnt, togo); - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nrs_fetch */ @@ -1290,151 +1290,151 @@ void aresonvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp->hz1_pHaSe = 1.0; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; - if (bw_pHaSe_ReG >= 1.0) { + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 0.0 : - (normalization_reg == 1 ? - 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * - omc3_reg / c3p1_reg)); - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 0.0 : + (normalization_reg == 1 ? + 1.0 - omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + 1.0 - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * + omc3_reg / c3p1_reg)); + } current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nri_fetch */ @@ -1465,9 +1465,9 @@ void aresonvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->hz1_pHaSe = 1.0; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); @@ -1475,164 +1475,164 @@ void aresonvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - if (susp->recompute) { - susp->recompute = false; - susp->c2 = susp->c3t4 * susp->coshz / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? 0.0 : - (susp->normalization == 1 ? - 1.0 - susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : - 1.0 - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * - susp->omc3 / susp->c3p1)); - } - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + if (susp->recompute) { + susp->recompute = false; + susp->c2 = susp->c3t4 * susp->coshz / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? 0.0 : + (susp->normalization == 1 ? + 1.0 - susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : + 1.0 - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * + susp->omc3 / susp->c3p1)); + } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double y0, current; current = *s1_ptr_reg++; y0 = c1_reg * current + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0 - current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* aresonvv_nrr_fetch */ void aresonvv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ aresonvv_susp_type susp = (aresonvv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr)) >= - susp->hz1->current) - susp_get_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1->current) + susp_get_samples(hz1, hz1_ptr, hz1_cnt); /* fetch samples from bw up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr)) >= - susp->bw->current) - susp_get_samples(bw, bw_ptr, bw_cnt); + susp->bw->current) + susp_get_samples(bw, bw_ptr, bw_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr - + n = (int) ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr - (susp->hz1->current - susp->hz1_cnt)); susp->hz1_ptr += n; susp_took(hz1_cnt, n); - n = ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - + n = (int) ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - (susp->bw->current - susp->bw_cnt)); susp->bw_ptr += n; susp_took(bw_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/aresonvv.h b/lib-src/libnyquist/nyquist/tran/aresonvv.h index 1aba1b670..59f53c2f4 100644 --- a/lib-src/libnyquist/nyquist/tran/aresonvv.h +++ b/lib-src/libnyquist/nyquist/tran/aresonvv.h @@ -1,3 +1,3 @@ sound_type snd_make_aresonvv(sound_type s1, sound_type hz1, sound_type bw, int normalization); sound_type snd_aresonvv(sound_type s1, sound_type hz1, sound_type bw, int normalization); - /* LISP: (snd-aresonvv SOUND SOUND SOUND FIXNUM) */ + /* LISP: (snd-aresonvv SOUND SOUND SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/atone.c b/lib-src/libnyquist/nyquist/tran/atone.c index 6b9082fd3..672703507 100644 --- a/lib-src/libnyquist/nyquist/tran/atone.c +++ b/lib-src/libnyquist/nyquist/tran/atone.c @@ -14,10 +14,10 @@ void atone_free(snd_susp_type a_susp); typedef struct atone_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; double cc; @@ -44,54 +44,54 @@ void atone_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cc_reg = susp->cc; - prev_reg = susp->prev; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cc_reg = susp->cc; + prev_reg = susp->prev; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double current; current = *s_ptr_reg++; /* use prev_reg as temp variable ... */ @@ -99,28 +99,28 @@ void atone_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* ... so we can do proper type conversion */ *out_ptr_reg++ = (float) prev_reg; prev_reg -= current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* atone_n_fetch */ @@ -145,54 +145,54 @@ void atone_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cc_reg = susp->cc; - prev_reg = susp->prev; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cc_reg = susp->cc; + prev_reg = susp->prev; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double current; current = (s_scale_reg * *s_ptr_reg++); /* use prev_reg as temp variable ... */ @@ -200,45 +200,45 @@ void atone_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* ... so we can do proper type conversion */ *out_ptr_reg++ = (float) prev_reg; prev_reg -= current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* atone_s_fetch */ void atone_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ atone_susp_type susp = (atone_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + susp->s->current) + susp_get_samples(s, s_ptr, s_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + n = (int) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/atonev.c b/lib-src/libnyquist/nyquist/tran/atonev.c index 355941d3a..246d917c0 100644 --- a/lib-src/libnyquist/nyquist/tran/atonev.c +++ b/lib-src/libnyquist/nyquist/tran/atonev.c @@ -15,13 +15,13 @@ void atonev_free(snd_susp_type a_susp); typedef struct atonev_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz; - long hz_cnt; + int hz_cnt; sample_block_values_type hz_ptr; /* support for interpolation of hz */ @@ -31,7 +31,7 @@ typedef struct atonev_susp_struct { /* support for ramp between samples of hz */ double output_per_hz; - long hz_n; + int64_t hz_n; double cc; double prev; @@ -59,92 +59,92 @@ void atonev_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz input sample block: */ - susp_check_term_samples(hz, hz_ptr, hz_cnt); - togo = min(togo, susp->hz_cnt); + /* don't run past the hz input sample block: */ + susp_check_term_samples(hz, hz_ptr, hz_cnt); + togo = min(togo, susp->hz_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cc_reg = susp->cc; - prev_reg = susp->prev; - hz_ptr_reg = susp->hz_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cc_reg = susp->cc; + prev_reg = susp->prev; + hz_ptr_reg = susp->hz_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double current; - register double bb; - bb = 2.0 - cos((hz_scale_reg * *hz_ptr_reg++)); - cc_reg = bb - sqrt((bb * bb) - 1.0); + register double bb; + bb = 2.0 - cos((hz_scale_reg * *hz_ptr_reg++)); + cc_reg = bb - sqrt((bb * bb) - 1.0); current = *s1_ptr_reg++; prev_reg = cc_reg * (prev_reg + current); *out_ptr_reg++ = (sample_type) prev_reg; prev_reg -= current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using hz_ptr_reg is a bad idea on RS/6000: */ - susp->hz_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using hz_ptr_reg is a bad idea on RS/6000: */ + susp->hz_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* atonev_ns_fetch */ @@ -172,108 +172,108 @@ void atonev_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - register double bb; - susp->started = true; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - bb = 2.0 - cos(susp->hz_x1_sample); - susp->cc = bb - sqrt((bb * bb) - 1.0); + register double bb; + susp->started = true; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + bb = 2.0 - cos(susp->hz_x1_sample); + susp->cc = bb - sqrt((bb * bb) - 1.0); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cc_reg = susp->cc; - prev_reg = susp->prev; - hz_pHaSe_ReG = susp->hz_pHaSe; - hz_x1_sample_reg = susp->hz_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cc_reg = susp->cc; + prev_reg = susp->prev; + hz_pHaSe_ReG = susp->hz_pHaSe; + hz_x1_sample_reg = susp->hz_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double current; - if (hz_pHaSe_ReG >= 1.0) { + if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ - register double bb; - /* pick up next sample as hz_x1_sample: */ - susp->hz_ptr++; - susp_took(hz_cnt, 1); - hz_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); - hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); - bb = 2.0 - cos(hz_x1_sample_reg); - cc_reg = bb - sqrt((bb * bb) - 1.0); - } + register double bb; + /* pick up next sample as hz_x1_sample: */ + susp->hz_ptr++; + susp_took(hz_cnt, 1); + hz_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); + hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); + bb = 2.0 - cos(hz_x1_sample_reg); + cc_reg = bb - sqrt((bb * bb) - 1.0); + } current = *s1_ptr_reg++; prev_reg = cc_reg * (prev_reg + current); *out_ptr_reg++ = (sample_type) prev_reg; prev_reg -= current; - hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->prev = prev_reg; - susp->hz_pHaSe = hz_pHaSe_ReG; - susp->hz_x1_sample = hz_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->prev = prev_reg; + susp->hz_pHaSe = hz_pHaSe_ReG; + susp->hz_x1_sample = hz_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* atonev_ni_fetch */ @@ -299,130 +299,130 @@ void atonev_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz_pHaSe = 1.0; + susp->started = true; + susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz_x1_sample when phase goes past 1.0; */ - /* use hz_n (computed below) to avoid roundoff errors: */ - if (susp->hz_n <= 0) { - register double bb; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->hz_pHaSe -= 1.0; - /* hz_n gets number of samples before phase exceeds 1.0: */ - susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * - susp->output_per_hz); - bb = 2.0 - cos(susp->hz_x1_sample); - susp->cc = bb - sqrt((bb * bb) - 1.0); - } - togo = min(togo, susp->hz_n); - hz_val = susp->hz_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz_x1_sample when phase goes past 1.0; */ + /* use hz_n (computed below) to avoid roundoff errors: */ + if (susp->hz_n <= 0) { + register double bb; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->hz_pHaSe -= 1.0; + /* hz_n gets number of samples before phase exceeds 1.0: */ + susp->hz_n = (int64_t) ((1.0 - susp->hz_pHaSe) * + susp->output_per_hz); + bb = 2.0 - cos(susp->hz_x1_sample); + susp->cc = bb - sqrt((bb * bb) - 1.0); + } + togo = (int) min(togo, susp->hz_n); + hz_val = susp->hz_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cc_reg = susp->cc; - prev_reg = susp->prev; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cc_reg = susp->cc; + prev_reg = susp->prev; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double current; current = *s1_ptr_reg++; prev_reg = cc_reg * (prev_reg + current); *out_ptr_reg++ = (sample_type) prev_reg; prev_reg -= current; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; - susp->hz_n -= togo; - cnt += togo; + susp->prev = prev_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; + susp->hz_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* atonev_nr_fetch */ void atonev_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ atonev_susp_type susp = (atonev_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr)) >= - susp->hz->current) - susp_get_samples(hz, hz_ptr, hz_cnt); + susp->hz->current) + susp_get_samples(hz, hz_ptr, hz_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - + n = (int) ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - (susp->hz->current - susp->hz_cnt)); susp->hz_ptr += n; susp_took(hz_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/biquadfilt.c b/lib-src/libnyquist/nyquist/tran/biquadfilt.c index a0d1ea517..2a4c4fed2 100644 --- a/lib-src/libnyquist/nyquist/tran/biquadfilt.c +++ b/lib-src/libnyquist/nyquist/tran/biquadfilt.c @@ -14,10 +14,10 @@ void biquadfilt_free(snd_susp_type a_susp); typedef struct biquadfilt_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; double z1; @@ -54,102 +54,102 @@ void biquadfilt_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - z1_reg = susp->z1; - z2_reg = susp->z2; - b0_reg = susp->b0; - b1_reg = susp->b1; - b2_reg = susp->b2; - a1_reg = susp->a1; - a2_reg = susp->a2; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + z1_reg = susp->z1; + z2_reg = susp->z2; + b0_reg = susp->b0; + b1_reg = susp->b1; + b2_reg = susp->b2; + a1_reg = susp->a1; + a2_reg = susp->a2; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; z0 = *s_ptr_reg++ + a1_reg*z1_reg + a2_reg*z2_reg; *out_ptr_reg++ = (sample_type) (z0*b0_reg + z1_reg*b1_reg + z2_reg*b2_reg); z2_reg = z1_reg; z1_reg = z0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->z1 = z1_reg; - susp->z2 = z2_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->z1 = z1_reg; + susp->z2 = z2_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* biquadfilt_n_fetch */ void biquadfilt_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ biquadfilt_susp_type susp = (biquadfilt_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + susp->s->current) + susp_get_samples(s, s_ptr, s_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + n = (int) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/buzz.alg b/lib-src/libnyquist/nyquist/tran/buzz.alg index 29bb17d7c..7d920036b 100644 --- a/lib-src/libnyquist/nyquist/tran/buzz.alg +++ b/lib-src/libnyquist/nyquist/tran/buzz.alg @@ -7,7 +7,7 @@ ") (STATE ("double" "ph_incr" "0") ("float" "n_2_r" "1.0F / (n * 2)") - ("float" "n_2_p1" "(n * 2) + 1") + ("float" "n_2_p1" "(float) ((n * 2) + 1)") ;; note: hz * 0.5 because this formula generates tones an octave up, ;; we also have to correct for the modulation s_fm. If hz != 0, then ;; ph_incr is the increment per hz, so ph_incr/hz is the right scale diff --git a/lib-src/libnyquist/nyquist/tran/buzz.c b/lib-src/libnyquist/nyquist/tran/buzz.c index c70cd8a68..b6aeb6119 100644 --- a/lib-src/libnyquist/nyquist/tran/buzz.c +++ b/lib-src/libnyquist/nyquist/tran/buzz.c @@ -15,10 +15,10 @@ void buzz_free(snd_susp_type a_susp); typedef struct buzz_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s_fm; - long s_fm_cnt; + int s_fm_cnt; sample_block_values_type s_fm_ptr; /* support for interpolation of s_fm */ @@ -28,7 +28,7 @@ typedef struct buzz_susp_struct { /* support for ramp between samples of s_fm */ double output_per_s_fm; - long s_fm_n; + int64_t s_fm_n; double ph_incr; float n_2_r; @@ -62,56 +62,56 @@ void buzz_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s_fm input sample block: */ - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - togo = min(togo, susp->s_fm_cnt); + /* don't run past the s_fm input sample block: */ + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + togo = min(togo, susp->s_fm_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - n_2_r_reg = susp->n_2_r; - n_2_p1_reg = susp->n_2_p1; - phase_reg = susp->phase; - s_fm_ptr_reg = susp->s_fm_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + n_2_r_reg = susp->n_2_r; + n_2_p1_reg = susp->n_2_p1; + phase_reg = susp->phase; + s_fm_ptr_reg = susp->s_fm_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; sample_type num, denom, samp; @@ -135,28 +135,28 @@ void buzz_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += SINE_TABLE_LEN; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - /* using s_fm_ptr_reg is a bad idea on RS/6000: */ - susp->s_fm_ptr += togo; - out_ptr += togo; - susp_took(s_fm_cnt, togo); - cnt += togo; + susp->phase = phase_reg; + /* using s_fm_ptr_reg is a bad idea on RS/6000: */ + susp->s_fm_ptr += togo; + out_ptr += togo; + susp_took(s_fm_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* buzz_s_fetch */ @@ -185,71 +185,71 @@ void buzz_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->started = true; + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - n_2_r_reg = susp->n_2_r; - n_2_p1_reg = susp->n_2_p1; - phase_reg = susp->phase; - s_fm_pHaSe_ReG = susp->s_fm_pHaSe; - s_fm_x1_sample_reg = susp->s_fm_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + n_2_r_reg = susp->n_2_r; + n_2_p1_reg = susp->n_2_p1; + phase_reg = susp->phase; + s_fm_pHaSe_ReG = susp->s_fm_pHaSe; + s_fm_x1_sample_reg = susp->s_fm_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; sample_type num, denom, samp; - if (s_fm_pHaSe_ReG >= 1.0) { + if (s_fm_pHaSe_ReG >= 1.0) { /* fixup-depends s_fm */ - /* pick up next sample as s_fm_x1_sample: */ - susp->s_fm_ptr++; - susp_took(s_fm_cnt, 1); - s_fm_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); - s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); - } + /* pick up next sample as s_fm_x1_sample: */ + susp->s_fm_ptr++; + susp_took(s_fm_cnt, 1); + s_fm_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); + s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); + } table_index = (long) phase_reg; x1 = sine_table[table_index]; denom = (sample_type) (x1 + (phase_reg - table_index) * @@ -270,29 +270,29 @@ void buzz_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += SINE_TABLE_LEN; - s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = phase_reg; - susp->s_fm_pHaSe = s_fm_pHaSe_ReG; - susp->s_fm_x1_sample = s_fm_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = phase_reg; + susp->s_fm_pHaSe = s_fm_pHaSe_ReG; + susp->s_fm_x1_sample = s_fm_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* buzz_i_fetch */ @@ -319,70 +319,70 @@ void buzz_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_fm_pHaSe = 1.0; + susp->started = true; + susp->s_fm_pHaSe = 1.0; } susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_fm_x1_sample when phase goes past 1.0; */ - /* use s_fm_n (computed below) to avoid roundoff errors: */ - if (susp->s_fm_n <= 0) { - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_pHaSe -= 1.0; - /* s_fm_n gets number of samples before phase exceeds 1.0: */ - susp->s_fm_n = (long) ((1.0 - susp->s_fm_pHaSe) * - susp->output_per_s_fm); - } - togo = min(togo, susp->s_fm_n); - s_fm_val = susp->s_fm_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next s_fm_x1_sample when phase goes past 1.0; */ + /* use s_fm_n (computed below) to avoid roundoff errors: */ + if (susp->s_fm_n <= 0) { + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_pHaSe -= 1.0; + /* s_fm_n gets number of samples before phase exceeds 1.0: */ + susp->s_fm_n = (int64_t) ((1.0 - susp->s_fm_pHaSe) * + susp->output_per_s_fm); + } + togo = (int) min(togo, susp->s_fm_n); + s_fm_val = susp->s_fm_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - ph_incr_reg = susp->ph_incr; - n_2_r_reg = susp->n_2_r; - n_2_p1_reg = susp->n_2_p1; - phase_reg = susp->phase; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + n_2_r_reg = susp->n_2_r; + n_2_p1_reg = susp->n_2_p1; + phase_reg = susp->phase; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; sample_type num, denom, samp; @@ -406,44 +406,44 @@ void buzz_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += SINE_TABLE_LEN; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - out_ptr += togo; - susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; - susp->s_fm_n -= togo; - cnt += togo; + susp->phase = phase_reg; + out_ptr += togo; + susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; + susp->s_fm_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* buzz_r_fetch */ void buzz_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ buzz_susp_type susp = (buzz_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s_fm up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr)) >= - susp->s_fm->current) - susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm->current) + susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - + n = (int) ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - (susp->s_fm->current - susp->s_fm_cnt)); susp->s_fm_ptr += n; susp_took(s_fm_cnt, n); @@ -487,7 +487,7 @@ sound_type snd_make_buzz(long n, rate_type sr, double hz, time_type t0, sound_ty falloc_generic(susp, buzz_susp_node, "snd_make_buzz"); susp->ph_incr = 0; susp->n_2_r = 1.0F / (n * 2); - susp->n_2_p1 = (n * 2) + 1; + susp->n_2_p1 = (float) ((n * 2) + 1); susp->phase = compute_phase(PI*0.5, 69.0, SINE_TABLE_LEN, SINE_TABLE_LEN * 440.0, sr, hz * 0.5, &susp->ph_incr); s_fm->scale *= hz != 0 ? (sample_type) (susp->ph_incr / hz) diff --git a/lib-src/libnyquist/nyquist/tran/buzz.h b/lib-src/libnyquist/nyquist/tran/buzz.h index 466c7f328..c07c7c685 100644 --- a/lib-src/libnyquist/nyquist/tran/buzz.h +++ b/lib-src/libnyquist/nyquist/tran/buzz.h @@ -1,3 +1,3 @@ sound_type snd_make_buzz(long n, rate_type sr, double hz, time_type t0, sound_type s_fm); sound_type snd_buzz(long n, rate_type sr, double hz, time_type t0, sound_type s_fm); - /* LISP: (snd-buzz FIXNUM ANYNUM ANYNUM ANYNUM SOUND) */ + /* LISP: (snd-buzz LONG ANYNUM ANYNUM ANYNUM SOUND) */ diff --git a/lib-src/libnyquist/nyquist/tran/chase.c b/lib-src/libnyquist/nyquist/tran/chase.c index 939be20a3..dfa1816c7 100644 --- a/lib-src/libnyquist/nyquist/tran/chase.c +++ b/lib-src/libnyquist/nyquist/tran/chase.c @@ -14,10 +14,10 @@ void chase_free(snd_susp_type a_susp); typedef struct chase_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double level; @@ -46,55 +46,55 @@ void chase_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - level_reg = susp->level; - upslope_reg = susp->upslope; - downslope_reg = susp->downslope; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + level_reg = susp->level; + upslope_reg = susp->upslope; + downslope_reg = susp->downslope; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = *input_ptr_reg++; if (x > level_reg) { level_reg += upslope_reg; @@ -104,30 +104,30 @@ void chase_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) if (x > level_reg) level_reg = x; } *out_ptr_reg++ = (sample_type) level_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->level = level_reg; - susp->upslope = upslope_reg; - susp->downslope = downslope_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->level = level_reg; + susp->upslope = upslope_reg; + susp->downslope = downslope_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* chase_n_fetch */ @@ -153,55 +153,55 @@ void chase_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - level_reg = susp->level; - upslope_reg = susp->upslope; - downslope_reg = susp->downslope; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + level_reg = susp->level; + upslope_reg = susp->upslope; + downslope_reg = susp->downslope; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = (input_scale_reg * *input_ptr_reg++); if (x > level_reg) { level_reg += upslope_reg; @@ -211,47 +211,47 @@ void chase_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) if (x > level_reg) level_reg = x; } *out_ptr_reg++ = (sample_type) level_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->level = level_reg; - susp->upslope = upslope_reg; - susp->downslope = downslope_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->level = level_reg; + susp->upslope = upslope_reg; + susp->downslope = downslope_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* chase_s_fetch */ void chase_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ chase_susp_type susp = (chase_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/clip.c b/lib-src/libnyquist/nyquist/tran/clip.c index 79bd4ad45..c26275856 100644 --- a/lib-src/libnyquist/nyquist/tran/clip.c +++ b/lib-src/libnyquist/nyquist/tran/clip.c @@ -14,10 +14,10 @@ void clip_free(snd_susp_type a_susp); typedef struct clip_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; sample_type level; @@ -42,79 +42,79 @@ void clip_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - level_reg = susp->level; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + level_reg = susp->level; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = *s_ptr_reg++; *out_ptr_reg++ = (sample_type) (x > level_reg ? level_reg : (x < -level_reg ? -level_reg : x)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->level = level_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->level = level_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* clip_n_fetch */ @@ -138,96 +138,96 @@ void clip_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - level_reg = susp->level; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + level_reg = susp->level; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = (s_scale_reg * *s_ptr_reg++); *out_ptr_reg++ = (sample_type) (x > level_reg ? level_reg : (x < -level_reg ? -level_reg : x)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->level = level_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->level = level_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* clip_s_fetch */ void clip_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ clip_susp_type susp = (clip_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + susp->s->current) + susp_get_samples(s, s_ptr, s_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + n = (int) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/congen.c b/lib-src/libnyquist/nyquist/tran/congen.c index 021726176..8923edb57 100644 --- a/lib-src/libnyquist/nyquist/tran/congen.c +++ b/lib-src/libnyquist/nyquist/tran/congen.c @@ -14,9 +14,9 @@ void congen_free(snd_susp_type a_susp); typedef struct congen_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type sndin; - long sndin_cnt; + int sndin_cnt; sample_block_values_type sndin_ptr; double value; @@ -45,29 +45,29 @@ void congen_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the sndin input sample block: */ - susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); - togo = min(togo, susp->sndin_cnt); + /* don't run past the sndin input sample block: */ + susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); + togo = min(togo, susp->sndin_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - value_reg = susp->value; - rise_factor_reg = susp->rise_factor; - fall_factor_reg = susp->fall_factor; - sndin_ptr_reg = susp->sndin_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + value_reg = susp->value; + rise_factor_reg = susp->rise_factor; + fall_factor_reg = susp->fall_factor; + sndin_ptr_reg = susp->sndin_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ sample_type current = *sndin_ptr_reg++; if (current > value_reg) { value_reg = current - (current - value_reg) * rise_factor_reg; @@ -75,22 +75,22 @@ void congen_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) value_reg = current - (current - value_reg) * fall_factor_reg; } *out_ptr_reg++ = (sample_type) value_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->value = value_reg; - /* using sndin_ptr_reg is a bad idea on RS/6000: */ - susp->sndin_ptr += togo; - out_ptr += togo; - susp_took(sndin_cnt, togo); - cnt += togo; + susp->value = value_reg; + /* using sndin_ptr_reg is a bad idea on RS/6000: */ + susp->sndin_ptr += togo; + out_ptr += togo; + susp_took(sndin_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* congen_n_fetch */ @@ -116,29 +116,29 @@ void congen_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the sndin input sample block: */ - susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); - togo = min(togo, susp->sndin_cnt); + /* don't run past the sndin input sample block: */ + susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); + togo = min(togo, susp->sndin_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - value_reg = susp->value; - rise_factor_reg = susp->rise_factor; - fall_factor_reg = susp->fall_factor; - sndin_ptr_reg = susp->sndin_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + value_reg = susp->value; + rise_factor_reg = susp->rise_factor; + fall_factor_reg = susp->fall_factor; + sndin_ptr_reg = susp->sndin_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ sample_type current = (sndin_scale_reg * *sndin_ptr_reg++); if (current > value_reg) { value_reg = current - (current - value_reg) * rise_factor_reg; @@ -146,39 +146,39 @@ void congen_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) value_reg = current - (current - value_reg) * fall_factor_reg; } *out_ptr_reg++ = (sample_type) value_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->value = value_reg; - /* using sndin_ptr_reg is a bad idea on RS/6000: */ - susp->sndin_ptr += togo; - out_ptr += togo; - susp_took(sndin_cnt, togo); - cnt += togo; + susp->value = value_reg; + /* using sndin_ptr_reg is a bad idea on RS/6000: */ + susp->sndin_ptr += togo; + out_ptr += togo; + susp_took(sndin_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* congen_s_fetch */ void congen_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ congen_susp_type susp = (congen_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from sndin up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr)) >= - susp->sndin->current) - susp_get_samples(sndin, sndin_ptr, sndin_cnt); + susp->sndin->current) + susp_get_samples(sndin, sndin_ptr, sndin_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr - + n = (int) ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr - (susp->sndin->current - susp->sndin_cnt)); susp->sndin_ptr += n; susp_took(sndin_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/const.c b/lib-src/libnyquist/nyquist/tran/const.c index 254ec9708..39d1316e0 100644 --- a/lib-src/libnyquist/nyquist/tran/const.c +++ b/lib-src/libnyquist/nyquist/tran/const.c @@ -14,7 +14,7 @@ void const_free(snd_susp_type a_susp); typedef struct const_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sample_type c; } const_susp_node, *const_susp_type; @@ -37,35 +37,35 @@ void const__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - c_reg = susp->c; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c_reg = susp->c; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = c_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - out_ptr += togo; - cnt += togo; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* const__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/coterm.alg b/lib-src/libnyquist/nyquist/tran/coterm.alg index 2855fa53d..507b15c57 100644 --- a/lib-src/libnyquist/nyquist/tran/coterm.alg +++ b/lib-src/libnyquist/nyquist/tran/coterm.alg @@ -3,7 +3,7 @@ (ARGUMENTS ("sound_type" "s1") ("sound_type" "s2")) (SAMPLE-RATE (MAX s1)) (START (MAX s1 s2)) - (INNER-LOOP "{sample_type dummy = s2; output = s1;}") + (INNER-LOOP "{ /* ignore s2 */ output = s1;}") (LINEAR s1) (TERMINATE (MIN s1 s2)) (LOGICAL-STOP (MIN s1 s2)) diff --git a/lib-src/libnyquist/nyquist/tran/coterm.c b/lib-src/libnyquist/nyquist/tran/coterm.c index 5609ebcc8..88f83ccac 100644 --- a/lib-src/libnyquist/nyquist/tran/coterm.c +++ b/lib-src/libnyquist/nyquist/tran/coterm.c @@ -15,13 +15,13 @@ void coterm_free(snd_susp_type a_susp); typedef struct coterm_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type s2; - long s2_cnt; + int s2_cnt; sample_block_values_type s2_ptr; /* support for interpolation of s2 */ @@ -31,7 +31,7 @@ typedef struct coterm_susp_struct { /* support for ramp between samples of s2 */ double output_per_s2; - long s2_n; + int64_t s2_n; } coterm_susp_node, *coterm_susp_type; @@ -53,82 +53,82 @@ void coterm_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the s2 input sample block: */ - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - togo = min(togo, susp->s2_cnt); + /* don't run past the s2 input sample block: */ + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + togo = min(togo, susp->s2_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_ptr_reg = susp->s2_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - {sample_type dummy = *s2_ptr_reg++; *out_ptr_reg++ = *s1_ptr_reg++;}; - } while (--n); /* inner loop */ + n = togo; + s2_ptr_reg = susp->s2_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + { /* ignore *s2_ptr_reg++ */ *out_ptr_reg++ = *s1_ptr_reg++;}; + } while (--n); /* inner loop */ - /* using s2_ptr_reg is a bad idea on RS/6000: */ - susp->s2_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(s2_cnt, togo); - cnt += togo; + /* using s2_ptr_reg is a bad idea on RS/6000: */ + susp->s2_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(s2_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* coterm_nn_fetch */ @@ -155,98 +155,99 @@ void coterm_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - susp->s2_x1_sample = (susp->s2_cnt--, *(susp->s2_ptr)); + susp->started = true; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + susp->s2_cnt--; + susp->s2_x1_sample = *(susp->s2_ptr); } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = *(susp->s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_pHaSe_ReG = susp->s2_pHaSe; - s2_x1_sample_reg = susp->s2_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s2_pHaSe_ReG >= 1.0) { - s2_x1_sample_reg = s2_x2_sample; - /* pick up next sample as s2_x2_sample: */ - susp->s2_ptr++; - susp_took(s2_cnt, 1); - s2_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); - } - {sample_type dummy = - (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); *out_ptr_reg++ = *s1_ptr_reg++;}; - s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + n = togo; + s2_pHaSe_ReG = susp->s2_pHaSe; + s2_x1_sample_reg = susp->s2_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (s2_pHaSe_ReG >= 1.0) { + s2_x1_sample_reg = s2_x2_sample; + /* pick up next sample as s2_x2_sample: */ + susp->s2_ptr++; + susp_took(s2_cnt, 1); + s2_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); + } + { /* ignore + (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG) */ *out_ptr_reg++ = *s1_ptr_reg++;}; + s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->s2_pHaSe = s2_pHaSe_ReG; - susp->s2_x1_sample = s2_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->s2_pHaSe = s2_pHaSe_ReG; + susp->s2_x1_sample = s2_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* coterm_ni_fetch */ @@ -272,128 +273,128 @@ void coterm_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s2_pHaSe = 1.0; + susp->started = true; + susp->s2_pHaSe = 1.0; } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = *(susp->s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next s2_x2_sample when phase goes past 1.0; */ - /* we use s2_n (computed below) to avoid roundoff errors: */ - if (susp->s2_n <= 0) { - susp->s2_x1_sample = s2_x2_sample; - susp->s2_ptr++; - susp_took(s2_cnt, 1); - susp->s2_pHaSe -= 1.0; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - s2_x2_sample = *(susp->s2_ptr); - /* s2_n gets number of samples before phase exceeds 1.0: */ - susp->s2_n = (long) ((1.0 - susp->s2_pHaSe) * - susp->output_per_s2); - } - togo = min(togo, susp->s2_n); - s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); - s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + - s2_x2_sample * susp->s2_pHaSe); + /* grab next s2_x2_sample when phase goes past 1.0; */ + /* we use s2_n (computed below) to avoid roundoff errors: */ + if (susp->s2_n <= 0) { + susp->s2_x1_sample = s2_x2_sample; + susp->s2_ptr++; + susp_took(s2_cnt, 1); + susp->s2_pHaSe -= 1.0; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + s2_x2_sample = *(susp->s2_ptr); + /* s2_n gets number of samples before phase exceeds 1.0: */ + susp->s2_n = (int64_t) ((1.0 - susp->s2_pHaSe) * + susp->output_per_s2); + } + togo = (int) min(togo, susp->s2_n); + s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); + s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + + s2_x2_sample * susp->s2_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - {sample_type dummy = s2_val; *out_ptr_reg++ = *s1_ptr_reg++;}; - s2_val += s2_DeLtA; - } while (--n); /* inner loop */ + n = togo; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + { /* ignore s2_val */ *out_ptr_reg++ = *s1_ptr_reg++;}; + s2_val += s2_DeLtA; + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; - susp->s2_n -= togo; - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; + susp->s2_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* coterm_nr_fetch */ void coterm_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ coterm_susp_type susp = (coterm_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from s2 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr)) >= - susp->s2->current) - susp_get_samples(s2, s2_ptr, s2_cnt); + susp->s2->current) + susp_get_samples(s2, s2_ptr, s2_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - + n = (int) ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - (susp->s2->current - susp->s2_cnt)); susp->s2_ptr += n; susp_took(s2_cnt, n); @@ -440,7 +441,7 @@ sound_type snd_make_coterm(sound_type s1, sound_type s2) int interp_desc = 0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - long lsc; + int64_t lsc; /* combine scale factors of linear inputs (S1) */ scale_factor *= s1->scale; s1->scale = 1.0F; diff --git a/lib-src/libnyquist/nyquist/tran/delaycc.c b/lib-src/libnyquist/nyquist/tran/delaycc.c index 8c2e0da01..c75dd0dc4 100644 --- a/lib-src/libnyquist/nyquist/tran/delaycc.c +++ b/lib-src/libnyquist/nyquist/tran/delaycc.c @@ -14,9 +14,9 @@ void delay_free(snd_susp_type a_susp); typedef struct delay_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double feedback; @@ -47,65 +47,65 @@ void delay_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - feedback_reg = susp->feedback; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + feedback_reg = susp->feedback; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; *delayptr_reg = (sample_type) (*delayptr_reg * feedback_reg) + *input_ptr_reg++; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delay_n_fetch */ void delay_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ delay_susp_type susp = (delay_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/delaycv.alg b/lib-src/libnyquist/nyquist/tran/delaycv.alg index 4dfe88a6f..da3e5ee24 100644 --- a/lib-src/libnyquist/nyquist/tran/delaycv.alg +++ b/lib-src/libnyquist/nyquist/tran/delaycv.alg @@ -1,18 +1,20 @@ (DELAYCV-ALG (NAME "delaycv") -(ARGUMENTS ("sound_type" "s") ("time_type" "delay") ("sound_type" "feedback")) -(START (MAX s feedback)) -(STATE ("long" "delaylen" "ROUND32(s->sr * delay)") +(ARGUMENTS ("sound_type" "input") ("time_type" "delay") + ("sound_type" "feedback")) +(START (MAX input feedback)) +(STATE ("long" "delaylen" "ROUND32(input->sr * delay)") ("sample_type *" "delaybuf" "(sample_type *) calloc (sizeof(double), susp->delaylen)") ("sample_type *" "delayptr" "susp->delaybuf") ("sample_type *" "endptr" "susp->delaybuf + susp->delaylen")) (CONSTANT "delaylen" "delaybuf") (NOT-REGISTER delaybuf) -(LINEAR s) -(TERMINATE (MIN s)) +(LINEAR input) +(TERMINATE (MIN input)) (INNER-LOOP "output = *delayptr; - *delayptr = *delayptr * feedback + s; + *delayptr = *delayptr * (sample_type) feedback + + (sample_type) input; if (++delayptr >= endptr) delayptr = susp->delaybuf") (FINALIZATION "free(susp->delaybuf);\n") ) diff --git a/lib-src/libnyquist/nyquist/tran/delaycv.c b/lib-src/libnyquist/nyquist/tran/delaycv.c index 0d6987506..2711e8828 100644 --- a/lib-src/libnyquist/nyquist/tran/delaycv.c +++ b/lib-src/libnyquist/nyquist/tran/delaycv.c @@ -15,21 +15,21 @@ void delaycv_free(snd_susp_type a_susp); typedef struct delaycv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; - sound_type s; - long s_cnt; - sample_block_values_type s_ptr; + int64_t terminate_cnt; + sound_type input; + int input_cnt; + sample_block_values_type input_ptr; - /* support for interpolation of s */ - sample_type s_x1_sample; - double s_pHaSe; - double s_pHaSe_iNcR; + /* support for interpolation of input */ + sample_type input_x1_sample; + double input_pHaSe; + double input_pHaSe_iNcR; - /* support for ramp between samples of s */ - double output_per_s; - long s_n; + /* support for ramp between samples of input */ + double output_per_input; + int64_t input_n; sound_type feedback; - long feedback_cnt; + int feedback_cnt; sample_block_values_type feedback_ptr; /* support for interpolation of feedback */ @@ -39,7 +39,7 @@ typedef struct delaycv_susp_struct { /* support for ramp between samples of feedback */ double output_per_feedback; - long feedback_n; + int64_t feedback_n; long delaylen; sample_type *delaybuf; @@ -62,62 +62,63 @@ void delaycv_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_type * delayptr_reg; register sample_type * endptr_reg; register sample_block_values_type feedback_ptr_reg; - register sample_block_values_type s_ptr_reg; + register sample_block_values_type input_ptr_reg; falloc_sample_block(out, "delaycv_nn_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * *feedback_ptr_reg++ + *s_ptr_reg++; + *delayptr_reg = *delayptr_reg * (sample_type) *feedback_ptr_reg++ + + (sample_type) *input_ptr_reg++; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_nn_fetch */ @@ -137,62 +138,63 @@ void delaycv_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_type * endptr_reg; register sample_type feedback_scale_reg = susp->feedback->scale; register sample_block_values_type feedback_ptr_reg; - register sample_block_values_type s_ptr_reg; + register sample_block_values_type input_ptr_reg; falloc_sample_block(out, "delaycv_ns_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * (feedback_scale_reg * *feedback_ptr_reg++) + *s_ptr_reg++; + *delayptr_reg = *delayptr_reg * (sample_type) (feedback_scale_reg * *feedback_ptr_reg++) + + (sample_type) *input_ptr_reg++; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_ns_fetch */ @@ -214,79 +216,80 @@ void delaycv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) register double feedback_pHaSe_iNcR_rEg = susp->feedback_pHaSe_iNcR; register double feedback_pHaSe_ReG; register sample_type feedback_x1_sample_reg; - register sample_block_values_type s_ptr_reg; + register sample_block_values_type input_ptr_reg; falloc_sample_block(out, "delaycv_ni_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); + susp->started = true; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback_x1_sample = susp_fetch_sample(feedback, feedback_ptr, feedback_cnt); } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_pHaSe_ReG = susp->feedback_pHaSe; - feedback_x1_sample_reg = susp->feedback_x1_sample; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (feedback_pHaSe_ReG >= 1.0) { - feedback_x1_sample_reg = feedback_x2_sample; - /* pick up next sample as feedback_x2_sample: */ - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - feedback_pHaSe_ReG -= 1.0; - susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); - } + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_pHaSe_ReG = susp->feedback_pHaSe; + feedback_x1_sample_reg = susp->feedback_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (feedback_pHaSe_ReG >= 1.0) { + feedback_x1_sample_reg = feedback_x2_sample; + /* pick up next sample as feedback_x2_sample: */ + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + feedback_pHaSe_ReG -= 1.0; + susp_check_samples_break(feedback, feedback_ptr, feedback_cnt, feedback_x2_sample); + } *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * - (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG) + *s_ptr_reg++; + *delayptr_reg = *delayptr_reg * (sample_type) + (feedback_x1_sample_reg * (1 - feedback_pHaSe_ReG) + feedback_x2_sample * feedback_pHaSe_ReG) + + (sample_type) *input_ptr_reg++; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + feedback_pHaSe_ReG += feedback_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - susp->feedback_pHaSe = feedback_pHaSe_ReG; - susp->feedback_x1_sample = feedback_x1_sample_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + togo -= n; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + susp->feedback_pHaSe = feedback_pHaSe_ReG; + susp->feedback_x1_sample = feedback_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_ni_fetch */ @@ -307,84 +310,85 @@ void delaycv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_type * delayptr_reg; register sample_type * endptr_reg; - register sample_block_values_type s_ptr_reg; + register sample_block_values_type input_ptr_reg; falloc_sample_block(out, "delaycv_nr_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->feedback_pHaSe = 1.0; + susp->started = true; + susp->feedback_pHaSe = 1.0; } susp_check_samples(feedback, feedback_ptr, feedback_cnt); feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the input input sample block: */ + susp_check_term_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next feedback_x2_sample when phase goes past 1.0; */ - /* we use feedback_n (computed below) to avoid roundoff errors: */ - if (susp->feedback_n <= 0) { - susp->feedback_x1_sample = feedback_x2_sample; - susp->feedback_ptr++; - susp_took(feedback_cnt, 1); - susp->feedback_pHaSe -= 1.0; - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); - /* feedback_n gets number of samples before phase exceeds 1.0: */ - susp->feedback_n = (long) ((1.0 - susp->feedback_pHaSe) * - susp->output_per_feedback); - } - togo = min(togo, susp->feedback_n); - feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); - feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + - feedback_x2_sample * susp->feedback_pHaSe); + /* grab next feedback_x2_sample when phase goes past 1.0; */ + /* we use feedback_n (computed below) to avoid roundoff errors: */ + if (susp->feedback_n <= 0) { + susp->feedback_x1_sample = feedback_x2_sample; + susp->feedback_ptr++; + susp_took(feedback_cnt, 1); + susp->feedback_pHaSe -= 1.0; + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + feedback_x2_sample = susp_current_sample(feedback, feedback_ptr); + /* feedback_n gets number of samples before phase exceeds 1.0: */ + susp->feedback_n = (int64_t) ((1.0 - susp->feedback_pHaSe) * + susp->output_per_feedback); + } + togo = (int) min(togo, susp->feedback_n); + feedback_DeLtA = (sample_type) ((feedback_x2_sample - susp->feedback_x1_sample) * susp->feedback_pHaSe_iNcR); + feedback_val = (sample_type) (susp->feedback_x1_sample * (1.0 - susp->feedback_pHaSe) + + feedback_x2_sample * susp->feedback_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * feedback_val + *s_ptr_reg++; + *delayptr_reg = *delayptr_reg * (sample_type) feedback_val + + (sample_type) *input_ptr_reg++; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - feedback_val += feedback_DeLtA; - } while (--n); /* inner loop */ + feedback_val += feedback_DeLtA; + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; - susp->feedback_n -= togo; - cnt += togo; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->feedback_pHaSe += togo * susp->feedback_pHaSe_iNcR; + susp->feedback_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_nr_fetch */ @@ -393,7 +397,7 @@ void delaycv_in_fetch(snd_susp_type a_susp, snd_list_type snd_list) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; int cnt = 0; /* how many samples computed */ - sample_type s_x2_sample; + sample_type input_x2_sample; int togo; int n; sample_block_type out; @@ -404,81 +408,82 @@ void delaycv_in_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_type * delayptr_reg; register sample_type * endptr_reg; register sample_block_values_type feedback_ptr_reg; - register double s_pHaSe_iNcR_rEg = susp->s_pHaSe_iNcR; - register double s_pHaSe_ReG; - register sample_type s_x1_sample_reg; + register double input_pHaSe_iNcR_rEg = susp->input_pHaSe_iNcR; + register double input_pHaSe_ReG; + register sample_type input_x1_sample_reg; falloc_sample_block(out, "delaycv_in_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(s, s_ptr, s_cnt); - susp->s_x1_sample = susp_fetch_sample(s, s_ptr, s_cnt); + susp->started = true; + susp_check_term_samples(input, input_ptr, input_cnt); + susp->input_x1_sample = susp_fetch_sample(input, input_ptr, input_cnt); } - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - s_pHaSe_ReG = susp->s_pHaSe; - s_x1_sample_reg = susp->s_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s_pHaSe_ReG >= 1.0) { - s_x1_sample_reg = s_x2_sample; - /* pick up next sample as s_x2_sample: */ - susp->s_ptr++; - susp_took(s_cnt, 1); - s_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(s, s_ptr, s_cnt, s_x2_sample); - } + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_pHaSe_ReG = susp->input_pHaSe; + input_x1_sample_reg = susp->input_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (input_pHaSe_ReG >= 1.0) { + input_x1_sample_reg = input_x2_sample; + /* pick up next sample as input_x2_sample: */ + susp->input_ptr++; + susp_took(input_cnt, 1); + input_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(input, input_ptr, input_cnt, input_x2_sample); + } *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * *feedback_ptr_reg++ + - (s_x1_sample_reg * (1 - s_pHaSe_ReG) + s_x2_sample * s_pHaSe_ReG); + *delayptr_reg = *delayptr_reg * (sample_type) *feedback_ptr_reg++ + + (sample_type) + (input_x1_sample_reg * (1 - input_pHaSe_ReG) + input_x2_sample * input_pHaSe_ReG); if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - s_pHaSe_ReG += s_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + input_pHaSe_ReG += input_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - susp->s_pHaSe = s_pHaSe_ReG; - susp->s_x1_sample = s_x1_sample_reg; - out_ptr += togo; - susp_took(feedback_cnt, togo); - cnt += togo; + togo -= n; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + susp->input_pHaSe = input_pHaSe_ReG; + susp->input_x1_sample = input_x1_sample_reg; + out_ptr += togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_in_fetch */ @@ -487,7 +492,7 @@ void delaycv_is_fetch(snd_susp_type a_susp, snd_list_type snd_list) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; int cnt = 0; /* how many samples computed */ - sample_type s_x2_sample; + sample_type input_x2_sample; int togo; int n; sample_block_type out; @@ -499,81 +504,82 @@ void delaycv_is_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_type * endptr_reg; register sample_type feedback_scale_reg = susp->feedback->scale; register sample_block_values_type feedback_ptr_reg; - register double s_pHaSe_iNcR_rEg = susp->s_pHaSe_iNcR; - register double s_pHaSe_ReG; - register sample_type s_x1_sample_reg; + register double input_pHaSe_iNcR_rEg = susp->input_pHaSe_iNcR; + register double input_pHaSe_ReG; + register sample_type input_x1_sample_reg; falloc_sample_block(out, "delaycv_is_fetch"); out_ptr = out->samples; snd_list->block = out; /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(s, s_ptr, s_cnt); - susp->s_x1_sample = susp_fetch_sample(s, s_ptr, s_cnt); + susp->started = true; + susp_check_term_samples(input, input_ptr, input_cnt); + susp->input_x1_sample = susp_fetch_sample(input, input_ptr, input_cnt); } - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - s_pHaSe_ReG = susp->s_pHaSe; - s_x1_sample_reg = susp->s_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s_pHaSe_ReG >= 1.0) { - s_x1_sample_reg = s_x2_sample; - /* pick up next sample as s_x2_sample: */ - susp->s_ptr++; - susp_took(s_cnt, 1); - s_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(s, s_ptr, s_cnt, s_x2_sample); - } + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + input_pHaSe_ReG = susp->input_pHaSe; + input_x1_sample_reg = susp->input_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (input_pHaSe_ReG >= 1.0) { + input_x1_sample_reg = input_x2_sample; + /* pick up next sample as input_x2_sample: */ + susp->input_ptr++; + susp_took(input_cnt, 1); + input_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(input, input_ptr, input_cnt, input_x2_sample); + } *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * (feedback_scale_reg * *feedback_ptr_reg++) + - (s_x1_sample_reg * (1 - s_pHaSe_ReG) + s_x2_sample * s_pHaSe_ReG); + *delayptr_reg = *delayptr_reg * (sample_type) (feedback_scale_reg * *feedback_ptr_reg++) + + (sample_type) + (input_x1_sample_reg * (1 - input_pHaSe_ReG) + input_x2_sample * input_pHaSe_ReG); if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - s_pHaSe_ReG += s_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + input_pHaSe_ReG += input_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - susp->s_pHaSe = s_pHaSe_ReG; - susp->s_x1_sample = s_x1_sample_reg; - out_ptr += togo; - susp_took(feedback_cnt, togo); - cnt += togo; + togo -= n; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + susp->input_pHaSe = input_pHaSe_ReG; + susp->input_x1_sample = input_x1_sample_reg; + out_ptr += togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_is_fetch */ @@ -582,9 +588,9 @@ void delaycv_rn_fetch(snd_susp_type a_susp, snd_list_type snd_list) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; int cnt = 0; /* how many samples computed */ - sample_type s_DeLtA; - sample_type s_val; - sample_type s_x2_sample; + sample_type input_DeLtA; + sample_type input_val; + sample_type input_x2_sample; int togo; int n; sample_block_type out; @@ -601,77 +607,78 @@ void delaycv_rn_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_pHaSe = 1.0; + susp->started = true; + susp->input_pHaSe = 1.0; } - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_x2_sample when phase goes past 1.0; */ - /* we use s_n (computed below) to avoid roundoff errors: */ - if (susp->s_n <= 0) { - susp->s_x1_sample = s_x2_sample; - susp->s_ptr++; - susp_took(s_cnt, 1); - susp->s_pHaSe -= 1.0; - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); - /* s_n gets number of samples before phase exceeds 1.0: */ - susp->s_n = (long) ((1.0 - susp->s_pHaSe) * - susp->output_per_s); - } - togo = min(togo, susp->s_n); - s_DeLtA = (sample_type) ((s_x2_sample - susp->s_x1_sample) * susp->s_pHaSe_iNcR); - s_val = (sample_type) (susp->s_x1_sample * (1.0 - susp->s_pHaSe) + - s_x2_sample * susp->s_pHaSe); + /* grab next input_x2_sample when phase goes past 1.0; */ + /* we use input_n (computed below) to avoid roundoff errors: */ + if (susp->input_n <= 0) { + susp->input_x1_sample = input_x2_sample; + susp->input_ptr++; + susp_took(input_cnt, 1); + susp->input_pHaSe -= 1.0; + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); + /* input_n gets number of samples before phase exceeds 1.0: */ + susp->input_n = (int64_t) ((1.0 - susp->input_pHaSe) * + susp->output_per_input); + } + togo = (int) min(togo, susp->input_n); + input_DeLtA = (sample_type) ((input_x2_sample - susp->input_x1_sample) * susp->input_pHaSe_iNcR); + input_val = (sample_type) (susp->input_x1_sample * (1.0 - susp->input_pHaSe) + + input_x2_sample * susp->input_pHaSe); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * *feedback_ptr_reg++ + s_val; + *delayptr_reg = *delayptr_reg * (sample_type) *feedback_ptr_reg++ + + (sample_type) input_val; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - s_val += s_DeLtA; - } while (--n); /* inner loop */ + input_val += input_DeLtA; + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - out_ptr += togo; - susp->s_pHaSe += togo * susp->s_pHaSe_iNcR; - susp->s_n -= togo; - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + out_ptr += togo; + susp->input_pHaSe += togo * susp->input_pHaSe_iNcR; + susp->input_n -= togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_rn_fetch */ @@ -680,9 +687,9 @@ void delaycv_rs_fetch(snd_susp_type a_susp, snd_list_type snd_list) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; int cnt = 0; /* how many samples computed */ - sample_type s_DeLtA; - sample_type s_val; - sample_type s_x2_sample; + sample_type input_DeLtA; + sample_type input_val; + sample_type input_x2_sample; int togo; int n; sample_block_type out; @@ -700,102 +707,103 @@ void delaycv_rs_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_pHaSe = 1.0; + susp->started = true; + susp->input_pHaSe = 1.0; } - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_x2_sample when phase goes past 1.0; */ - /* we use s_n (computed below) to avoid roundoff errors: */ - if (susp->s_n <= 0) { - susp->s_x1_sample = s_x2_sample; - susp->s_ptr++; - susp_took(s_cnt, 1); - susp->s_pHaSe -= 1.0; - susp_check_term_samples(s, s_ptr, s_cnt); - s_x2_sample = susp_current_sample(s, s_ptr); - /* s_n gets number of samples before phase exceeds 1.0: */ - susp->s_n = (long) ((1.0 - susp->s_pHaSe) * - susp->output_per_s); - } - togo = min(togo, susp->s_n); - s_DeLtA = (sample_type) ((s_x2_sample - susp->s_x1_sample) * susp->s_pHaSe_iNcR); - s_val = (sample_type) (susp->s_x1_sample * (1.0 - susp->s_pHaSe) + - s_x2_sample * susp->s_pHaSe); + /* grab next input_x2_sample when phase goes past 1.0; */ + /* we use input_n (computed below) to avoid roundoff errors: */ + if (susp->input_n <= 0) { + susp->input_x1_sample = input_x2_sample; + susp->input_ptr++; + susp_took(input_cnt, 1); + susp->input_pHaSe -= 1.0; + susp_check_term_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); + /* input_n gets number of samples before phase exceeds 1.0: */ + susp->input_n = (int64_t) ((1.0 - susp->input_pHaSe) * + susp->output_per_input); + } + togo = (int) min(togo, susp->input_n); + input_DeLtA = (sample_type) ((input_x2_sample - susp->input_x1_sample) * susp->input_pHaSe_iNcR); + input_val = (sample_type) (susp->input_x1_sample * (1.0 - susp->input_pHaSe) + + input_x2_sample * susp->input_pHaSe); - /* don't run past the feedback input sample block: */ - susp_check_samples(feedback, feedback_ptr, feedback_cnt); - togo = min(togo, susp->feedback_cnt); + /* don't run past the feedback input sample block: */ + susp_check_samples(feedback, feedback_ptr, feedback_cnt); + togo = min(togo, susp->feedback_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - delayptr_reg = susp->delayptr; - endptr_reg = susp->endptr; - feedback_ptr_reg = susp->feedback_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + delayptr_reg = susp->delayptr; + endptr_reg = susp->endptr; + feedback_ptr_reg = susp->feedback_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *delayptr_reg; - *delayptr_reg = *delayptr_reg * (feedback_scale_reg * *feedback_ptr_reg++) + s_val; + *delayptr_reg = *delayptr_reg * (sample_type) (feedback_scale_reg * *feedback_ptr_reg++) + + (sample_type) input_val; if (++delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf; - s_val += s_DeLtA; - } while (--n); /* inner loop */ + input_val += input_DeLtA; + } while (--n); /* inner loop */ - susp->delayptr = delayptr_reg; - susp->endptr = endptr_reg; - /* using feedback_ptr_reg is a bad idea on RS/6000: */ - susp->feedback_ptr += togo; - out_ptr += togo; - susp->s_pHaSe += togo * susp->s_pHaSe_iNcR; - susp->s_n -= togo; - susp_took(feedback_cnt, togo); - cnt += togo; + susp->delayptr = delayptr_reg; + susp->endptr = endptr_reg; + /* using feedback_ptr_reg is a bad idea on RS/6000: */ + susp->feedback_ptr += togo; + out_ptr += togo; + susp->input_pHaSe += togo * susp->input_pHaSe_iNcR; + susp->input_n -= togo; + susp_took(feedback_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* delaycv_rs_fetch */ void delaycv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ delaycv_susp_type susp = (delaycv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; - /* fetch samples from s up to final_time for this block of zeros */ - while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + /* fetch samples from input up to final_time for this block of zeros */ + while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* fetch samples from feedback up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr)) >= - susp->feedback->current) - susp_get_samples(feedback, feedback_ptr, feedback_cnt); + susp->feedback->current) + susp_get_samples(feedback, feedback_ptr, feedback_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - - (susp->s->current - susp->s_cnt)); - susp->s_ptr += n; - susp_took(s_cnt, n); - n = ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + (susp->input->current - susp->input_cnt)); + susp->input_ptr += n; + susp_took(input_cnt, n); + n = (int) ROUNDBIG((final_time - susp->feedback->t0) * susp->feedback->sr - (susp->feedback->current - susp->feedback_cnt)); susp->feedback_ptr += n; susp_took(feedback_cnt, n); @@ -807,7 +815,7 @@ void delaycv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) void delaycv_mark(snd_susp_type a_susp) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; - sound_xlmark(susp->s); + sound_xlmark(susp->input); sound_xlmark(susp->feedback); } @@ -816,7 +824,7 @@ void delaycv_free(snd_susp_type a_susp) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; free(susp->delaybuf); - sound_unref(susp->s); + sound_unref(susp->input); sound_unref(susp->feedback); ffree_generic(susp, sizeof(delaycv_susp_node), "delaycv_free"); } @@ -826,8 +834,8 @@ void delaycv_print_tree(snd_susp_type a_susp, int n) { delaycv_susp_type susp = (delaycv_susp_type) a_susp; indent(n); - stdputstr("s:"); - sound_print_tree_1(susp->s, n); + stdputstr("input:"); + sound_print_tree_1(susp->input, n); indent(n); stdputstr("feedback:"); @@ -835,29 +843,29 @@ void delaycv_print_tree(snd_susp_type a_susp, int n) } -sound_type snd_make_delaycv(sound_type s, time_type delay, sound_type feedback) +sound_type snd_make_delaycv(sound_type input, time_type delay, sound_type feedback) { register delaycv_susp_type susp; - rate_type sr = max(s->sr, feedback->sr); - time_type t0 = max(s->t0, feedback->t0); + rate_type sr = max(input->sr, feedback->sr); + time_type t0 = max(input->t0, feedback->t0); int interp_desc = 0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - /* combine scale factors of linear inputs (S) */ - scale_factor *= s->scale; - s->scale = 1.0F; + /* combine scale factors of linear inputs (INPUT) */ + scale_factor *= input->scale; + input->scale = 1.0F; /* try to push scale_factor back to a low sr input */ - if (s->sr < sr) { s->scale = scale_factor; scale_factor = 1.0F; } + if (input->sr < sr) { input->scale = scale_factor; scale_factor = 1.0F; } falloc_generic(susp, delaycv_susp_node, "snd_make_delaycv"); - susp->delaylen = ROUND32(s->sr * delay); + susp->delaylen = ROUND32(input->sr * delay); susp->delaybuf = (sample_type *) calloc (sizeof(double), susp->delaylen); susp->delayptr = susp->delaybuf; susp->endptr = susp->delaybuf + susp->delaylen; /* select a susp fn based on sample rates */ - interp_desc = (interp_desc << 2) + interp_style(s, sr); + interp_desc = (interp_desc << 2) + interp_style(input, sr); interp_desc = (interp_desc << 2) + interp_style(feedback, sr); switch (interp_desc) { case INTERP_nn: susp->susp.fetch = delaycv_nn_fetch; break; @@ -873,10 +881,10 @@ sound_type snd_make_delaycv(sound_type s, time_type delay, sound_type feedback) susp->terminate_cnt = UNKNOWN; /* handle unequal start times, if any */ - if (t0 < s->t0) sound_prepend_zeros(s, t0); + if (t0 < input->t0) sound_prepend_zeros(input, t0); if (t0 < feedback->t0) sound_prepend_zeros(feedback, t0); /* minimum start time over all inputs: */ - t0_min = min(s->t0, min(feedback->t0, t0)); + t0_min = min(input->t0, min(feedback->t0, t0)); /* how many samples to toss before t0: */ susp->susp.toss_cnt = (long) ((t0 - t0_min) * sr + 0.5); if (susp->susp.toss_cnt > 0) { @@ -894,12 +902,12 @@ sound_type snd_make_delaycv(sound_type s, time_type delay, sound_type feedback) susp->susp.log_stop_cnt = UNKNOWN; susp->started = false; susp->susp.current = 0; - susp->s = s; - susp->s_cnt = 0; - susp->s_pHaSe = 0.0; - susp->s_pHaSe_iNcR = s->sr / sr; - susp->s_n = 0; - susp->output_per_s = sr / s->sr; + susp->input = input; + susp->input_cnt = 0; + susp->input_pHaSe = 0.0; + susp->input_pHaSe_iNcR = input->sr / sr; + susp->input_n = 0; + susp->output_per_input = sr / input->sr; susp->feedback = feedback; susp->feedback_cnt = 0; susp->feedback_pHaSe = 0.0; @@ -910,9 +918,9 @@ sound_type snd_make_delaycv(sound_type s, time_type delay, sound_type feedback) } -sound_type snd_delaycv(sound_type s, time_type delay, sound_type feedback) +sound_type snd_delaycv(sound_type input, time_type delay, sound_type feedback) { - sound_type s_copy = sound_copy(s); + sound_type input_copy = sound_copy(input); sound_type feedback_copy = sound_copy(feedback); - return snd_make_delaycv(s_copy, delay, feedback_copy); + return snd_make_delaycv(input_copy, delay, feedback_copy); } diff --git a/lib-src/libnyquist/nyquist/tran/delaycv.h b/lib-src/libnyquist/nyquist/tran/delaycv.h index 5c6e3d06e..a65da0dda 100644 --- a/lib-src/libnyquist/nyquist/tran/delaycv.h +++ b/lib-src/libnyquist/nyquist/tran/delaycv.h @@ -1,3 +1,3 @@ -sound_type snd_make_delaycv(sound_type s, time_type delay, sound_type feedback); -sound_type snd_delaycv(sound_type s, time_type delay, sound_type feedback); +sound_type snd_make_delaycv(sound_type input, time_type delay, sound_type feedback); +sound_type snd_delaycv(sound_type input, time_type delay, sound_type feedback); /* LISP: (snd-delaycv SOUND ANYNUM SOUND) */ diff --git a/lib-src/libnyquist/nyquist/tran/eqbandvvv.c b/lib-src/libnyquist/nyquist/tran/eqbandvvv.c index 5a37ebd89..9029a1f75 100644 --- a/lib-src/libnyquist/nyquist/tran/eqbandvvv.c +++ b/lib-src/libnyquist/nyquist/tran/eqbandvvv.c @@ -15,13 +15,13 @@ void eqbandvvv_free(snd_susp_type a_susp); typedef struct eqbandvvv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; sound_type hz; - long hz_cnt; + int hz_cnt; sample_block_values_type hz_ptr; /* support for interpolation of hz */ @@ -31,9 +31,9 @@ typedef struct eqbandvvv_susp_struct { /* support for ramp between samples of hz */ double output_per_hz; - long hz_n; + int64_t hz_n; sound_type gain; - long gain_cnt; + int gain_cnt; sample_block_values_type gain_ptr; /* support for interpolation of gain */ @@ -43,9 +43,9 @@ typedef struct eqbandvvv_susp_struct { /* support for ramp between samples of gain */ double output_per_gain; - long gain_n; + int64_t gain_n; sound_type width; - long width_cnt; + int width_cnt; sample_block_values_type width_ptr; /* support for interpolation of width */ @@ -55,7 +55,7 @@ typedef struct eqbandvvv_susp_struct { /* support for ramp between samples of width */ double output_per_width; - long width_n; + int64_t width_n; double inp_scale; double w1; @@ -116,140 +116,140 @@ void eqbandvvv_nsss_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past the hz input sample block: */ - susp_check_term_log_samples(hz, hz_ptr, hz_cnt); - togo = min(togo, susp->hz_cnt); + /* don't run past the hz input sample block: */ + susp_check_term_log_samples(hz, hz_ptr, hz_cnt); + togo = min(togo, susp->hz_cnt); - /* don't run past the gain input sample block: */ - susp_check_term_log_samples(gain, gain_ptr, gain_cnt); - togo = min(togo, susp->gain_cnt); + /* don't run past the gain input sample block: */ + susp_check_term_log_samples(gain, gain_ptr, gain_cnt); + togo = min(togo, susp->gain_cnt); - /* don't run past the width input sample block: */ - susp_check_term_log_samples(width, width_ptr, width_cnt); - togo = min(togo, susp->width_cnt); + /* don't run past the width input sample block: */ + susp_check_term_log_samples(width, width_ptr, width_cnt); + togo = min(togo, susp->width_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - w1_reg = susp->w1; - sw_reg = susp->sw; - cw_reg = susp->cw; - J_reg = susp->J; - gg_reg = susp->gg; - b0_reg = susp->b0; - b1_reg = susp->b1; - b2_reg = susp->b2; - a0_reg = susp->a0; - a1_reg = susp->a1; - a2_reg = susp->a2; - z1_reg = susp->z1; - z2_reg = susp->z2; - recompute_reg = susp->recompute; - inp_period_reg = susp->inp_period; - width_ptr_reg = susp->width_ptr; - gain_ptr_reg = susp->gain_ptr; - hz_ptr_reg = susp->hz_ptr; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + w1_reg = susp->w1; + sw_reg = susp->sw; + cw_reg = susp->cw; + J_reg = susp->J; + gg_reg = susp->gg; + b0_reg = susp->b0; + b1_reg = susp->b1; + b2_reg = susp->b2; + a0_reg = susp->a0; + a1_reg = susp->a1; + a2_reg = susp->a2; + z1_reg = susp->z1; + z2_reg = susp->z2; + recompute_reg = susp->recompute; + inp_period_reg = susp->inp_period; + width_ptr_reg = susp->width_ptr; + gain_ptr_reg = susp->gain_ptr; + hz_ptr_reg = susp->hz_ptr; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; - w1_reg = PI2 * (hz_scale_reg * *hz_ptr_reg++) * inp_period_reg; - sw_reg = sin(w1_reg); - cw_reg = cos(w1_reg); - b1_reg = -2.0 * cw_reg; - a1_reg = -b1_reg; - J_reg = sqrt((gain_scale_reg * *gain_ptr_reg++)); - recompute_reg = true; - recompute_reg = true; - recompute_reg = true; - if (recompute_reg) { - /* a0_reg = 1.0 + gg_reg / J_reg; */ - double a_0_recip = J_reg / (J_reg + gg_reg); - recompute_reg = false; - gg_reg = sw_reg * sinh(log_of_2_over_2 * - (width_scale_reg * *width_ptr_reg++) * w1_reg / sw_reg); - b0_reg = (1.0 + gg_reg * J_reg) * a_0_recip; - b1_reg *= a_0_recip; - b2_reg = (1.0 - gg_reg * J_reg) * a_0_recip; - a1_reg *= a_0_recip; - a2_reg = (gg_reg / J_reg - 1.0) * a_0_recip; - } + w1_reg = PI2 * (hz_scale_reg * *hz_ptr_reg++) * inp_period_reg; + sw_reg = sin(w1_reg); + cw_reg = cos(w1_reg); + b1_reg = -2.0 * cw_reg; + a1_reg = -b1_reg; + J_reg = sqrt((gain_scale_reg * *gain_ptr_reg++)); + recompute_reg = true; + recompute_reg = true; + recompute_reg = true; + if (recompute_reg) { + /* a0_reg = 1.0 + gg_reg / J_reg; */ + double a_0_recip = J_reg / (J_reg + gg_reg); + recompute_reg = false; + gg_reg = sw_reg * sinh(log_of_2_over_2 * + (width_scale_reg * *width_ptr_reg++) * w1_reg / sw_reg); + b0_reg = (1.0 + gg_reg * J_reg) * a_0_recip; + b1_reg *= a_0_recip; + b2_reg = (1.0 - gg_reg * J_reg) * a_0_recip; + a1_reg *= a_0_recip; + a2_reg = (gg_reg / J_reg - 1.0) * a_0_recip; + } z0 = *input_ptr_reg++ + a1_reg*z1_reg + a2_reg*z2_reg; *out_ptr_reg++ = (sample_type) (z0*b0_reg + z1_reg*b1_reg + z2_reg*b2_reg); z2_reg = z1_reg; z1_reg = z0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->z1 = z1_reg; - susp->z2 = z2_reg; - susp->recompute = recompute_reg; - /* using width_ptr_reg is a bad idea on RS/6000: */ - susp->width_ptr += togo; - /* using gain_ptr_reg is a bad idea on RS/6000: */ - susp->gain_ptr += togo; - /* using hz_ptr_reg is a bad idea on RS/6000: */ - susp->hz_ptr += togo; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp_took(hz_cnt, togo); - susp_took(gain_cnt, togo); - susp_took(width_cnt, togo); - cnt += togo; + susp->z1 = z1_reg; + susp->z2 = z2_reg; + susp->recompute = recompute_reg; + /* using width_ptr_reg is a bad idea on RS/6000: */ + susp->width_ptr += togo; + /* using gain_ptr_reg is a bad idea on RS/6000: */ + susp->gain_ptr += togo; + /* using hz_ptr_reg is a bad idea on RS/6000: */ + susp->hz_ptr += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp_took(hz_cnt, togo); + susp_took(gain_cnt, togo); + susp_took(width_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* eqbandvvv_nsss_fetch */ @@ -296,178 +296,178 @@ void eqbandvvv_niii_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->w1 = PI2 * susp->hz_x1_sample * susp->inp_period; - susp->sw = sin(susp->w1); - susp->cw = cos(susp->w1); - susp->b1 = -2.0 * susp->cw; - susp->a1 = -susp->b1; - susp->recompute = true; - susp_check_term_log_samples(gain, gain_ptr, gain_cnt); - susp->gain_x1_sample = susp_fetch_sample(gain, gain_ptr, gain_cnt); - susp->J = sqrt(susp->gain_x1_sample); - susp->recompute = true; - susp_check_term_log_samples(width, width_ptr, width_cnt); - susp->width_x1_sample = susp_fetch_sample(width, width_ptr, width_cnt); - susp->recompute = true; + susp->started = true; + susp_check_term_log_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->w1 = PI2 * susp->hz_x1_sample * susp->inp_period; + susp->sw = sin(susp->w1); + susp->cw = cos(susp->w1); + susp->b1 = -2.0 * susp->cw; + susp->a1 = -susp->b1; + susp->recompute = true; + susp_check_term_log_samples(gain, gain_ptr, gain_cnt); + susp->gain_x1_sample = susp_fetch_sample(gain, gain_ptr, gain_cnt); + susp->J = sqrt(susp->gain_x1_sample); + susp->recompute = true; + susp_check_term_log_samples(width, width_ptr, width_cnt); + susp->width_x1_sample = susp_fetch_sample(width, width_ptr, width_cnt); + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - w1_reg = susp->w1; - sw_reg = susp->sw; - cw_reg = susp->cw; - J_reg = susp->J; - gg_reg = susp->gg; - b0_reg = susp->b0; - b1_reg = susp->b1; - b2_reg = susp->b2; - a0_reg = susp->a0; - a1_reg = susp->a1; - a2_reg = susp->a2; - z1_reg = susp->z1; - z2_reg = susp->z2; - recompute_reg = susp->recompute; - inp_period_reg = susp->inp_period; - width_pHaSe_ReG = susp->width_pHaSe; - width_x1_sample_reg = susp->width_x1_sample; - gain_pHaSe_ReG = susp->gain_pHaSe; - gain_x1_sample_reg = susp->gain_x1_sample; - hz_pHaSe_ReG = susp->hz_pHaSe; - hz_x1_sample_reg = susp->hz_x1_sample; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + w1_reg = susp->w1; + sw_reg = susp->sw; + cw_reg = susp->cw; + J_reg = susp->J; + gg_reg = susp->gg; + b0_reg = susp->b0; + b1_reg = susp->b1; + b2_reg = susp->b2; + a0_reg = susp->a0; + a1_reg = susp->a1; + a2_reg = susp->a2; + z1_reg = susp->z1; + z2_reg = susp->z2; + recompute_reg = susp->recompute; + inp_period_reg = susp->inp_period; + width_pHaSe_ReG = susp->width_pHaSe; + width_x1_sample_reg = susp->width_x1_sample; + gain_pHaSe_ReG = susp->gain_pHaSe; + gain_x1_sample_reg = susp->gain_x1_sample; + hz_pHaSe_ReG = susp->hz_pHaSe; + hz_x1_sample_reg = susp->hz_x1_sample; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; - if (hz_pHaSe_ReG >= 1.0) { + if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ - /* pick up next sample as hz_x1_sample: */ - susp->hz_ptr++; - susp_took(hz_cnt, 1); - hz_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); - hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); - w1_reg = PI2 * hz_x1_sample_reg * inp_period_reg; - sw_reg = sin(w1_reg); - cw_reg = cos(w1_reg); - b1_reg = -2.0 * cw_reg; - a1_reg = -b1_reg; - recompute_reg = true; - } - if (gain_pHaSe_ReG >= 1.0) { + /* pick up next sample as hz_x1_sample: */ + susp->hz_ptr++; + susp_took(hz_cnt, 1); + hz_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); + hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); + w1_reg = PI2 * hz_x1_sample_reg * inp_period_reg; + sw_reg = sin(w1_reg); + cw_reg = cos(w1_reg); + b1_reg = -2.0 * cw_reg; + a1_reg = -b1_reg; + recompute_reg = true; + } + if (gain_pHaSe_ReG >= 1.0) { /* fixup-depends gain */ - /* pick up next sample as gain_x1_sample: */ - susp->gain_ptr++; - susp_took(gain_cnt, 1); - gain_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(gain, gain_ptr, gain_cnt, gain_x1_sample_reg); - gain_x1_sample_reg = susp_current_sample(gain, gain_ptr); - J_reg = sqrt(gain_x1_sample_reg); - recompute_reg = true; - } - if (width_pHaSe_ReG >= 1.0) { + /* pick up next sample as gain_x1_sample: */ + susp->gain_ptr++; + susp_took(gain_cnt, 1); + gain_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(gain, gain_ptr, gain_cnt, gain_x1_sample_reg); + gain_x1_sample_reg = susp_current_sample(gain, gain_ptr); + J_reg = sqrt(gain_x1_sample_reg); + recompute_reg = true; + } + if (width_pHaSe_ReG >= 1.0) { /* fixup-depends width */ - /* pick up next sample as width_x1_sample: */ - susp->width_ptr++; - susp_took(width_cnt, 1); - width_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(width, width_ptr, width_cnt, width_x1_sample_reg); - width_x1_sample_reg = susp_current_sample(width, width_ptr); - recompute_reg = true; - } - if (recompute_reg) { - /* a0_reg = 1.0 + gg_reg / J_reg; */ - double a_0_recip = J_reg / (J_reg + gg_reg); - recompute_reg = false; - gg_reg = sw_reg * sinh(log_of_2_over_2 * - width_x1_sample_reg * w1_reg / sw_reg); - b0_reg = (1.0 + gg_reg * J_reg) * a_0_recip; - b1_reg *= a_0_recip; - b2_reg = (1.0 - gg_reg * J_reg) * a_0_recip; - a1_reg *= a_0_recip; - a2_reg = (gg_reg / J_reg - 1.0) * a_0_recip; - } + /* pick up next sample as width_x1_sample: */ + susp->width_ptr++; + susp_took(width_cnt, 1); + width_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(width, width_ptr, width_cnt, width_x1_sample_reg); + width_x1_sample_reg = susp_current_sample(width, width_ptr); + recompute_reg = true; + } + if (recompute_reg) { + /* a0_reg = 1.0 + gg_reg / J_reg; */ + double a_0_recip = J_reg / (J_reg + gg_reg); + recompute_reg = false; + gg_reg = sw_reg * sinh(log_of_2_over_2 * + width_x1_sample_reg * w1_reg / sw_reg); + b0_reg = (1.0 + gg_reg * J_reg) * a_0_recip; + b1_reg *= a_0_recip; + b2_reg = (1.0 - gg_reg * J_reg) * a_0_recip; + a1_reg *= a_0_recip; + a2_reg = (gg_reg / J_reg - 1.0) * a_0_recip; + } z0 = *input_ptr_reg++ + a1_reg*z1_reg + a2_reg*z2_reg; *out_ptr_reg++ = (sample_type) (z0*b0_reg + z1_reg*b1_reg + z2_reg*b2_reg); z2_reg = z1_reg; z1_reg = z0; - hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; - gain_pHaSe_ReG += gain_pHaSe_iNcR_rEg; - width_pHaSe_ReG += width_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; + gain_pHaSe_ReG += gain_pHaSe_iNcR_rEg; + width_pHaSe_ReG += width_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->z1 = z1_reg; - susp->z2 = z2_reg; - susp->recompute = recompute_reg; - susp->width_pHaSe = width_pHaSe_ReG; - susp->width_x1_sample = width_x1_sample_reg; - susp->gain_pHaSe = gain_pHaSe_ReG; - susp->gain_x1_sample = gain_x1_sample_reg; - susp->hz_pHaSe = hz_pHaSe_ReG; - susp->hz_x1_sample = hz_x1_sample_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + togo -= n; + susp->z1 = z1_reg; + susp->z2 = z2_reg; + susp->recompute = recompute_reg; + susp->width_pHaSe = width_pHaSe_ReG; + susp->width_x1_sample = width_x1_sample_reg; + susp->gain_pHaSe = gain_pHaSe_ReG; + susp->gain_x1_sample = gain_x1_sample_reg; + susp->hz_pHaSe = hz_pHaSe_ReG; + susp->hz_x1_sample = hz_x1_sample_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* eqbandvvv_niii_fetch */ @@ -502,10 +502,10 @@ void eqbandvvv_nrrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz_pHaSe = 1.0; - susp->gain_pHaSe = 1.0; - susp->width_pHaSe = 1.0; + susp->started = true; + susp->hz_pHaSe = 1.0; + susp->gain_pHaSe = 1.0; + susp->width_pHaSe = 1.0; } susp_check_term_log_samples(hz, hz_ptr, hz_cnt); @@ -515,192 +515,192 @@ void eqbandvvv_nrrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp_check_term_log_samples(width, width_ptr, width_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* grab next hz_x1_sample when phase goes past 1.0; */ - /* use hz_n (computed below) to avoid roundoff errors: */ - if (susp->hz_n <= 0) { - susp_check_term_log_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->hz_pHaSe -= 1.0; - /* hz_n gets number of samples before phase exceeds 1.0: */ - susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * - susp->output_per_hz); - susp->w1 = PI2 * susp->hz_x1_sample * susp->inp_period; - susp->sw = sin(susp->w1); - susp->cw = cos(susp->w1); - susp->b1 = -2.0 * susp->cw; - susp->a1 = -susp->b1; - susp->recompute = true; - } - togo = min(togo, susp->hz_n); - hz_val = susp->hz_x1_sample; - /* grab next gain_x1_sample when phase goes past 1.0; */ - /* use gain_n (computed below) to avoid roundoff errors: */ - if (susp->gain_n <= 0) { - susp_check_term_log_samples(gain, gain_ptr, gain_cnt); - susp->gain_x1_sample = susp_fetch_sample(gain, gain_ptr, gain_cnt); - susp->gain_pHaSe -= 1.0; - /* gain_n gets number of samples before phase exceeds 1.0: */ - susp->gain_n = (long) ((1.0 - susp->gain_pHaSe) * - susp->output_per_gain); - susp->J = sqrt(susp->gain_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->gain_n); - gain_val = susp->gain_x1_sample; - /* grab next width_x1_sample when phase goes past 1.0; */ - /* use width_n (computed below) to avoid roundoff errors: */ - if (susp->width_n <= 0) { - susp_check_term_log_samples(width, width_ptr, width_cnt); - susp->width_x1_sample = susp_fetch_sample(width, width_ptr, width_cnt); - susp->width_pHaSe -= 1.0; - /* width_n gets number of samples before phase exceeds 1.0: */ - susp->width_n = (long) ((1.0 - susp->width_pHaSe) * - susp->output_per_width); - susp->recompute = true; - } - togo = min(togo, susp->width_n); - width_val = susp->width_x1_sample; - if (susp->recompute) { - /* susp->a0 = 1.0 + susp->gg / susp->J; */ - double a_0_recip = susp->J / (susp->J + susp->gg); - susp->recompute = false; - susp->gg = susp->sw * sinh(log_of_2_over_2 * - width_val * susp->w1 / susp->sw); - susp->b0 = (1.0 + susp->gg * susp->J) * a_0_recip; - susp->b1 *= a_0_recip; - susp->b2 = (1.0 - susp->gg * susp->J) * a_0_recip; - susp->a1 *= a_0_recip; - susp->a2 = (susp->gg / susp->J - 1.0) * a_0_recip; - } - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz_x1_sample when phase goes past 1.0; */ + /* use hz_n (computed below) to avoid roundoff errors: */ + if (susp->hz_n <= 0) { + susp_check_term_log_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->hz_pHaSe -= 1.0; + /* hz_n gets number of samples before phase exceeds 1.0: */ + susp->hz_n = (int64_t) ((1.0 - susp->hz_pHaSe) * + susp->output_per_hz); + susp->w1 = PI2 * susp->hz_x1_sample * susp->inp_period; + susp->sw = sin(susp->w1); + susp->cw = cos(susp->w1); + susp->b1 = -2.0 * susp->cw; + susp->a1 = -susp->b1; + susp->recompute = true; + } + togo = (int) min(togo, susp->hz_n); + hz_val = susp->hz_x1_sample; + /* grab next gain_x1_sample when phase goes past 1.0; */ + /* use gain_n (computed below) to avoid roundoff errors: */ + if (susp->gain_n <= 0) { + susp_check_term_log_samples(gain, gain_ptr, gain_cnt); + susp->gain_x1_sample = susp_fetch_sample(gain, gain_ptr, gain_cnt); + susp->gain_pHaSe -= 1.0; + /* gain_n gets number of samples before phase exceeds 1.0: */ + susp->gain_n = (int64_t) ((1.0 - susp->gain_pHaSe) * + susp->output_per_gain); + susp->J = sqrt(susp->gain_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->gain_n); + gain_val = susp->gain_x1_sample; + /* grab next width_x1_sample when phase goes past 1.0; */ + /* use width_n (computed below) to avoid roundoff errors: */ + if (susp->width_n <= 0) { + susp_check_term_log_samples(width, width_ptr, width_cnt); + susp->width_x1_sample = susp_fetch_sample(width, width_ptr, width_cnt); + susp->width_pHaSe -= 1.0; + /* width_n gets number of samples before phase exceeds 1.0: */ + susp->width_n = (int64_t) ((1.0 - susp->width_pHaSe) * + susp->output_per_width); + susp->recompute = true; + } + togo = (int) min(togo, susp->width_n); + width_val = susp->width_x1_sample; + if (susp->recompute) { + /* susp->a0 = 1.0 + susp->gg / susp->J; */ + double a_0_recip = susp->J / (susp->J + susp->gg); + susp->recompute = false; + susp->gg = susp->sw * sinh(log_of_2_over_2 * + width_val * susp->w1 / susp->sw); + susp->b0 = (1.0 + susp->gg * susp->J) * a_0_recip; + susp->b1 *= a_0_recip; + susp->b2 = (1.0 - susp->gg * susp->J) * a_0_recip; + susp->a1 *= a_0_recip; + susp->a2 = (susp->gg / susp->J - 1.0) * a_0_recip; + } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - cw_reg = susp->cw; - b0_reg = susp->b0; - b1_reg = susp->b1; - b2_reg = susp->b2; - a1_reg = susp->a1; - a2_reg = susp->a2; - z1_reg = susp->z1; - z2_reg = susp->z2; - inp_period_reg = susp->inp_period; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + cw_reg = susp->cw; + b0_reg = susp->b0; + b1_reg = susp->b1; + b2_reg = susp->b2; + a1_reg = susp->a1; + a2_reg = susp->a2; + z1_reg = susp->z1; + z2_reg = susp->z2; + inp_period_reg = susp->inp_period; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; z0 = *input_ptr_reg++ + a1_reg*z1_reg + a2_reg*z2_reg; *out_ptr_reg++ = (sample_type) (z0*b0_reg + z1_reg*b1_reg + z2_reg*b2_reg); z2_reg = z1_reg; z1_reg = z0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->z1 = z1_reg; - susp->z2 = z2_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; - susp->hz_n -= togo; - susp->gain_pHaSe += togo * susp->gain_pHaSe_iNcR; - susp->gain_n -= togo; - susp->width_pHaSe += togo * susp->width_pHaSe_iNcR; - susp->width_n -= togo; - cnt += togo; + susp->z1 = z1_reg; + susp->z2 = z2_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; + susp->hz_n -= togo; + susp->gain_pHaSe += togo * susp->gain_pHaSe_iNcR; + susp->gain_n -= togo; + susp->width_pHaSe += togo * susp->width_pHaSe_iNcR; + susp->width_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* eqbandvvv_nrrr_fetch */ void eqbandvvv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ eqbandvvv_susp_type susp = (eqbandvvv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* fetch samples from hz up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr)) >= - susp->hz->current) - susp_get_samples(hz, hz_ptr, hz_cnt); + susp->hz->current) + susp_get_samples(hz, hz_ptr, hz_cnt); /* fetch samples from gain up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->gain->t0) * susp->gain->sr)) >= - susp->gain->current) - susp_get_samples(gain, gain_ptr, gain_cnt); + susp->gain->current) + susp_get_samples(gain, gain_ptr, gain_cnt); /* fetch samples from width up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->width->t0) * susp->width->sr)) >= - susp->width->current) - susp_get_samples(width, width_ptr, width_cnt); + susp->width->current) + susp_get_samples(width, width_ptr, width_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); - n = ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - + n = (int) ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - (susp->hz->current - susp->hz_cnt)); susp->hz_ptr += n; susp_took(hz_cnt, n); - n = ROUNDBIG((final_time - susp->gain->t0) * susp->gain->sr - + n = (int) ROUNDBIG((final_time - susp->gain->t0) * susp->gain->sr - (susp->gain->current - susp->gain_cnt)); susp->gain_ptr += n; susp_took(gain_cnt, n); - n = ROUNDBIG((final_time - susp->width->t0) * susp->width->sr - + n = (int) ROUNDBIG((final_time - susp->width->t0) * susp->width->sr - (susp->width->current - susp->width_cnt)); susp->width_ptr += n; susp_took(width_cnt, n); @@ -759,7 +759,7 @@ sound_type snd_make_eqbandvvv(sound_type input, sound_type hz, sound_type gain, int interp_desc = 0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - long lsc; + int64_t lsc; /* combine scale factors of linear inputs (INPUT) */ scale_factor *= input->scale; input->scale = 1.0F; diff --git a/lib-src/libnyquist/nyquist/tran/exp.c b/lib-src/libnyquist/nyquist/tran/exp.c index 9cc35cac0..c198c4701 100644 --- a/lib-src/libnyquist/nyquist/tran/exp.c +++ b/lib-src/libnyquist/nyquist/tran/exp.c @@ -14,10 +14,10 @@ void exp_free(snd_susp_type a_susp); typedef struct exp_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type in; - long in_cnt; + int in_cnt; sample_block_values_type in_ptr; } exp_susp_node, *exp_susp_type; @@ -40,91 +40,91 @@ void exp_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the in input sample block: */ - susp_check_term_log_samples(in, in_ptr, in_cnt); - togo = min(togo, susp->in_cnt); + /* don't run past the in input sample block: */ + susp_check_term_log_samples(in, in_ptr, in_cnt); + togo = min(togo, susp->in_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - in_ptr_reg = susp->in_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + in_ptr_reg = susp->in_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) exp((in_scale_reg * *in_ptr_reg++)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using in_ptr_reg is a bad idea on RS/6000: */ - susp->in_ptr += togo; - out_ptr += togo; - susp_took(in_cnt, togo); - cnt += togo; + /* using in_ptr_reg is a bad idea on RS/6000: */ + susp->in_ptr += togo; + out_ptr += togo; + susp_took(in_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* exp_s_fetch */ void exp_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ exp_susp_type susp = (exp_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from in up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->in->t0) * susp->in->sr)) >= - susp->in->current) - susp_get_samples(in, in_ptr, in_cnt); + susp->in->current) + susp_get_samples(in, in_ptr, in_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->in->t0) * susp->in->sr - + n = (int) ROUNDBIG((final_time - susp->in->t0) * susp->in->sr - (susp->in->current - susp->in_cnt)); susp->in_ptr += n; susp_took(in_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/fmfb.alg b/lib-src/libnyquist/nyquist/tran/fmfb.alg index 0bc2b7e67..153292292 100644 --- a/lib-src/libnyquist/nyquist/tran/fmfb.alg +++ b/lib-src/libnyquist/nyquist/tran/fmfb.alg @@ -19,7 +19,7 @@ while (yy < 0) yy += SINE_TABLE_LEN; sin_y = sine_table[(int) yy]; /* truncation gets valid index */ /* sin_y is now a signal not ready for table lookup */ - output = sin_y") + output = (sample_type) sin_y") (CONSTANT "x_incr") (SAMPLE-RATE "sr") (SUPPORT-HEADER "#include \"sine.h\" /* sine_table and SINE_TABLE_LEN */\n") diff --git a/lib-src/libnyquist/nyquist/tran/fmfb.c b/lib-src/libnyquist/nyquist/tran/fmfb.c index fb5c37b55..44ee0cf61 100644 --- a/lib-src/libnyquist/nyquist/tran/fmfb.c +++ b/lib-src/libnyquist/nyquist/tran/fmfb.c @@ -14,7 +14,7 @@ void fmfb_free(snd_susp_type a_susp); typedef struct fmfb_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; double yy; double sin_y; @@ -45,26 +45,26 @@ void fmfb__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - yy_reg = susp->yy; - sin_y_reg = susp->sin_y; - xx_reg = susp->xx; - x_incr_reg = susp->x_incr; - index_reg = susp->index; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + yy_reg = susp->yy; + sin_y_reg = susp->sin_y; + xx_reg = susp->xx; + x_incr_reg = susp->x_incr; + index_reg = susp->index; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ xx_reg += x_incr_reg; if (xx_reg > SINE_TABLE_LEN) xx_reg -= SINE_TABLE_LEN; /* xx_reg incremented and index_reg scaled to table index_reg, and @@ -75,23 +75,23 @@ void fmfb__fetch(snd_susp_type a_susp, snd_list_type snd_list) while (yy_reg < 0) yy_reg += SINE_TABLE_LEN; sin_y_reg = sine_table[(int) yy_reg]; /* truncation gets valid index_reg */ /* sin_y_reg is now a signal not ready for table lookup */ - *out_ptr_reg++ = sin_y_reg; - } while (--n); /* inner loop */ + *out_ptr_reg++ = (sample_type) sin_y_reg; + } while (--n); /* inner loop */ - susp->yy = yy_reg; - susp->sin_y = sin_y_reg; - susp->xx = xx_reg; - susp->index = index_reg; - out_ptr += togo; - cnt += togo; + susp->yy = yy_reg; + susp->sin_y = sin_y_reg; + susp->xx = xx_reg; + susp->index = index_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* fmfb__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/fmfbv.alg b/lib-src/libnyquist/nyquist/tran/fmfbv.alg index 5295c29e4..f1c40916c 100644 --- a/lib-src/libnyquist/nyquist/tran/fmfbv.alg +++ b/lib-src/libnyquist/nyquist/tran/fmfbv.alg @@ -10,7 +10,7 @@ ("double" "sin_y" "0.0") ("double" "phase" "0.0") ("double" "ph_incr" "hz * SINE_TABLE_LEN / sr; - index->scale *= SINE_TABLE_LEN / PI2 + index->scale *= SINE_TABLE_LEN / (sample_type) PI2 ")) (INNER-LOOP "phase += ph_incr; if (phase > SINE_TABLE_LEN) phase -= SINE_TABLE_LEN; @@ -22,7 +22,7 @@ while (yy < 0) yy += SINE_TABLE_LEN; sin_y = sine_table[(int) yy]; /* truncation gets valid index */ /* sin_y is now a signal ready for table lookup */ - output = sin_y") + output = (sample_type) sin_y") (CONSTANT "ph_incr") (SAMPLE-RATE "sr") (SUPPORT-HEADER "#include \"sine.h\" /* sine_table and SINE_TABLE_LEN */ diff --git a/lib-src/libnyquist/nyquist/tran/fmfbv.c b/lib-src/libnyquist/nyquist/tran/fmfbv.c index 1384243b2..537e34a5c 100644 --- a/lib-src/libnyquist/nyquist/tran/fmfbv.c +++ b/lib-src/libnyquist/nyquist/tran/fmfbv.c @@ -15,10 +15,10 @@ void fmfbv_free(snd_susp_type a_susp); typedef struct fmfbv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type index; - long index_cnt; + int index_cnt; sample_block_values_type index_ptr; /* support for interpolation of index */ @@ -28,7 +28,7 @@ typedef struct fmfbv_susp_struct { /* support for ramp between samples of index */ double output_per_index; - long index_n; + int64_t index_n; double yy; double sin_y; @@ -58,56 +58,56 @@ void fmfbv_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the index input sample block: */ - susp_check_term_log_samples(index, index_ptr, index_cnt); - togo = min(togo, susp->index_cnt); + /* don't run past the index input sample block: */ + susp_check_term_log_samples(index, index_ptr, index_cnt); + togo = min(togo, susp->index_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - yy_reg = susp->yy; - sin_y_reg = susp->sin_y; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - index_ptr_reg = susp->index_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + yy_reg = susp->yy; + sin_y_reg = susp->sin_y; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + index_ptr_reg = susp->index_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ phase_reg += ph_incr_reg; if (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* PHASE is incremented and INDEX scaled to table INDEX, and @@ -118,31 +118,31 @@ void fmfbv_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (yy_reg < 0) yy_reg += SINE_TABLE_LEN; sin_y_reg = sine_table[(int) yy_reg]; /* truncation gets valid index */ /* sin_y_reg is now a signal ready for table lookup */ - *out_ptr_reg++ = sin_y_reg; - } while (--n); /* inner loop */ + *out_ptr_reg++ = (sample_type) sin_y_reg; + } while (--n); /* inner loop */ - susp->yy = yy_reg; - susp->sin_y = sin_y_reg; - susp->phase = phase_reg; - /* using index_ptr_reg is a bad idea on RS/6000: */ - susp->index_ptr += togo; - out_ptr += togo; - susp_took(index_cnt, togo); - cnt += togo; + susp->yy = yy_reg; + susp->sin_y = sin_y_reg; + susp->phase = phase_reg; + /* using index_ptr_reg is a bad idea on RS/6000: */ + susp->index_ptr += togo; + out_ptr += togo; + susp_took(index_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmfbv_n_fetch */ @@ -169,56 +169,56 @@ void fmfbv_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the index input sample block: */ - susp_check_term_log_samples(index, index_ptr, index_cnt); - togo = min(togo, susp->index_cnt); + /* don't run past the index input sample block: */ + susp_check_term_log_samples(index, index_ptr, index_cnt); + togo = min(togo, susp->index_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - yy_reg = susp->yy; - sin_y_reg = susp->sin_y; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - index_ptr_reg = susp->index_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + yy_reg = susp->yy; + sin_y_reg = susp->sin_y; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + index_ptr_reg = susp->index_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ phase_reg += ph_incr_reg; if (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* PHASE is incremented and INDEX scaled to table INDEX, and @@ -229,31 +229,31 @@ void fmfbv_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (yy_reg < 0) yy_reg += SINE_TABLE_LEN; sin_y_reg = sine_table[(int) yy_reg]; /* truncation gets valid index */ /* sin_y_reg is now a signal ready for table lookup */ - *out_ptr_reg++ = sin_y_reg; - } while (--n); /* inner loop */ + *out_ptr_reg++ = (sample_type) sin_y_reg; + } while (--n); /* inner loop */ - susp->yy = yy_reg; - susp->sin_y = sin_y_reg; - susp->phase = phase_reg; - /* using index_ptr_reg is a bad idea on RS/6000: */ - susp->index_ptr += togo; - out_ptr += togo; - susp_took(index_cnt, togo); - cnt += togo; + susp->yy = yy_reg; + susp->sin_y = sin_y_reg; + susp->phase = phase_reg; + /* using index_ptr_reg is a bad idea on RS/6000: */ + susp->index_ptr += togo; + out_ptr += togo; + susp_took(index_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmfbv_s_fetch */ @@ -282,68 +282,68 @@ void fmfbv_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(index, index_ptr, index_cnt); - susp->index_x1_sample = susp_fetch_sample(index, index_ptr, index_cnt); + susp->started = true; + susp_check_term_log_samples(index, index_ptr, index_cnt); + susp->index_x1_sample = susp_fetch_sample(index, index_ptr, index_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - yy_reg = susp->yy; - sin_y_reg = susp->sin_y; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - index_pHaSe_ReG = susp->index_pHaSe; - index_x1_sample_reg = susp->index_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (index_pHaSe_ReG >= 1.0) { + n = togo; + yy_reg = susp->yy; + sin_y_reg = susp->sin_y; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + index_pHaSe_ReG = susp->index_pHaSe; + index_x1_sample_reg = susp->index_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (index_pHaSe_ReG >= 1.0) { /* fixup-depends index */ - /* pick up next sample as index_x1_sample: */ - susp->index_ptr++; - susp_took(index_cnt, 1); - index_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(index, index_ptr, index_cnt, index_x1_sample_reg); - index_x1_sample_reg = susp_current_sample(index, index_ptr); - } + /* pick up next sample as index_x1_sample: */ + susp->index_ptr++; + susp_took(index_cnt, 1); + index_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(index, index_ptr, index_cnt, index_x1_sample_reg); + index_x1_sample_reg = susp_current_sample(index, index_ptr); + } phase_reg += ph_incr_reg; if (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* PHASE is incremented and INDEX scaled to table INDEX, and @@ -354,32 +354,32 @@ void fmfbv_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (yy_reg < 0) yy_reg += SINE_TABLE_LEN; sin_y_reg = sine_table[(int) yy_reg]; /* truncation gets valid index */ /* sin_y_reg is now a signal ready for table lookup */ - *out_ptr_reg++ = sin_y_reg; - index_pHaSe_ReG += index_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + *out_ptr_reg++ = (sample_type) sin_y_reg; + index_pHaSe_ReG += index_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->yy = yy_reg; - susp->sin_y = sin_y_reg; - susp->phase = phase_reg; - susp->index_pHaSe = index_pHaSe_ReG; - susp->index_x1_sample = index_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->yy = yy_reg; + susp->sin_y = sin_y_reg; + susp->phase = phase_reg; + susp->index_pHaSe = index_pHaSe_ReG; + susp->index_x1_sample = index_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmfbv_i_fetch */ @@ -406,70 +406,70 @@ void fmfbv_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->index_pHaSe = 1.0; + susp->started = true; + susp->index_pHaSe = 1.0; } susp_check_term_log_samples(index, index_ptr, index_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next index_x1_sample when phase goes past 1.0; */ - /* use index_n (computed below) to avoid roundoff errors: */ - if (susp->index_n <= 0) { - susp_check_term_log_samples(index, index_ptr, index_cnt); - susp->index_x1_sample = susp_fetch_sample(index, index_ptr, index_cnt); - susp->index_pHaSe -= 1.0; - /* index_n gets number of samples before phase exceeds 1.0: */ - susp->index_n = (long) ((1.0 - susp->index_pHaSe) * - susp->output_per_index); - } - togo = min(togo, susp->index_n); - index_val = susp->index_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next index_x1_sample when phase goes past 1.0; */ + /* use index_n (computed below) to avoid roundoff errors: */ + if (susp->index_n <= 0) { + susp_check_term_log_samples(index, index_ptr, index_cnt); + susp->index_x1_sample = susp_fetch_sample(index, index_ptr, index_cnt); + susp->index_pHaSe -= 1.0; + /* index_n gets number of samples before phase exceeds 1.0: */ + susp->index_n = (int64_t) ((1.0 - susp->index_pHaSe) * + susp->output_per_index); + } + togo = (int) min(togo, susp->index_n); + index_val = susp->index_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - yy_reg = susp->yy; - sin_y_reg = susp->sin_y; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + yy_reg = susp->yy; + sin_y_reg = susp->sin_y; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ phase_reg += ph_incr_reg; if (phase_reg > SINE_TABLE_LEN) phase_reg -= SINE_TABLE_LEN; /* PHASE is incremented and INDEX scaled to table INDEX, and @@ -480,47 +480,47 @@ void fmfbv_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (yy_reg < 0) yy_reg += SINE_TABLE_LEN; sin_y_reg = sine_table[(int) yy_reg]; /* truncation gets valid index */ /* sin_y_reg is now a signal ready for table lookup */ - *out_ptr_reg++ = sin_y_reg; - } while (--n); /* inner loop */ + *out_ptr_reg++ = (sample_type) sin_y_reg; + } while (--n); /* inner loop */ - susp->yy = yy_reg; - susp->sin_y = sin_y_reg; - susp->phase = phase_reg; - out_ptr += togo; - susp->index_pHaSe += togo * susp->index_pHaSe_iNcR; - susp->index_n -= togo; - cnt += togo; + susp->yy = yy_reg; + susp->sin_y = sin_y_reg; + susp->phase = phase_reg; + out_ptr += togo; + susp->index_pHaSe += togo * susp->index_pHaSe_iNcR; + susp->index_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmfbv_r_fetch */ void fmfbv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ fmfbv_susp_type susp = (fmfbv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from index up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->index->t0) * susp->index->sr)) >= - susp->index->current) - susp_get_samples(index, index_ptr, index_cnt); + susp->index->current) + susp_get_samples(index, index_ptr, index_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->index->t0) * susp->index->sr - + n = (int) ROUNDBIG((final_time - susp->index->t0) * susp->index->sr - (susp->index->current - susp->index_cnt)); susp->index_ptr += n; susp_took(index_cnt, n); @@ -566,7 +566,7 @@ sound_type snd_make_fmfbv(time_type t0, double hz, rate_type sr, sound_type inde susp->sin_y = 0.0; susp->phase = 0.0; susp->ph_incr = hz * SINE_TABLE_LEN / sr; - index->scale *= SINE_TABLE_LEN / PI2 + index->scale *= SINE_TABLE_LEN / (sample_type) PI2 ; /* make sure no sample rate is too high */ diff --git a/lib-src/libnyquist/nyquist/tran/fmosc.c b/lib-src/libnyquist/nyquist/tran/fmosc.c index eca494220..a30ffd3ec 100644 --- a/lib-src/libnyquist/nyquist/tran/fmosc.c +++ b/lib-src/libnyquist/nyquist/tran/fmosc.c @@ -15,10 +15,10 @@ void fmosc_free(snd_susp_type a_susp); typedef struct fmosc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s_fm; - long s_fm_cnt; + int s_fm_cnt; sample_block_values_type s_fm_ptr; /* support for interpolation of s_fm */ @@ -28,7 +28,7 @@ typedef struct fmosc_susp_struct { /* support for ramp between samples of s_fm */ double output_per_s_fm; - long s_fm_n; + int64_t s_fm_n; table_type the_table; double table_len; @@ -60,56 +60,56 @@ void fmosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s_fm input sample block: */ - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - togo = min(togo, susp->s_fm_cnt); + /* don't run past the s_fm input sample block: */ + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + togo = min(togo, susp->s_fm_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - phase_reg = susp->phase; - s_fm_ptr_reg = susp->s_fm_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + phase_reg = susp->phase; + s_fm_ptr_reg = susp->s_fm_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; @@ -120,28 +120,28 @@ void fmosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - /* using s_fm_ptr_reg is a bad idea on RS/6000: */ - susp->s_fm_ptr += togo; - out_ptr += togo; - susp_took(s_fm_cnt, togo); - cnt += togo; + susp->phase = phase_reg; + /* using s_fm_ptr_reg is a bad idea on RS/6000: */ + susp->s_fm_ptr += togo; + out_ptr += togo; + susp_took(s_fm_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmosc_s_fetch */ @@ -170,70 +170,70 @@ void fmosc_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->started = true; + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - phase_reg = susp->phase; - s_fm_pHaSe_ReG = susp->s_fm_pHaSe; - s_fm_x1_sample_reg = susp->s_fm_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + phase_reg = susp->phase; + s_fm_pHaSe_ReG = susp->s_fm_pHaSe; + s_fm_x1_sample_reg = susp->s_fm_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; - if (s_fm_pHaSe_ReG >= 1.0) { + if (s_fm_pHaSe_ReG >= 1.0) { /* fixup-depends s_fm */ - /* pick up next sample as s_fm_x1_sample: */ - susp->s_fm_ptr++; - susp_took(s_fm_cnt, 1); - s_fm_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); - s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); - } + /* pick up next sample as s_fm_x1_sample: */ + susp->s_fm_ptr++; + susp_took(s_fm_cnt, 1); + s_fm_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); + s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); + } table_index = (long) phase_reg; x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * @@ -242,29 +242,29 @@ void fmosc_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = phase_reg; - susp->s_fm_pHaSe = s_fm_pHaSe_ReG; - susp->s_fm_x1_sample = s_fm_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = phase_reg; + susp->s_fm_pHaSe = s_fm_pHaSe_ReG; + susp->s_fm_x1_sample = s_fm_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmosc_i_fetch */ @@ -291,70 +291,70 @@ void fmosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_fm_pHaSe = 1.0; + susp->started = true; + susp->s_fm_pHaSe = 1.0; } susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_fm_x1_sample when phase goes past 1.0; */ - /* use s_fm_n (computed below) to avoid roundoff errors: */ - if (susp->s_fm_n <= 0) { - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_pHaSe -= 1.0; - /* s_fm_n gets number of samples before phase exceeds 1.0: */ - susp->s_fm_n = (long) ((1.0 - susp->s_fm_pHaSe) * - susp->output_per_s_fm); - } - togo = min(togo, susp->s_fm_n); - s_fm_val = susp->s_fm_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next s_fm_x1_sample when phase goes past 1.0; */ + /* use s_fm_n (computed below) to avoid roundoff errors: */ + if (susp->s_fm_n <= 0) { + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_pHaSe -= 1.0; + /* s_fm_n gets number of samples before phase exceeds 1.0: */ + susp->s_fm_n = (int64_t) ((1.0 - susp->s_fm_pHaSe) * + susp->output_per_s_fm); + } + togo = (int) min(togo, susp->s_fm_n); + s_fm_val = susp->s_fm_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - phase_reg = susp->phase; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + phase_reg = susp->phase; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; @@ -365,44 +365,44 @@ void fmosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - out_ptr += togo; - susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; - susp->s_fm_n -= togo; - cnt += togo; + susp->phase = phase_reg; + out_ptr += togo; + susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; + susp->s_fm_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* fmosc_r_fetch */ void fmosc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ fmosc_susp_type susp = (fmosc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s_fm up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr)) >= - susp->s_fm->current) - susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm->current) + susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - + n = (int) ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - (susp->s_fm->current - susp->s_fm_cnt)); susp->s_fm_ptr += n; susp_took(s_fm_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/follow.c b/lib-src/libnyquist/nyquist/tran/follow.c index e41418cc7..0c680b2bf 100644 --- a/lib-src/libnyquist/nyquist/tran/follow.c +++ b/lib-src/libnyquist/nyquist/tran/follow.c @@ -14,9 +14,9 @@ void follow_free(snd_susp_type a_susp); typedef struct follow_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type sndin; - long sndin_cnt; + int sndin_cnt; sample_block_values_type sndin_ptr; long lookahead; @@ -101,33 +101,33 @@ void follow_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the sndin input sample block: */ - susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); - togo = min(togo, susp->sndin_cnt); + /* don't run past the sndin input sample block: */ + susp_check_term_samples(sndin, sndin_ptr, sndin_cnt); + togo = min(togo, susp->sndin_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - lookahead_reg = susp->lookahead; - delayptr_reg = susp->delayptr; - prevptr_reg = susp->prevptr; - endptr_reg = susp->endptr; - floor_reg = susp->floor; - rise_factor_reg = susp->rise_factor; - fall_factor_reg = susp->fall_factor; - sndin_ptr_reg = susp->sndin_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + lookahead_reg = susp->lookahead; + delayptr_reg = susp->delayptr; + prevptr_reg = susp->prevptr; + endptr_reg = susp->endptr; + floor_reg = susp->floor; + rise_factor_reg = susp->rise_factor; + fall_factor_reg = susp->fall_factor; + sndin_ptr_reg = susp->sndin_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ sample_type current = (sndin_scale_reg * *sndin_ptr_reg++); sample_type high = (sample_type) (*prevptr_reg * rise_factor_reg); sample_type low = (sample_type) (*prevptr_reg * fall_factor_reg); @@ -166,43 +166,43 @@ void follow_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) prevptr_reg = delayptr_reg++; if (delayptr_reg == endptr_reg) delayptr_reg = susp->delaybuf; *out_ptr_reg++ = *delayptr_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - togo -= n; - susp->lookahead = lookahead_reg; - susp->delayptr = delayptr_reg; - susp->prevptr = prevptr_reg; - susp->floor = floor_reg; - /* using sndin_ptr_reg is a bad idea on RS/6000: */ - susp->sndin_ptr += togo; - out_ptr += togo; - susp_took(sndin_cnt, togo); - cnt += togo; + togo -= n; + susp->lookahead = lookahead_reg; + susp->delayptr = delayptr_reg; + susp->prevptr = prevptr_reg; + susp->floor = floor_reg; + /* using sndin_ptr_reg is a bad idea on RS/6000: */ + susp->sndin_ptr += togo; + out_ptr += togo; + susp_took(sndin_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* follow_s_fetch */ void follow_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ follow_susp_type susp = (follow_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from sndin up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr)) >= - susp->sndin->current) - susp_get_samples(sndin, sndin_ptr, sndin_cnt); + susp->sndin->current) + susp_get_samples(sndin, sndin_ptr, sndin_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr - + n = (int) ROUNDBIG((final_time - susp->sndin->t0) * susp->sndin->sr - (susp->sndin->current - susp->sndin_cnt)); susp->sndin_ptr += n; susp_took(sndin_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/follow.h b/lib-src/libnyquist/nyquist/tran/follow.h index 6dbc3bbf4..58e3e32c6 100644 --- a/lib-src/libnyquist/nyquist/tran/follow.h +++ b/lib-src/libnyquist/nyquist/tran/follow.h @@ -1,3 +1,3 @@ sound_type snd_make_follow(sound_type sndin, double floor, double risetime, double falltime, long lookahead); sound_type snd_follow(sound_type sndin, double floor, double risetime, double falltime, long lookahead); - /* LISP: (snd-follow SOUND ANYNUM ANYNUM ANYNUM FIXNUM) */ + /* LISP: (snd-follow SOUND ANYNUM ANYNUM ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/fromarraystream.c b/lib-src/libnyquist/nyquist/tran/fromarraystream.c index b7db2c76b..409b0425d 100644 --- a/lib-src/libnyquist/nyquist/tran/fromarraystream.c +++ b/lib-src/libnyquist/nyquist/tran/fromarraystream.c @@ -52,9 +52,9 @@ void fromarraystream__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; if (susp->src == NULL) { @@ -96,25 +96,25 @@ out: togo = 0; /* indicate termination */ } togo = min(togo, susp->length - susp->index); - n = togo; - index_reg = susp->index; - samples_reg = susp->samples; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + index_reg = susp->index; + samples_reg = susp->samples; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = samples_reg[index_reg++]; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->index = index_reg; - out_ptr += togo; - cnt += togo; + susp->index = index_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* fromarraystream__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/fromobject.c b/lib-src/libnyquist/nyquist/tran/fromobject.c index edb758c37..7bc4dc052 100644 --- a/lib-src/libnyquist/nyquist/tran/fromobject.c +++ b/lib-src/libnyquist/nyquist/tran/fromobject.c @@ -47,20 +47,20 @@ void fromobject__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; if (susp->done) { togo = 0; /* indicate termination */ break; /* we're done */ } - n = togo; - done_reg = susp->done; - src_reg = susp->src; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + done_reg = susp->done; + src_reg = susp->src; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ LVAL rslt = xleval(cons(s_send, cons(src_reg, consa(s_next)))); if (floatp(rslt)) { @@ -70,20 +70,20 @@ void fromobject__fetch(snd_susp_type a_susp, snd_list_type snd_list) /* adjust togo to what it should have been */ break; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - togo -= n; - susp->done = done_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->done = done_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* fromobject__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/gate.alg b/lib-src/libnyquist/nyquist/tran/gate.alg index 576ef5510..e7cd45727 100644 --- a/lib-src/libnyquist/nyquist/tran/gate.alg +++ b/lib-src/libnyquist/nyquist/tran/gate.alg @@ -37,8 +37,8 @@ points, remembered as sample counts are saved in variables: off_count -- the time at which the fall should begin rise_factor -- multiply by this to get exponential rise fall_factor -- multiply by this to get exponential fall - rise_time -- number of samples for a full rise - fall_time -- number of samples for a full fall + rise_samps -- number of samples for a full rise + fall_samps -- number of samples for a full fall floor -- the lowest value to output threshold -- compare the signal s to this value start_rise -- the sample count at which a rise begins @@ -58,48 +58,52 @@ computing fall_factor: void compute_start_rise(gate_susp_type susp) { /* to compute when to start rise to achieve 0dB at on_count: - By similar triangles: - truncated rise time truncated fall time - ------------------- == ------------------- - full rise time full fall time - when you enter ST_FALL, set start_fall = now - then if (on_count - start_fall) < (rise_time + fall_time) - then start rise at - on_time - rise_time * (on_count-start_fall)/(rise_time+fall_time) + let frt = full rise time = rise_time, art = actual rise time, + fft = full fall time = fall_time, aft = actual fall time + If there's no time for a fft + frt, scale both the the fall time + and rise times proportionally by available time / (fft + frt). + + When you enter ST_FALL, set start_fall = now. + Let avail = available time = (on_count - start_fall). + If there is not enough time for a full fall and full rise, + i.e. if avail < (fft + frt) then let + art = frt * avail / (fft + frt) + So start rise at + on_time - rise_time * (on_count-start_fall)/(rise_time+fall_time) */ - long total = (long) (susp->rise_time + susp->fall_time); + int64_t total = susp->rise_samps + susp->fall_samps; if ((susp->on_count - susp->start_fall) < total) { - susp->start_rise = (long) (susp->on_count - - (susp->rise_time * susp->on_count - susp->start_fall) / total); - } else susp->start_rise = (long) (susp->on_count - susp->rise_time); + susp->start_rise = susp->on_count - + (susp->rise_samps * (susp->on_count - susp->start_fall)) / total; + } else susp->start_rise = susp->on_count - susp->rise_samps; } ") (STATE - ("double" "rise_time" "signal->sr * risetime + 0.5") - ("double" "fall_time" "signal->sr * falltime + 0.5") - ("double" "floor" "floor; floor = log(floor);") - ("double" "threshold" "threshold") - ("long" "on_count" "0") - ("long" "off_count" "0") - ("double" "rise_factor" "exp(- floor / susp->rise_time)") - ("double" "fall_factor" "exp(floor / susp->fall_time)") - ("long" "start_fall" "0") - ("long" "start_rise" "0") - ("long" "stop_count" "0") + ("int64_t" "rise_samps" "(int64_t) (signal->sr * risetime + 0.5)") + ("int64_t" "fall_samps" "(int64_t) (signal->sr * falltime + 0.5)") + ("double" "floor" "floor; floor = log(floor / signal->scale)") + ("double" "threshold" "threshold; threshold /= signal->scale") + ("int64_t" "on_count" "0") + ("int64_t" "off_count" "0") + ("double" "rise_factor" "exp(- floor / susp->rise_samps)") + ("double" "fall_factor" "exp(floor / susp->fall_samps)") + ("int64_t" "start_fall" "-susp->fall_samps") + ("int64_t" "start_rise" "0") + ("int64_t" "stop_count" "0") ("long" "delay_len" "max(1, ROUND32(signal->sr * lookahead))") ("int" "state" "ST_OFF") ("double" "value" "susp->floor")) -(CONSTANT "lookahead" "rise_time" "fall_time" "floor" - "threshold" "delay_len" "end_ptr" +(CONSTANT "lookahead" "rise_time" "rise_samps" "fall_time" "fall_samps" + "floor" "threshold" "delay_len" "end_ptr" "rise_factor" "fall_factor") -(NOT-REGISTER delay_buf rise_factor fall_factor rise_time fall_time floor - on_count start_fall start_rise) -(LINEAR signal) +(NOT-REGISTER delay_buf rise_factor fall_factor rise_time rise_samps + fall_time fall_samps floor on_count start_fall start_rise) (TERMINATE (MIN signal)) +(INTERNAL-SCALING signal) (INNER-LOOP "{ sample_type future = signal; - long now = susp->susp.current + cnt + togo - n; + int64_t now = susp->susp.current + cnt + togo - n; switch (state) { /* hold at 1.0 and look for the moment to begin fall: */ @@ -108,12 +112,13 @@ void compute_start_rise(gate_susp_type susp) off_count = now + delay_len; } else if (now >= off_count) { state = ST_FALL; - stop_count = (long) (now + susp->fall_time); + stop_count = now + susp->fall_samps; susp->start_fall = now; } break; /* fall until stop_count while looking for next rise time */ case ST_FALL: + value *= susp->fall_factor; if (future >= threshold) { off_count = susp->on_count = now + delay_len; compute_start_rise(susp); @@ -121,7 +126,7 @@ void compute_start_rise(gate_susp_type susp) } else if (now == stop_count) { state = ST_OFF; value = susp->floor; - } else value *= susp->fall_factor; + } break; /* fall until start_rise while looking for next fall time */ case ST_FALL_UNTIL: @@ -141,10 +146,14 @@ void compute_start_rise(gate_susp_type susp) if (future >= threshold) { off_count = susp->on_count = now + delay_len; compute_start_rise(susp); - state = ST_OFF_UNTIL; + if (now >= susp->start_rise) { + state = ST_RISE; + } else { + state = ST_OFF_UNTIL; + } } break; - /* hold at floor until start_rise while looking for next fall time */ + /* hold at floor until start_rise and look for next fall time */ case ST_OFF_UNTIL: if (future >= threshold) { off_count = now + delay_len; diff --git a/lib-src/libnyquist/nyquist/tran/gate.c b/lib-src/libnyquist/nyquist/tran/gate.c index 8ae4c498f..41020e96d 100644 --- a/lib-src/libnyquist/nyquist/tran/gate.c +++ b/lib-src/libnyquist/nyquist/tran/gate.c @@ -14,22 +14,22 @@ void gate_free(snd_susp_type a_susp); typedef struct gate_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type signal; - long signal_cnt; + int signal_cnt; sample_block_values_type signal_ptr; - double rise_time; - double fall_time; + int64_t rise_samps; + int64_t fall_samps; double floor; double threshold; - long on_count; - long off_count; + int64_t on_count; + int64_t off_count; double rise_factor; double fall_factor; - long start_fall; - long start_rise; - long stop_count; + int64_t start_fall; + int64_t start_rise; + int64_t stop_count; long delay_len; int state; double value; @@ -68,8 +68,8 @@ points, remembered as sample counts are saved in variables: off_count -- the time at which the fall should begin rise_factor -- multiply by this to get exponential rise fall_factor -- multiply by this to get exponential fall - rise_time -- number of samples for a full rise - fall_time -- number of samples for a full fall + rise_samps -- number of samples for a full rise + fall_samps -- number of samples for a full fall floor -- the lowest value to output threshold -- compare the signal s to this value start_rise -- the sample count at which a rise begins @@ -89,20 +89,24 @@ computing fall_factor: void compute_start_rise(gate_susp_type susp) { /* to compute when to start rise to achieve 0dB at on_count: - By similar triangles: - truncated rise time truncated fall time - ------------------- == ------------------- - full rise time full fall time - when you enter ST_FALL, set start_fall = now - then if (on_count - start_fall) < (rise_time + fall_time) - then start rise at - on_time - rise_time * (on_count-start_fall)/(rise_time+fall_time) + let frt = full rise time = rise_time, art = actual rise time, + fft = full fall time = fall_time, aft = actual fall time + If there's no time for a fft + frt, scale both the the fall time + and rise times proportionally by available time / (fft + frt). + + When you enter ST_FALL, set start_fall = now. + Let avail = available time = (on_count - start_fall). + If there is not enough time for a full fall and full rise, + i.e. if avail < (fft + frt) then let + art = frt * avail / (fft + frt) + So start rise at + on_time - rise_time * (on_count-start_fall)/(rise_time+fall_time) */ - long total = (long) (susp->rise_time + susp->fall_time); + int64_t total = susp->rise_samps + susp->fall_samps; if ((susp->on_count - susp->start_fall) < total) { - susp->start_rise = (long) (susp->on_count - - (susp->rise_time * susp->on_count - susp->start_fall) / total); - } else susp->start_rise = (long) (susp->on_count - susp->rise_time); + susp->start_rise = susp->on_count - + (susp->rise_samps * (susp->on_count - susp->start_fall)) / total; + } else susp->start_rise = susp->on_count - susp->rise_samps; } @@ -118,8 +122,8 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_block_values_type out_ptr_reg; register double threshold_reg; - register long off_count_reg; - register long stop_count_reg; + register int64_t off_count_reg; + register int64_t stop_count_reg; register long delay_len_reg; register int state_reg; register double value_reg; @@ -129,35 +133,35 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the signal input sample block: */ - susp_check_term_samples(signal, signal_ptr, signal_cnt); - togo = min(togo, susp->signal_cnt); + /* don't run past the signal input sample block: */ + susp_check_term_samples(signal, signal_ptr, signal_cnt); + togo = min(togo, susp->signal_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - threshold_reg = susp->threshold; - off_count_reg = susp->off_count; - stop_count_reg = susp->stop_count; - delay_len_reg = susp->delay_len; - state_reg = susp->state; - value_reg = susp->value; - signal_ptr_reg = susp->signal_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + threshold_reg = susp->threshold; + off_count_reg = susp->off_count; + stop_count_reg = susp->stop_count; + delay_len_reg = susp->delay_len; + state_reg = susp->state; + value_reg = susp->value; + signal_ptr_reg = susp->signal_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { sample_type future = *signal_ptr_reg++; - long now = susp->susp.current + cnt + togo - n; + int64_t now = susp->susp.current + cnt + togo - n; switch (state_reg) { /* hold at 1.0 and look for the moment to begin fall: */ @@ -166,12 +170,13 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) off_count_reg = now + delay_len_reg; } else if (now >= off_count_reg) { state_reg = ST_FALL; - stop_count_reg = (long) (now + susp->fall_time); + stop_count_reg = now + susp->fall_samps; susp->start_fall = now; } break; /* fall until stop_count_reg while looking for next rise time */ case ST_FALL: + value_reg *= susp->fall_factor; if (future >= threshold_reg) { off_count_reg = susp->on_count = now + delay_len_reg; compute_start_rise(susp); @@ -179,7 +184,7 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) } else if (now == stop_count_reg) { state_reg = ST_OFF; value_reg = susp->floor; - } else value_reg *= susp->fall_factor; + } break; /* fall until start_rise while looking for next fall time */ case ST_FALL_UNTIL: @@ -199,10 +204,14 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) if (future >= threshold_reg) { off_count_reg = susp->on_count = now + delay_len_reg; compute_start_rise(susp); - state_reg = ST_OFF_UNTIL; + if (now >= susp->start_rise) { + state_reg = ST_RISE; + } else { + state_reg = ST_OFF_UNTIL; + } } break; - /* hold at floor until start_rise while looking for next fall time */ + /* hold at floor until start_rise and look for next fall time */ case ST_OFF_UNTIL: if (future >= threshold_reg) { off_count_reg = now + delay_len_reg; @@ -225,43 +234,43 @@ void gate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) } *out_ptr_reg++ = (sample_type) value_reg; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - togo -= n; - susp->off_count = off_count_reg; - susp->stop_count = stop_count_reg; - susp->state = state_reg; - susp->value = value_reg; - /* using signal_ptr_reg is a bad idea on RS/6000: */ - susp->signal_ptr += togo; - out_ptr += togo; - susp_took(signal_cnt, togo); - cnt += togo; + togo -= n; + susp->off_count = off_count_reg; + susp->stop_count = stop_count_reg; + susp->state = state_reg; + susp->value = value_reg; + /* using signal_ptr_reg is a bad idea on RS/6000: */ + susp->signal_ptr += togo; + out_ptr += togo; + susp_took(signal_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* gate_n_fetch */ void gate_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ gate_susp_type susp = (gate_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from signal up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->signal->t0) * susp->signal->sr)) >= - susp->signal->current) - susp_get_samples(signal, signal_ptr, signal_cnt); + susp->signal->current) + susp_get_samples(signal, signal_ptr, signal_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->signal->t0) * susp->signal->sr - + n = (int) ROUNDBIG((final_time - susp->signal->t0) * susp->signal->sr - (susp->signal->current - susp->signal_cnt)); susp->signal_ptr += n; susp_took(signal_cnt, n); @@ -301,23 +310,16 @@ sound_type snd_make_gate(sound_type signal, time_type lookahead, double risetime time_type t0 = signal->t0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - /* combine scale factors of linear inputs (SIGNAL) */ - scale_factor *= signal->scale; - signal->scale = 1.0F; - - /* try to push scale_factor back to a low sr input */ - if (signal->sr < sr) { signal->scale = scale_factor; scale_factor = 1.0F; } - falloc_generic(susp, gate_susp_node, "snd_make_gate"); - susp->rise_time = signal->sr * risetime + 0.5; - susp->fall_time = signal->sr * falltime + 0.5; - susp->floor = floor; floor = log(floor);; - susp->threshold = threshold; + susp->rise_samps = (int64_t) (signal->sr * risetime + 0.5); + susp->fall_samps = (int64_t) (signal->sr * falltime + 0.5); + susp->floor = floor; floor = log(floor / signal->scale); + susp->threshold = threshold; threshold /= signal->scale; susp->on_count = 0; susp->off_count = 0; - susp->rise_factor = exp(- floor / susp->rise_time); - susp->fall_factor = exp(floor / susp->fall_time); - susp->start_fall = 0; + susp->rise_factor = exp(- floor / susp->rise_samps); + susp->fall_factor = exp(floor / susp->fall_samps); + susp->start_fall = -susp->fall_samps; susp->start_rise = 0; susp->stop_count = 0; susp->delay_len = max(1, ROUND32(signal->sr * lookahead)); diff --git a/lib-src/libnyquist/nyquist/tran/ifft.c b/lib-src/libnyquist/nyquist/tran/ifft.c index 4c2aa7180..9a91d2a56 100644 --- a/lib-src/libnyquist/nyquist/tran/ifft.c +++ b/lib-src/libnyquist/nyquist/tran/ifft.c @@ -67,7 +67,7 @@ typedef struct ifft_susp_struct { #include "fft.h" #define MUST_BE_FLONUM(e) \ - if (!(e) || ntype(e) != FLONUM) { xlerror("flonum expected", (e)); } + if (!(e) || ntype(e) != FLONUM) { xlerror("in IFFT: flonum expected", (e)); } table_type get_window_samples(LVAL window, sample_type **samples, long *len) { @@ -102,9 +102,9 @@ void ifft__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; if (susp->src == NULL) { @@ -122,7 +122,7 @@ out: togo = 0; /* indicate termination */ susp->src = NULL; goto out; } else if (!vectorp(susp->array)) { - xlerror("array expected", susp->array); + xlerror("in IFFT: array expected", susp->array); } else if (susp->samples == NULL) { /* assume arrays are all the same size as first one; now that we know the size, we just have to do this @@ -130,9 +130,9 @@ out: togo = 0; /* indicate termination */ */ susp->length = getsize(susp->array); if (susp->length < 1) - xlerror("array has no elements", susp->array); + xlerror("in IFFT: array has no elements", susp->array); if (susp->window && (susp->window_len != susp->length)) - xlerror("window size and spectrum size differ", + xlerror("in IFFT: window size and spectrum size differ", susp->array); /* tricky non-power of 2 detector: only if this is a * power of 2 will the highest 1 bit be cleared when @@ -140,12 +140,17 @@ out: togo = 0; /* indicate termination */ */ if (susp->length & (susp->length - 1)) xlfail("spectrum size must be a power of 2"); + if (susp->stepsize < 1) + xlfail("in IFFT: step size must be greater than zero"); + if (susp->length < susp->stepsize) + xlerror("in IFFT: step size must be smaller than spectrum size", + susp->array); susp->samples = (sample_type *) calloc(susp->length, sizeof(sample_type)); susp->outbuf = (sample_type *) calloc(susp->length, sizeof(sample_type)); } else if (getsize(susp->array) != susp->length) { - xlerror("arrays must all be the same length", susp->array); + xlerror("in IFFT: arrays must all be the same length", susp->array); } /* at this point, we have a new array to put samples */ @@ -204,26 +209,26 @@ out: togo = 0; /* indicate termination */ } togo = min(togo, susp->stepsize - susp->index); - n = togo; - index_reg = susp->index; - outbuf_reg = susp->outbuf; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + index_reg = susp->index; + outbuf_reg = susp->outbuf; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = outbuf_reg[index_reg++]; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->index = index_reg; - susp->outbuf = outbuf_reg; - out_ptr += togo; - cnt += togo; + susp->index = index_reg; + susp->outbuf = outbuf_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* ifft__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/ifft.h b/lib-src/libnyquist/nyquist/tran/ifft.h index 186cec68a..87699e87d 100644 --- a/lib-src/libnyquist/nyquist/tran/ifft.h +++ b/lib-src/libnyquist/nyquist/tran/ifft.h @@ -1,3 +1,3 @@ sound_type snd_make_ifft(time_type t0, rate_type sr, LVAL src, long stepsize, LVAL window); sound_type snd_ifft(time_type t0, rate_type sr, LVAL src, long stepsize, LVAL window); - /* LISP: (snd-ifft ANYNUM ANYNUM ANY FIXNUM ANY) */ + /* LISP: (snd-ifft ANYNUM ANYNUM ANY LONG ANY) */ diff --git a/lib-src/libnyquist/nyquist/tran/innerloop.lsp b/lib-src/libnyquist/nyquist/tran/innerloop.lsp index 7d914aa79..6b8247720 100644 --- a/lib-src/libnyquist/nyquist/tran/innerloop.lsp +++ b/lib-src/libnyquist/nyquist/tran/innerloop.lsp @@ -24,8 +24,8 @@ ;; this loop computes and applies substitutions to the INNER-LOOP spec (setf inner-loop (substitute inner-loop "output" "*out_ptr_reg++" nil)) - (push "\tout_ptr_reg = out_ptr;\n" register-init) - (push "\tout_ptr += togo;\n" register-cleanup) + (push " out_ptr_reg = out_ptr;\n" register-init) + (push " out_ptr += togo;\n" register-cleanup) (dotimes (n (length interp)) (let ((name (nth n sound-names)) @@ -41,114 +41,117 @@ ; ::= *NAME_ptr_reg++ ;----------------- (pushnew (format nil - " register sample_block_values_type ~A_ptr_reg;~%" name) + " register sample_block_values_type ~A_ptr_reg;~%" name) register-decl) (pushnew (format nil - "\t~A_ptr_reg = susp->~A_ptr;~%" name name) - register-init) + " ~A_ptr_reg = susp->~A_ptr;~%" name name) + register-init) (pushnew (format nil - "\t/* using ~A_ptr_reg is a bad idea on RS/6000: */~ - ~%\tsusp->~A_ptr += togo;~%" name name name) - register-cleanup) + " /* using ~A_ptr_reg is a bad idea on RS/6000: */~ + ~% susp->~A_ptr += togo;~%" name name name) + register-cleanup) (setf expression (format nil "*~A_ptr_reg++" name))) ((eq method 'SCALE) ;----------------- ; SCALE - ; ::= (NAME_scale_reg * *NAME_ptr_reg++) + ; ::= (NAME_scale_reg * *NAME_ptr_reg++) ;----------------- (pushnew (format nil - " register sample_block_values_type ~A_ptr_reg;~%" name) + " register sample_block_values_type ~A_ptr_reg;~%" name) register-decl) (pushnew (format nil - " register sample_type ~A_scale_reg = susp->~A->scale;~%" name name) + " register sample_type ~A_scale_reg = susp->~A->scale;~%" + name name) register-decl) (pushnew (format nil - "\t~A_ptr_reg = susp->~A_ptr;~%" name name) - register-init) + " ~A_ptr_reg = susp->~A_ptr;~%" name name) + register-init) (pushnew (format nil - "\t/* using ~A_ptr_reg is a bad idea on RS/6000: */~ - ~%\tsusp->~A_ptr += togo;~%" name name name) - register-cleanup) + " /* using ~A_ptr_reg is a bad idea on RS/6000: */~ + ~% susp->~A_ptr += togo;~%" name name name) + register-cleanup) (setf expression (format nil "(~A_scale_reg * *~A_ptr_reg++)" name name))) ((and interpolate-samples (eq method 'INTERP)) ;----------------- ; INTERP: - ; ::= susp->NAME_x1_sample * (1 - - ; susp->NAME_pHaSe + - ; susp->NAME_x2_sample * susp->NAME_pHaSe) + ; ::= susp->NAME_x1_sample * (1 - + ; susp->NAME_pHaSe + + ; susp->NAME_x2_sample * susp->NAME_pHaSe) ;----------------- (pushnew (format nil - " register sample_type ~A_x1_sample_reg;~%" name) + " register sample_type ~A_x1_sample_reg;~%" name) register-decl) (pushnew (format nil - " register double ~A_pHaSe_ReG;~%" name) + " register double ~A_pHaSe_ReG;~%" name) register-decl) (pushnew (format nil - " register double ~A_pHaSe_iNcR_rEg = susp->~A_pHaSe_iNcR;~%" name name) + " register double ~A_pHaSe_iNcR_rEg = susp->~A_pHaSe_iNcR;~%" + name name) register-decl) (pushnew (format nil - "\t~A_x1_sample_reg = susp->~A_x1_sample;~%" name name) - register-init) + " ~A_x1_sample_reg = susp->~A_x1_sample;~%" name name) + register-init) (pushnew (format nil - "\t~A_pHaSe_ReG = susp->~A_pHaSe;~%" name name) - register-init) + " ~A_pHaSe_ReG = susp->~A_pHaSe;~%" name name) + register-init) (pushnew (format nil - "\tsusp->~A_x1_sample = ~A_x1_sample_reg;~%" name name) - register-cleanup) + " susp->~A_x1_sample = ~A_x1_sample_reg;~%" name name) + register-cleanup) (pushnew (format nil - "\tsusp->~A_pHaSe = ~A_pHaSe_ReG;~%" name name) - register-cleanup) + " susp->~A_pHaSe = ~A_pHaSe_ReG;~%" name name) + register-cleanup) (setf expression (format nil - "\n\t\t(~A_x1_sample_reg * (1 - ~A_pHaSe_ReG) + ~A_x2_sample * ~A_pHaSe_ReG)" + "\n (~A_x1_sample_reg * (1 - ~A_pHaSe_ReG) + ~A_x2_sample * ~A_pHaSe_ReG)" name name name name))) ((eq method 'INTERP) ;----------------- ; STEP FUNCTION: - ; ::= NAME_x1_sample_reg + ; ::= NAME_x1_sample_reg ;----------------- (pushnew (format nil - " register sample_type ~A_x1_sample_reg;~%" name) + " register sample_type ~A_x1_sample_reg;~%" name) register-decl) (pushnew (format nil - " register double ~A_pHaSe_ReG;~%" name) + " register double ~A_pHaSe_ReG;~%" name) register-decl) (pushnew (format nil - " register double ~A_pHaSe_iNcR_rEg = susp->~A_pHaSe_iNcR;~%" name name) + " register double ~A_pHaSe_iNcR_rEg = susp->~A_pHaSe_iNcR;~%" + name name) register-decl) (pushnew (format nil - "\t~A_x1_sample_reg = susp->~A_x1_sample;~%" name name) - register-init) + " ~A_x1_sample_reg = susp->~A_x1_sample;~%" name name) + register-init) (pushnew (format nil - "\t~A_pHaSe_ReG = susp->~A_pHaSe;~%" name name) - register-init) + " ~A_pHaSe_ReG = susp->~A_pHaSe;~%" name name) + register-init) (pushnew (format nil - "\tsusp->~A_x1_sample = ~A_x1_sample_reg;~%" name name) - register-cleanup) + " susp->~A_x1_sample = ~A_x1_sample_reg;~%" name name) + register-cleanup) (pushnew (format nil - "\tsusp->~A_pHaSe = ~A_pHaSe_ReG;~%" name name) - register-cleanup) + " susp->~A_pHaSe = ~A_pHaSe_ReG;~%" name name) + register-cleanup) (setf expression (format nil "~A_x1_sample_reg" name))) ((and interpolate-samples (eq method 'RAMP)) ;----------------- ; RAMP: - ; ::= NAME_val + ; ::= NAME_val ;----------------- (setf expression (format nil "~A_val" name))) ((eq method 'RAMP) ;----------------- ; RAMP: - ; ::= NAME_val + ; ::= NAME_val ;----------------- ; this doesn't seem to be used -RBD 7/97 ;(pushnew (format nil @@ -177,18 +180,19 @@ (let ((var-name (cadr state)) maintain) (pushnew (format nil " register ~A ~A_reg;~%" (car state) var-name) - register-decl) - (pushnew (format nil "\t~A_reg = susp->~A;~%" var-name var-name) - register-init) + register-decl) + (pushnew (format nil " ~A_reg = susp->~A;~%" var-name var-name) + register-init) (setf maintain (find-maintain-stmt var-name maintain-list)) ; (display "find-maintain-stmt returned:" maintain) (cond (maintain - (pushnew (format nil "\t~A;~%" maintain) register-cleanup)) + (pushnew (format nil " ~A;~%" maintain) register-cleanup)) ((not (is-constant-in-inner-loop var-name constant-list)) ;(pushnew (format nil "var-name: ~A constant-list: ~A~%" var-name constant-list) ; register-cleanup) - (pushnew (format nil "\tsusp->~A = ~A_reg;~%" var-name var-name) - register-cleanup))) + (pushnew (format nil + " susp->~A = ~A_reg;~%" var-name var-name) + register-cleanup))) (setf inner-loop (substitute inner-loop var-name (format nil "~A_reg" var-name) t)) )) @@ -201,7 +205,7 @@ ;; because it makes n a live variable and affects compiler optimization. (cond ((or (member 'INTERP interp) (string-search "break" inner-loop)) - (push "\ttogo -= n;\n" register-cleanup))) + (push " togo -= n;\n" register-cleanup))) (put-slot alg inner-loop 'inner-loop-stmts) (put-slot alg register-decl 'register-decl) @@ -218,7 +222,7 @@ ; so I don't know where to get it... ;----------------- ; (if *WATCH* -; (format stream "\t show_samples(1,s1,s1_ptr - s1_samples);~%") +; (format stream " show_samples(1,s1,s1_ptr - s1_samples);~%") ; ) )) @@ -246,10 +250,10 @@ ;;********** ;; substitute -- string substitution ;; Inputs: -;; s - input string -;; pat - pattern -;; repl - replacement for pattern -;; all - T or NIL (T : replace everywhere; NIL : replace once) +;; s - input string +;; pat - pattern +;; repl - replacement for pattern +;; all - T or NIL (T : replace everywhere; NIL : replace once) ;; ;;********** @@ -288,24 +292,24 @@ ; ; NAME_pHaSe_ReG += NAME_pHaSe_iNcR_rEg; ;----------------- - (format stream "\t ~A_pHaSe_ReG += ~A_pHaSe_iNcR_rEg;~%" + (format stream " ~A_pHaSe_ReG += ~A_pHaSe_iNcR_rEg;~%" name name)) ((and interpolate-samples (eq method 'RAMP)) ;----------------- ; RAMP: - ; NAME_val += NAME_DeLtA + ; NAME_val += NAME_DeLtA ;----------------- - (format stream "\t ~A_val += ~A_DeLtA;~%" name name))))) + (format stream " ~A_val += ~A_DeLtA;~%" name name))))) ;---------------------------- ; WATCH: - ; show_samples(0,out,out_ptr - 1 - out->samples); + ; show_samples(0,out,out_ptr - 1 - out->samples); ;---------------------------- ; (if *WATCH* -; (format stream "\t show_samples(0,out,out_ptr - 1 - out->samples);~%")) +; (format stream " show_samples(0,out,out_ptr - 1 - out->samples);~%")) ;---------------------------- ; } while (--n); /* inner loop */ ;---------------------------- - (format stream "\t} while (--n); /* inner loop */~%~%"))) + (format stream " } while (--n); /* inner loop */~%~%"))) diff --git a/lib-src/libnyquist/nyquist/tran/instrbanded.c b/lib-src/libnyquist/nyquist/tran/instrbanded.c index bf8af0e85..e5b2a3d34 100644 --- a/lib-src/libnyquist/nyquist/tran/instrbanded.c +++ b/lib-src/libnyquist/nyquist/tran/instrbanded.c @@ -14,9 +14,9 @@ void bandedwg_free(snd_susp_type a_susp); typedef struct bandedwg_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type bowpress_env; - long bowpress_env_cnt; + int bowpress_env_cnt; sample_block_values_type bowpress_env_ptr; struct instr *mybanded; @@ -47,63 +47,63 @@ void bandedwg_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the bowpress_env input sample block: */ - susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); - togo = min(togo, susp->bowpress_env_cnt); + /* don't run past the bowpress_env input sample block: */ + susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + togo = min(togo, susp->bowpress_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mybanded_reg = susp->mybanded; - bowpress_scale_reg = susp->bowpress_scale; - bowpress_env_ptr_reg = susp->bowpress_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mybanded_reg = susp->mybanded; + bowpress_scale_reg = susp->bowpress_scale; + bowpress_env_ptr_reg = susp->bowpress_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(mybanded_reg, 2, bowpress_scale_reg * *bowpress_env_ptr_reg++); *out_ptr_reg++ = (sample_type) tick(mybanded_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mybanded = mybanded_reg; - /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ - susp->bowpress_env_ptr += togo; - out_ptr += togo; - susp_took(bowpress_env_cnt, togo); - cnt += togo; + susp->mybanded = mybanded_reg; + /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ + susp->bowpress_env_ptr += togo; + out_ptr += togo; + susp_took(bowpress_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* bandedwg_n_fetch */ void bandedwg_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ bandedwg_susp_type susp = (bandedwg_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from bowpress_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr)) >= - susp->bowpress_env->current) - susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + susp->bowpress_env->current) + susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - + n = (int) ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - (susp->bowpress_env->current - susp->bowpress_env_cnt)); susp->bowpress_env_ptr += n; susp_took(bowpress_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrbanded.h b/lib-src/libnyquist/nyquist/tran/instrbanded.h index 99970dc94..22b209c59 100644 --- a/lib-src/libnyquist/nyquist/tran/instrbanded.h +++ b/lib-src/libnyquist/nyquist/tran/instrbanded.h @@ -1,4 +1,4 @@ sound_type snd_make_bandedwg(double freq, sound_type bowpress_env, int preset, rate_type sr); sound_type snd_bandedwg(double freq, sound_type bowpress_env, int preset, rate_type sr); - /* LISP: (snd-bandedwg ANYNUM SOUND FIXNUM ANYNUM) */ + /* LISP: (snd-bandedwg ANYNUM SOUND LONG ANYNUM) */ #define BANDEDWG_CONTROL_CHANGE_CONST 128 diff --git a/lib-src/libnyquist/nyquist/tran/instrbow.c b/lib-src/libnyquist/nyquist/tran/instrbow.c index dd7b50269..e2983722b 100644 --- a/lib-src/libnyquist/nyquist/tran/instrbow.c +++ b/lib-src/libnyquist/nyquist/tran/instrbow.c @@ -14,9 +14,9 @@ void bowed_free(snd_susp_type a_susp); typedef struct bowed_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type bowpress_env; - long bowpress_env_cnt; + int bowpress_env_cnt; sample_block_values_type bowpress_env_ptr; struct instr *mybow; @@ -47,63 +47,63 @@ void bowed_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the bowpress_env input sample block: */ - susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); - togo = min(togo, susp->bowpress_env_cnt); + /* don't run past the bowpress_env input sample block: */ + susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + togo = min(togo, susp->bowpress_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mybow_reg = susp->mybow; - bow_scale_reg = susp->bow_scale; - bowpress_env_ptr_reg = susp->bowpress_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mybow_reg = susp->mybow; + bow_scale_reg = susp->bow_scale; + bowpress_env_ptr_reg = susp->bowpress_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(mybow_reg, 128, bow_scale_reg * *bowpress_env_ptr_reg++); *out_ptr_reg++ = (sample_type) tick(mybow_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mybow = mybow_reg; - /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ - susp->bowpress_env_ptr += togo; - out_ptr += togo; - susp_took(bowpress_env_cnt, togo); - cnt += togo; + susp->mybow = mybow_reg; + /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ + susp->bowpress_env_ptr += togo; + out_ptr += togo; + susp_took(bowpress_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* bowed_n_fetch */ void bowed_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ bowed_susp_type susp = (bowed_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from bowpress_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr)) >= - susp->bowpress_env->current) - susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + susp->bowpress_env->current) + susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - + n = (int) ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - (susp->bowpress_env->current - susp->bowpress_env_cnt)); susp->bowpress_env_ptr += n; susp_took(bowpress_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrbowedfreq.c b/lib-src/libnyquist/nyquist/tran/instrbowedfreq.c index 3580f7bb9..4f6d3694f 100644 --- a/lib-src/libnyquist/nyquist/tran/instrbowedfreq.c +++ b/lib-src/libnyquist/nyquist/tran/instrbowedfreq.c @@ -14,12 +14,12 @@ void bowed_freq_free(snd_susp_type a_susp); typedef struct bowed_freq_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type bowpress_env; - long bowpress_env_cnt; + int bowpress_env_cnt; sample_block_values_type bowpress_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; struct instr *mybow; @@ -54,81 +54,81 @@ void bowed_freq_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the bowpress_env input sample block: */ - susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); - togo = min(togo, susp->bowpress_env_cnt); + /* don't run past the bowpress_env input sample block: */ + susp_check_term_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + togo = min(togo, susp->bowpress_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mybow_reg = susp->mybow; - bow_scale_reg = susp->bow_scale; - frequency_reg = susp->frequency; - freq_env_ptr_reg = susp->freq_env_ptr; - bowpress_env_ptr_reg = susp->bowpress_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mybow_reg = susp->mybow; + bow_scale_reg = susp->bow_scale; + frequency_reg = susp->frequency; + freq_env_ptr_reg = susp->freq_env_ptr; + bowpress_env_ptr_reg = susp->bowpress_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(mybow_reg, 128, bow_scale_reg * *bowpress_env_ptr_reg++); setFrequency(mybow_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(mybow_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mybow = mybow_reg; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ - susp->bowpress_env_ptr += togo; - out_ptr += togo; - susp_took(bowpress_env_cnt, togo); - susp_took(freq_env_cnt, togo); - cnt += togo; + susp->mybow = mybow_reg; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using bowpress_env_ptr_reg is a bad idea on RS/6000: */ + susp->bowpress_env_ptr += togo; + out_ptr += togo; + susp_took(bowpress_env_cnt, togo); + susp_took(freq_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* bowed_freq_ns_fetch */ void bowed_freq_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ bowed_freq_susp_type susp = (bowed_freq_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from bowpress_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr)) >= - susp->bowpress_env->current) - susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); + susp->bowpress_env->current) + susp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - + n = (int) ROUNDBIG((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr - (susp->bowpress_env->current - susp->bowpress_env_cnt)); susp->bowpress_env_ptr += n; susp_took(bowpress_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrclar.c b/lib-src/libnyquist/nyquist/tran/instrclar.c index 67ca8e7ec..13541dfbf 100644 --- a/lib-src/libnyquist/nyquist/tran/instrclar.c +++ b/lib-src/libnyquist/nyquist/tran/instrclar.c @@ -14,9 +14,9 @@ void clarinet_free(snd_susp_type a_susp); typedef struct clarinet_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; struct instr *clar; @@ -47,63 +47,63 @@ void clarinet_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - clar_reg = susp->clar; - breath_scale_reg = susp->breath_scale; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + clar_reg = susp->clar; + breath_scale_reg = susp->breath_scale; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(clar_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); *out_ptr_reg++ = (sample_type) tick(clar_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->clar = clar_reg; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - cnt += togo; + susp->clar = clar_reg; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* clarinet_n_fetch */ void clarinet_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ clarinet_susp_type susp = (clarinet_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrclarall.c b/lib-src/libnyquist/nyquist/tran/instrclarall.c index 8c0c1f221..a1b781570 100644 --- a/lib-src/libnyquist/nyquist/tran/instrclarall.c +++ b/lib-src/libnyquist/nyquist/tran/instrclarall.c @@ -14,18 +14,18 @@ void clarinet_all_free(snd_susp_type a_susp); typedef struct clarinet_all_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; sound_type reed_stiffness; - long reed_stiffness_cnt; + int reed_stiffness_cnt; sample_block_values_type reed_stiffness_ptr; sound_type noise_env; - long noise_env_cnt; + int noise_env_cnt; sample_block_values_type noise_env_ptr; struct instr *clar; @@ -65,117 +65,117 @@ void clarinet_all_nsnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past the reed_stiffness input sample block: */ - susp_check_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); - togo = min(togo, susp->reed_stiffness_cnt); + /* don't run past the reed_stiffness input sample block: */ + susp_check_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); + togo = min(togo, susp->reed_stiffness_cnt); - /* don't run past the noise_env input sample block: */ - susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); - togo = min(togo, susp->noise_env_cnt); + /* don't run past the noise_env input sample block: */ + susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); + togo = min(togo, susp->noise_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - clar_reg = susp->clar; - frequency_reg = susp->frequency; - breath_scale_reg = susp->breath_scale; - reed_scale_reg = susp->reed_scale; - noise_scale_reg = susp->noise_scale; - noise_env_ptr_reg = susp->noise_env_ptr; - reed_stiffness_ptr_reg = susp->reed_stiffness_ptr; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + clar_reg = susp->clar; + frequency_reg = susp->frequency; + breath_scale_reg = susp->breath_scale; + reed_scale_reg = susp->reed_scale; + noise_scale_reg = susp->noise_scale; + noise_env_ptr_reg = susp->noise_env_ptr; + reed_stiffness_ptr_reg = susp->reed_stiffness_ptr; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(clar_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); controlChange(clar_reg, 2, reed_scale_reg * *reed_stiffness_ptr_reg++); controlChange(clar_reg, 4, noise_scale_reg * *noise_env_ptr_reg++); setFrequency(clar_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(clar_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->clar = clar_reg; - /* using noise_env_ptr_reg is a bad idea on RS/6000: */ - susp->noise_env_ptr += togo; - /* using reed_stiffness_ptr_reg is a bad idea on RS/6000: */ - susp->reed_stiffness_ptr += togo; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - susp_took(reed_stiffness_cnt, togo); - susp_took(noise_env_cnt, togo); - cnt += togo; + susp->clar = clar_reg; + /* using noise_env_ptr_reg is a bad idea on RS/6000: */ + susp->noise_env_ptr += togo; + /* using reed_stiffness_ptr_reg is a bad idea on RS/6000: */ + susp->reed_stiffness_ptr += togo; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + susp_took(reed_stiffness_cnt, togo); + susp_took(noise_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* clarinet_all_nsnn_fetch */ void clarinet_all_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ clarinet_all_susp_type susp = (clarinet_all_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* fetch samples from reed_stiffness up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr)) >= - susp->reed_stiffness->current) - susp_get_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); + susp->reed_stiffness->current) + susp_get_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); /* fetch samples from noise_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr)) >= - susp->noise_env->current) - susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); + susp->noise_env->current) + susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); - n = ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr - + n = (int) ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr - (susp->reed_stiffness->current - susp->reed_stiffness_cnt)); susp->reed_stiffness_ptr += n; susp_took(reed_stiffness_cnt, n); - n = ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - + n = (int) ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - (susp->noise_env->current - susp->noise_env_cnt)); susp->noise_env_ptr += n; susp_took(noise_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrclarfreq.c b/lib-src/libnyquist/nyquist/tran/instrclarfreq.c index 422b917a9..80d0b55c1 100644 --- a/lib-src/libnyquist/nyquist/tran/instrclarfreq.c +++ b/lib-src/libnyquist/nyquist/tran/instrclarfreq.c @@ -14,12 +14,12 @@ void clarinet_freq_free(snd_susp_type a_susp); typedef struct clarinet_freq_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; struct instr *clar; @@ -54,81 +54,81 @@ void clarinet_freq_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - clar_reg = susp->clar; - frequency_reg = susp->frequency; - breath_scale_reg = susp->breath_scale; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + clar_reg = susp->clar; + frequency_reg = susp->frequency; + breath_scale_reg = susp->breath_scale; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(clar_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); setFrequency(clar_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(clar_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->clar = clar_reg; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - cnt += togo; + susp->clar = clar_reg; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* clarinet_freq_ns_fetch */ void clarinet_freq_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ clarinet_freq_susp_type susp = (clarinet_freq_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrflute.c b/lib-src/libnyquist/nyquist/tran/instrflute.c index 5e0aa2405..e61f5136f 100644 --- a/lib-src/libnyquist/nyquist/tran/instrflute.c +++ b/lib-src/libnyquist/nyquist/tran/instrflute.c @@ -14,9 +14,9 @@ void flute_free(snd_susp_type a_susp); typedef struct flute_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; struct instr *myflute; @@ -47,63 +47,63 @@ void flute_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - myflute_reg = susp->myflute; - breath_scale_reg = susp->breath_scale; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + myflute_reg = susp->myflute; + breath_scale_reg = susp->breath_scale; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(myflute_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); *out_ptr_reg++ = (sample_type) tick(myflute_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->myflute = myflute_reg; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - cnt += togo; + susp->myflute = myflute_reg; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* flute_n_fetch */ void flute_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ flute_susp_type susp = (flute_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrfluteall.c b/lib-src/libnyquist/nyquist/tran/instrfluteall.c index 346932144..a33390a1e 100644 --- a/lib-src/libnyquist/nyquist/tran/instrfluteall.c +++ b/lib-src/libnyquist/nyquist/tran/instrfluteall.c @@ -14,18 +14,18 @@ void flute_all_free(snd_susp_type a_susp); typedef struct flute_all_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; sound_type jet_delay; - long jet_delay_cnt; + int jet_delay_cnt; sample_block_values_type jet_delay_ptr; sound_type noise_env; - long noise_env_cnt; + int noise_env_cnt; sample_block_values_type noise_env_ptr; struct instr *myflute; @@ -65,117 +65,117 @@ void flute_all_nsnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past the jet_delay input sample block: */ - susp_check_samples(jet_delay, jet_delay_ptr, jet_delay_cnt); - togo = min(togo, susp->jet_delay_cnt); + /* don't run past the jet_delay input sample block: */ + susp_check_samples(jet_delay, jet_delay_ptr, jet_delay_cnt); + togo = min(togo, susp->jet_delay_cnt); - /* don't run past the noise_env input sample block: */ - susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); - togo = min(togo, susp->noise_env_cnt); + /* don't run past the noise_env input sample block: */ + susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); + togo = min(togo, susp->noise_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - myflute_reg = susp->myflute; - frequency_reg = susp->frequency; - breath_scale_reg = susp->breath_scale; - jet_scale_reg = susp->jet_scale; - noise_scale_reg = susp->noise_scale; - noise_env_ptr_reg = susp->noise_env_ptr; - jet_delay_ptr_reg = susp->jet_delay_ptr; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + myflute_reg = susp->myflute; + frequency_reg = susp->frequency; + breath_scale_reg = susp->breath_scale; + jet_scale_reg = susp->jet_scale; + noise_scale_reg = susp->noise_scale; + noise_env_ptr_reg = susp->noise_env_ptr; + jet_delay_ptr_reg = susp->jet_delay_ptr; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(myflute_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); controlChange(myflute_reg, 2, jet_scale_reg * *jet_delay_ptr_reg++); controlChange(myflute_reg, 4, noise_scale_reg * *noise_env_ptr_reg++); setFrequency(myflute_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(myflute_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->myflute = myflute_reg; - /* using noise_env_ptr_reg is a bad idea on RS/6000: */ - susp->noise_env_ptr += togo; - /* using jet_delay_ptr_reg is a bad idea on RS/6000: */ - susp->jet_delay_ptr += togo; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - susp_took(jet_delay_cnt, togo); - susp_took(noise_env_cnt, togo); - cnt += togo; + susp->myflute = myflute_reg; + /* using noise_env_ptr_reg is a bad idea on RS/6000: */ + susp->noise_env_ptr += togo; + /* using jet_delay_ptr_reg is a bad idea on RS/6000: */ + susp->jet_delay_ptr += togo; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + susp_took(jet_delay_cnt, togo); + susp_took(noise_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* flute_all_nsnn_fetch */ void flute_all_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ flute_all_susp_type susp = (flute_all_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* fetch samples from jet_delay up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->jet_delay->t0) * susp->jet_delay->sr)) >= - susp->jet_delay->current) - susp_get_samples(jet_delay, jet_delay_ptr, jet_delay_cnt); + susp->jet_delay->current) + susp_get_samples(jet_delay, jet_delay_ptr, jet_delay_cnt); /* fetch samples from noise_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr)) >= - susp->noise_env->current) - susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); + susp->noise_env->current) + susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); - n = ROUNDBIG((final_time - susp->jet_delay->t0) * susp->jet_delay->sr - + n = (int) ROUNDBIG((final_time - susp->jet_delay->t0) * susp->jet_delay->sr - (susp->jet_delay->current - susp->jet_delay_cnt)); susp->jet_delay_ptr += n; susp_took(jet_delay_cnt, n); - n = ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - + n = (int) ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - (susp->noise_env->current - susp->noise_env_cnt)); susp->noise_env_ptr += n; susp_took(noise_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrflutefreq.c b/lib-src/libnyquist/nyquist/tran/instrflutefreq.c index 03c9d47de..5be58094f 100644 --- a/lib-src/libnyquist/nyquist/tran/instrflutefreq.c +++ b/lib-src/libnyquist/nyquist/tran/instrflutefreq.c @@ -14,12 +14,12 @@ void flute_freq_free(snd_susp_type a_susp); typedef struct flute_freq_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; struct instr *myflute; @@ -54,81 +54,81 @@ void flute_freq_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - myflute_reg = susp->myflute; - breath_scale_reg = susp->breath_scale; - frequency_reg = susp->frequency; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + myflute_reg = susp->myflute; + breath_scale_reg = susp->breath_scale; + frequency_reg = susp->frequency; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(myflute_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); setFrequency(myflute_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(myflute_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->myflute = myflute_reg; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - cnt += togo; + susp->myflute = myflute_reg; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* flute_freq_ns_fetch */ void flute_freq_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ flute_freq_susp_type susp = (flute_freq_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrmandolin.c b/lib-src/libnyquist/nyquist/tran/instrmandolin.c index 8f7233e64..82fdc29cd 100644 --- a/lib-src/libnyquist/nyquist/tran/instrmandolin.c +++ b/lib-src/libnyquist/nyquist/tran/instrmandolin.c @@ -14,7 +14,7 @@ void mandolin_free(snd_susp_type a_susp); typedef struct mandolin_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; struct instr *mymand; int temp_ret_value; @@ -40,36 +40,36 @@ void mandolin__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mymand_reg = susp->mymand; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mymand_reg = susp->mymand; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) tick(mymand_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mymand = mymand_reg; - out_ptr += togo; - cnt += togo; + susp->mymand = mymand_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* mandolin__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/instrmodalbar.c b/lib-src/libnyquist/nyquist/tran/instrmodalbar.c index cec752270..d3f9cd3ab 100644 --- a/lib-src/libnyquist/nyquist/tran/instrmodalbar.c +++ b/lib-src/libnyquist/nyquist/tran/instrmodalbar.c @@ -14,7 +14,7 @@ void modalbar_free(snd_susp_type a_susp); typedef struct modalbar_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; struct instr *mymbar; int temp_ret_value; @@ -40,36 +40,36 @@ void modalbar__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mymbar_reg = susp->mymbar; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mymbar_reg = susp->mymbar; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) tick(mymbar_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mymbar = mymbar_reg; - out_ptr += togo; - cnt += togo; + susp->mymbar = mymbar_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* modalbar__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/instrmodalbar.h b/lib-src/libnyquist/nyquist/tran/instrmodalbar.h index 21c9ac4c4..5f21895ee 100644 --- a/lib-src/libnyquist/nyquist/tran/instrmodalbar.h +++ b/lib-src/libnyquist/nyquist/tran/instrmodalbar.h @@ -1,3 +1,3 @@ sound_type snd_make_modalbar(time_type t0, double freq, int preset, time_type dur, rate_type sr); sound_type snd_modalbar(time_type t0, double freq, int preset, time_type dur, rate_type sr); - /* LISP: (snd-modalbar ANYNUM ANYNUM FIXNUM ANYNUM ANYNUM) */ + /* LISP: (snd-modalbar ANYNUM ANYNUM LONG ANYNUM ANYNUM) */ diff --git a/lib-src/libnyquist/nyquist/tran/instrsax.c b/lib-src/libnyquist/nyquist/tran/instrsax.c index 97c9cb717..e1ba10ef2 100644 --- a/lib-src/libnyquist/nyquist/tran/instrsax.c +++ b/lib-src/libnyquist/nyquist/tran/instrsax.c @@ -14,9 +14,9 @@ void sax_free(snd_susp_type a_susp); typedef struct sax_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; struct instr *sax; @@ -47,64 +47,64 @@ void sax_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - sax_reg = susp->sax; - breath_scale_reg = susp->breath_scale; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + sax_reg = susp->sax; + breath_scale_reg = susp->breath_scale; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(sax_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); *out_ptr_reg++ = (sample_type) tick(sax_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->sax = sax_reg; - susp->breath_scale = breath_scale_reg; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - cnt += togo; + susp->sax = sax_reg; + susp->breath_scale = breath_scale_reg; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* sax_n_fetch */ void sax_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ sax_susp_type susp = (sax_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrsaxall.c b/lib-src/libnyquist/nyquist/tran/instrsaxall.c index c9d7993f9..98e20d6e9 100644 --- a/lib-src/libnyquist/nyquist/tran/instrsaxall.c +++ b/lib-src/libnyquist/nyquist/tran/instrsaxall.c @@ -14,24 +14,24 @@ void sax_all_free(snd_susp_type a_susp); typedef struct sax_all_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; sound_type reed_stiffness; - long reed_stiffness_cnt; + int reed_stiffness_cnt; sample_block_values_type reed_stiffness_ptr; sound_type noise_env; - long noise_env_cnt; + int noise_env_cnt; sample_block_values_type noise_env_ptr; sound_type blow_pos; - long blow_pos_cnt; + int blow_pos_cnt; sample_block_values_type blow_pos_ptr; sound_type reed_table_offset; - long reed_table_offset_cnt; + int reed_table_offset_cnt; sample_block_values_type reed_table_offset_ptr; struct instr *sax; @@ -77,58 +77,58 @@ void sax_all_nsnnnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past the reed_stiffness input sample block: */ - susp_check_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); - togo = min(togo, susp->reed_stiffness_cnt); + /* don't run past the reed_stiffness input sample block: */ + susp_check_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); + togo = min(togo, susp->reed_stiffness_cnt); - /* don't run past the noise_env input sample block: */ - susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); - togo = min(togo, susp->noise_env_cnt); + /* don't run past the noise_env input sample block: */ + susp_check_samples(noise_env, noise_env_ptr, noise_env_cnt); + togo = min(togo, susp->noise_env_cnt); - /* don't run past the blow_pos input sample block: */ - susp_check_samples(blow_pos, blow_pos_ptr, blow_pos_cnt); - togo = min(togo, susp->blow_pos_cnt); + /* don't run past the blow_pos input sample block: */ + susp_check_samples(blow_pos, blow_pos_ptr, blow_pos_cnt); + togo = min(togo, susp->blow_pos_cnt); - /* don't run past the reed_table_offset input sample block: */ - susp_check_samples(reed_table_offset, reed_table_offset_ptr, reed_table_offset_cnt); - togo = min(togo, susp->reed_table_offset_cnt); + /* don't run past the reed_table_offset input sample block: */ + susp_check_samples(reed_table_offset, reed_table_offset_ptr, reed_table_offset_cnt); + togo = min(togo, susp->reed_table_offset_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - sax_reg = susp->sax; - frequency_reg = susp->frequency; - breath_scale_reg = susp->breath_scale; - reed_scale_reg = susp->reed_scale; - noise_scale_reg = susp->noise_scale; - blow_scale_reg = susp->blow_scale; - offset_scale_reg = susp->offset_scale; - reed_table_offset_ptr_reg = susp->reed_table_offset_ptr; - blow_pos_ptr_reg = susp->blow_pos_ptr; - noise_env_ptr_reg = susp->noise_env_ptr; - reed_stiffness_ptr_reg = susp->reed_stiffness_ptr; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + sax_reg = susp->sax; + frequency_reg = susp->frequency; + breath_scale_reg = susp->breath_scale; + reed_scale_reg = susp->reed_scale; + noise_scale_reg = susp->noise_scale; + blow_scale_reg = susp->blow_scale; + offset_scale_reg = susp->offset_scale; + reed_table_offset_ptr_reg = susp->reed_table_offset_ptr; + blow_pos_ptr_reg = susp->blow_pos_ptr; + noise_env_ptr_reg = susp->noise_env_ptr; + reed_stiffness_ptr_reg = susp->reed_stiffness_ptr; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(sax_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); controlChange(sax_reg, 2, reed_scale_reg * *reed_stiffness_ptr_reg++); controlChange(sax_reg, 4, noise_scale_reg * *noise_env_ptr_reg++); @@ -136,94 +136,94 @@ void sax_all_nsnnnn_fetch(snd_susp_type a_susp, snd_list_type snd_list) controlChange(sax_reg, 26, offset_scale_reg * *reed_table_offset_ptr_reg++); setFrequency(sax_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(sax_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->sax = sax_reg; - /* using reed_table_offset_ptr_reg is a bad idea on RS/6000: */ - susp->reed_table_offset_ptr += togo; - /* using blow_pos_ptr_reg is a bad idea on RS/6000: */ - susp->blow_pos_ptr += togo; - /* using noise_env_ptr_reg is a bad idea on RS/6000: */ - susp->noise_env_ptr += togo; - /* using reed_stiffness_ptr_reg is a bad idea on RS/6000: */ - susp->reed_stiffness_ptr += togo; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - susp_took(reed_stiffness_cnt, togo); - susp_took(noise_env_cnt, togo); - susp_took(blow_pos_cnt, togo); - susp_took(reed_table_offset_cnt, togo); - cnt += togo; + susp->sax = sax_reg; + /* using reed_table_offset_ptr_reg is a bad idea on RS/6000: */ + susp->reed_table_offset_ptr += togo; + /* using blow_pos_ptr_reg is a bad idea on RS/6000: */ + susp->blow_pos_ptr += togo; + /* using noise_env_ptr_reg is a bad idea on RS/6000: */ + susp->noise_env_ptr += togo; + /* using reed_stiffness_ptr_reg is a bad idea on RS/6000: */ + susp->reed_stiffness_ptr += togo; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + susp_took(reed_stiffness_cnt, togo); + susp_took(noise_env_cnt, togo); + susp_took(blow_pos_cnt, togo); + susp_took(reed_table_offset_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* sax_all_nsnnnn_fetch */ void sax_all_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ sax_all_susp_type susp = (sax_all_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* fetch samples from reed_stiffness up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr)) >= - susp->reed_stiffness->current) - susp_get_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); + susp->reed_stiffness->current) + susp_get_samples(reed_stiffness, reed_stiffness_ptr, reed_stiffness_cnt); /* fetch samples from noise_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr)) >= - susp->noise_env->current) - susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); + susp->noise_env->current) + susp_get_samples(noise_env, noise_env_ptr, noise_env_cnt); /* fetch samples from blow_pos up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->blow_pos->t0) * susp->blow_pos->sr)) >= - susp->blow_pos->current) - susp_get_samples(blow_pos, blow_pos_ptr, blow_pos_cnt); + susp->blow_pos->current) + susp_get_samples(blow_pos, blow_pos_ptr, blow_pos_cnt); /* fetch samples from reed_table_offset up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->reed_table_offset->t0) * susp->reed_table_offset->sr)) >= - susp->reed_table_offset->current) - susp_get_samples(reed_table_offset, reed_table_offset_ptr, reed_table_offset_cnt); + susp->reed_table_offset->current) + susp_get_samples(reed_table_offset, reed_table_offset_ptr, reed_table_offset_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); - n = ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr - + n = (int) ROUNDBIG((final_time - susp->reed_stiffness->t0) * susp->reed_stiffness->sr - (susp->reed_stiffness->current - susp->reed_stiffness_cnt)); susp->reed_stiffness_ptr += n; susp_took(reed_stiffness_cnt, n); - n = ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - + n = (int) ROUNDBIG((final_time - susp->noise_env->t0) * susp->noise_env->sr - (susp->noise_env->current - susp->noise_env_cnt)); susp->noise_env_ptr += n; susp_took(noise_env_cnt, n); - n = ROUNDBIG((final_time - susp->blow_pos->t0) * susp->blow_pos->sr - + n = (int) ROUNDBIG((final_time - susp->blow_pos->t0) * susp->blow_pos->sr - (susp->blow_pos->current - susp->blow_pos_cnt)); susp->blow_pos_ptr += n; susp_took(blow_pos_cnt, n); - n = ROUNDBIG((final_time - susp->reed_table_offset->t0) * susp->reed_table_offset->sr - + n = (int) ROUNDBIG((final_time - susp->reed_table_offset->t0) * susp->reed_table_offset->sr - (susp->reed_table_offset->current - susp->reed_table_offset_cnt)); susp->reed_table_offset_ptr += n; susp_took(reed_table_offset_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrsaxfreq.c b/lib-src/libnyquist/nyquist/tran/instrsaxfreq.c index 97b3903fc..90e1f464d 100644 --- a/lib-src/libnyquist/nyquist/tran/instrsaxfreq.c +++ b/lib-src/libnyquist/nyquist/tran/instrsaxfreq.c @@ -14,12 +14,12 @@ void sax_freq_free(snd_susp_type a_susp); typedef struct sax_freq_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; sound_type breath_env; - long breath_env_cnt; + int breath_env_cnt; sample_block_values_type breath_env_ptr; sound_type freq_env; - long freq_env_cnt; + int freq_env_cnt; sample_block_values_type freq_env_ptr; struct instr *sax; @@ -54,81 +54,81 @@ void sax_freq_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the breath_env input sample block: */ - susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); - togo = min(togo, susp->breath_env_cnt); + /* don't run past the breath_env input sample block: */ + susp_check_term_samples(breath_env, breath_env_ptr, breath_env_cnt); + togo = min(togo, susp->breath_env_cnt); - /* don't run past the freq_env input sample block: */ - susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); - togo = min(togo, susp->freq_env_cnt); + /* don't run past the freq_env input sample block: */ + susp_check_samples(freq_env, freq_env_ptr, freq_env_cnt); + togo = min(togo, susp->freq_env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - sax_reg = susp->sax; - breath_scale_reg = susp->breath_scale; - frequency_reg = susp->frequency; - freq_env_ptr_reg = susp->freq_env_ptr; - breath_env_ptr_reg = susp->breath_env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + sax_reg = susp->sax; + breath_scale_reg = susp->breath_scale; + frequency_reg = susp->frequency; + freq_env_ptr_reg = susp->freq_env_ptr; + breath_env_ptr_reg = susp->breath_env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ controlChange(sax_reg, 128, breath_scale_reg * *breath_env_ptr_reg++); setFrequency(sax_reg, frequency_reg + (freq_env_scale_reg * *freq_env_ptr_reg++)); *out_ptr_reg++ = (sample_type) tick(sax_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->sax = sax_reg; - /* using freq_env_ptr_reg is a bad idea on RS/6000: */ - susp->freq_env_ptr += togo; - /* using breath_env_ptr_reg is a bad idea on RS/6000: */ - susp->breath_env_ptr += togo; - out_ptr += togo; - susp_took(breath_env_cnt, togo); - susp_took(freq_env_cnt, togo); - cnt += togo; + susp->sax = sax_reg; + /* using freq_env_ptr_reg is a bad idea on RS/6000: */ + susp->freq_env_ptr += togo; + /* using breath_env_ptr_reg is a bad idea on RS/6000: */ + susp->breath_env_ptr += togo; + out_ptr += togo; + susp_took(breath_env_cnt, togo); + susp_took(freq_env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* sax_freq_ns_fetch */ void sax_freq_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ sax_freq_susp_type susp = (sax_freq_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from breath_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr)) >= - susp->breath_env->current) - susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); + susp->breath_env->current) + susp_get_samples(breath_env, breath_env_ptr, breath_env_cnt); /* fetch samples from freq_env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >= - susp->freq_env->current) - susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); + susp->freq_env->current) + susp_get_samples(freq_env, freq_env_ptr, freq_env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - + n = (int) ROUNDBIG((final_time - susp->breath_env->t0) * susp->breath_env->sr - (susp->breath_env->current - susp->breath_env_cnt)); susp->breath_env_ptr += n; susp_took(breath_env_cnt, n); - n = ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - + n = (int) ROUNDBIG((final_time - susp->freq_env->t0) * susp->freq_env->sr - (susp->freq_env->current - susp->freq_env_cnt)); susp->freq_env_ptr += n; susp_took(freq_env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/instrsitar.c b/lib-src/libnyquist/nyquist/tran/instrsitar.c index 32fafb9a9..ba37301e7 100644 --- a/lib-src/libnyquist/nyquist/tran/instrsitar.c +++ b/lib-src/libnyquist/nyquist/tran/instrsitar.c @@ -14,7 +14,7 @@ void sitar_free(snd_susp_type a_susp); typedef struct sitar_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; struct instr *mysitar; int temp_ret_value; @@ -40,36 +40,36 @@ void sitar__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - mysitar_reg = susp->mysitar; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mysitar_reg = susp->mysitar; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) tick(mysitar_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mysitar = mysitar_reg; - out_ptr += togo; - cnt += togo; + susp->mysitar = mysitar_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* sitar__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/integrate.c b/lib-src/libnyquist/nyquist/tran/integrate.c index f55f48b31..d3442598d 100644 --- a/lib-src/libnyquist/nyquist/tran/integrate.c +++ b/lib-src/libnyquist/nyquist/tran/integrate.c @@ -14,10 +14,10 @@ void integrate_free(snd_susp_type a_susp); typedef struct integrate_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double integral; @@ -42,93 +42,93 @@ void integrate_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - integral_reg = susp->integral; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + integral_reg = susp->integral; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) integral_reg; integral_reg += *input_ptr_reg++; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->integral = integral_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->integral = integral_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* integrate_n_fetch */ void integrate_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ integrate_susp_type susp = (integrate_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/log.c b/lib-src/libnyquist/nyquist/tran/log.c index 95db96bd5..297d1ac60 100644 --- a/lib-src/libnyquist/nyquist/tran/log.c +++ b/lib-src/libnyquist/nyquist/tran/log.c @@ -14,10 +14,10 @@ void log_free(snd_susp_type a_susp); typedef struct log_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; } log_susp_node, *log_susp_type; @@ -40,91 +40,91 @@ void log_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) log((input_scale_reg * *input_ptr_reg++)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* log_s_fetch */ void log_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ log_susp_type susp = (log_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/lpreson.c b/lib-src/libnyquist/nyquist/tran/lpreson.c index 42c8707c7..f2e759c03 100644 --- a/lib-src/libnyquist/nyquist/tran/lpreson.c +++ b/lib-src/libnyquist/nyquist/tran/lpreson.c @@ -14,10 +14,10 @@ void lpreson_free(snd_susp_type a_susp); typedef struct lpreson_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type x_snd; - long x_snd_cnt; + int x_snd_cnt; sample_block_values_type x_snd_ptr; long fr_indx; @@ -60,47 +60,47 @@ void lpreson_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the x_snd input sample block: */ - susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt); - togo = min(togo, susp->x_snd_cnt); + /* don't run past the x_snd input sample block: */ + susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt); + togo = min(togo, susp->x_snd_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } if (susp->src == NULL) { @@ -162,16 +162,16 @@ out: togo = 0; /* indicate termination */ togo = min(susp->frame_length - susp->fr_indx, togo); - n = togo; - fr_indx_reg = susp->fr_indx; - ak_len_reg = susp->ak_len; - ak_coefs_reg = susp->ak_coefs; - zk_buf_reg = susp->zk_buf; - gain_reg = susp->gain; - index_reg = susp->index; - x_snd_ptr_reg = susp->x_snd_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + fr_indx_reg = susp->fr_indx; + ak_len_reg = susp->ak_len; + ak_coefs_reg = susp->ak_coefs; + zk_buf_reg = susp->zk_buf; + gain_reg = susp->gain; + index_reg = susp->index; + x_snd_ptr_reg = susp->x_snd_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double z0; long xi; long xj; z0 = (x_snd_scale_reg * *x_snd_ptr_reg++) * gain_reg; for (xi=0; xi < ak_len_reg; xi++) { xj = index_reg + xi; if (xj >= ak_len_reg) xj -= ak_len_reg; @@ -181,50 +181,50 @@ out: togo = 0; /* indicate termination */ index_reg++; if (index_reg == ak_len_reg) index_reg = 0; fr_indx_reg++; *out_ptr_reg++ = (sample_type) z0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->fr_indx = fr_indx_reg; - susp->ak_len = ak_len_reg; - susp->ak_coefs = ak_coefs_reg; - susp->zk_buf = zk_buf_reg; - susp->gain = gain_reg; - susp->index = index_reg; - /* using x_snd_ptr_reg is a bad idea on RS/6000: */ - susp->x_snd_ptr += togo; - out_ptr += togo; - susp_took(x_snd_cnt, togo); - cnt += togo; + susp->fr_indx = fr_indx_reg; + susp->ak_len = ak_len_reg; + susp->ak_coefs = ak_coefs_reg; + susp->zk_buf = zk_buf_reg; + susp->gain = gain_reg; + susp->index = index_reg; + /* using x_snd_ptr_reg is a bad idea on RS/6000: */ + susp->x_snd_ptr += togo; + out_ptr += togo; + susp_took(x_snd_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* lpreson_s_fetch */ void lpreson_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ lpreson_susp_type susp = (lpreson_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from x_snd up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr)) >= - susp->x_snd->current) - susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt); + susp->x_snd->current) + susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - + n = (int) ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr - (susp->x_snd->current - susp->x_snd_cnt)); susp->x_snd_ptr += n; susp_took(x_snd_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/maxv.c b/lib-src/libnyquist/nyquist/tran/maxv.c index c3488b437..7d3758b1d 100644 --- a/lib-src/libnyquist/nyquist/tran/maxv.c +++ b/lib-src/libnyquist/nyquist/tran/maxv.c @@ -15,13 +15,13 @@ void maxv_free(snd_susp_type a_susp); typedef struct maxv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type s2; - long s2_cnt; + int s2_cnt; sample_block_values_type s2_ptr; /* support for interpolation of s2 */ @@ -31,7 +31,7 @@ typedef struct maxv_susp_struct { /* support for ramp between samples of s2 */ double output_per_s2; - long s2_n; + int64_t s2_n; } maxv_susp_node, *maxv_susp_type; @@ -53,86 +53,86 @@ void maxv_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the s2 input sample block: */ - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - togo = min(togo, susp->s2_cnt); + /* don't run past the s2 input sample block: */ + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + togo = min(togo, susp->s2_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_ptr_reg = susp->s2_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + s2_ptr_reg = susp->s2_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double x1 = *s1_ptr_reg++; double x2 = *s2_ptr_reg++; *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s2_ptr_reg is a bad idea on RS/6000: */ - susp->s2_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(s2_cnt, togo); - cnt += togo; + /* using s2_ptr_reg is a bad idea on RS/6000: */ + susp->s2_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(s2_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_nn_fetch */ @@ -156,86 +156,86 @@ void maxv_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the s2 input sample block: */ - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - togo = min(togo, susp->s2_cnt); + /* don't run past the s2 input sample block: */ + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + togo = min(togo, susp->s2_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_ptr_reg = susp->s2_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + s2_ptr_reg = susp->s2_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double x1 = *s1_ptr_reg++; double x2 = (s2_scale_reg * *s2_ptr_reg++); *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s2_ptr_reg is a bad idea on RS/6000: */ - susp->s2_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(s2_cnt, togo); - cnt += togo; + /* using s2_ptr_reg is a bad idea on RS/6000: */ + susp->s2_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(s2_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_ns_fetch */ @@ -262,102 +262,102 @@ void maxv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); + susp->started = true; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_pHaSe_ReG = susp->s2_pHaSe; - s2_x1_sample_reg = susp->s2_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s2_pHaSe_ReG >= 1.0) { - s2_x1_sample_reg = s2_x2_sample; - /* pick up next sample as s2_x2_sample: */ - susp->s2_ptr++; - susp_took(s2_cnt, 1); - s2_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); - } + n = togo; + s2_pHaSe_ReG = susp->s2_pHaSe; + s2_x1_sample_reg = susp->s2_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (s2_pHaSe_ReG >= 1.0) { + s2_x1_sample_reg = s2_x2_sample; + /* pick up next sample as s2_x2_sample: */ + susp->s2_ptr++; + susp_took(s2_cnt, 1); + s2_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); + } { double x1 = *s1_ptr_reg++; double x2 = - (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); + (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->s2_pHaSe = s2_pHaSe_ReG; - susp->s2_x1_sample = s2_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->s2_pHaSe = s2_pHaSe_ReG; + susp->s2_x1_sample = s2_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_ni_fetch */ @@ -383,107 +383,107 @@ void maxv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s2_pHaSe = 1.0; + susp->started = true; + susp->s2_pHaSe = 1.0; } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next s2_x2_sample when phase goes past 1.0; */ - /* we use s2_n (computed below) to avoid roundoff errors: */ - if (susp->s2_n <= 0) { - susp->s2_x1_sample = s2_x2_sample; - susp->s2_ptr++; - susp_took(s2_cnt, 1); - susp->s2_pHaSe -= 1.0; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - s2_x2_sample = susp_current_sample(s2, s2_ptr); - /* s2_n gets number of samples before phase exceeds 1.0: */ - susp->s2_n = (long) ((1.0 - susp->s2_pHaSe) * - susp->output_per_s2); - } - togo = min(togo, susp->s2_n); - s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); - s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + - s2_x2_sample * susp->s2_pHaSe); + /* grab next s2_x2_sample when phase goes past 1.0; */ + /* we use s2_n (computed below) to avoid roundoff errors: */ + if (susp->s2_n <= 0) { + susp->s2_x1_sample = s2_x2_sample; + susp->s2_ptr++; + susp_took(s2_cnt, 1); + susp->s2_pHaSe -= 1.0; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + s2_x2_sample = susp_current_sample(s2, s2_ptr); + /* s2_n gets number of samples before phase exceeds 1.0: */ + susp->s2_n = (int64_t) ((1.0 - susp->s2_pHaSe) * + susp->output_per_s2); + } + togo = (int) min(togo, susp->s2_n); + s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); + s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + + s2_x2_sample * susp->s2_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double x1 = *s1_ptr_reg++; double x2 = s2_val; *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - s2_val += s2_DeLtA; - } while (--n); /* inner loop */ + s2_val += s2_DeLtA; + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; - susp->s2_n -= togo; - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; + susp->s2_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_nr_fetch */ @@ -508,86 +508,86 @@ void maxv_ss_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the s2 input sample block: */ - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - togo = min(togo, susp->s2_cnt); + /* don't run past the s2 input sample block: */ + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + togo = min(togo, susp->s2_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_ptr_reg = susp->s2_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + s2_ptr_reg = susp->s2_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double x1 = (s1_scale_reg * *s1_ptr_reg++); double x2 = (s2_scale_reg * *s2_ptr_reg++); *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s2_ptr_reg is a bad idea on RS/6000: */ - susp->s2_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(s2_cnt, togo); - cnt += togo; + /* using s2_ptr_reg is a bad idea on RS/6000: */ + susp->s2_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(s2_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_ss_fetch */ @@ -615,102 +615,102 @@ void maxv_si_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); + susp->started = true; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_pHaSe_ReG = susp->s2_pHaSe; - s2_x1_sample_reg = susp->s2_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s2_pHaSe_ReG >= 1.0) { - s2_x1_sample_reg = s2_x2_sample; - /* pick up next sample as s2_x2_sample: */ - susp->s2_ptr++; - susp_took(s2_cnt, 1); - s2_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); - } + n = togo; + s2_pHaSe_ReG = susp->s2_pHaSe; + s2_x1_sample_reg = susp->s2_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (s2_pHaSe_ReG >= 1.0) { + s2_x1_sample_reg = s2_x2_sample; + /* pick up next sample as s2_x2_sample: */ + susp->s2_ptr++; + susp_took(s2_cnt, 1); + s2_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); + } { double x1 = (s1_scale_reg * *s1_ptr_reg++); double x2 = - (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); + (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->s2_pHaSe = s2_pHaSe_ReG; - susp->s2_x1_sample = s2_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->s2_pHaSe = s2_pHaSe_ReG; + susp->s2_x1_sample = s2_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_si_fetch */ @@ -737,132 +737,132 @@ void maxv_sr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s2_pHaSe = 1.0; + susp->started = true; + susp->s2_pHaSe = 1.0; } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next s2_x2_sample when phase goes past 1.0; */ - /* we use s2_n (computed below) to avoid roundoff errors: */ - if (susp->s2_n <= 0) { - susp->s2_x1_sample = s2_x2_sample; - susp->s2_ptr++; - susp_took(s2_cnt, 1); - susp->s2_pHaSe -= 1.0; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - s2_x2_sample = susp_current_sample(s2, s2_ptr); - /* s2_n gets number of samples before phase exceeds 1.0: */ - susp->s2_n = (long) ((1.0 - susp->s2_pHaSe) * - susp->output_per_s2); - } - togo = min(togo, susp->s2_n); - s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); - s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + - s2_x2_sample * susp->s2_pHaSe); + /* grab next s2_x2_sample when phase goes past 1.0; */ + /* we use s2_n (computed below) to avoid roundoff errors: */ + if (susp->s2_n <= 0) { + susp->s2_x1_sample = s2_x2_sample; + susp->s2_ptr++; + susp_took(s2_cnt, 1); + susp->s2_pHaSe -= 1.0; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + s2_x2_sample = susp_current_sample(s2, s2_ptr); + /* s2_n gets number of samples before phase exceeds 1.0: */ + susp->s2_n = (int64_t) ((1.0 - susp->s2_pHaSe) * + susp->output_per_s2); + } + togo = (int) min(togo, susp->s2_n); + s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); + s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + + s2_x2_sample * susp->s2_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double x1 = (s1_scale_reg * *s1_ptr_reg++); double x2 = s2_val; *out_ptr_reg++ = (sample_type) (x1 > x2 ? x1 : x2); }; - s2_val += s2_DeLtA; - } while (--n); /* inner loop */ + s2_val += s2_DeLtA; + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; - susp->s2_n -= togo; - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; + susp->s2_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* maxv_sr_fetch */ void maxv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ maxv_susp_type susp = (maxv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from s2 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr)) >= - susp->s2->current) - susp_get_samples(s2, s2_ptr, s2_cnt); + susp->s2->current) + susp_get_samples(s2, s2_ptr, s2_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - + n = (int) ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - (susp->s2->current - susp->s2_cnt)); susp->s2_ptr += n; susp_took(s2_cnt, n); @@ -909,7 +909,7 @@ sound_type snd_make_maxv(sound_type s1, sound_type s2) int interp_desc = 0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - long lsc; + int64_t lsc; /* sort commutative signals: (S1 S2) */ snd_sort_2(&s1, &s2, sr); diff --git a/lib-src/libnyquist/nyquist/tran/offset.c b/lib-src/libnyquist/nyquist/tran/offset.c index f7058b4ed..53a1a9761 100644 --- a/lib-src/libnyquist/nyquist/tran/offset.c +++ b/lib-src/libnyquist/nyquist/tran/offset.c @@ -14,10 +14,10 @@ void offset_free(snd_susp_type a_susp); typedef struct offset_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sample_type offset; @@ -42,75 +42,75 @@ void offset_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *s1_ptr_reg++ + offset_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* offset_n_fetch */ @@ -134,92 +134,92 @@ void offset_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (s1_scale_reg * *s1_ptr_reg++) + offset_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* offset_s_fetch */ void offset_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ offset_susp_type susp = (offset_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/oneshot.alg b/lib-src/libnyquist/nyquist/tran/oneshot.alg index 5cbeb0cf0..9c543106a 100644 --- a/lib-src/libnyquist/nyquist/tran/oneshot.alg +++ b/lib-src/libnyquist/nyquist/tran/oneshot.alg @@ -3,7 +3,9 @@ (ARGUMENTS ("sound_type" "input") ("double" "level") ("double" "ontime")) ; (INTERNAL-SCALING input) ; scale factor not handled in level because scale could be negative (STATE ("double" "lev" "level") - ("long" "oncount" "ROUNDBIG(ontime * input->sr)") + ; maybe we need a ROUNDLONG: long is int64 on macOS but int32 on Win64 + ; the cast to long eliminates a warning on Visual Studio for Windows + ("long" "oncount" "(long) ROUNDBIG(ontime * input->sr)") ("long" "cnt" "0")) (START (MIN input)) (INNER-LOOP "double x = input; diff --git a/lib-src/libnyquist/nyquist/tran/oneshot.c b/lib-src/libnyquist/nyquist/tran/oneshot.c index 28a148a93..866e9b776 100644 --- a/lib-src/libnyquist/nyquist/tran/oneshot.c +++ b/lib-src/libnyquist/nyquist/tran/oneshot.c @@ -14,10 +14,10 @@ void oneshot_free(snd_susp_type a_susp); typedef struct oneshot_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double lev; @@ -46,81 +46,81 @@ void oneshot_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - lev_reg = susp->lev; - oncount_reg = susp->oncount; - cnt_reg = susp->cnt; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + lev_reg = susp->lev; + oncount_reg = susp->oncount; + cnt_reg = susp->cnt; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = *input_ptr_reg++; if (x > lev_reg) cnt_reg = oncount_reg; cnt_reg--; *out_ptr_reg++ = (cnt_reg >= 0 ? 1.0F : 0.0F);; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->cnt = cnt_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->cnt = cnt_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* oneshot_n_fetch */ @@ -146,98 +146,98 @@ void oneshot_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - lev_reg = susp->lev; - oncount_reg = susp->oncount; - cnt_reg = susp->cnt; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + lev_reg = susp->lev; + oncount_reg = susp->oncount; + cnt_reg = susp->cnt; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double x = (input_scale_reg * *input_ptr_reg++); if (x > lev_reg) cnt_reg = oncount_reg; cnt_reg--; *out_ptr_reg++ = (cnt_reg >= 0 ? 1.0F : 0.0F);; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->cnt = cnt_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->cnt = cnt_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* oneshot_s_fetch */ void oneshot_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ oneshot_susp_type susp = (oneshot_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); @@ -280,7 +280,7 @@ sound_type snd_make_oneshot(sound_type input, double level, double ontime) time_type t0_min = t0; falloc_generic(susp, oneshot_susp_node, "snd_make_oneshot"); susp->lev = level; - susp->oncount = ROUNDBIG(ontime * input->sr); + susp->oncount = (long) ROUNDBIG(ontime * input->sr); susp->cnt = 0; /* select a susp fn based on sample rates */ diff --git a/lib-src/libnyquist/nyquist/tran/osc.c b/lib-src/libnyquist/nyquist/tran/osc.c index 8fb059ce2..64a146dfb 100644 --- a/lib-src/libnyquist/nyquist/tran/osc.c +++ b/lib-src/libnyquist/nyquist/tran/osc.c @@ -14,7 +14,7 @@ void osc_free(snd_susp_type a_susp); typedef struct osc_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; double ph_incr; table_type the_table; @@ -44,44 +44,44 @@ void osc__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - ph_incr_reg = susp->ph_incr; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + ph_incr_reg = susp->ph_incr; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index = (long) phase_reg; double x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * (table_ptr_reg[table_index + 1] - x1)); phase_reg += ph_incr_reg; while (phase_reg >= table_len_reg) phase_reg -= table_len_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - out_ptr += togo; - cnt += togo; + susp->phase = phase_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* osc__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/partial.alg b/lib-src/libnyquist/nyquist/tran/partial.alg index 5af884ef0..7ed578f2e 100644 --- a/lib-src/libnyquist/nyquist/tran/partial.alg +++ b/lib-src/libnyquist/nyquist/tran/partial.alg @@ -9,7 +9,7 @@ ("long" "ph_incr" "ROUND32((hz * SINE_TABLE_LEN) * (1 << SINE_TABLE_SHIFT) / sr)")) (TERMINATE (MIN env)) (LOGICAL-STOP (MIN env)) -(INNER-LOOP "output = sine_table[phase >> SINE_TABLE_SHIFT] * env; +(INNER-LOOP "output = sine_table[phase >> SINE_TABLE_SHIFT] * (sample_type) env; phase += ph_incr; phase &= SINE_TABLE_MASK;") (MAINTAIN ("phase" diff --git a/lib-src/libnyquist/nyquist/tran/partial.c b/lib-src/libnyquist/nyquist/tran/partial.c index b582f4931..07cf2d23e 100644 --- a/lib-src/libnyquist/nyquist/tran/partial.c +++ b/lib-src/libnyquist/nyquist/tran/partial.c @@ -15,10 +15,10 @@ void partial_free(snd_susp_type a_susp); typedef struct partial_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type env; - long env_cnt; + int env_cnt; sample_block_values_type env_ptr; /* support for interpolation of env */ @@ -28,7 +28,7 @@ typedef struct partial_susp_struct { /* support for ramp between samples of env */ double output_per_env; - long env_n; + int64_t env_n; long phase; long ph_incr; @@ -57,79 +57,79 @@ void partial_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the env input sample block: */ - susp_check_term_log_samples(env, env_ptr, env_cnt); - togo = min(togo, susp->env_cnt); + /* don't run past the env input sample block: */ + susp_check_term_log_samples(env, env_ptr, env_cnt); + togo = min(togo, susp->env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - env_ptr_reg = susp->env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * *env_ptr_reg++; + n = togo; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + env_ptr_reg = susp->env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * (sample_type) *env_ptr_reg++; phase_reg += ph_incr_reg; phase_reg &= SINE_TABLE_MASK;; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; - /* using env_ptr_reg is a bad idea on RS/6000: */ - susp->env_ptr += togo; - out_ptr += togo; - susp_took(env_cnt, togo); - cnt += togo; + susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; + /* using env_ptr_reg is a bad idea on RS/6000: */ + susp->env_ptr += togo; + out_ptr += togo; + susp_took(env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* partial_n_fetch */ @@ -154,79 +154,79 @@ void partial_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the env input sample block: */ - susp_check_term_log_samples(env, env_ptr, env_cnt); - togo = min(togo, susp->env_cnt); + /* don't run past the env input sample block: */ + susp_check_term_log_samples(env, env_ptr, env_cnt); + togo = min(togo, susp->env_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - env_ptr_reg = susp->env_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * (env_scale_reg * *env_ptr_reg++); + n = togo; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + env_ptr_reg = susp->env_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * (sample_type) (env_scale_reg * *env_ptr_reg++); phase_reg += ph_incr_reg; phase_reg &= SINE_TABLE_MASK;; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; - /* using env_ptr_reg is a bad idea on RS/6000: */ - susp->env_ptr += togo; - out_ptr += togo; - susp_took(env_cnt, togo); - cnt += togo; + susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; + /* using env_ptr_reg is a bad idea on RS/6000: */ + susp->env_ptr += togo; + out_ptr += togo; + susp_took(env_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* partial_s_fetch */ @@ -254,95 +254,95 @@ void partial_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(env, env_ptr, env_cnt); - susp->env_x1_sample = susp_fetch_sample(env, env_ptr, env_cnt); + susp->started = true; + susp_check_term_log_samples(env, env_ptr, env_cnt); + susp->env_x1_sample = susp_fetch_sample(env, env_ptr, env_cnt); } susp_check_term_log_samples(env, env_ptr, env_cnt); env_x2_sample = susp_current_sample(env, env_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - env_pHaSe_ReG = susp->env_pHaSe; - env_x1_sample_reg = susp->env_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (env_pHaSe_ReG >= 1.0) { - env_x1_sample_reg = env_x2_sample; - /* pick up next sample as env_x2_sample: */ - susp->env_ptr++; - susp_took(env_cnt, 1); - env_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(env, env_ptr, env_cnt, env_x2_sample); - } - *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * - (env_x1_sample_reg * (1 - env_pHaSe_ReG) + env_x2_sample * env_pHaSe_ReG); + n = togo; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + env_pHaSe_ReG = susp->env_pHaSe; + env_x1_sample_reg = susp->env_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (env_pHaSe_ReG >= 1.0) { + env_x1_sample_reg = env_x2_sample; + /* pick up next sample as env_x2_sample: */ + susp->env_ptr++; + susp_took(env_cnt, 1); + env_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(env, env_ptr, env_cnt, env_x2_sample); + } + *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * (sample_type) + (env_x1_sample_reg * (1 - env_pHaSe_ReG) + env_x2_sample * env_pHaSe_ReG); phase_reg += ph_incr_reg; phase_reg &= SINE_TABLE_MASK;; - env_pHaSe_ReG += env_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + env_pHaSe_ReG += env_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; - susp->env_pHaSe = env_pHaSe_ReG; - susp->env_x1_sample = env_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; + susp->env_pHaSe = env_pHaSe_ReG; + susp->env_x1_sample = env_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* partial_i_fetch */ @@ -369,117 +369,117 @@ void partial_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->env_pHaSe = 1.0; + susp->started = true; + susp->env_pHaSe = 1.0; } susp_check_term_log_samples(env, env_ptr, env_cnt); env_x2_sample = susp_current_sample(env, env_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next env_x2_sample when phase goes past 1.0; */ - /* we use env_n (computed below) to avoid roundoff errors: */ - if (susp->env_n <= 0) { - susp->env_x1_sample = env_x2_sample; - susp->env_ptr++; - susp_took(env_cnt, 1); - susp->env_pHaSe -= 1.0; - susp_check_term_log_samples(env, env_ptr, env_cnt); - env_x2_sample = susp_current_sample(env, env_ptr); - /* env_n gets number of samples before phase exceeds 1.0: */ - susp->env_n = (long) ((1.0 - susp->env_pHaSe) * - susp->output_per_env); - } - togo = min(togo, susp->env_n); - env_DeLtA = (sample_type) ((env_x2_sample - susp->env_x1_sample) * susp->env_pHaSe_iNcR); - env_val = (sample_type) (susp->env_x1_sample * (1.0 - susp->env_pHaSe) + - env_x2_sample * susp->env_pHaSe); + /* grab next env_x2_sample when phase goes past 1.0; */ + /* we use env_n (computed below) to avoid roundoff errors: */ + if (susp->env_n <= 0) { + susp->env_x1_sample = env_x2_sample; + susp->env_ptr++; + susp_took(env_cnt, 1); + susp->env_pHaSe -= 1.0; + susp_check_term_log_samples(env, env_ptr, env_cnt); + env_x2_sample = susp_current_sample(env, env_ptr); + /* env_n gets number of samples before phase exceeds 1.0: */ + susp->env_n = (int64_t) ((1.0 - susp->env_pHaSe) * + susp->output_per_env); + } + togo = (int) min(togo, susp->env_n); + env_DeLtA = (sample_type) ((env_x2_sample - susp->env_x1_sample) * susp->env_pHaSe_iNcR); + env_val = (sample_type) (susp->env_x1_sample * (1.0 - susp->env_pHaSe) + + env_x2_sample * susp->env_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * env_val; + n = togo; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT] * (sample_type) env_val; phase_reg += ph_incr_reg; phase_reg &= SINE_TABLE_MASK;; - env_val += env_DeLtA; - } while (--n); /* inner loop */ + env_val += env_DeLtA; + } while (--n); /* inner loop */ - susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; - out_ptr += togo; - susp->env_pHaSe += togo * susp->env_pHaSe_iNcR; - susp->env_n -= togo; - cnt += togo; + susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; + out_ptr += togo; + susp->env_pHaSe += togo * susp->env_pHaSe_iNcR; + susp->env_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* partial_r_fetch */ void partial_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ partial_susp_type susp = (partial_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from env up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->env->t0) * susp->env->sr)) >= - susp->env->current) - susp_get_samples(env, env_ptr, env_cnt); + susp->env->current) + susp_get_samples(env, env_ptr, env_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->env->t0) * susp->env->sr - + n = (int) ROUNDBIG((final_time - susp->env->t0) * susp->env->sr - (susp->env->current - susp->env_cnt)); susp->env_ptr += n; susp_took(env_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/pluck.alg b/lib-src/libnyquist/nyquist/tran/pluck.alg index 84cb2bc78..7e183c67e 100644 --- a/lib-src/libnyquist/nyquist/tran/pluck.alg +++ b/lib-src/libnyquist/nyquist/tran/pluck.alg @@ -93,7 +93,7 @@ void pluck_initialize(sample_type *shiftreg, sample_type *array, values to +1 or -1. The following does the same thing with much less code: */ - *array = (krand() & 2) - 1; + *array = (sample_type) ((krand() & 2) - 1); suma += *array; /* compute sum for the average */ } avea = suma / len; diff --git a/lib-src/libnyquist/nyquist/tran/pluck.c b/lib-src/libnyquist/nyquist/tran/pluck.c index 57aae5003..7d949b24f 100644 --- a/lib-src/libnyquist/nyquist/tran/pluck.c +++ b/lib-src/libnyquist/nyquist/tran/pluck.c @@ -14,7 +14,7 @@ void pluck_free(snd_susp_type a_susp); typedef struct pluck_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; double stretch; double cons; @@ -105,7 +105,7 @@ void pluck_initialize(sample_type *shiftreg, sample_type *array, values to +1 or -1. The following does the same thing with much less code: */ - *array = (krand() & 2) - 1; + *array = (sample_type) ((krand() & 2) - 1); suma += *array; /* compute sum for the average */ } avea = suma / len; @@ -141,31 +141,31 @@ void pluck__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - stretch_reg = susp->stretch; - cons_reg = susp->cons; - loss_reg = susp->loss; - x2_reg = susp->x2; - x3_reg = susp->x3; - i1_reg = susp->i1; - i2_reg = susp->i2; - i3_reg = susp->i3; - i4_reg = susp->i4; - endptr_reg = susp->endptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + stretch_reg = susp->stretch; + cons_reg = susp->cons; + loss_reg = susp->loss; + x2_reg = susp->x2; + x3_reg = susp->x3; + i1_reg = susp->i1; + i2_reg = susp->i2; + i3_reg = susp->i3; + i4_reg = susp->i4; + endptr_reg = susp->endptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ sample_type sum = (sample_type) ((*i1_reg++ * x2_reg) + (*i2_reg++ * x3_reg) + (*i3_reg++ * stretch_reg) - (*i4_reg++ * cons_reg)); @@ -180,22 +180,22 @@ void pluck__fetch(snd_susp_type a_susp, snd_list_type snd_list) /* deliver sample */ *out_ptr_reg++ = sum; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->i1 = i1_reg; - susp->i2 = i2_reg; - susp->i3 = i3_reg; - susp->i4 = i4_reg; - out_ptr += togo; - cnt += togo; + susp->i1 = i1_reg; + susp->i2 = i2_reg; + susp->i3 = i3_reg; + susp->i4 = i4_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* pluck__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/prod.alg b/lib-src/libnyquist/nyquist/tran/prod.alg index 1a36c045e..272d73630 100644 --- a/lib-src/libnyquist/nyquist/tran/prod.alg +++ b/lib-src/libnyquist/nyquist/tran/prod.alg @@ -3,7 +3,7 @@ (ARGUMENTS ("sound_type" "s1") ("sound_type" "s2")) (START (MAX s1 s2)) (COMMUTATIVE (s1 s2)) - (INNER-LOOP "output = s1 * s2") + (INNER-LOOP "output = (sample_type) s1 * (sample_type) s2") (LINEAR s1 s2) (TERMINATE (MIN s1 s2)) (LOGICAL-STOP (MIN s1 s2)) diff --git a/lib-src/libnyquist/nyquist/tran/prod.c b/lib-src/libnyquist/nyquist/tran/prod.c index 2996f7cb9..213b6d0b8 100644 --- a/lib-src/libnyquist/nyquist/tran/prod.c +++ b/lib-src/libnyquist/nyquist/tran/prod.c @@ -15,13 +15,13 @@ void prod_free(snd_susp_type a_susp); typedef struct prod_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type s2; - long s2_cnt; + int s2_cnt; sample_block_values_type s2_ptr; /* support for interpolation of s2 */ @@ -31,7 +31,7 @@ typedef struct prod_susp_struct { /* support for ramp between samples of s2 */ double output_per_s2; - long s2_n; + int64_t s2_n; } prod_susp_node, *prod_susp_type; @@ -53,82 +53,82 @@ void prod_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the s2 input sample block: */ - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - togo = min(togo, susp->s2_cnt); + /* don't run past the s2 input sample block: */ + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + togo = min(togo, susp->s2_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_ptr_reg = susp->s2_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - *out_ptr_reg++ = *s1_ptr_reg++ * *s2_ptr_reg++; - } while (--n); /* inner loop */ + n = togo; + s2_ptr_reg = susp->s2_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + *out_ptr_reg++ = (sample_type) *s1_ptr_reg++ * (sample_type) *s2_ptr_reg++; + } while (--n); /* inner loop */ - /* using s2_ptr_reg is a bad idea on RS/6000: */ - susp->s2_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(s2_cnt, togo); - cnt += togo; + /* using s2_ptr_reg is a bad idea on RS/6000: */ + susp->s2_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(s2_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* prod_nn_fetch */ @@ -155,98 +155,98 @@ void prod_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); + susp->started = true; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + susp->s2_x1_sample = susp_fetch_sample(s2, s2_ptr, s2_cnt); } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s2_pHaSe_ReG = susp->s2_pHaSe; - s2_x1_sample_reg = susp->s2_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (s2_pHaSe_ReG >= 1.0) { - s2_x1_sample_reg = s2_x2_sample; - /* pick up next sample as s2_x2_sample: */ - susp->s2_ptr++; - susp_took(s2_cnt, 1); - s2_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); - } - *out_ptr_reg++ = *s1_ptr_reg++ * - (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); - s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + n = togo; + s2_pHaSe_ReG = susp->s2_pHaSe; + s2_x1_sample_reg = susp->s2_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (s2_pHaSe_ReG >= 1.0) { + s2_x1_sample_reg = s2_x2_sample; + /* pick up next sample as s2_x2_sample: */ + susp->s2_ptr++; + susp_took(s2_cnt, 1); + s2_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s2, s2_ptr, s2_cnt, s2_x2_sample); + } + *out_ptr_reg++ = (sample_type) *s1_ptr_reg++ * (sample_type) + (s2_x1_sample_reg * (1 - s2_pHaSe_ReG) + s2_x2_sample * s2_pHaSe_ReG); + s2_pHaSe_ReG += s2_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->s2_pHaSe = s2_pHaSe_ReG; - susp->s2_x1_sample = s2_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->s2_pHaSe = s2_pHaSe_ReG; + susp->s2_x1_sample = s2_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* prod_ni_fetch */ @@ -272,128 +272,128 @@ void prod_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s2_pHaSe = 1.0; + susp->started = true; + susp->s2_pHaSe = 1.0; } susp_check_term_log_samples(s2, s2_ptr, s2_cnt); s2_x2_sample = susp_current_sample(s2, s2_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next s2_x2_sample when phase goes past 1.0; */ - /* we use s2_n (computed below) to avoid roundoff errors: */ - if (susp->s2_n <= 0) { - susp->s2_x1_sample = s2_x2_sample; - susp->s2_ptr++; - susp_took(s2_cnt, 1); - susp->s2_pHaSe -= 1.0; - susp_check_term_log_samples(s2, s2_ptr, s2_cnt); - s2_x2_sample = susp_current_sample(s2, s2_ptr); - /* s2_n gets number of samples before phase exceeds 1.0: */ - susp->s2_n = (long) ((1.0 - susp->s2_pHaSe) * - susp->output_per_s2); - } - togo = min(togo, susp->s2_n); - s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); - s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + - s2_x2_sample * susp->s2_pHaSe); + /* grab next s2_x2_sample when phase goes past 1.0; */ + /* we use s2_n (computed below) to avoid roundoff errors: */ + if (susp->s2_n <= 0) { + susp->s2_x1_sample = s2_x2_sample; + susp->s2_ptr++; + susp_took(s2_cnt, 1); + susp->s2_pHaSe -= 1.0; + susp_check_term_log_samples(s2, s2_ptr, s2_cnt); + s2_x2_sample = susp_current_sample(s2, s2_ptr); + /* s2_n gets number of samples before phase exceeds 1.0: */ + susp->s2_n = (int64_t) ((1.0 - susp->s2_pHaSe) * + susp->output_per_s2); + } + togo = (int) min(togo, susp->s2_n); + s2_DeLtA = (sample_type) ((s2_x2_sample - susp->s2_x1_sample) * susp->s2_pHaSe_iNcR); + s2_val = (sample_type) (susp->s2_x1_sample * (1.0 - susp->s2_pHaSe) + + s2_x2_sample * susp->s2_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - *out_ptr_reg++ = *s1_ptr_reg++ * s2_val; - s2_val += s2_DeLtA; - } while (--n); /* inner loop */ + n = togo; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + *out_ptr_reg++ = (sample_type) *s1_ptr_reg++ * (sample_type) s2_val; + s2_val += s2_DeLtA; + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; - susp->s2_n -= togo; - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->s2_pHaSe += togo * susp->s2_pHaSe_iNcR; + susp->s2_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* prod_nr_fetch */ void prod_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ prod_susp_type susp = (prod_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from s2 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr)) >= - susp->s2->current) - susp_get_samples(s2, s2_ptr, s2_cnt); + susp->s2->current) + susp_get_samples(s2, s2_ptr, s2_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - + n = (int) ROUNDBIG((final_time - susp->s2->t0) * susp->s2->sr - (susp->s2->current - susp->s2_cnt)); susp->s2_ptr += n; susp_took(s2_cnt, n); @@ -440,7 +440,7 @@ sound_type snd_make_prod(sound_type s1, sound_type s2) int interp_desc = 0; sample_type scale_factor = 1.0F; time_type t0_min = t0; - long lsc; + int64_t lsc; /* sort commutative signals: (S1 S2) */ snd_sort_2(&s1, &s2, sr); diff --git a/lib-src/libnyquist/nyquist/tran/pwl.alg b/lib-src/libnyquist/nyquist/tran/pwl.alg index 91f7306e6..c7302844e 100644 --- a/lib-src/libnyquist/nyquist/tran/pwl.alg +++ b/lib-src/libnyquist/nyquist/tran/pwl.alg @@ -46,7 +46,7 @@ boolean compute_lvl(pwl_susp_type susp) /* * returns true if it is time to terminate */ -boolean compute_incr(pwl_susp_type susp, long *n, long cur) +boolean compute_incr(pwl_susp_type susp, int64_t *n, int64_t cur) { double target; while (*n == 0) { @@ -74,19 +74,19 @@ boolean compute_incr(pwl_susp_type susp, long *n, long cur) ("LVAL" "bpt_ptr" "lis") ("double" "incr" "0.0") ("double" "lvl" "0.0; - { long temp = 0; compute_incr(susp, &temp, 0); }")) + { int64_t temp = 0; compute_incr(susp, &temp, 0); }")) (OUTER-LOOP " if (susp->bpt_ptr == NULL) { out: togo = 0; /* indicate termination */ break; /* we're done */ } - { long cur = susp->susp.current + cnt; - long nn = getfixnum(car(susp->bpt_ptr)) - cur; + { int64_t cur = susp->susp.current + cnt; + int64_t nn = getfixnum(car(susp->bpt_ptr)) - cur; if (nn == 0) { if (compute_lvl(susp) || compute_incr(susp, &nn, cur)) goto out; } - togo = min(nn, togo); + togo = (int) min(nn, togo); } ") (INNER-LOOP "output = (sample_type) lvl; lvl += incr") diff --git a/lib-src/libnyquist/nyquist/tran/pwl.c b/lib-src/libnyquist/nyquist/tran/pwl.c index d52a8ee2a..5348d8237 100644 --- a/lib-src/libnyquist/nyquist/tran/pwl.c +++ b/lib-src/libnyquist/nyquist/tran/pwl.c @@ -65,7 +65,7 @@ boolean compute_lvl(pwl_susp_type susp) /* * returns true if it is time to terminate */ -boolean compute_incr(pwl_susp_type susp, long *n, long cur) +boolean compute_incr(pwl_susp_type susp, int64_t *n, int64_t cur) { double target; while (*n == 0) { @@ -107,42 +107,42 @@ void pwl__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; if (susp->bpt_ptr == NULL) { out: togo = 0; /* indicate termination */ break; /* we're done */ } - { long cur = susp->susp.current + cnt; - long nn = getfixnum(car(susp->bpt_ptr)) - cur; + { int64_t cur = susp->susp.current + cnt; + int64_t nn = getfixnum(car(susp->bpt_ptr)) - cur; if (nn == 0) { if (compute_lvl(susp) || compute_incr(susp, &nn, cur)) goto out; } - togo = min(nn, togo); + togo = (int) min(nn, togo); } - n = togo; - incr_reg = susp->incr; - lvl_reg = susp->lvl; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + incr_reg = susp->incr; + lvl_reg = susp->lvl; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) lvl_reg; lvl_reg += incr_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->lvl += susp->incr * togo; - out_ptr += togo; - cnt += togo; + susp->lvl += susp->incr * togo; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* pwl__fetch */ @@ -176,7 +176,7 @@ sound_type snd_make_pwl(time_type t0, rate_type sr, LVAL lis) susp->bpt_ptr = lis; susp->incr = 0.0; susp->lvl = 0.0; - { long temp = 0; compute_incr(susp, &temp, 0); }; + { int64_t temp = 0; compute_incr(susp, &temp, 0); }; susp->susp.fetch = pwl__fetch; /* initialize susp state */ diff --git a/lib-src/libnyquist/nyquist/tran/quantize.alg b/lib-src/libnyquist/nyquist/tran/quantize.alg index 465a648ab..b3f200466 100644 --- a/lib-src/libnyquist/nyquist/tran/quantize.alg +++ b/lib-src/libnyquist/nyquist/tran/quantize.alg @@ -3,15 +3,15 @@ (ARGUMENTS ("sound_type" "s1") ("long" "steps")) (INTERNAL-SCALING s1) (START (MIN s1)) - (STATE ("double" "factor" "s1->scale * steps; + (STATE ("sample_type" "factor" "s1->scale * steps; scale_factor = (sample_type) (1.0 / steps);")) (INNER-LOOP "{ -\t\tfloat x = s1 * factor; -\t\tlong xx; -\t\tx = (x > 0.0F ? x + 0.5F : x - 0.5F); -\t\txx = (long) x; -\t\toutput = (float) xx; -\t }") + float x = s1 * factor; + long xx; + x = (x > 0.0F ? x + 0.5F : x - 0.5F); + xx = (long) x; + output = (float) xx; + }") (TERMINATE (MIN s1)) (CONSTANT "factor") (LOGICAL-STOP (MIN s1)) diff --git a/lib-src/libnyquist/nyquist/tran/quantize.c b/lib-src/libnyquist/nyquist/tran/quantize.c index 712b48cea..555a8e9db 100644 --- a/lib-src/libnyquist/nyquist/tran/quantize.c +++ b/lib-src/libnyquist/nyquist/tran/quantize.c @@ -14,13 +14,13 @@ void quantize_free(snd_susp_type a_susp); typedef struct quantize_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; - double factor; + sample_type factor; } quantize_susp_node, *quantize_susp_type; @@ -35,105 +35,105 @@ void quantize_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) register sample_block_values_type out_ptr_reg; - register double factor_reg; + register sample_type factor_reg; register sample_block_values_type s1_ptr_reg; falloc_sample_block(out, "quantize_n_fetch"); out_ptr = out->samples; snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - factor_reg = susp->factor; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + factor_reg = susp->factor; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { - float x = *s1_ptr_reg++ * factor_reg; - long xx; - x = (x > 0.0F ? x + 0.5F : x - 0.5F); - xx = (long) x; - *out_ptr_reg++ = (float) xx; - }; - } while (--n); /* inner loop */ + float x = *s1_ptr_reg++ * factor_reg; + long xx; + x = (x > 0.0F ? x + 0.5F : x - 0.5F); + xx = (long) x; + *out_ptr_reg++ = (float) xx; + }; + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* quantize_n_fetch */ void quantize_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ quantize_susp_type susp = (quantize_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/quantize.h b/lib-src/libnyquist/nyquist/tran/quantize.h index 49630da1c..12a3f29d5 100644 --- a/lib-src/libnyquist/nyquist/tran/quantize.h +++ b/lib-src/libnyquist/nyquist/tran/quantize.h @@ -1,3 +1,3 @@ sound_type snd_make_quantize(sound_type s1, long steps); sound_type snd_quantize(sound_type s1, long steps); - /* LISP: (snd-quantize SOUND FIXNUM) */ + /* LISP: (snd-quantize SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/recip.c b/lib-src/libnyquist/nyquist/tran/recip.c index 93b058b0f..a6b26fc2c 100644 --- a/lib-src/libnyquist/nyquist/tran/recip.c +++ b/lib-src/libnyquist/nyquist/tran/recip.c @@ -14,10 +14,10 @@ void recip_free(snd_susp_type a_susp); typedef struct recip_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; double scale; @@ -42,92 +42,92 @@ void recip_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale_reg = susp->scale; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + scale_reg = susp->scale; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (scale_reg / *s1_ptr_reg++); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* recip_n_fetch */ void recip_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ recip_susp_type susp = (recip_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/reson.c b/lib-src/libnyquist/nyquist/tran/reson.c index a49d6ec1b..cebb9345d 100644 --- a/lib-src/libnyquist/nyquist/tran/reson.c +++ b/lib-src/libnyquist/nyquist/tran/reson.c @@ -14,10 +14,10 @@ void reson_free(snd_susp_type a_susp); typedef struct reson_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s; - long s_cnt; + int s_cnt; sample_block_values_type s_ptr; double c3; @@ -53,83 +53,83 @@ void reson_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3_reg = susp->c3; - c2_reg = susp->c2; - c1_reg = susp->c1; - y1_reg = susp->y1; - y2_reg = susp->y2; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3_reg = susp->c3; + c2_reg = susp->c2; + c1_reg = susp->c1; + y1_reg = susp->y1; + y2_reg = susp->y2; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * *s_ptr_reg++ + c2_reg * y1_reg - c3_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* reson_n_fetch */ @@ -157,100 +157,100 @@ void reson_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s input sample block: */ - susp_check_term_log_samples(s, s_ptr, s_cnt); - togo = min(togo, susp->s_cnt); + /* don't run past the s input sample block: */ + susp_check_term_log_samples(s, s_ptr, s_cnt); + togo = min(togo, susp->s_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3_reg = susp->c3; - c2_reg = susp->c2; - c1_reg = susp->c1; - y1_reg = susp->y1; - y2_reg = susp->y2; - s_ptr_reg = susp->s_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3_reg = susp->c3; + c2_reg = susp->c2; + c1_reg = susp->c1; + y1_reg = susp->y1; + y2_reg = susp->y2; + s_ptr_reg = susp->s_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * (s_scale_reg * *s_ptr_reg++) + c2_reg * y1_reg - c3_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s_ptr_reg is a bad idea on RS/6000: */ - susp->s_ptr += togo; - out_ptr += togo; - susp_took(s_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s_ptr_reg is a bad idea on RS/6000: */ + susp->s_ptr += togo; + out_ptr += togo; + susp_took(s_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* reson_s_fetch */ void reson_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ reson_susp_type susp = (reson_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >= - susp->s->current) - susp_get_samples(s, s_ptr, s_cnt); + susp->s->current) + susp_get_samples(s, s_ptr, s_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - + n = (int) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr - (susp->s->current - susp->s_cnt)); susp->s_ptr += n; susp_took(s_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/reson.h b/lib-src/libnyquist/nyquist/tran/reson.h index aec354aa0..23d491112 100644 --- a/lib-src/libnyquist/nyquist/tran/reson.h +++ b/lib-src/libnyquist/nyquist/tran/reson.h @@ -1,3 +1,3 @@ sound_type snd_make_reson(sound_type s, double hz, double bw, int normalization); sound_type snd_reson(sound_type s, double hz, double bw, int normalization); - /* LISP: (snd-reson SOUND ANYNUM ANYNUM FIXNUM) */ + /* LISP: (snd-reson SOUND ANYNUM ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/resoncv.c b/lib-src/libnyquist/nyquist/tran/resoncv.c index c33b13789..0eee8528f 100644 --- a/lib-src/libnyquist/nyquist/tran/resoncv.c +++ b/lib-src/libnyquist/nyquist/tran/resoncv.c @@ -15,13 +15,13 @@ void resoncv_free(snd_susp_type a_susp); typedef struct resoncv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type bw; - long bw_cnt; + int bw_cnt; sample_block_values_type bw_ptr; /* support for interpolation of bw */ @@ -31,7 +31,7 @@ typedef struct resoncv_susp_struct { /* support for ramp between samples of bw */ double output_per_bw; - long bw_n; + int64_t bw_n; double scale1; double c3co; @@ -71,105 +71,105 @@ void resoncv_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - double c3p1; - double c3t4; - double omc3; - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1 = c3co_reg + 1.0; - c3t4 = c3co_reg * 4.0; - omc3 = 1.0 - c3co_reg; - c2_reg = c3t4 * coshz_reg / c3p1; - c1_reg = (normalization_reg == 0 ? 1.0 : + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + double c3p1; + double c3t4; + double omc3; + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1 = c3co_reg + 1.0; + c3t4 = c3co_reg * 4.0; + omc3 = 1.0 - c3co_reg; + c2_reg = c3t4 * coshz_reg / c3p1; + c1_reg = (normalization_reg == 0 ? 1.0 : (normalization_reg == 1 ? omc3 * sqrt(1.0 - c2_reg * c2_reg / c3t4) : sqrt(c3p1 * c3p1 - c2_reg * c2_reg) * omc3 / c3p1)) * scale1_reg; { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resoncv_ns_fetch */ @@ -203,129 +203,129 @@ void resoncv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - double c3p1; - double c3t4; - double omc3; - susp->started = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - c3p1 = susp->c3co + 1.0; - c3t4 = susp->c3co * 4.0; - omc3 = 1.0 - susp->c3co; - susp->c2 = c3t4 * susp->coshz / c3p1; - susp->c1 = (susp->normalization == 0 ? 1.0 : + double c3p1; + double c3t4; + double omc3; + susp->started = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + c3p1 = susp->c3co + 1.0; + c3t4 = susp->c3co * 4.0; + omc3 = 1.0 - susp->c3co; + susp->c2 = c3t4 * susp->coshz / c3p1; + susp->c1 = (susp->normalization == 0 ? 1.0 : (susp->normalization == 1 ? omc3 * sqrt(1.0 - susp->c2 * susp->c2 / c3t4) : sqrt(c3p1 * c3p1 - susp->c2 * susp->c2) * omc3 / c3p1)) * susp->scale1; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (bw_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - double c3p1; - double c3t4; - double omc3; - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1 = c3co_reg + 1.0; - c3t4 = c3co_reg * 4.0; - omc3 = 1.0 - c3co_reg; - c2_reg = c3t4 * coshz_reg / c3p1; - c1_reg = (normalization_reg == 0 ? 1.0 : + double c3p1; + double c3t4; + double omc3; + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1 = c3co_reg + 1.0; + c3t4 = c3co_reg * 4.0; + omc3 = 1.0 - c3co_reg; + c2_reg = c3t4 * coshz_reg / c3p1; + c1_reg = (normalization_reg == 0 ? 1.0 : (normalization_reg == 1 ? omc3 * sqrt(1.0 - c2_reg * c2_reg / c3t4) : sqrt(c3p1 * c3p1 - c2_reg * c2_reg) * omc3 / c3p1)) * scale1_reg; - } + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resoncv_ni_fetch */ @@ -357,143 +357,143 @@ void resoncv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - double c3p1; - double c3t4; - double omc3; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - c3p1 = susp->c3co + 1.0; - c3t4 = susp->c3co * 4.0; - omc3 = 1.0 - susp->c3co; - susp->c2 = c3t4 * susp->coshz / c3p1; - susp->c1 = (susp->normalization == 0 ? 1.0 : + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + double c3p1; + double c3t4; + double omc3; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + c3p1 = susp->c3co + 1.0; + c3t4 = susp->c3co * 4.0; + omc3 = 1.0 - susp->c3co; + susp->c2 = c3t4 * susp->coshz / c3p1; + susp->c1 = (susp->normalization == 0 ? 1.0 : (susp->normalization == 1 ? omc3 * sqrt(1.0 - susp->c2 * susp->c2 / c3t4) : sqrt(c3p1 * c3p1 - susp->c2 * susp->c2) * omc3 / c3p1)) * susp->scale1; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resoncv_nr_fetch */ void resoncv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ resoncv_susp_type susp = (resoncv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from bw up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr)) >= - susp->bw->current) - susp_get_samples(bw, bw_ptr, bw_cnt); + susp->bw->current) + susp_get_samples(bw, bw_ptr, bw_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - + n = (int) ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - (susp->bw->current - susp->bw_cnt)); susp->bw_ptr += n; susp_took(bw_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/resoncv.h b/lib-src/libnyquist/nyquist/tran/resoncv.h index 57bbf60b4..e478574f4 100644 --- a/lib-src/libnyquist/nyquist/tran/resoncv.h +++ b/lib-src/libnyquist/nyquist/tran/resoncv.h @@ -1,3 +1,3 @@ sound_type snd_make_resoncv(sound_type s1, double hz, sound_type bw, int normalization); sound_type snd_resoncv(sound_type s1, double hz, sound_type bw, int normalization); - /* LISP: (snd-resoncv SOUND ANYNUM SOUND FIXNUM) */ + /* LISP: (snd-resoncv SOUND ANYNUM SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/resonvc.c b/lib-src/libnyquist/nyquist/tran/resonvc.c index 5267ee80e..c15edb7b1 100644 --- a/lib-src/libnyquist/nyquist/tran/resonvc.c +++ b/lib-src/libnyquist/nyquist/tran/resonvc.c @@ -15,13 +15,13 @@ void resonvc_free(snd_susp_type a_susp); typedef struct resonvc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz; - long hz_cnt; + int hz_cnt; sample_block_values_type hz_ptr; /* support for interpolation of hz */ @@ -31,7 +31,7 @@ typedef struct resonvc_susp_struct { /* support for ramp between samples of hz */ double output_per_hz; - long hz_n; + int64_t hz_n; double scale1; double c3co; @@ -75,100 +75,100 @@ void resonvc_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz input sample block: */ - susp_check_term_samples(hz, hz_ptr, hz_cnt); - togo = min(togo, susp->hz_cnt); + /* don't run past the hz input sample block: */ + susp_check_term_samples(hz, hz_ptr, hz_cnt); + togo = min(togo, susp->hz_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz_ptr_reg = susp->hz_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - c2_reg = c3t4_reg * cos((hz_scale_reg * *hz_ptr_reg++)) / c3p1_reg; - c1_reg = (normalization_reg == 0 ? scale1_reg : + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz_ptr_reg = susp->hz_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + c2_reg = c3t4_reg * cos((hz_scale_reg * *hz_ptr_reg++)) / c3p1_reg; + c1_reg = (normalization_reg == 0 ? scale1_reg : (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using hz_ptr_reg is a bad idea on RS/6000: */ - susp->hz_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz_cnt, togo); - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using hz_ptr_reg is a bad idea on RS/6000: */ + susp->hz_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvc_ns_fetch */ @@ -204,117 +204,117 @@ void resonvc_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? susp->scale1 : + susp->started = true; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? susp->scale1 : (susp->normalization == 1 ? susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)) * susp->scale1; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz_pHaSe_ReG = susp->hz_pHaSe; - hz_x1_sample_reg = susp->hz_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (hz_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz_pHaSe_ReG = susp->hz_pHaSe; + hz_x1_sample_reg = susp->hz_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ - /* pick up next sample as hz_x1_sample: */ - susp->hz_ptr++; - susp_took(hz_cnt, 1); - hz_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); - hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); - c2_reg = c3t4_reg * cos(hz_x1_sample_reg) / c3p1_reg; - c1_reg = (normalization_reg == 0 ? scale1_reg : + /* pick up next sample as hz_x1_sample: */ + susp->hz_ptr++; + susp_took(hz_cnt, 1); + hz_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); + hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); + c2_reg = c3t4_reg * cos(hz_x1_sample_reg) / c3p1_reg; + c1_reg = (normalization_reg == 0 ? scale1_reg : (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->hz_pHaSe = hz_pHaSe_ReG; - susp->hz_x1_sample = hz_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->hz_pHaSe = hz_pHaSe_ReG; + susp->hz_x1_sample = hz_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvc_ni_fetch */ @@ -348,138 +348,138 @@ void resonvc_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz_pHaSe = 1.0; + susp->started = true; + susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz_x1_sample when phase goes past 1.0; */ - /* use hz_n (computed below) to avoid roundoff errors: */ - if (susp->hz_n <= 0) { - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->hz_pHaSe -= 1.0; - /* hz_n gets number of samples before phase exceeds 1.0: */ - susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * - susp->output_per_hz); - susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? susp->scale1 : + /* grab next hz_x1_sample when phase goes past 1.0; */ + /* use hz_n (computed below) to avoid roundoff errors: */ + if (susp->hz_n <= 0) { + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->hz_pHaSe -= 1.0; + /* hz_n gets number of samples before phase exceeds 1.0: */ + susp->hz_n = (int64_t) ((1.0 - susp->hz_pHaSe) * + susp->output_per_hz); + susp->c2 = susp->c3t4 * cos(susp->hz_x1_sample) / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? susp->scale1 : (susp->normalization == 1 ? susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)) * susp->scale1; - } - togo = min(togo, susp->hz_n); - hz_val = susp->hz_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + } + togo = (int) min(togo, susp->hz_n); + hz_val = susp->hz_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - c2_reg = susp->c2; - c1_reg = susp->c1; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + c2_reg = susp->c2; + c1_reg = susp->c1; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; - susp->hz_n -= togo; - cnt += togo; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; + susp->hz_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvc_nr_fetch */ void resonvc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ resonvc_susp_type susp = (resonvc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr)) >= - susp->hz->current) - susp_get_samples(hz, hz_ptr, hz_cnt); + susp->hz->current) + susp_get_samples(hz, hz_ptr, hz_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - + n = (int) ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - (susp->hz->current - susp->hz_cnt)); susp->hz_ptr += n; susp_took(hz_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/resonvc.h b/lib-src/libnyquist/nyquist/tran/resonvc.h index b7b5d84fd..5f5a27027 100644 --- a/lib-src/libnyquist/nyquist/tran/resonvc.h +++ b/lib-src/libnyquist/nyquist/tran/resonvc.h @@ -1,3 +1,3 @@ sound_type snd_make_resonvc(sound_type s1, sound_type hz, double bw, int normalization); sound_type snd_resonvc(sound_type s1, sound_type hz, double bw, int normalization); - /* LISP: (snd-resonvc SOUND SOUND ANYNUM FIXNUM) */ + /* LISP: (snd-resonvc SOUND SOUND ANYNUM LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/resonvv.c b/lib-src/libnyquist/nyquist/tran/resonvv.c index e7eb67b25..9e73b399f 100644 --- a/lib-src/libnyquist/nyquist/tran/resonvv.c +++ b/lib-src/libnyquist/nyquist/tran/resonvv.c @@ -15,13 +15,13 @@ void resonvv_free(snd_susp_type a_susp); typedef struct resonvv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz1; - long hz1_cnt; + int hz1_cnt; sample_block_values_type hz1_ptr; /* support for interpolation of hz1 */ @@ -31,9 +31,9 @@ typedef struct resonvv_susp_struct { /* support for ramp between samples of hz1 */ double output_per_hz1; - long hz1_n; + int64_t hz1_n; sound_type bw; - long bw_cnt; + int bw_cnt; sample_block_values_type bw_ptr; /* support for interpolation of bw */ @@ -43,7 +43,7 @@ typedef struct resonvv_susp_struct { /* support for ramp between samples of bw */ double output_per_bw; - long bw_n; + int64_t bw_n; double scale1; double c3co; @@ -93,121 +93,121 @@ void resonvv_nss_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nss_fetch */ @@ -247,139 +247,139 @@ void resonvv_nsi_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (bw_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nsi_fetch */ @@ -417,134 +417,134 @@ void resonvv_nsr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz1 input sample block: */ - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - togo = min(togo, susp->hz1_cnt); + /* don't run past the hz1 input sample block: */ + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + togo = min(togo, susp->hz1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz1_ptr_reg = susp->hz1_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz1_ptr_reg = susp->hz1_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + coshz_reg = cos((hz1_scale_reg * *hz1_ptr_reg++)); + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using hz1_ptr_reg is a bad idea on RS/6000: */ - susp->hz1_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using hz1_ptr_reg is a bad idea on RS/6000: */ + susp->hz1_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nsr_fetch */ @@ -584,136 +584,136 @@ void resonvv_nis_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (hz1_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(bw_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nis_fetch */ @@ -754,149 +754,149 @@ void resonvv_nii_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (hz1_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - if (bw_pHaSe_ReG >= 1.0) { + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nii_fetch */ @@ -935,145 +935,145 @@ void resonvv_nir_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - hz1_pHaSe_ReG = susp->hz1_pHaSe; - hz1_x1_sample_reg = susp->hz1_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (hz1_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + hz1_pHaSe_ReG = susp->hz1_pHaSe; + hz1_x1_sample_reg = susp->hz1_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (hz1_pHaSe_ReG >= 1.0) { /* fixup-depends hz1 */ - /* pick up next sample as hz1_x1_sample: */ - susp->hz1_ptr++; - susp_took(hz1_cnt, 1); - hz1_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); - hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); - coshz_reg = cos(hz1_x1_sample_reg); - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + /* pick up next sample as hz1_x1_sample: */ + susp->hz1_ptr++; + susp_took(hz1_cnt, 1); + hz1_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz1, hz1_ptr, hz1_cnt, hz1_x1_sample_reg); + hz1_x1_sample_reg = susp_current_sample(hz1, hz1_ptr); + coshz_reg = cos(hz1_x1_sample_reg); + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz1_pHaSe_ReG += hz1_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->hz1_pHaSe = hz1_pHaSe_ReG; - susp->hz1_x1_sample = hz1_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->hz1_pHaSe = hz1_pHaSe_ReG; + susp->hz1_x1_sample = hz1_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nir_fetch */ @@ -1111,134 +1111,134 @@ void resonvv_nrs_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; + susp->started = true; + susp->hz1_pHaSe = 1.0; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* don't run past the bw input sample block: */ - susp_check_term_samples(bw, bw_ptr, bw_cnt); - togo = min(togo, susp->bw_cnt); + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* don't run past the bw input sample block: */ + susp_check_term_samples(bw, bw_ptr, bw_cnt); + togo = min(togo, susp->bw_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_ptr_reg = susp->bw_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_ptr_reg = susp->bw_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + c3co_reg = exp((bw_scale_reg * *bw_ptr_reg++)); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using bw_ptr_reg is a bad idea on RS/6000: */ - susp->bw_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - susp_took(bw_cnt, togo); - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using bw_ptr_reg is a bad idea on RS/6000: */ + susp->bw_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + susp_took(bw_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nrs_fetch */ @@ -1277,148 +1277,148 @@ void resonvv_nri_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; + susp->started = true; + susp->hz1_pHaSe = 1.0; + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c3co_reg = susp->c3co; - c3p1_reg = susp->c3p1; - c3t4_reg = susp->c3t4; - omc3_reg = susp->omc3; - coshz_reg = susp->coshz; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - normalization_reg = susp->normalization; - y1_reg = susp->y1; - y2_reg = susp->y2; - bw_pHaSe_ReG = susp->bw_pHaSe; - bw_x1_sample_reg = susp->bw_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (bw_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c3co_reg = susp->c3co; + c3p1_reg = susp->c3p1; + c3t4_reg = susp->c3t4; + omc3_reg = susp->omc3; + coshz_reg = susp->coshz; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + normalization_reg = susp->normalization; + y1_reg = susp->y1; + y2_reg = susp->y2; + bw_pHaSe_ReG = susp->bw_pHaSe; + bw_x1_sample_reg = susp->bw_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (bw_pHaSe_ReG >= 1.0) { /* fixup-depends bw */ - /* pick up next sample as bw_x1_sample: */ - susp->bw_ptr++; - susp_took(bw_cnt, 1); - bw_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); - bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); - c3co_reg = exp(bw_x1_sample_reg); - c3p1_reg = c3co_reg + 1.0; - c3t4_reg = c3co_reg * 4.0; - omc3_reg = 1.0 - c3co_reg; - recompute_reg = true; - } - if (recompute_reg) { - recompute_reg = false; - c2_reg = c3t4_reg * coshz_reg / c3p1_reg; - c1_reg = (normalization_reg == 0 ? 1.0 : - (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : - sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; - } + /* pick up next sample as bw_x1_sample: */ + susp->bw_ptr++; + susp_took(bw_cnt, 1); + bw_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(bw, bw_ptr, bw_cnt, bw_x1_sample_reg); + bw_x1_sample_reg = susp_current_sample(bw, bw_ptr); + c3co_reg = exp(bw_x1_sample_reg); + c3p1_reg = c3co_reg + 1.0; + c3t4_reg = c3co_reg * 4.0; + omc3_reg = 1.0 - c3co_reg; + recompute_reg = true; + } + if (recompute_reg) { + recompute_reg = false; + c2_reg = c3t4_reg * coshz_reg / c3p1_reg; + c1_reg = (normalization_reg == 0 ? 1.0 : + (normalization_reg == 1 ? omc3_reg * sqrt(1.0 - c2_reg * c2_reg / c3t4_reg) : + sqrt(c3p1_reg * c3p1_reg - c2_reg * c2_reg) * omc3_reg / c3p1_reg)) * scale1_reg; + } { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + bw_pHaSe_ReG += bw_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - susp->bw_pHaSe = bw_pHaSe_ReG; - susp->bw_x1_sample = bw_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - cnt += togo; + togo -= n; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + susp->bw_pHaSe = bw_pHaSe_ReG; + susp->bw_x1_sample = bw_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nri_fetch */ @@ -1449,9 +1449,9 @@ void resonvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz1_pHaSe = 1.0; - susp->bw_pHaSe = 1.0; + susp->started = true; + susp->hz1_pHaSe = 1.0; + susp->bw_pHaSe = 1.0; } susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); @@ -1459,160 +1459,160 @@ void resonvv_nrr_fetch(snd_susp_type a_susp, snd_list_type snd_list) susp_check_term_samples(bw, bw_ptr, bw_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz1_x1_sample when phase goes past 1.0; */ - /* use hz1_n (computed below) to avoid roundoff errors: */ - if (susp->hz1_n <= 0) { - susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); - susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); - susp->hz1_pHaSe -= 1.0; - /* hz1_n gets number of samples before phase exceeds 1.0: */ - susp->hz1_n = (long) ((1.0 - susp->hz1_pHaSe) * - susp->output_per_hz1); - susp->coshz = cos(susp->hz1_x1_sample); - susp->recompute = true; - } - togo = min(togo, susp->hz1_n); - hz1_val = susp->hz1_x1_sample; - /* grab next bw_x1_sample when phase goes past 1.0; */ - /* use bw_n (computed below) to avoid roundoff errors: */ - if (susp->bw_n <= 0) { - susp_check_term_samples(bw, bw_ptr, bw_cnt); - susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); - susp->bw_pHaSe -= 1.0; - /* bw_n gets number of samples before phase exceeds 1.0: */ - susp->bw_n = (long) ((1.0 - susp->bw_pHaSe) * - susp->output_per_bw); - susp->c3co = exp(susp->bw_x1_sample); - susp->c3p1 = susp->c3co + 1.0; - susp->c3t4 = susp->c3co * 4.0; - susp->omc3 = 1.0 - susp->c3co; - susp->recompute = true; - } - togo = min(togo, susp->bw_n); - bw_val = susp->bw_x1_sample; - if (susp->recompute) { - susp->recompute = false; - susp->c2 = susp->c3t4 * susp->coshz / susp->c3p1; - susp->c1 = (susp->normalization == 0 ? 1.0 : - (susp->normalization == 1 ? susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : - sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)) * susp->scale1; - } - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz1_x1_sample when phase goes past 1.0; */ + /* use hz1_n (computed below) to avoid roundoff errors: */ + if (susp->hz1_n <= 0) { + susp_check_term_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1_x1_sample = susp_fetch_sample(hz1, hz1_ptr, hz1_cnt); + susp->hz1_pHaSe -= 1.0; + /* hz1_n gets number of samples before phase exceeds 1.0: */ + susp->hz1_n = (int64_t) ((1.0 - susp->hz1_pHaSe) * + susp->output_per_hz1); + susp->coshz = cos(susp->hz1_x1_sample); + susp->recompute = true; + } + togo = (int) min(togo, susp->hz1_n); + hz1_val = susp->hz1_x1_sample; + /* grab next bw_x1_sample when phase goes past 1.0; */ + /* use bw_n (computed below) to avoid roundoff errors: */ + if (susp->bw_n <= 0) { + susp_check_term_samples(bw, bw_ptr, bw_cnt); + susp->bw_x1_sample = susp_fetch_sample(bw, bw_ptr, bw_cnt); + susp->bw_pHaSe -= 1.0; + /* bw_n gets number of samples before phase exceeds 1.0: */ + susp->bw_n = (int64_t) ((1.0 - susp->bw_pHaSe) * + susp->output_per_bw); + susp->c3co = exp(susp->bw_x1_sample); + susp->c3p1 = susp->c3co + 1.0; + susp->c3t4 = susp->c3co * 4.0; + susp->omc3 = 1.0 - susp->c3co; + susp->recompute = true; + } + togo = (int) min(togo, susp->bw_n); + bw_val = susp->bw_x1_sample; + if (susp->recompute) { + susp->recompute = false; + susp->c2 = susp->c3t4 * susp->coshz / susp->c3p1; + susp->c1 = (susp->normalization == 0 ? 1.0 : + (susp->normalization == 1 ? susp->omc3 * sqrt(1.0 - susp->c2 * susp->c2 / susp->c3t4) : + sqrt(susp->c3p1 * susp->c3p1 - susp->c2 * susp->c2) * susp->omc3 / susp->c3p1)) * susp->scale1; + } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c3co_reg = susp->c3co; - c2_reg = susp->c2; - c1_reg = susp->c1; - recompute_reg = susp->recompute; - y1_reg = susp->y1; - y2_reg = susp->y2; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c3co_reg = susp->c3co; + c2_reg = susp->c2; + c1_reg = susp->c1; + recompute_reg = susp->recompute; + y1_reg = susp->y1; + y2_reg = susp->y2; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { double y0 = c1_reg * *s1_ptr_reg++ + c2_reg * y1_reg - c3co_reg * y2_reg; *out_ptr_reg++ = (sample_type) y0; y2_reg = y1_reg; y1_reg = y0; }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->recompute = recompute_reg; - susp->y1 = y1_reg; - susp->y2 = y2_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; - susp->hz1_n -= togo; - susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; - susp->bw_n -= togo; - cnt += togo; + susp->recompute = recompute_reg; + susp->y1 = y1_reg; + susp->y2 = y2_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz1_pHaSe += togo * susp->hz1_pHaSe_iNcR; + susp->hz1_n -= togo; + susp->bw_pHaSe += togo * susp->bw_pHaSe_iNcR; + susp->bw_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* resonvv_nrr_fetch */ void resonvv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ resonvv_susp_type susp = (resonvv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr)) >= - susp->hz1->current) - susp_get_samples(hz1, hz1_ptr, hz1_cnt); + susp->hz1->current) + susp_get_samples(hz1, hz1_ptr, hz1_cnt); /* fetch samples from bw up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr)) >= - susp->bw->current) - susp_get_samples(bw, bw_ptr, bw_cnt); + susp->bw->current) + susp_get_samples(bw, bw_ptr, bw_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr - + n = (int) ROUNDBIG((final_time - susp->hz1->t0) * susp->hz1->sr - (susp->hz1->current - susp->hz1_cnt)); susp->hz1_ptr += n; susp_took(hz1_cnt, n); - n = ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - + n = (int) ROUNDBIG((final_time - susp->bw->t0) * susp->bw->sr - (susp->bw->current - susp->bw_cnt)); susp->bw_ptr += n; susp_took(bw_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/resonvv.h b/lib-src/libnyquist/nyquist/tran/resonvv.h index f1fee48b1..409349c68 100644 --- a/lib-src/libnyquist/nyquist/tran/resonvv.h +++ b/lib-src/libnyquist/nyquist/tran/resonvv.h @@ -1,3 +1,3 @@ sound_type snd_make_resonvv(sound_type s1, sound_type hz1, sound_type bw, int normalization); sound_type snd_resonvv(sound_type s1, sound_type hz1, sound_type bw, int normalization); - /* LISP: (snd-resonvv SOUND SOUND SOUND FIXNUM) */ + /* LISP: (snd-resonvv SOUND SOUND SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/sampler.c b/lib-src/libnyquist/nyquist/tran/sampler.c index 1d4eadcb5..d38cf93d9 100644 --- a/lib-src/libnyquist/nyquist/tran/sampler.c +++ b/lib-src/libnyquist/nyquist/tran/sampler.c @@ -15,10 +15,10 @@ void sampler_free(snd_susp_type a_susp); typedef struct sampler_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s_fm; - long s_fm_cnt; + int s_fm_cnt; sample_block_values_type s_fm_ptr; /* support for interpolation of s_fm */ @@ -28,7 +28,7 @@ typedef struct sampler_susp_struct { /* support for ramp between samples of s_fm */ double output_per_s_fm; - long s_fm_n; + int64_t s_fm_n; double loop_to; table_type the_table; @@ -62,57 +62,57 @@ void sampler_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s_fm input sample block: */ - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - togo = min(togo, susp->s_fm_cnt); + /* don't run past the s_fm input sample block: */ + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + togo = min(togo, susp->s_fm_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - loop_to_reg = susp->loop_to; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - s_fm_ptr_reg = susp->s_fm_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + loop_to_reg = susp->loop_to; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + s_fm_ptr_reg = susp->s_fm_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; @@ -123,28 +123,28 @@ void sampler_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= (table_len_reg - loop_to_reg); /* watch out for negative frequencies! */ if (phase_reg < 0) phase_reg = 0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - /* using s_fm_ptr_reg is a bad idea on RS/6000: */ - susp->s_fm_ptr += togo; - out_ptr += togo; - susp_took(s_fm_cnt, togo); - cnt += togo; + susp->phase = phase_reg; + /* using s_fm_ptr_reg is a bad idea on RS/6000: */ + susp->s_fm_ptr += togo; + out_ptr += togo; + susp_took(s_fm_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* sampler_s_fetch */ @@ -174,71 +174,71 @@ void sampler_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->started = true; + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - loop_to_reg = susp->loop_to; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - s_fm_pHaSe_ReG = susp->s_fm_pHaSe; - s_fm_x1_sample_reg = susp->s_fm_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + loop_to_reg = susp->loop_to; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + s_fm_pHaSe_ReG = susp->s_fm_pHaSe; + s_fm_x1_sample_reg = susp->s_fm_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; - if (s_fm_pHaSe_ReG >= 1.0) { + if (s_fm_pHaSe_ReG >= 1.0) { /* fixup-depends s_fm */ - /* pick up next sample as s_fm_x1_sample: */ - susp->s_fm_ptr++; - susp_took(s_fm_cnt, 1); - s_fm_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); - s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); - } + /* pick up next sample as s_fm_x1_sample: */ + susp->s_fm_ptr++; + susp_took(s_fm_cnt, 1); + s_fm_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); + s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); + } table_index = (long) phase_reg; x1 = table_ptr_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (phase_reg - table_index) * @@ -247,29 +247,29 @@ void sampler_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= (table_len_reg - loop_to_reg); /* watch out for negative frequencies! */ if (phase_reg < 0) phase_reg = 0; - s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = phase_reg; - susp->s_fm_pHaSe = s_fm_pHaSe_ReG; - susp->s_fm_x1_sample = s_fm_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = phase_reg; + susp->s_fm_pHaSe = s_fm_pHaSe_ReG; + susp->s_fm_x1_sample = s_fm_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* sampler_i_fetch */ @@ -297,71 +297,71 @@ void sampler_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_fm_pHaSe = 1.0; + susp->started = true; + susp->s_fm_pHaSe = 1.0; } susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_fm_x1_sample when phase goes past 1.0; */ - /* use s_fm_n (computed below) to avoid roundoff errors: */ - if (susp->s_fm_n <= 0) { - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_pHaSe -= 1.0; - /* s_fm_n gets number of samples before phase exceeds 1.0: */ - susp->s_fm_n = (long) ((1.0 - susp->s_fm_pHaSe) * - susp->output_per_s_fm); - } - togo = min(togo, susp->s_fm_n); - s_fm_val = susp->s_fm_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next s_fm_x1_sample when phase goes past 1.0; */ + /* use s_fm_n (computed below) to avoid roundoff errors: */ + if (susp->s_fm_n <= 0) { + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_pHaSe -= 1.0; + /* s_fm_n gets number of samples before phase exceeds 1.0: */ + susp->s_fm_n = (int64_t) ((1.0 - susp->s_fm_pHaSe) * + susp->output_per_s_fm); + } + togo = (int) min(togo, susp->s_fm_n); + s_fm_val = susp->s_fm_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - loop_to_reg = susp->loop_to; - table_ptr_reg = susp->table_ptr; - table_len_reg = susp->table_len; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + loop_to_reg = susp->loop_to; + table_ptr_reg = susp->table_ptr; + table_len_reg = susp->table_len; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double x1; table_index = (long) phase_reg; @@ -372,44 +372,44 @@ void sampler_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= (table_len_reg - loop_to_reg); /* watch out for negative frequencies! */ if (phase_reg < 0) phase_reg = 0; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - out_ptr += togo; - susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; - susp->s_fm_n -= togo; - cnt += togo; + susp->phase = phase_reg; + out_ptr += togo; + susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; + susp->s_fm_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* sampler_r_fetch */ void sampler_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ sampler_susp_type susp = (sampler_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s_fm up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr)) >= - susp->s_fm->current) - susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm->current) + susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - + n = (int) ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - (susp->s_fm->current - susp->s_fm_cnt)); susp->s_fm_ptr += n; susp_took(s_fm_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/sampler.h b/lib-src/libnyquist/nyquist/tran/sampler.h index 49be41e3a..e0eeb578b 100644 --- a/lib-src/libnyquist/nyquist/tran/sampler.h +++ b/lib-src/libnyquist/nyquist/tran/sampler.h @@ -1,3 +1,3 @@ sound_type snd_make_sampler(sound_type s, double step, double loop_start, rate_type sr, double hz, time_type t0, sound_type s_fm, long npoints); sound_type snd_sampler(sound_type s, double step, double loop_start, rate_type sr, double hz, time_type t0, sound_type s_fm, long npoints); - /* LISP: (snd-sampler SOUND ANYNUM ANYNUM ANYNUM ANYNUM ANYNUM SOUND FIXNUM) */ + /* LISP: (snd-sampler SOUND ANYNUM ANYNUM ANYNUM ANYNUM ANYNUM SOUND LONG) */ diff --git a/lib-src/libnyquist/nyquist/tran/scale.c b/lib-src/libnyquist/nyquist/tran/scale.c index fbdc4bd52..bcbf81f5c 100644 --- a/lib-src/libnyquist/nyquist/tran/scale.c +++ b/lib-src/libnyquist/nyquist/tran/scale.c @@ -14,10 +14,10 @@ void normalize_free(snd_susp_type a_susp); typedef struct normalize_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sample_type scale; @@ -42,92 +42,92 @@ void normalize_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale_reg = susp->scale; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + scale_reg = susp->scale; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = *s1_ptr_reg++ * scale_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* normalize_n_fetch */ void normalize_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ normalize_susp_type susp = (normalize_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/shape.c b/lib-src/libnyquist/nyquist/tran/shape.c index 80334a18b..9f7fa6f81 100644 --- a/lib-src/libnyquist/nyquist/tran/shape.c +++ b/lib-src/libnyquist/nyquist/tran/shape.c @@ -14,10 +14,10 @@ void shape_free(snd_susp_type a_susp); typedef struct shape_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type sin; - long sin_cnt; + int sin_cnt; sample_block_values_type sin_ptr; double time_to_index; @@ -50,56 +50,56 @@ void shape_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the sin input sample block: */ - susp_check_term_log_samples(sin, sin_ptr, sin_cnt); - togo = min(togo, susp->sin_cnt); + /* don't run past the sin input sample block: */ + susp_check_term_log_samples(sin, sin_ptr, sin_cnt); + togo = min(togo, susp->sin_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - time_to_index_reg = susp->time_to_index; - origin_reg = susp->origin; - fcn_table_reg = susp->fcn_table; - table_len_reg = susp->table_len; - sin_ptr_reg = susp->sin_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + time_to_index_reg = susp->time_to_index; + origin_reg = susp->origin; + fcn_table_reg = susp->fcn_table; + table_len_reg = susp->table_len; + sin_ptr_reg = susp->sin_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ register double offset, x1; register long table_index; register double phase = (sin_scale_reg * *sin_ptr_reg++); @@ -118,45 +118,45 @@ void shape_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) x1 = fcn_table_reg[table_index]; *out_ptr_reg++ = (sample_type) (x1 + (offset - table_index) * (fcn_table_reg[table_index + 1] - x1)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->origin = origin_reg; - /* using sin_ptr_reg is a bad idea on RS/6000: */ - susp->sin_ptr += togo; - out_ptr += togo; - susp_took(sin_cnt, togo); - cnt += togo; + susp->origin = origin_reg; + /* using sin_ptr_reg is a bad idea on RS/6000: */ + susp->sin_ptr += togo; + out_ptr += togo; + susp_took(sin_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* shape_s_fetch */ void shape_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ shape_susp_type susp = (shape_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from sin up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->sin->t0) * susp->sin->sr)) >= - susp->sin->current) - susp_get_samples(sin, sin_ptr, sin_cnt); + susp->sin->current) + susp_get_samples(sin, sin_ptr, sin_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->sin->t0) * susp->sin->sr - + n = (int) ROUNDBIG((final_time - susp->sin->t0) * susp->sin->sr - (susp->sin->current - susp->sin_cnt)); susp->sin_ptr += n; susp_took(sin_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/sine.c b/lib-src/libnyquist/nyquist/tran/sine.c index 9da29bc9f..bd419c056 100644 --- a/lib-src/libnyquist/nyquist/tran/sine.c +++ b/lib-src/libnyquist/nyquist/tran/sine.c @@ -14,7 +14,7 @@ void sine_free(snd_susp_type a_susp); typedef struct sine_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; long phase; long ph_incr; @@ -49,39 +49,39 @@ void sine__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - phase_reg = susp->phase; - ph_incr_reg = susp->ph_incr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + phase_reg = susp->phase; + ph_incr_reg = susp->ph_incr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = sine_table[phase_reg >> SINE_TABLE_SHIFT]; phase_reg += ph_incr_reg; phase_reg &= SINE_TABLE_MASK; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; - out_ptr += togo; - cnt += togo; + susp->phase = (susp->phase + susp->ph_incr * togo) & SINE_TABLE_MASK; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* sine__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/siosc.alg b/lib-src/libnyquist/nyquist/tran/siosc.alg index ca5a515fa..d572a5714 100644 --- a/lib-src/libnyquist/nyquist/tran/siosc.alg +++ b/lib-src/libnyquist/nyquist/tran/siosc.alg @@ -31,9 +31,9 @@ void siosc_table_init(siosc_susp_type susp) /* siosc_table_update -- outer loop processing, get next table */ /**/ -long siosc_table_update(siosc_susp_type susp, long cur) +int64_t siosc_table_update(siosc_susp_type susp, int64_t cur) { - long n; + int64_t n; /* swap ampramps: */ susp->ampramp_a = 1.0; @@ -67,8 +67,7 @@ long siosc_table_update(siosc_susp_type susp, long cur) susp->lis = cdr(susp->lis); } else { /* use only table a */ susp->ampslope = 0.0; - susp->next_breakpoint = 0x7FFFFFFF; - n = 0x7FFFFFFF; + susp->next_breakpoint = n = 0x7FFFFFFFFFFFFFFF; } return n; } @@ -83,7 +82,7 @@ long siosc_table_update(siosc_susp_type susp, long cur) ("double" "table_sr" "0.0") ("double" "phase" "0.0") ("LVAL" "lis" "lis") - ("long" "next_breakpoint" "0") + ("int64_t" "next_breakpoint" "0") ("double" "ampramp_a" "1.0") ("double" "ampramp_b" "0.0") ("double" "ampslope" "0.0; @@ -104,11 +103,11 @@ long siosc_table_update(siosc_susp_type susp, long cur) ; "lis" points to the next time to be used, or NULL (OUTER-LOOP " - { long cur = susp->susp.current + cnt; - n = susp->next_breakpoint - cur; - if (n == 0) n = siosc_table_update(susp, cur); + { int64_t cur = susp->susp.current + cnt; + int64_t n64 = susp->next_breakpoint - cur; + if (n64 == 0) n64 = siosc_table_update(susp, cur); + if (n64 < togo) togo = (int) n64; } - togo = min(n, togo); ") (INNER-LOOP "table_index = (long) phase; diff --git a/lib-src/libnyquist/nyquist/tran/siosc.c b/lib-src/libnyquist/nyquist/tran/siosc.c index 6a2d6a059..662bf1ad9 100644 --- a/lib-src/libnyquist/nyquist/tran/siosc.c +++ b/lib-src/libnyquist/nyquist/tran/siosc.c @@ -15,10 +15,10 @@ void siosc_free(snd_susp_type a_susp); typedef struct siosc_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s_fm; - long s_fm_cnt; + int s_fm_cnt; sample_block_values_type s_fm_ptr; /* support for interpolation of s_fm */ @@ -28,7 +28,7 @@ typedef struct siosc_susp_struct { /* support for ramp between samples of s_fm */ double output_per_s_fm; - long s_fm_n; + int64_t s_fm_n; double table_len; double ph_incr; @@ -39,7 +39,7 @@ typedef struct siosc_susp_struct { double table_sr; double phase; LVAL lis; - long next_breakpoint; + int64_t next_breakpoint; double ampramp_a; double ampramp_b; double ampslope; @@ -65,9 +65,9 @@ void siosc_table_init(siosc_susp_type susp) /* siosc_table_update -- outer loop processing, get next table */ /**/ -long siosc_table_update(siosc_susp_type susp, long cur) +int64_t siosc_table_update(siosc_susp_type susp, int64_t cur) { - long n; + int64_t n; /* swap ampramps: */ susp->ampramp_a = 1.0; @@ -101,8 +101,7 @@ long siosc_table_update(siosc_susp_type susp, long cur) susp->lis = cdr(susp->lis); } else { /* use only table a */ susp->ampslope = 0.0; - susp->next_breakpoint = 0x7FFFFFFF; - n = 0x7FFFFFFF; + susp->next_breakpoint = n = 0x7FFFFFFFFFFFFFFF; } return n; } @@ -134,67 +133,67 @@ void siosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s_fm input sample block: */ - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - togo = min(togo, susp->s_fm_cnt); + /* don't run past the s_fm input sample block: */ + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + togo = min(togo, susp->s_fm_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } - - - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } - - - { long cur = susp->susp.current + cnt; - n = susp->next_breakpoint - cur; - if (n == 0) n = siosc_table_update(susp, cur); + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; } - togo = min(n, togo); - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_a_samps_reg = susp->table_a_samps; - table_b_samps_reg = susp->table_b_samps; - phase_reg = susp->phase; - ampramp_a_reg = susp->ampramp_a; - ampramp_b_reg = susp->ampramp_b; - ampslope_reg = susp->ampslope; - s_fm_ptr_reg = susp->s_fm_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } + + + { int64_t cur = susp->susp.current + cnt; + int64_t n64 = susp->next_breakpoint - cur; + if (n64 == 0) n64 = siosc_table_update(susp, cur); + if (n64 < togo) togo = (int) n64; + } + + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_a_samps_reg = susp->table_a_samps; + table_b_samps_reg = susp->table_b_samps; + phase_reg = susp->phase; + ampramp_a_reg = susp->ampramp_a; + ampramp_b_reg = susp->ampramp_b; + ampslope_reg = susp->ampslope; + s_fm_ptr_reg = susp->s_fm_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double xa, xb; table_index = (long) phase_reg; @@ -211,30 +210,30 @@ void siosc_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - susp->ampramp_a = ampramp_a_reg; - susp->ampramp_b = ampramp_b_reg; - /* using s_fm_ptr_reg is a bad idea on RS/6000: */ - susp->s_fm_ptr += togo; - out_ptr += togo; - susp_took(s_fm_cnt, togo); - cnt += togo; + susp->phase = phase_reg; + susp->ampramp_a = ampramp_a_reg; + susp->ampramp_b = ampramp_b_reg; + /* using s_fm_ptr_reg is a bad idea on RS/6000: */ + susp->s_fm_ptr += togo; + out_ptr += togo; + susp_took(s_fm_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* siosc_s_fetch */ @@ -267,81 +266,81 @@ void siosc_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->started = true; + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } - - - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } - - - { long cur = susp->susp.current + cnt; - n = susp->next_breakpoint - cur; - if (n == 0) n = siosc_table_update(susp, cur); + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; } - togo = min(n, togo); - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_a_samps_reg = susp->table_a_samps; - table_b_samps_reg = susp->table_b_samps; - phase_reg = susp->phase; - ampramp_a_reg = susp->ampramp_a; - ampramp_b_reg = susp->ampramp_b; - ampslope_reg = susp->ampslope; - s_fm_pHaSe_ReG = susp->s_fm_pHaSe; - s_fm_x1_sample_reg = susp->s_fm_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } + + + { int64_t cur = susp->susp.current + cnt; + int64_t n64 = susp->next_breakpoint - cur; + if (n64 == 0) n64 = siosc_table_update(susp, cur); + if (n64 < togo) togo = (int) n64; + } + + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_a_samps_reg = susp->table_a_samps; + table_b_samps_reg = susp->table_b_samps; + phase_reg = susp->phase; + ampramp_a_reg = susp->ampramp_a; + ampramp_b_reg = susp->ampramp_b; + ampslope_reg = susp->ampslope; + s_fm_pHaSe_ReG = susp->s_fm_pHaSe; + s_fm_x1_sample_reg = susp->s_fm_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double xa, xb; - if (s_fm_pHaSe_ReG >= 1.0) { + if (s_fm_pHaSe_ReG >= 1.0) { /* fixup-depends s_fm */ - /* pick up next sample as s_fm_x1_sample: */ - susp->s_fm_ptr++; - susp_took(s_fm_cnt, 1); - s_fm_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); - s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); - } + /* pick up next sample as s_fm_x1_sample: */ + susp->s_fm_ptr++; + susp_took(s_fm_cnt, 1); + s_fm_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(s_fm, s_fm_ptr, s_fm_cnt, s_fm_x1_sample_reg); + s_fm_x1_sample_reg = susp_current_sample(s_fm, s_fm_ptr); + } table_index = (long) phase_reg; xa = table_a_samps_reg[table_index]; xb = table_b_samps_reg[table_index]; @@ -356,31 +355,31 @@ void siosc_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + s_fm_pHaSe_ReG += s_fm_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->phase = phase_reg; - susp->ampramp_a = ampramp_a_reg; - susp->ampramp_b = ampramp_b_reg; - susp->s_fm_pHaSe = s_fm_pHaSe_ReG; - susp->s_fm_x1_sample = s_fm_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->phase = phase_reg; + susp->ampramp_a = ampramp_a_reg; + susp->ampramp_b = ampramp_b_reg; + susp->s_fm_pHaSe = s_fm_pHaSe_ReG; + susp->s_fm_x1_sample = s_fm_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* siosc_i_fetch */ @@ -411,81 +410,81 @@ void siosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->s_fm_pHaSe = 1.0; + susp->started = true; + susp->s_fm_pHaSe = 1.0; } susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next s_fm_x1_sample when phase goes past 1.0; */ - /* use s_fm_n (computed below) to avoid roundoff errors: */ - if (susp->s_fm_n <= 0) { - susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); - susp->s_fm_pHaSe -= 1.0; - /* s_fm_n gets number of samples before phase exceeds 1.0: */ - susp->s_fm_n = (long) ((1.0 - susp->s_fm_pHaSe) * - susp->output_per_s_fm); - } - togo = min(togo, susp->s_fm_n); - s_fm_val = susp->s_fm_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } - - - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } - - - { long cur = susp->susp.current + cnt; - n = susp->next_breakpoint - cur; - if (n == 0) n = siosc_table_update(susp, cur); + /* grab next s_fm_x1_sample when phase goes past 1.0; */ + /* use s_fm_n (computed below) to avoid roundoff errors: */ + if (susp->s_fm_n <= 0) { + susp_check_term_log_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_x1_sample = susp_fetch_sample(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm_pHaSe -= 1.0; + /* s_fm_n gets number of samples before phase exceeds 1.0: */ + susp->s_fm_n = (int64_t) ((1.0 - susp->s_fm_pHaSe) * + susp->output_per_s_fm); + } + togo = (int) min(togo, susp->s_fm_n); + s_fm_val = susp->s_fm_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; } - togo = min(n, togo); - n = togo; - table_len_reg = susp->table_len; - ph_incr_reg = susp->ph_incr; - table_a_samps_reg = susp->table_a_samps; - table_b_samps_reg = susp->table_b_samps; - phase_reg = susp->phase; - ampramp_a_reg = susp->ampramp_a; - ampramp_b_reg = susp->ampramp_b; - ampslope_reg = susp->ampslope; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } + + + { int64_t cur = susp->susp.current + cnt; + int64_t n64 = susp->next_breakpoint - cur; + if (n64 == 0) n64 = siosc_table_update(susp, cur); + if (n64 < togo) togo = (int) n64; + } + + n = togo; + table_len_reg = susp->table_len; + ph_incr_reg = susp->ph_incr; + table_a_samps_reg = susp->table_a_samps; + table_b_samps_reg = susp->table_b_samps; + phase_reg = susp->phase; + ampramp_a_reg = susp->ampramp_a; + ampramp_b_reg = susp->ampramp_b; + ampslope_reg = susp->ampslope; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long table_index; double xa, xb; table_index = (long) phase_reg; @@ -502,46 +501,46 @@ void siosc_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) while (phase_reg > table_len_reg) phase_reg -= table_len_reg; /* watch out for negative frequencies! */ while (phase_reg < 0) phase_reg += table_len_reg; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->phase = phase_reg; - susp->ampramp_a = ampramp_a_reg; - susp->ampramp_b = ampramp_b_reg; - out_ptr += togo; - susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; - susp->s_fm_n -= togo; - cnt += togo; + susp->phase = phase_reg; + susp->ampramp_a = ampramp_a_reg; + susp->ampramp_b = ampramp_b_reg; + out_ptr += togo; + susp->s_fm_pHaSe += togo * susp->s_fm_pHaSe_iNcR; + susp->s_fm_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* siosc_r_fetch */ void siosc_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ siosc_susp_type susp = (siosc_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s_fm up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr)) >= - susp->s_fm->current) - susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); + susp->s_fm->current) + susp_get_samples(s_fm, s_fm_ptr, s_fm_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - + n = (int) ROUNDBIG((final_time - susp->s_fm->t0) * susp->s_fm->sr - (susp->s_fm->current - susp->s_fm_cnt)); susp->s_fm_ptr += n; susp_took(s_fm_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/slope.c b/lib-src/libnyquist/nyquist/tran/slope.c index 24f94a872..36ad75618 100644 --- a/lib-src/libnyquist/nyquist/tran/slope.c +++ b/lib-src/libnyquist/nyquist/tran/slope.c @@ -14,10 +14,10 @@ void slope_free(snd_susp_type a_susp); typedef struct slope_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; sample_type prev; @@ -44,96 +44,96 @@ void slope_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - prev_reg = susp->prev; - scale_reg = susp->scale; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + prev_reg = susp->prev; + scale_reg = susp->scale; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { register sample_type x = *input_ptr_reg++; *out_ptr_reg++ = (sample_type) ((x - prev_reg) * scale_reg); prev_reg = x;}; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* slope_n_fetch */ void slope_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ slope_susp_type susp = (slope_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/sqrt.c b/lib-src/libnyquist/nyquist/tran/sqrt.c index 477fcfc14..772de7051 100644 --- a/lib-src/libnyquist/nyquist/tran/sqrt.c +++ b/lib-src/libnyquist/nyquist/tran/sqrt.c @@ -14,10 +14,10 @@ void sqrt_free(snd_susp_type a_susp); typedef struct sqrt_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; } sqrt_susp_node, *sqrt_susp_type; @@ -40,93 +40,93 @@ void sqrt_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ { sample_type i = (input_scale_reg * *input_ptr_reg++); if (i < 0) i = 0; *out_ptr_reg++ = (sample_type) sqrt(i); }; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* sqrt_s_fetch */ void sqrt_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ sqrt_susp_type susp = (sqrt_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/stkchorus.c b/lib-src/libnyquist/nyquist/tran/stkchorus.c index 867974616..448a80123 100644 --- a/lib-src/libnyquist/nyquist/tran/stkchorus.c +++ b/lib-src/libnyquist/nyquist/tran/stkchorus.c @@ -14,10 +14,10 @@ void stkchorus_free(snd_susp_type a_susp); typedef struct stkchorus_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; struct stkEffect *mych; @@ -44,93 +44,93 @@ void stkchorus_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - mych_reg = susp->mych; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mych_reg = susp->mych; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (stkEffectTick(mych_reg, *s1_ptr_reg++)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mych = mych_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + susp->mych = mych_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* stkchorus_n_fetch */ void stkchorus_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ stkchorus_susp_type susp = (stkchorus_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/stkpitshift.c b/lib-src/libnyquist/nyquist/tran/stkpitshift.c index 75d8c1ef8..66e8b9bc2 100644 --- a/lib-src/libnyquist/nyquist/tran/stkpitshift.c +++ b/lib-src/libnyquist/nyquist/tran/stkpitshift.c @@ -14,10 +14,10 @@ void stkpitshift_free(snd_susp_type a_susp); typedef struct stkpitshift_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; struct stkEffect *mych; @@ -46,93 +46,93 @@ void stkpitshift_s_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - mych_reg = susp->mych; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + mych_reg = susp->mych; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (stkEffectTick(mych_reg, (s1_scale_reg * *s1_ptr_reg++))); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->mych = mych_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + susp->mych = mych_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* stkpitshift_s_fetch */ void stkpitshift_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ stkpitshift_susp_type susp = (stkpitshift_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/stkrev.c b/lib-src/libnyquist/nyquist/tran/stkrev.c index 3a1379d90..2784e2e0f 100644 --- a/lib-src/libnyquist/nyquist/tran/stkrev.c +++ b/lib-src/libnyquist/nyquist/tran/stkrev.c @@ -14,10 +14,10 @@ void stkrev_free(snd_susp_type a_susp); typedef struct stkrev_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; struct stkEffect *myrv; @@ -44,93 +44,93 @@ void stkrev_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - myrv_reg = susp->myrv; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + myrv_reg = susp->myrv; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (stkEffectTick(myrv_reg, *s1_ptr_reg++)); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->myrv = myrv_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + susp->myrv = myrv_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* stkrev_n_fetch */ void stkrev_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ stkrev_susp_type susp = (stkrev_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/stkrev.h b/lib-src/libnyquist/nyquist/tran/stkrev.h index 5a71e4ff6..a32d145d5 100644 --- a/lib-src/libnyquist/nyquist/tran/stkrev.h +++ b/lib-src/libnyquist/nyquist/tran/stkrev.h @@ -1,3 +1,3 @@ sound_type snd_make_stkrev(int rev_type, sound_type s1, time_type trev, double mix); sound_type snd_stkrev(int rev_type, sound_type s1, time_type trev, double mix); - /* LISP: (snd-stkrev FIXNUM SOUND ANYNUM ANYNUM) */ + /* LISP: (snd-stkrev LONG SOUND ANYNUM ANYNUM) */ diff --git a/lib-src/libnyquist/nyquist/tran/tapf.c b/lib-src/libnyquist/nyquist/tran/tapf.c index 489f3c8c8..dd50b4a86 100644 --- a/lib-src/libnyquist/nyquist/tran/tapf.c +++ b/lib-src/libnyquist/nyquist/tran/tapf.c @@ -15,13 +15,13 @@ void tapf_free(snd_susp_type a_susp); typedef struct tapf_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type vardelay; - long vardelay_cnt; + int vardelay_cnt; sample_block_values_type vardelay_ptr; /* support for interpolation of vardelay */ @@ -31,7 +31,7 @@ typedef struct tapf_susp_struct { /* support for ramp between samples of vardelay */ double output_per_vardelay; - long vardelay_n; + int64_t vardelay_n; double offset; double vdscale; @@ -66,63 +66,63 @@ void tapf_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the vardelay input sample block: */ - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - togo = min(togo, susp->vardelay_cnt); + /* don't run past the vardelay input sample block: */ + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + togo = min(togo, susp->vardelay_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_ptr_reg = susp->vardelay_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_ptr_reg = susp->vardelay_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; phase = (long) (*vardelay_ptr_reg++ * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ @@ -147,32 +147,32 @@ void tapf_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using vardelay_ptr_reg is a bad idea on RS/6000: */ - susp->vardelay_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(vardelay_cnt, togo); - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using vardelay_ptr_reg is a bad idea on RS/6000: */ + susp->vardelay_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(vardelay_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_nn_fetch */ @@ -205,80 +205,81 @@ void tapf_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - susp->vardelay_x1_sample = (susp->vardelay_cnt--, *(susp->vardelay_ptr)); + susp->started = true; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay_cnt--; + susp->vardelay_x1_sample = *(susp->vardelay_ptr); } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_pHaSe_ReG = susp->vardelay_pHaSe; - vardelay_x1_sample_reg = susp->vardelay_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_pHaSe_ReG = susp->vardelay_pHaSe; + vardelay_x1_sample_reg = susp->vardelay_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; - if (vardelay_pHaSe_ReG >= 1.0) { - vardelay_x1_sample_reg = vardelay_x2_sample; - /* pick up next sample as vardelay_x2_sample: */ - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - vardelay_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); - } + if (vardelay_pHaSe_ReG >= 1.0) { + vardelay_x1_sample_reg = vardelay_x2_sample; + /* pick up next sample as vardelay_x2_sample: */ + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + vardelay_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); + } phase = (long) ( - (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg); + (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ if (phase < 0) phase = 0; else if (phase > maxdelay_reg) phase = maxdelay_reg; @@ -301,33 +302,33 @@ void tapf_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->bufflen = bufflen_reg; - susp->index = index_reg; - susp->vardelay_pHaSe = vardelay_pHaSe_ReG; - susp->vardelay_x1_sample = vardelay_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + susp->vardelay_pHaSe = vardelay_pHaSe_ReG; + susp->vardelay_x1_sample = vardelay_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_ni_fetch */ @@ -359,84 +360,84 @@ void tapf_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->vardelay_pHaSe = 1.0; + susp->started = true; + susp->vardelay_pHaSe = 1.0; } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next vardelay_x2_sample when phase goes past 1.0; */ - /* we use vardelay_n (computed below) to avoid roundoff errors: */ - if (susp->vardelay_n <= 0) { - susp->vardelay_x1_sample = vardelay_x2_sample; - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - susp->vardelay_pHaSe -= 1.0; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - vardelay_x2_sample = *(susp->vardelay_ptr); - /* vardelay_n gets number of samples before phase exceeds 1.0: */ - susp->vardelay_n = (long) ((1.0 - susp->vardelay_pHaSe) * - susp->output_per_vardelay); - } - togo = min(togo, susp->vardelay_n); - vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); - vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + - vardelay_x2_sample * susp->vardelay_pHaSe); + /* grab next vardelay_x2_sample when phase goes past 1.0; */ + /* we use vardelay_n (computed below) to avoid roundoff errors: */ + if (susp->vardelay_n <= 0) { + susp->vardelay_x1_sample = vardelay_x2_sample; + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + susp->vardelay_pHaSe -= 1.0; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + vardelay_x2_sample = *(susp->vardelay_ptr); + /* vardelay_n gets number of samples before phase exceeds 1.0: */ + susp->vardelay_n = (int64_t) ((1.0 - susp->vardelay_pHaSe) * + susp->output_per_vardelay); + } + togo = (int) min(togo, susp->vardelay_n); + vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); + vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + + vardelay_x2_sample * susp->vardelay_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; phase = (long) (vardelay_val * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ @@ -461,32 +462,32 @@ void tapf_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - vardelay_val += vardelay_DeLtA; - } while (--n); /* inner loop */ + vardelay_val += vardelay_DeLtA; + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; - susp->vardelay_n -= togo; - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; + susp->vardelay_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_nr_fetch */ @@ -516,63 +517,63 @@ void tapf_sn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the vardelay input sample block: */ - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - togo = min(togo, susp->vardelay_cnt); + /* don't run past the vardelay input sample block: */ + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + togo = min(togo, susp->vardelay_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_ptr_reg = susp->vardelay_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_ptr_reg = susp->vardelay_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; phase = (long) (*vardelay_ptr_reg++ * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ @@ -597,32 +598,32 @@ void tapf_sn_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using vardelay_ptr_reg is a bad idea on RS/6000: */ - susp->vardelay_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(vardelay_cnt, togo); - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using vardelay_ptr_reg is a bad idea on RS/6000: */ + susp->vardelay_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(vardelay_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_sn_fetch */ @@ -656,80 +657,81 @@ void tapf_si_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - susp->vardelay_x1_sample = (susp->vardelay_cnt--, *(susp->vardelay_ptr)); + susp->started = true; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay_cnt--; + susp->vardelay_x1_sample = *(susp->vardelay_ptr); } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_pHaSe_ReG = susp->vardelay_pHaSe; - vardelay_x1_sample_reg = susp->vardelay_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_pHaSe_ReG = susp->vardelay_pHaSe; + vardelay_x1_sample_reg = susp->vardelay_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; - if (vardelay_pHaSe_ReG >= 1.0) { - vardelay_x1_sample_reg = vardelay_x2_sample; - /* pick up next sample as vardelay_x2_sample: */ - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - vardelay_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); - } + if (vardelay_pHaSe_ReG >= 1.0) { + vardelay_x1_sample_reg = vardelay_x2_sample; + /* pick up next sample as vardelay_x2_sample: */ + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + vardelay_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); + } phase = (long) ( - (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg); + (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ if (phase < 0) phase = 0; else if (phase > maxdelay_reg) phase = maxdelay_reg; @@ -752,33 +754,33 @@ void tapf_si_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->bufflen = bufflen_reg; - susp->index = index_reg; - susp->vardelay_pHaSe = vardelay_pHaSe_ReG; - susp->vardelay_x1_sample = vardelay_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + susp->vardelay_pHaSe = vardelay_pHaSe_ReG; + susp->vardelay_x1_sample = vardelay_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_si_fetch */ @@ -811,84 +813,84 @@ void tapf_sr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->vardelay_pHaSe = 1.0; + susp->started = true; + susp->vardelay_pHaSe = 1.0; } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next vardelay_x2_sample when phase goes past 1.0; */ - /* we use vardelay_n (computed below) to avoid roundoff errors: */ - if (susp->vardelay_n <= 0) { - susp->vardelay_x1_sample = vardelay_x2_sample; - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - susp->vardelay_pHaSe -= 1.0; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - vardelay_x2_sample = *(susp->vardelay_ptr); - /* vardelay_n gets number of samples before phase exceeds 1.0: */ - susp->vardelay_n = (long) ((1.0 - susp->vardelay_pHaSe) * - susp->output_per_vardelay); - } - togo = min(togo, susp->vardelay_n); - vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); - vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + - vardelay_x2_sample * susp->vardelay_pHaSe); + /* grab next vardelay_x2_sample when phase goes past 1.0; */ + /* we use vardelay_n (computed below) to avoid roundoff errors: */ + if (susp->vardelay_n <= 0) { + susp->vardelay_x1_sample = vardelay_x2_sample; + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + susp->vardelay_pHaSe -= 1.0; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + vardelay_x2_sample = *(susp->vardelay_ptr); + /* vardelay_n gets number of samples before phase exceeds 1.0: */ + susp->vardelay_n = (int64_t) ((1.0 - susp->vardelay_pHaSe) * + susp->output_per_vardelay); + } + togo = (int) min(togo, susp->vardelay_n); + vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); + vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + + vardelay_x2_sample * susp->vardelay_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ long phase; phase = (long) (vardelay_val * vdscale_reg + offset_reg); /* now phase should give number of samples of delay */ @@ -913,57 +915,57 @@ void tapf_sr_fetch(snd_susp_type a_susp, snd_list_type snd_list) */ if (phase < 0) phase += bufflen_reg; *out_ptr_reg++ = (sample_type) (buffer_reg[phase]); - vardelay_val += vardelay_DeLtA; - } while (--n); /* inner loop */ + vardelay_val += vardelay_DeLtA; + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; - susp->vardelay_n -= togo; - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; + susp->vardelay_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapf_sr_fetch */ void tapf_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ tapf_susp_type susp = (tapf_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from vardelay up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr)) >= - susp->vardelay->current) - susp_get_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay->current) + susp_get_samples(vardelay, vardelay_ptr, vardelay_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr - + n = (int) ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr - (susp->vardelay->current - susp->vardelay_cnt)); susp->vardelay_ptr += n; susp_took(vardelay_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/tapv.c b/lib-src/libnyquist/nyquist/tran/tapv.c index ae7582104..bffdfa904 100644 --- a/lib-src/libnyquist/nyquist/tran/tapv.c +++ b/lib-src/libnyquist/nyquist/tran/tapv.c @@ -15,13 +15,13 @@ void tapv_free(snd_susp_type a_susp); typedef struct tapv_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type vardelay; - long vardelay_cnt; + int vardelay_cnt; sample_block_values_type vardelay_ptr; /* support for interpolation of vardelay */ @@ -31,7 +31,7 @@ typedef struct tapv_susp_struct { /* support for ramp between samples of vardelay */ double output_per_vardelay; - long vardelay_n; + int64_t vardelay_n; double offset; double vdscale; @@ -66,63 +66,63 @@ void tapv_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the vardelay input sample block: */ - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - togo = min(togo, susp->vardelay_cnt); + /* don't run past the vardelay input sample block: */ + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + togo = min(togo, susp->vardelay_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_ptr_reg = susp->vardelay_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_ptr_reg = susp->vardelay_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; phase = *vardelay_ptr_reg++ * vdscale_reg + offset_reg; @@ -152,32 +152,32 @@ void tapv_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using vardelay_ptr_reg is a bad idea on RS/6000: */ - susp->vardelay_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(vardelay_cnt, togo); - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using vardelay_ptr_reg is a bad idea on RS/6000: */ + susp->vardelay_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(vardelay_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_nn_fetch */ @@ -210,81 +210,82 @@ void tapv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - susp->vardelay_x1_sample = (susp->vardelay_cnt--, *(susp->vardelay_ptr)); + susp->started = true; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay_cnt--; + susp->vardelay_x1_sample = *(susp->vardelay_ptr); } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_pHaSe_ReG = susp->vardelay_pHaSe; - vardelay_x1_sample_reg = susp->vardelay_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_pHaSe_ReG = susp->vardelay_pHaSe; + vardelay_x1_sample_reg = susp->vardelay_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; - if (vardelay_pHaSe_ReG >= 1.0) { - vardelay_x1_sample_reg = vardelay_x2_sample; - /* pick up next sample as vardelay_x2_sample: */ - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - vardelay_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); - } + if (vardelay_pHaSe_ReG >= 1.0) { + vardelay_x1_sample_reg = vardelay_x2_sample; + /* pick up next sample as vardelay_x2_sample: */ + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + vardelay_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); + } phase = - (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg; + (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg; /* now phase should give number of samples of delay */ if (phase < 0) phase = 0; else if (phase > maxdelay_reg) phase = maxdelay_reg; @@ -311,33 +312,33 @@ void tapv_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->bufflen = bufflen_reg; - susp->index = index_reg; - susp->vardelay_pHaSe = vardelay_pHaSe_ReG; - susp->vardelay_x1_sample = vardelay_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + susp->vardelay_pHaSe = vardelay_pHaSe_ReG; + susp->vardelay_x1_sample = vardelay_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_ni_fetch */ @@ -369,84 +370,84 @@ void tapv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->vardelay_pHaSe = 1.0; + susp->started = true; + susp->vardelay_pHaSe = 1.0; } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next vardelay_x2_sample when phase goes past 1.0; */ - /* we use vardelay_n (computed below) to avoid roundoff errors: */ - if (susp->vardelay_n <= 0) { - susp->vardelay_x1_sample = vardelay_x2_sample; - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - susp->vardelay_pHaSe -= 1.0; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - vardelay_x2_sample = *(susp->vardelay_ptr); - /* vardelay_n gets number of samples before phase exceeds 1.0: */ - susp->vardelay_n = (long) ((1.0 - susp->vardelay_pHaSe) * - susp->output_per_vardelay); - } - togo = min(togo, susp->vardelay_n); - vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); - vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + - vardelay_x2_sample * susp->vardelay_pHaSe); + /* grab next vardelay_x2_sample when phase goes past 1.0; */ + /* we use vardelay_n (computed below) to avoid roundoff errors: */ + if (susp->vardelay_n <= 0) { + susp->vardelay_x1_sample = vardelay_x2_sample; + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + susp->vardelay_pHaSe -= 1.0; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + vardelay_x2_sample = *(susp->vardelay_ptr); + /* vardelay_n gets number of samples before phase exceeds 1.0: */ + susp->vardelay_n = (int64_t) ((1.0 - susp->vardelay_pHaSe) * + susp->output_per_vardelay); + } + togo = (int) min(togo, susp->vardelay_n); + vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); + vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + + vardelay_x2_sample * susp->vardelay_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; phase = vardelay_val * vdscale_reg + offset_reg; @@ -476,32 +477,32 @@ void tapv_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - vardelay_val += vardelay_DeLtA; - } while (--n); /* inner loop */ + vardelay_val += vardelay_DeLtA; + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; - susp->vardelay_n -= togo; - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; + susp->vardelay_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_nr_fetch */ @@ -531,63 +532,63 @@ void tapv_sn_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the vardelay input sample block: */ - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - togo = min(togo, susp->vardelay_cnt); + /* don't run past the vardelay input sample block: */ + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + togo = min(togo, susp->vardelay_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_ptr_reg = susp->vardelay_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_ptr_reg = susp->vardelay_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; phase = *vardelay_ptr_reg++ * vdscale_reg + offset_reg; @@ -617,32 +618,32 @@ void tapv_sn_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using vardelay_ptr_reg is a bad idea on RS/6000: */ - susp->vardelay_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(vardelay_cnt, togo); - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using vardelay_ptr_reg is a bad idea on RS/6000: */ + susp->vardelay_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(vardelay_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_sn_fetch */ @@ -676,81 +677,82 @@ void tapv_si_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - susp->vardelay_x1_sample = (susp->vardelay_cnt--, *(susp->vardelay_ptr)); + susp->started = true; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay_cnt--; + susp->vardelay_x1_sample = *(susp->vardelay_ptr); } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - vardelay_pHaSe_ReG = susp->vardelay_pHaSe; - vardelay_x1_sample_reg = susp->vardelay_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + vardelay_pHaSe_ReG = susp->vardelay_pHaSe; + vardelay_x1_sample_reg = susp->vardelay_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; - if (vardelay_pHaSe_ReG >= 1.0) { - vardelay_x1_sample_reg = vardelay_x2_sample; - /* pick up next sample as vardelay_x2_sample: */ - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - vardelay_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); - } + if (vardelay_pHaSe_ReG >= 1.0) { + vardelay_x1_sample_reg = vardelay_x2_sample; + /* pick up next sample as vardelay_x2_sample: */ + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + vardelay_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(vardelay, vardelay_ptr, vardelay_cnt, vardelay_x2_sample); + } phase = - (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg; + (vardelay_x1_sample_reg * (1 - vardelay_pHaSe_ReG) + vardelay_x2_sample * vardelay_pHaSe_ReG) * vdscale_reg + offset_reg; /* now phase should give number of samples of delay */ if (phase < 0) phase = 0; else if (phase > maxdelay_reg) phase = maxdelay_reg; @@ -777,33 +779,33 @@ void tapv_si_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + vardelay_pHaSe_ReG += vardelay_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->bufflen = bufflen_reg; - susp->index = index_reg; - susp->vardelay_pHaSe = vardelay_pHaSe_ReG; - susp->vardelay_x1_sample = vardelay_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + susp->vardelay_pHaSe = vardelay_pHaSe_ReG; + susp->vardelay_x1_sample = vardelay_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_si_fetch */ @@ -836,84 +838,84 @@ void tapv_sr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->vardelay_pHaSe = 1.0; + susp->started = true; + susp->vardelay_pHaSe = 1.0; } susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); vardelay_x2_sample = *(susp->vardelay_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next vardelay_x2_sample when phase goes past 1.0; */ - /* we use vardelay_n (computed below) to avoid roundoff errors: */ - if (susp->vardelay_n <= 0) { - susp->vardelay_x1_sample = vardelay_x2_sample; - susp->vardelay_ptr++; - susp_took(vardelay_cnt, 1); - susp->vardelay_pHaSe -= 1.0; - susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); - vardelay_x2_sample = *(susp->vardelay_ptr); - /* vardelay_n gets number of samples before phase exceeds 1.0: */ - susp->vardelay_n = (long) ((1.0 - susp->vardelay_pHaSe) * - susp->output_per_vardelay); - } - togo = min(togo, susp->vardelay_n); - vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); - vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + - vardelay_x2_sample * susp->vardelay_pHaSe); + /* grab next vardelay_x2_sample when phase goes past 1.0; */ + /* we use vardelay_n (computed below) to avoid roundoff errors: */ + if (susp->vardelay_n <= 0) { + susp->vardelay_x1_sample = vardelay_x2_sample; + susp->vardelay_ptr++; + susp_took(vardelay_cnt, 1); + susp->vardelay_pHaSe -= 1.0; + susp_check_term_samples(vardelay, vardelay_ptr, vardelay_cnt); + vardelay_x2_sample = *(susp->vardelay_ptr); + /* vardelay_n gets number of samples before phase exceeds 1.0: */ + susp->vardelay_n = (int64_t) ((1.0 - susp->vardelay_pHaSe) * + susp->output_per_vardelay); + } + togo = (int) min(togo, susp->vardelay_n); + vardelay_DeLtA = (sample_type) ((vardelay_x2_sample - susp->vardelay_x1_sample) * susp->vardelay_pHaSe_iNcR); + vardelay_val = (sample_type) (susp->vardelay_x1_sample * (1.0 - susp->vardelay_pHaSe) + + vardelay_x2_sample * susp->vardelay_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - offset_reg = susp->offset; - vdscale_reg = susp->vdscale; - maxdelay_reg = susp->maxdelay; - bufflen_reg = susp->bufflen; - index_reg = susp->index; - buffer_reg = susp->buffer; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + offset_reg = susp->offset; + vdscale_reg = susp->vdscale; + maxdelay_reg = susp->maxdelay; + bufflen_reg = susp->bufflen; + index_reg = susp->index; + buffer_reg = susp->buffer; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ double phase; long i; phase = vardelay_val * vdscale_reg + offset_reg; @@ -943,57 +945,57 @@ void tapv_sr_fetch(snd_susp_type a_susp, snd_list_type snd_list) phase -= (double) i; /* put fractional part in phase */ *out_ptr_reg++ = (sample_type) (buffer_reg[i] * (1.0 - phase) + buffer_reg[i + 1] * phase); - vardelay_val += vardelay_DeLtA; - } while (--n); /* inner loop */ + vardelay_val += vardelay_DeLtA; + } while (--n); /* inner loop */ - susp->bufflen = bufflen_reg; - susp->index = index_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; - susp->vardelay_n -= togo; - cnt += togo; + susp->bufflen = bufflen_reg; + susp->index = index_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->vardelay_pHaSe += togo * susp->vardelay_pHaSe_iNcR; + susp->vardelay_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tapv_sr_fetch */ void tapv_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ tapv_susp_type susp = (tapv_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from vardelay up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr)) >= - susp->vardelay->current) - susp_get_samples(vardelay, vardelay_ptr, vardelay_cnt); + susp->vardelay->current) + susp_get_samples(vardelay, vardelay_ptr, vardelay_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr - + n = (int) ROUNDBIG((final_time - susp->vardelay->t0) * susp->vardelay->sr - (susp->vardelay->current - susp->vardelay_cnt)); susp->vardelay_ptr += n; susp_took(vardelay_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/tone.c b/lib-src/libnyquist/nyquist/tran/tone.c index de0aaede8..9c515eab2 100644 --- a/lib-src/libnyquist/nyquist/tran/tone.c +++ b/lib-src/libnyquist/nyquist/tran/tone.c @@ -14,10 +14,10 @@ void tone_free(snd_susp_type a_susp); typedef struct tone_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; double c2; @@ -46,95 +46,95 @@ void tone_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - c2_reg = susp->c2; - c1_reg = susp->c1; - prev_reg = susp->prev; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + c2_reg = susp->c2; + c1_reg = susp->c1; + prev_reg = susp->prev; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (prev_reg = c1_reg * *input_ptr_reg++ + c2_reg * prev_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tone_n_fetch */ void tone_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ tone_susp_type susp = (tone_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/tonev.c b/lib-src/libnyquist/nyquist/tran/tonev.c index f83b10644..8b5e57bd8 100644 --- a/lib-src/libnyquist/nyquist/tran/tonev.c +++ b/lib-src/libnyquist/nyquist/tran/tonev.c @@ -15,13 +15,13 @@ void tonev_free(snd_susp_type a_susp); typedef struct tonev_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type s1; - long s1_cnt; + int s1_cnt; sample_block_values_type s1_ptr; sound_type hz; - long hz_cnt; + int hz_cnt; sample_block_values_type hz_ptr; /* support for interpolation of hz */ @@ -31,7 +31,7 @@ typedef struct tonev_susp_struct { /* support for ramp between samples of hz */ double output_per_hz; - long hz_n; + int64_t hz_n; double scale1; double c2; @@ -63,91 +63,91 @@ void tonev_ns_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past the hz input sample block: */ - susp_check_term_samples(hz, hz_ptr, hz_cnt); - togo = min(togo, susp->hz_cnt); + /* don't run past the hz input sample block: */ + susp_check_term_samples(hz, hz_ptr, hz_cnt); + togo = min(togo, susp->hz_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c2_reg = susp->c2; - c1_reg = susp->c1; - prev_reg = susp->prev; - hz_ptr_reg = susp->hz_ptr; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - register double b; - b = 2.0 - cos((hz_scale_reg * *hz_ptr_reg++)); - c2_reg = b - sqrt((b * b) - 1.0); - c1_reg = (1.0 - c2_reg) * scale1_reg; + n = togo; + scale1_reg = susp->scale1; + c2_reg = susp->c2; + c1_reg = susp->c1; + prev_reg = susp->prev; + hz_ptr_reg = susp->hz_ptr; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + register double b; + b = 2.0 - cos((hz_scale_reg * *hz_ptr_reg++)); + c2_reg = b - sqrt((b * b) - 1.0); + c1_reg = (1.0 - c2_reg) * scale1_reg; *out_ptr_reg++ = (sample_type) (prev_reg = c1_reg * *s1_ptr_reg++ + c2_reg * prev_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using hz_ptr_reg is a bad idea on RS/6000: */ - susp->hz_ptr += togo; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp_took(hz_cnt, togo); - cnt += togo; + susp->prev = prev_reg; + /* using hz_ptr_reg is a bad idea on RS/6000: */ + susp->hz_ptr += togo; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp_took(hz_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tonev_ns_fetch */ @@ -177,108 +177,108 @@ void tonev_ni_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - register double b; - susp->started = true; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - b = 2.0 - cos(susp->hz_x1_sample); - susp->c2 = b - sqrt((b * b) - 1.0); - susp->c1 = (1.0 - susp->c2) * susp->scale1; + register double b; + susp->started = true; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + b = 2.0 - cos(susp->hz_x1_sample); + susp->c2 = b - sqrt((b * b) - 1.0); + susp->c1 = (1.0 - susp->c2) * susp->scale1; } while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c2_reg = susp->c2; - c1_reg = susp->c1; - prev_reg = susp->prev; - hz_pHaSe_ReG = susp->hz_pHaSe; - hz_x1_sample_reg = susp->hz_x1_sample; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (hz_pHaSe_ReG >= 1.0) { + n = togo; + scale1_reg = susp->scale1; + c2_reg = susp->c2; + c1_reg = susp->c1; + prev_reg = susp->prev; + hz_pHaSe_ReG = susp->hz_pHaSe; + hz_x1_sample_reg = susp->hz_x1_sample; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (hz_pHaSe_ReG >= 1.0) { /* fixup-depends hz */ - register double b; - /* pick up next sample as hz_x1_sample: */ - susp->hz_ptr++; - susp_took(hz_cnt, 1); - hz_pHaSe_ReG -= 1.0; - susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); - hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); - b = 2.0 - cos(hz_x1_sample_reg); - c2_reg = b - sqrt((b * b) - 1.0); - c1_reg = (1.0 - c2_reg) * scale1_reg; - } + register double b; + /* pick up next sample as hz_x1_sample: */ + susp->hz_ptr++; + susp_took(hz_cnt, 1); + hz_pHaSe_ReG -= 1.0; + susp_check_term_samples_break(hz, hz_ptr, hz_cnt, hz_x1_sample_reg); + hz_x1_sample_reg = susp_current_sample(hz, hz_ptr); + b = 2.0 - cos(hz_x1_sample_reg); + c2_reg = b - sqrt((b * b) - 1.0); + c1_reg = (1.0 - c2_reg) * scale1_reg; + } *out_ptr_reg++ = (sample_type) (prev_reg = c1_reg * *s1_ptr_reg++ + c2_reg * prev_reg); - hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + hz_pHaSe_ReG += hz_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->prev = prev_reg; - susp->hz_pHaSe = hz_pHaSe_ReG; - susp->hz_x1_sample = hz_x1_sample_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - cnt += togo; + togo -= n; + susp->prev = prev_reg; + susp->hz_pHaSe = hz_pHaSe_ReG; + susp->hz_x1_sample = hz_x1_sample_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tonev_ni_fetch */ @@ -306,129 +306,129 @@ void tonev_nr_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->hz_pHaSe = 1.0; + susp->started = true; + susp->hz_pHaSe = 1.0; } susp_check_term_samples(hz, hz_ptr, hz_cnt); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the s1 input sample block: */ - susp_check_term_log_samples(s1, s1_ptr, s1_cnt); - togo = min(togo, susp->s1_cnt); + /* don't run past the s1 input sample block: */ + susp_check_term_log_samples(s1, s1_ptr, s1_cnt); + togo = min(togo, susp->s1_cnt); - /* grab next hz_x1_sample when phase goes past 1.0; */ - /* use hz_n (computed below) to avoid roundoff errors: */ - if (susp->hz_n <= 0) { - register double b; - susp_check_term_samples(hz, hz_ptr, hz_cnt); - susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); - susp->hz_pHaSe -= 1.0; - /* hz_n gets number of samples before phase exceeds 1.0: */ - susp->hz_n = (long) ((1.0 - susp->hz_pHaSe) * - susp->output_per_hz); - b = 2.0 - cos(susp->hz_x1_sample); - susp->c2 = b - sqrt((b * b) - 1.0); - susp->c1 = (1.0 - susp->c2) * susp->scale1; - } - togo = min(togo, susp->hz_n); - hz_val = susp->hz_x1_sample; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* grab next hz_x1_sample when phase goes past 1.0; */ + /* use hz_n (computed below) to avoid roundoff errors: */ + if (susp->hz_n <= 0) { + register double b; + susp_check_term_samples(hz, hz_ptr, hz_cnt); + susp->hz_x1_sample = susp_fetch_sample(hz, hz_ptr, hz_cnt); + susp->hz_pHaSe -= 1.0; + /* hz_n gets number of samples before phase exceeds 1.0: */ + susp->hz_n = (int64_t) ((1.0 - susp->hz_pHaSe) * + susp->output_per_hz); + b = 2.0 - cos(susp->hz_x1_sample); + susp->c2 = b - sqrt((b * b) - 1.0); + susp->c1 = (1.0 - susp->c2) * susp->scale1; + } + togo = (int) min(togo, susp->hz_n); + hz_val = susp->hz_x1_sample; + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - scale1_reg = susp->scale1; - c2_reg = susp->c2; - c1_reg = susp->c1; - prev_reg = susp->prev; - s1_ptr_reg = susp->s1_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + scale1_reg = susp->scale1; + c2_reg = susp->c2; + c1_reg = susp->c1; + prev_reg = susp->prev; + s1_ptr_reg = susp->s1_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (prev_reg = c1_reg * *s1_ptr_reg++ + c2_reg * prev_reg); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - susp->prev = prev_reg; - /* using s1_ptr_reg is a bad idea on RS/6000: */ - susp->s1_ptr += togo; - out_ptr += togo; - susp_took(s1_cnt, togo); - susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; - susp->hz_n -= togo; - cnt += togo; + susp->prev = prev_reg; + /* using s1_ptr_reg is a bad idea on RS/6000: */ + susp->s1_ptr += togo; + out_ptr += togo; + susp_took(s1_cnt, togo); + susp->hz_pHaSe += togo * susp->hz_pHaSe_iNcR; + susp->hz_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* tonev_nr_fetch */ void tonev_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ tonev_susp_type susp = (tonev_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from s1 up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr)) >= - susp->s1->current) - susp_get_samples(s1, s1_ptr, s1_cnt); + susp->s1->current) + susp_get_samples(s1, s1_ptr, s1_cnt); /* fetch samples from hz up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr)) >= - susp->hz->current) - susp_get_samples(hz, hz_ptr, hz_cnt); + susp->hz->current) + susp_get_samples(hz, hz_ptr, hz_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - + n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr - (susp->s1->current - susp->s1_cnt)); susp->s1_ptr += n; susp_took(s1_cnt, n); - n = ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - + n = (int) ROUNDBIG((final_time - susp->hz->t0) * susp->hz->sr - (susp->hz->current - susp->hz_cnt)); susp->hz_ptr += n; susp_took(hz_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/translate.lsp b/lib-src/libnyquist/nyquist/tran/translate.lsp index 00ed4b51a..927a25259 100644 --- a/lib-src/libnyquist/nyquist/tran/translate.lsp +++ b/lib-src/libnyquist/nyquist/tran/translate.lsp @@ -17,13 +17,13 @@ (setf *debug* t) ;;********** -;; combinations - generate all combinations +;; combinations - generate all combinations ;; Inputs: -;; n - number of combinations to generate +;; n - number of combinations to generate ;; Result: -;; list of the form -;; ( (a1 b1) (a2 b2) (a3 b3) ... (an bn) ) -;; +;; list of the form +;; ( (a1 b1) (a2 b2) (a3 b3) ... (an bn) ) +;; ;;********** (defun combinations (n) @@ -194,14 +194,14 @@ ;; **************** -;; header-list +;; header-list ;; ;; Result: -;; '( "s1" "s2" ... "sn" ) -;; where s1, s2, etc. are the strings for the header part of the -;; resulting .c file +;; '( "s1" "s2" ... "sn" ) +;; where s1, s2, etc. are the strings for the header part of the +;; resulting .c file ;; Notes: -;; Kludgy. Fix this up for easier maintenance +;; Kludgy. Fix this up for easier maintenance ;; **************** (if *ANSI* @@ -231,9 +231,9 @@ ;; make this work correctly if it is being assigned to a long, float, or ;; double, and if a long, float, or double is being compared ; '("\n#ifndef UNKNOWN\n" -; "#define UNKNOWN -1\n" -; "#define isunknown(x) ( (x) < 0)\n" -; "#endif /* UNKNOWN */\n")) +; "#define UNKNOWN -1\n" +; "#define isunknown(x) ( (x) < 0)\n" +; "#endif /* UNKNOWN */\n")) ;------------------------- @@ -241,9 +241,9 @@ ;; code-gen -- do the output ;; ;; Inputs: -;; alg - -;; stream - -;; hstream - +;; alg - +;; stream - +;; hstream - ;;********** (defun code-gen (alg stream hstream) @@ -304,10 +304,10 @@ ;; commute-check -- ;; ;; Purpose: -;; see if interpolation spec is redundant due to commutativity +;; see if interpolation spec is redundant due to commutativity ;; Algorithm: -;; for each list of "commutable" sounds, make sure spec asks for -;; cannonical ordering: NONE > SCALE > INTERP > RAMP +;; for each list of "commutable" sounds, make sure spec asks for +;; cannonical ordering: NONE > SCALE > INTERP > RAMP ;;********** (defun commute-check (alg spec) (let ((sounds (get-slot alg 'sound-args)) @@ -337,10 +337,10 @@ ;; concatenate -- string concatenation ;; ;; Inputs: -;; "s1" - string -;; "s2" - string +;; "s1" - string +;; "s2" - string ;; Result: -;; "s1s2" +;; "s1s2" ;;********** (defun concatenate (type s1 s2) @@ -360,11 +360,11 @@ ;; index -- find location of list element ;; ;; Inputs: -;; atom - atom to be found in list -;; lis - list searched for +;; atom - atom to be found in list +;; lis - list searched for ;; Result: -;; integer - index of atom in lis -;; NIL - atom not member of lis +;; integer - index of atom in lis +;; NIL - atom not member of lis ;;********** (defun index (atom lis) @@ -379,10 +379,10 @@ ;; insert -- insert an atom at the front of each element of a list ;; ;; Inputs: -;; atom - -;; list-of-lists - lists of the form ( (L1) (L2) ... (Ln)) +;; atom - +;; list-of-lists - lists of the form ( (L1) (L2) ... (Ln)) ;; Result: -;; ( (atom L1) (atom L2) ... (atom Ln) ) +;; ( (atom L1) (atom L2) ... (atom Ln) ) ;;********** (defun insert (atom list-of-lists) (mapcar '(lambda (lis) (cons atom lis)) list-of-lists)) @@ -407,7 +407,7 @@ ;; make-interpolation-list -- figure out the possible interpolation forms ;; ;; Inputs: -;; alg - algorithm description +;; alg - algorithm description ;; Output: ;; List of interpolation styles, e.g. ;; ((NONE NONE) (NONE INTERP) (NONE RAMP)), where the styles @@ -433,7 +433,7 @@ (setf sound-to-name (cons (cons (car sound-args) (car sound-names)) sound-to-name)) -; (display "in make-interpolation-list" sound-to-name) +; (display "in make-interpolation-list" sound-to-name) ))) ; (display "make-interpolation-list: " (reverse sound-args)) (put-slot alg (reverse sound-args) 'sound-args) @@ -503,18 +503,18 @@ ;; make-schema-from-slots -- take attr/value pairs and make property list ;; ;; Inputs: -;; slots - a list of the form -;; (name -;; (attribute1 value1) (attribute2 value2) -;; ... (attributen valuen) ) +;; slots - a list of the form +;; (name +;; (attribute1 value1) (attribute2 value2) +;; ... (attributen valuen) ) ;; Result: -;; The atom 'name' with the attached property list +;; The atom 'name' with the attached property list ;; Effect: -;; Adds properties to the atom 'name' based on the attribute-value -;; pairs. +;; Adds properties to the atom 'name' based on the attribute-value +;; pairs. ;; Notes: -;; The property-list representation is chosen for time efficiency of -;; access +;; The property-list representation is chosen for time efficiency of +;; access ;;********** (defun make-schema-from-slots (slots) @@ -535,8 +535,8 @@ ;; position -- find a pattern in a string ;; ;; Inputs: -;; s - -;; p - +;; s - +;; p - ;;********** (defun position (s p) @@ -552,10 +552,10 @@ ;; print a list of strings to a stream ;; ;; Inputs: -;; strings - a list of strings -;; stream - stream on which to write the strings +;; strings - a list of strings +;; stream - stream on which to write the strings ;; Effect: -;; +;; ;;********** (defun print-strings (strings stream) @@ -565,11 +565,11 @@ ;;********** ;; put-slot: -;; +;; ;; Inputs: -;; schema - name of the schema -;; value - value of the attribute to be added or modified -;; property - name of the attribute to be modified +;; schema - name of the schema +;; value - value of the attribute to be added or modified +;; property - name of the attribute to be modified ;; ;;********** @@ -580,18 +580,18 @@ ;;********** ;; scale-check -- make sure scale method is not used on linear input or -;; on input where scaling is factored into other computation; -;; Also, don't use NONE scale method if sound appears on always-scale -;; list (these sounds have low likelihood of ever using 'NONE method - -;; see fmosc for an example). Note that if you say always-scale (removing +;; on input where scaling is factored into other computation; +;; Also, don't use NONE scale method if sound appears on always-scale +;; list (these sounds have low likelihood of ever using 'NONE method - +;; see fmosc for an example). Note that if you say always-scale (removing ;; NONE) and linear or internal-scaling (removing SCALE), ;; then you'll be in big trouble. ;; ;; Inputs: -;; alg - algorithm description -;; spec - +;; alg - algorithm description +;; spec - ;; Notes: -;; +;; ;;********** (defun scale-check (alg spec) @@ -610,7 +610,7 @@ (cond ((member snd always-scale) (setf result nil) (return)))))))) - (cond ((member 'SCALE spec) ; quick test + (cond ((member 'SCALE spec) ; quick test (dotimes (n (length spec)) ; look at each method in spec (cond ((eq 'SCALE (nth n spec)) (setf snd (nth n sounds)) @@ -707,10 +707,10 @@ ;; translate -- main procedure ;; ;; Inputs: -;; name - string which is name of file to translate +;; name - string which is name of file to translate ;; Effect: -;; Reads the algorithm specification as "name.alg" -;; Generates output files "name.c" and "name.h" +;; Reads the algorithm specification as "name.alg" +;; Generates output files "name.c" and "name.h" ;;********** (defun translate (name) (prog* ((infile (concatenate 'string name ".alg")) @@ -766,12 +766,12 @@ ;; type-check-and-transform -- fix up slots in an algorithm schema ;; ;; Inputs: -;; alg - the name of the algorithm; values are its property list +;; alg - the name of the algorithm; values are its property list ;; Notes: -;; Report an error if required slot values are absent -;; Any slot which should be a single value and is a list is -;; coerced to be the car of the list -;; Put argument string names on argument symbols for conversion. +;; Report an error if required slot values are absent +;; Any slot which should be a single value and is a list is +;; coerced to be the car of the list +;; Put argument string names on argument symbols for conversion. ;;********** (defun type-check-and-transform (alg) @@ -786,7 +786,7 @@ ; fix single-value slots to not be stored as lists: ; If the value is a list, the value is coerced to - ; be the car of the list + ; be the car of the list (dolist (slot @@ -842,14 +842,14 @@ ;; write-header -- write a header file for the suspension create routine ;; ;; Inputs: -;; alg - algorithm name -;; stream - output stream for .h file +;; alg - algorithm name +;; stream - output stream for .h file ;; Effect: -;; Writes to the stream -;; sound_type snd_make_NAME(); +;; Writes to the stream +;; sound_type snd_make_NAME(); ;; Notes: -;; Uses NAME property of algorithm to emit the procedure header to -;; the .h file +;; Uses NAME property of algorithm to emit the procedure header to +;; the .h file ;;********** (setf c-to-xlisp-type '( @@ -861,8 +861,8 @@ ("sound_type" . "SOUND") ("char *" . "STRING") ("LVAL" . "ANY") - ("int" . "FIXNUM") - ("long" . "FIXNUM") + ("int" . "LONG") + ("long" . "LONG") ("boolean" . "BOOLEAN") )) @@ -885,10 +885,10 @@ ; write the type specification for intgen (format stream " /* LISP: (snd-~A" lisp-name) (dolist (arg arguments) - (let ((xltype (assoc (car arg) c-to-xlisp-type :test #'equal))) - (cond ((null xltype) - (error "couldn't translate c-type" (car arg)))) - (format stream " ~A" (cdr xltype)))) + (let ((xltype (assoc (car arg) c-to-xlisp-type :test #'equal))) + (cond ((null xltype) + (error "couldn't translate c-type" (car arg)))) + (format stream " ~A" (cdr xltype)))) (format stream ") */~%"))) @@ -896,12 +896,12 @@ ;; write-typedef -- compile the suspension type definition ;; ;; Inputs: -;; alg - the algorithm specification -;; stream - stream to which to write it +;; alg - the algorithm specification +;; stream - stream to which to write it ;; Effect: -;; typedef struct NAME_susp_struct { -;; ... -;; } NAME_susp_node, *NAME_susp_type; +;; typedef struct NAME_susp_struct { +;; ... +;; } NAME_susp_node, *NAME_susp_type; ;; ;; A side-effect of write-typedef is the initialization ;; of slot xlisp-pointers in alg. This is used later by @@ -935,7 +935,7 @@ (cond ((any-ramp-or-interp-in interpolation-list) ;--------------------- ; INTERP/RAMP: - ; boolean started; + ; boolean started; ;--------------------- (format stream " boolean started;~%"))) @@ -943,9 +943,9 @@ terminate alg (terminate-check-needed terminate alg)) (cond ((terminate-check-needed terminate alg) ;---------------- - ; long terminate_cnt; + ; int64_t terminate_cnt; ;---------------- - (format stream " long terminate_cnt;~%"))) + (format stream " int64_t terminate_cnt;~%"))) (cond ((logical-stop-check-needed logical-stop) ;---------------- @@ -961,14 +961,14 @@ ; each possible interpolation (dotimes (n (length (get alg 'sound-args))) (let ((interpolation (union-of-nth interpolation-list n))) - (setf name (nth n sound-names)) ; get name of signal + (setf name (nth n sound-names)) ; get name of signal ;------------------------ - ; sound_type NAMEi; - ; long NAME_cnt; - ; sample_block_values_type NAME_ptr; + ; sound_type NAMEi; + ; int NAME_cnt; + ; sample_block_values_type NAME_ptr; ;------------------------ (format stream " sound_type ~A;~%" name) - (format stream " long ~A_cnt;~%" name) + (format stream " int ~A_cnt;~%" name) (format stream " sample_block_values_type ~A_ptr;~%" name) (cond ((or (member 'INTERP interpolation) (member 'RAMP interpolation)) @@ -993,23 +993,23 @@ (cond ((member 'RAMP interpolation) ;----------------- ; RAMP: - ; /* support for ramp between samples of NAME */ - ; double output_per_NAME; - ; long NAME_n; + ; /* support for ramp between samples of NAME */ + ; double output_per_NAME; + ; int64_t NAME_n; ;----------------- (format stream "~% /* support for ramp between samples of ~A */~%" name) (format stream " double output_per_~A;~%" name) - (format stream " long ~A_n;~%" name) )))) + (format stream " int64_t ~A_n;~%" name) )))) ;---------------------------- ; STATE - ; TYPEi VARNAMEi ; + ; TYPEi VARNAMEi ; ;---------------------------- ;; now write state variables ;; (STATE (s1) (s2)... (sn) ) ;; each (si) is of the form - ;; ("type" "varname" "?" [TEMP]) + ;; ("type" "varname" "?" [TEMP]) (cond (state-list (format stream "~%"))) (dolist (state state-list) (cond ((equal "LVAL" (car state)) @@ -1026,7 +1026,7 @@ (put-slot alg xlisp-pointers 'xlisp-pointers) ;---------------------------- - ; } ALG-NAME_susp_node, *ALG-NAME_susp_type; + ; } ALG-NAME_susp_node, *ALG-NAME_susp_type; ;---------------------------- (format stream "} ~A_susp_node, *~A_susp_type;~%" alg-name alg-name))) diff --git a/lib-src/libnyquist/nyquist/tran/upsample.c b/lib-src/libnyquist/nyquist/tran/upsample.c index 68686b802..82814af98 100644 --- a/lib-src/libnyquist/nyquist/tran/upsample.c +++ b/lib-src/libnyquist/nyquist/tran/upsample.c @@ -15,10 +15,10 @@ void up_free(snd_susp_type a_susp); typedef struct up_susp_struct { snd_susp_node susp; boolean started; - long terminate_cnt; + int64_t terminate_cnt; boolean logically_stopped; sound_type input; - long input_cnt; + int input_cnt; sample_block_values_type input_ptr; /* support for interpolation of input */ @@ -28,7 +28,7 @@ typedef struct up_susp_struct { /* support for ramp between samples of input */ double output_per_input; - long input_n; + int64_t input_n; } up_susp_node, *up_susp_type; @@ -49,74 +49,74 @@ void up_n_fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past the input input sample block: */ - susp_check_term_log_samples(input, input_ptr, input_cnt); - togo = min(togo, susp->input_cnt); + /* don't run past the input input sample block: */ + susp_check_term_log_samples(input, input_ptr, input_cnt); + togo = min(togo, susp->input_cnt); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - input_ptr_reg = susp->input_ptr; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + input_ptr_reg = susp->input_ptr; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) *input_ptr_reg++; - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - /* using input_ptr_reg is a bad idea on RS/6000: */ - susp->input_ptr += togo; - out_ptr += togo; - susp_took(input_cnt, togo); - cnt += togo; + /* using input_ptr_reg is a bad idea on RS/6000: */ + susp->input_ptr += togo; + out_ptr += togo; + susp_took(input_cnt, togo); + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* up_n_fetch */ @@ -142,90 +142,90 @@ void up_i_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp_check_term_log_samples(input, input_ptr, input_cnt); - susp->input_x1_sample = susp_fetch_sample(input, input_ptr, input_cnt); + susp->started = true; + susp_check_term_log_samples(input, input_ptr, input_cnt); + susp->input_x1_sample = susp_fetch_sample(input, input_ptr, input_cnt); } susp_check_term_log_samples(input, input_ptr, input_cnt); input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - input_pHaSe_ReG = susp->input_pHaSe; - input_x1_sample_reg = susp->input_x1_sample; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ - if (input_pHaSe_ReG >= 1.0) { - input_x1_sample_reg = input_x2_sample; - /* pick up next sample as input_x2_sample: */ - susp->input_ptr++; - susp_took(input_cnt, 1); - input_pHaSe_ReG -= 1.0; - susp_check_term_log_samples_break(input, input_ptr, input_cnt, input_x2_sample); - } + n = togo; + input_pHaSe_ReG = susp->input_pHaSe; + input_x1_sample_reg = susp->input_x1_sample; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ + if (input_pHaSe_ReG >= 1.0) { + input_x1_sample_reg = input_x2_sample; + /* pick up next sample as input_x2_sample: */ + susp->input_ptr++; + susp_took(input_cnt, 1); + input_pHaSe_ReG -= 1.0; + susp_check_term_log_samples_break(input, input_ptr, input_cnt, input_x2_sample); + } *out_ptr_reg++ = (sample_type) - (input_x1_sample_reg * (1 - input_pHaSe_ReG) + input_x2_sample * input_pHaSe_ReG); - input_pHaSe_ReG += input_pHaSe_iNcR_rEg; - } while (--n); /* inner loop */ + (input_x1_sample_reg * (1 - input_pHaSe_ReG) + input_x2_sample * input_pHaSe_ReG); + input_pHaSe_ReG += input_pHaSe_iNcR_rEg; + } while (--n); /* inner loop */ - togo -= n; - susp->input_pHaSe = input_pHaSe_ReG; - susp->input_x1_sample = input_x1_sample_reg; - out_ptr += togo; - cnt += togo; + togo -= n; + susp->input_pHaSe = input_pHaSe_ReG; + susp->input_x1_sample = input_x1_sample_reg; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* up_i_fetch */ @@ -250,112 +250,112 @@ void up_r_fetch(snd_susp_type a_susp, snd_list_type snd_list) /* make sure sounds are primed with first values */ if (!susp->started) { - susp->started = true; - susp->input_pHaSe = 1.0; + susp->started = true; + susp->input_pHaSe = 1.0; } susp_check_term_log_samples(input, input_ptr, input_cnt); input_x2_sample = susp_current_sample(input, input_ptr); while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* grab next input_x2_sample when phase goes past 1.0; */ - /* we use input_n (computed below) to avoid roundoff errors: */ - if (susp->input_n <= 0) { - susp->input_x1_sample = input_x2_sample; - susp->input_ptr++; - susp_took(input_cnt, 1); - susp->input_pHaSe -= 1.0; - susp_check_term_log_samples(input, input_ptr, input_cnt); - input_x2_sample = susp_current_sample(input, input_ptr); - /* input_n gets number of samples before phase exceeds 1.0: */ - susp->input_n = (long) ((1.0 - susp->input_pHaSe) * - susp->output_per_input); - } - togo = min(togo, susp->input_n); - input_DeLtA = (sample_type) ((input_x2_sample - susp->input_x1_sample) * susp->input_pHaSe_iNcR); - input_val = (sample_type) (susp->input_x1_sample * (1.0 - susp->input_pHaSe) + - input_x2_sample * susp->input_pHaSe); + /* grab next input_x2_sample when phase goes past 1.0; */ + /* we use input_n (computed below) to avoid roundoff errors: */ + if (susp->input_n <= 0) { + susp->input_x1_sample = input_x2_sample; + susp->input_ptr++; + susp_took(input_cnt, 1); + susp->input_pHaSe -= 1.0; + susp_check_term_log_samples(input, input_ptr, input_cnt); + input_x2_sample = susp_current_sample(input, input_ptr); + /* input_n gets number of samples before phase exceeds 1.0: */ + susp->input_n = (int64_t) ((1.0 - susp->input_pHaSe) * + susp->output_per_input); + } + togo = (int) min(togo, susp->input_n); + input_DeLtA = (sample_type) ((input_x2_sample - susp->input_x1_sample) * susp->input_pHaSe_iNcR); + input_val = (sample_type) (susp->input_x1_sample * (1.0 - susp->input_pHaSe) + + input_x2_sample * susp->input_pHaSe); - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - /* don't run past logical stop time */ - if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); - /* break if to_stop == 0 (we're at the logical stop) - * AND cnt > 0 (we're not at the beginning of the - * output block). - */ - if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ - if (to_stop < togo) { - if (to_stop == 0) { - if (cnt) { - togo = 0; - break; - } else /* keep togo as is: since cnt == 0, we - * can set the logical stop flag on this - * output block - */ - susp->logically_stopped = true; - } else /* limit togo so we can start a new - * block at the LST - */ - togo = to_stop; - } - } + /* don't run past logical stop time */ + if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + /* break if to_stop == 0 (we're at the logical stop) + * AND cnt > 0 (we're not at the beginning of the + * output block). + */ + if (to_stop < 0) to_stop = 0; /* avoids rounding errors */ + if (to_stop < togo) { + if (to_stop == 0) { + if (cnt) { + togo = 0; + break; + } else /* keep togo as is: since cnt == 0, we + * can set the logical stop flag on this + * output block + */ + susp->logically_stopped = true; + } else /* limit togo so we can start a new + * block at the LST + */ + togo = (int) to_stop; + } + } - n = togo; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) input_val; - input_val += input_DeLtA; - } while (--n); /* inner loop */ + input_val += input_DeLtA; + } while (--n); /* inner loop */ - out_ptr += togo; - susp->input_pHaSe += togo * susp->input_pHaSe_iNcR; - susp->input_n -= togo; - cnt += togo; + out_ptr += togo; + susp->input_pHaSe += togo * susp->input_pHaSe_iNcR; + susp->input_n -= togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } /* test for logical stop */ if (susp->logically_stopped) { - snd_list->logically_stopped = true; + snd_list->logically_stopped = true; } else if (susp->susp.log_stop_cnt == susp->susp.current) { - susp->logically_stopped = true; + susp->logically_stopped = true; } } /* up_r_fetch */ void up_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list) - { +{ up_susp_type susp = (up_susp_type) a_susp; time_type final_time = susp->susp.t0; - long n; + int n; /* fetch samples from input up to final_time for this block of zeros */ while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >= - susp->input->current) - susp_get_samples(input, input_ptr, input_cnt); + susp->input->current) + susp_get_samples(input, input_ptr, input_cnt); /* convert to normal processing when we hit final_count */ /* we want each signal positioned at final_time */ - n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - + n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr - (susp->input->current - susp->input_cnt)); susp->input_ptr += n; susp_took(input_cnt, n); diff --git a/lib-src/libnyquist/nyquist/tran/white.c b/lib-src/libnyquist/nyquist/tran/white.c index fb32a25aa..778c7e382 100644 --- a/lib-src/libnyquist/nyquist/tran/white.c +++ b/lib-src/libnyquist/nyquist/tran/white.c @@ -14,7 +14,7 @@ void white_free(snd_susp_type a_susp); typedef struct white_susp_struct { snd_susp_node susp; - long terminate_cnt; + int64_t terminate_cnt; } white_susp_node, *white_susp_type; @@ -34,34 +34,34 @@ void white__fetch(snd_susp_type a_susp, snd_list_type snd_list) snd_list->block = out; while (cnt < max_sample_block_len) { /* outer loop */ - /* first compute how many samples to generate in inner loop: */ - /* don't overflow the output sample block: */ - togo = max_sample_block_len - cnt; + /* first compute how many samples to generate in inner loop: */ + /* don't overflow the output sample block: */ + togo = max_sample_block_len - cnt; - /* don't run past terminate time */ - if (susp->terminate_cnt != UNKNOWN && - susp->terminate_cnt <= susp->susp.current + cnt + togo) { - togo = susp->terminate_cnt - (susp->susp.current + cnt); - if (togo < 0) togo = 0; /* avoids rounding errros */ - if (togo == 0) break; - } + /* don't run past terminate time */ + if (susp->terminate_cnt != UNKNOWN && + susp->terminate_cnt <= susp->susp.current + cnt + togo) { + togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); + if (togo < 0) togo = 0; /* avoids rounding errros */ + if (togo == 0) break; + } - n = togo; - out_ptr_reg = out_ptr; - if (n) do { /* the inner sample computation loop */ + n = togo; + out_ptr_reg = out_ptr; + if (n) do { /* the inner sample computation loop */ *out_ptr_reg++ = (sample_type) (rand() * rand_scale - 1.0); - } while (--n); /* inner loop */ + } while (--n); /* inner loop */ - out_ptr += togo; - cnt += togo; + out_ptr += togo; + cnt += togo; } /* outer loop */ /* test for termination */ if (togo == 0 && cnt == 0) { - snd_list_terminate(snd_list); + snd_list_terminate(snd_list); } else { - snd_list->block_len = cnt; - susp->susp.current += cnt; + snd_list->block_len = cnt; + susp->susp.current += cnt; } } /* white__fetch */ diff --git a/lib-src/libnyquist/nyquist/tran/writemake.lsp b/lib-src/libnyquist/nyquist/tran/writemake.lsp index 07cb9090f..edd130bb9 100644 --- a/lib-src/libnyquist/nyquist/tran/writemake.lsp +++ b/lib-src/libnyquist/nyquist/tran/writemake.lsp @@ -26,76 +26,81 @@ ;; Hint: this algorithm constructs the 2^n variations by substituting ;; (or not) 'n' for 's' whereever s'es occur. The search is cut off -;; however, when an altered string is found in the encoding-list, which -;; tells what cases are handled directly. +;; however, when an altered string is found in the encoding-list, +;; which tells what cases are handled directly. ;; -;; Wow, returning to the description above after several months, I couldn't make -;; heads or tails of it, and I wrote it! Here's another perhaps better, description: +;; Wow, returning to the description above after several months, I +;; couldn't make heads or tails of it, and I wrote it! Here's another +;; perhaps better, description: ;; -;; We generated various _fetch routines that differ in their assumptions about how to -;; access signal arguments. There are (now) 4 variations: NONE, SCALE, INTERP, and -;; RAMP. All 4^N combinations of these are generated initially, but many combinations -;; are deleted before any code is generated. Reasons for removing a combination include -;; the use of symetry, linearity, and simply the promise that input arguments will be -;; interpolated externally. In most of these cases, combinations are removed because -;; they cannot occur in practice. But in others, combinations are removed because they -;; should be handled by different code. For example, an input signal matching the output -;; sample rate and with a scale factor of 1 is normally handled by NONE style -;; "interpolation". Note: "interpolation" is used throughout this code, but a better term -;; would be "access method," because no interpolation is involved in the NONE and -;; SCALE variants. The inner loop access code for NONE style is something like "*s++". -;; However, an input signal suitable for NONE style interpolation can also be handled -;; by SCALE style interpolation (which looks something like "(*s++ * s_scale)", i.e. -;; an extra multiplication is required. If the attribute INTERNAL-SCALING is used, -;; then the scale factor does not actually appear at the access point because it has been -;; factored into a filter coefficient or some other factor, saving the multiply. -;; Alternatively, the ALWAYS-SCALE attribute can specify that there is little to be -;; gained by saving a multiply. In these cases, we want to handle NONE style signals -;; with SCALE style interpolation. Let's run through these possibilities again and -;; describe how they are handled: +;; We generated various _fetch routines that differ in their +;; assumptions about how to access signal arguments. There are (now) +;; 4 variations: NONE, SCALE, INTERP, and RAMP. All 4^N combinations +;; of these are generated initially, but many combinations are deleted +;; before any code is generated. Reasons for removing a combination +;; include the use of symetry, linearity, and simply the promise that +;; input arguments will be interpolated externally. In most of these +;; cases, combinations are removed because they cannot occur in +;; practice. But in others, combinations are removed because they +;; should be handled by different code. For example, an input signal +;; matching the output sample rate and with a scale factor of 1 is +;; normally handled by NONE style "interpolation". Note: +;; "interpolation" is used throughout this code, but a better term +;; would be "access method," because no interpolation is involved in +;; the NONE and SCALE variants. The inner loop access code for NONE +;; style is something like "*s++". However, an input signal suitable +;; for NONE style interpolation can also be handled by SCALE style +;; interpolation (which looks something like "(*s++ * s_scale)", i.e. +;; an extra multiplication is required. If the attribute +;; INTERNAL-SCALING is used, then the scale factor does not actually +;; appear at the access point because it has been factored into a +;; filter coefficient or some other factor, saving the multiply. +;; Alternatively, the ALWAYS-SCALE attribute can specify that there is +;; little to be gained by saving a multiply. In these cases, we want +;; to handle NONE style signals with SCALE style interpolation. Let's +;; run through these possibilities again and describe how they are +;; handled: ;; -;; ALWAYS-SCALE: here we delete the NONE variant(s) and only generate fetch -;; routines that have scaling code in them. When we get an actual parameter with -;; a scale factor of 1 (implying NONE interpolation), we handle it with the SCALE -;; fetch routine. +;; ALWAYS-SCALE: here we delete the NONE variant(s) and only generate +;; fetch routines that have scaling code in them. When we get an +;; actual parameter with a scale factor of 1 (implying NONE +;; interpolation), we handle it with the SCALE fetch routine. ;; INTERNAL-SCALING: here we generate NONE fetch routines because the -;; scale factor is taken care of elsewhere in the code, e.g. in a filter coefficient. -;; LINEAR: here, the scale factor of the actual argument becomes a scale factor -;; on the output (part of the data structure), deferring multiplies until later. We -;; then modify the argument scale factor to 1, and NONE style interpolation applies. -;; There is no need to generate SCALE style routines, because there will never be -;; any need for them. +;; scale factor is taken care of elsewhere in the code, e.g. in a +;; filter coefficient. LINEAR: here, the scale factor of the actual +;; argument becomes a scale factor on the output (part of the data +;; structure), deferring multiplies until later. We then modify the +;; argument scale factor to 1, and NONE style interpolation applies. +;; There is no need to generate SCALE style routines, because there +;; will never be any need for them. ;; ;; For a given signal parameter, these 3 cases are mutually exclusive. ;; -;; Looking at these three cases, we see that sometimes there will be SCALE style -;; routines handling NONE arguments, sometimes NONE style routines handling -;; SCALE arguments, and sometimes NONE style routines because there will -;; never be a need for SCALE. -;; This code is going to generate labels so that other fetch routines -;; handle the "missing" ones. -;; To do this, we generate extra labels in the case -;; statement that selects the fetch routine (interpolation is in the inner loop in the -;; fetch routine. For example, we might generate this code: -;; ... -;; case INTERP_nn: -;; case INTERP_sn: -;; case INTERP_ns: -;; case INTERP_ss: susp->susp.fetch = tonev_ss_fetch; break; -;; ... -;; Here, a single fetch routine (tonev_ss_fetch) handles all variations of NONE and -;; SCALE (n and s) types of the two signal arguments. The basic rule is: if you did not -;; generate a fetch routine for the NONE case, then handle it with the SCALE case, and -;; if you did not generate a fetch routine for the SCALE case, handle it with the NONE -;; case. +;; Looking at these three cases, we see that sometimes there will be +;; SCALE style routines handling NONE arguments, sometimes NONE style +;; routines handling SCALE arguments, and sometimes NONE style +;; routines because there will never be a need for SCALE. This code +;; is going to generate labels so that other fetch routines handle the +;; "missing" ones. To do this, we generate extra labels in the case +;; statement that selects the fetch routine (interpolation is in the +;; inner loop in the fetch routine. For example, we might generate +;; this code: ... case INTERP_nn: case INTERP_sn: case INTERP_ns: +;; case INTERP_ss: susp->susp.fetch = tonev_ss_fetch; break; ... +;; Here, a single fetch routine (tonev_ss_fetch) handles all +;; variations of NONE and SCALE (n and s) types of the two signal +;; arguments. The basic rule is: if you did not generate a fetch +;; routine for the NONE case, then handle it with the SCALE case, and +;; if you did not generate a fetch routine for the SCALE case, handle +;; it with the NONE case. ;; -;; The algorithm uses the list interpolation-rationale, which lists for each sound -;; parameter one of {NIL, LINEAR, ALWAYS-SCALE, INTERNAL-SCALING}. -;; Using this list, the code enumerates all the possible cases that might be handled -;; by the current fetch routine (represented by the "encoding" parameter). -;; This is a recursive algorithm because, if there are n SCALE type parameters, then -;; there are 2^N possible variations to enumerate. (E.g. look at the 4 variations in -;; the code example above.) +;; The algorithm uses the list interpolation-rationale, which lists +;; for each sound parameter one of {NIL, LINEAR, ALWAYS-SCALE, +;; INTERNAL-SCALING}. Using this list, the code enumerates all the +;; possible cases that might be handled by the current fetch routine +;; (represented by the "encoding" parameter). This is a recursive +;; algorithm because, if there are n SCALE type parameters, then there +;; are 2^N possible variations to enumerate. (E.g. look at the 4 +;; variations in the code example above.) ;; ;; (defun check-for-no-interpolation-1 (encoding index @@ -184,13 +189,13 @@ ;;************ -;; write-mark +;; write-mark ;; ;; Inputs: -;; alg - algorithm description -;; stream - stream on which to write .c file +;; alg - algorithm description +;; stream - stream on which to write .c file ;; Effect: -;; writes NAME_mark(...) +;; writes NAME_mark(...) ;;************ (defun write-mark (alg stream) @@ -306,13 +311,13 @@ ;;************ -;; write-make +;; write-make ;; ;; Inputs: -;; alg - algorithm description -;; stream - stream on which to write .c file +;; alg - algorithm description +;; stream - stream on which to write .c file ;; Effect: -;; writes NAME_free(...), NAME_print_tree, and snd_make_NAME(...) +;; writes NAME_free(...), NAME_print_tree, and snd_make_NAME(...) ;;************ (defun write-make (alg stream) @@ -445,12 +450,12 @@ ;-------------------- ; sample_type scale_factor = 1.0F; ; time_type t0_min; -- but only if there are sound args, implied by non-null sound-names - ; long lsc; + ; int64_t lsc; ;-------------------- (format stream " sample_type scale_factor = 1.0F;~%") (if sound-names (format stream " time_type t0_min = t0;~%")) (if (lsc-needed-p alg) - (format stream " long lsc;~%")) + (format stream " int64_t lsc;~%")) ; now do canonical ordering of commutable sounds ; @@ -690,9 +695,9 @@ ; /* how many samples to toss before t0: */ ; susp->susp.toss_cnt = (long) ((t0 - t0_min) * sr + .5); ; if (susp->susp.toss_cnt > 0) { - ; susp->susp.keep_fetch = susp->susp.fetch; - ; susp->susp.fetch = NAME_toss_fetch; - ; t0 = t0_min; -- DELETED 3MAY99 by RBD + ; susp->susp.keep_fetch = susp->susp.fetch; + ; susp->susp.fetch = NAME_toss_fetch; + ; t0 = t0_min; -- DELETED 3MAY99 by RBD ; } ;---------------- (cond (sound-names @@ -704,7 +709,7 @@ (format stream " if (susp->susp.toss_cnt > 0) {\n") (format stream " susp->susp.keep_fetch = susp->susp.fetch;\n") (format stream " susp->susp.fetch = ~A_toss_fetch;~%" name) -; (format stream " t0 = t0_min;~% }\n\n"))) +; (format stream " t0 = t0_min;~% }\n\n"))) (format stream " }\n\n"))) ;-------------------- @@ -750,13 +755,13 @@ ;-------------------- ; ramped or interpolated: ; - ; susp->started = false; + ; susp->started = false; ;-------------------- (cond ((any-ramp-or-interp-in interpolation-list) (format stream " susp->started = false;~%"))) ;-------------------- - ; susp->susp.current = 0; + ; susp->susp.current = 0; ;-------------------- (format stream " susp->susp.current = 0;~%") @@ -769,13 +774,13 @@ (dotimes (n (length (get alg 'sound-args))) (let ((interpolation (union-of-nth interpolation-list n))) - (setf arg (nth n sound-names)) ; get name of signal + (setf arg (nth n sound-names)) ; get name of signal (format stream " susp->~A = ~A;~%" arg arg) (format stream " susp->~A_cnt = 0;~%" arg) ;----------------------------------------------- ; Interpolation: ; - ; susp-> _pHaSe = 0.0; + ; susp-> _pHaSe = 0.0; ; susp-> _pHaSe_iNcR = ->sr ;----------------------------------------------- (cond ((member 'INTERP interpolation) @@ -820,15 +825,15 @@ ;; write-ansi-prototype-list -- with comma separator, open and close parens ;; ;; Inputs: -;; stream - output stream -;; prefix - arg prefix, perhaps "" -;; args - argument type/name pairs of the form -;; ( (type1 name1) (type2 name2) ... ) +;; stream - output stream +;; prefix - arg prefix, perhaps "" +;; args - argument type/name pairs of the form +;; ( (type1 name1) (type2 name2) ... ) ;; Effect: -;; if *ANSI* is set T, writes ANSI-style parameter list of the form -;; type name, ... -;; if *ANSI* is set NIL, writes antique-style parameter list of the form -;; () +;; if *ANSI* is set T, writes ANSI-style parameter list of the form +;; type name, ... +;; if *ANSI* is set NIL, writes antique-style parameter list of the form +;; () ;;************ (defun write-ansi-prototype-list (stream prefix args) @@ -838,7 +843,7 @@ (dolist (parm args) ;-------------------- ; for each parameter - ; type + ; type ;-------------------- (format stream "~A~A ~A~A" comma (car parm) prefix (cadr parm)) (setf comma ", ")) @@ -846,18 +851,18 @@ (format stream ")"))) ;;************ -;; write-ansi-parameter-list +;; write-ansi-parameter-list ;; ;; Inputs: -;; stream - output stream -;; prefix - arg prefix, perhaps "" -;; args - argument type/name pairs of the form -;; ( (type1 name1) (type2 name2) ... ) +;; stream - output stream +;; prefix - arg prefix, perhaps "" +;; args - argument type/name pairs of the form +;; ( (type1 name1) (type2 name2) ... ) ;; Effect: -;; if *ANSI* is set T, writes ANSI-style parameter list of the form -;; (type name, ...) -;; if *ANSI* is set NIL, writes antique-style parameter list of the form -;; (name, ...) +;; if *ANSI* is set T, writes ANSI-style parameter list of the form +;; (type name, ...) +;; if *ANSI* is set NIL, writes antique-style parameter list of the form +;; (name, ...) ;; Note: ;; to get a space between types and arguments, a space is prepended to prefix if ;; this is an *ANSI* arg list. @@ -877,16 +882,16 @@ (format stream ")"))) ;;************ -;; write-sample-rate +;; write-sample-rate ;; Effect: -;; declare sr and compute the sample rate for the new signal +;; declare sr and compute the sample rate for the new signal ;; Notes: -;; If sr is an input parameter, it is not declared -;; If (SAMPLE-RATE expr) is specified, declare sr to be initialized -;; to the expr -;; If (SAMPLE-RATE (MAX s1 s2 ...)), sr is initialized to the max. -;; Otherwise, sr is initialized to the max of the sample rates of -;; all the sound-type arguments +;; If sr is an input parameter, it is not declared +;; If (SAMPLE-RATE expr) is specified, declare sr to be initialized +;; to the expr +;; If (SAMPLE-RATE (MAX s1 s2 ...)), sr is initialized to the max. +;; Otherwise, sr is initialized to the max of the sample rates of +;; all the sound-type arguments ;;************ (defun write-sample-rate (stream sr sound-names arguments) @@ -920,7 +925,7 @@ ;--------------------- ; rate_type sr = max( ->sr, ->sr); ;--------------------- - (format stream " rate_type sr = ") ; jmn + (format stream " rate_type sr = ") ; jmn (write-redux-of-names stream "max" sound-names "->sr") (format stream ";~%") ) @@ -940,14 +945,14 @@ ;;************ -;; write-start-time +;; write-start-time ;; Effect: -;; declare sr and compute the start time for the new signal +;; declare sr and compute the start time for the new signal ;; Notes: -;; If t0 is an input parameter, it is not declared -;; If (START (AT expr)) is specified, declare t0 to be initialized -;; to the expr -;; Otherwise, t0 is initialized to 0 +;; If t0 is an input parameter, it is not declared +;; If (START (AT expr)) is specified, declare t0 to be initialized +;; to the expr +;; Otherwise, t0 is initialized to 0 ;;************ (defun write-start-time (stream start arguments) diff --git a/lib-src/libnyquist/nyquist/tran/writesusp.lsp b/lib-src/libnyquist/nyquist/tran/writesusp.lsp index 4d5062c87..4f6f2bce8 100644 --- a/lib-src/libnyquist/nyquist/tran/writesusp.lsp +++ b/lib-src/libnyquist/nyquist/tran/writesusp.lsp @@ -8,7 +8,7 @@ ;; | errors ;; 13-Jan-92 | [1.2] reformatted and recommented ;;************ - + ;;**************** ;; depended-on-in-inner-loop - test if variables updated in inner loop ;;**************** @@ -26,8 +26,8 @@ ;;**************** ;; fixup-depends-prime - write code to update depend variables -;; this code is only run the first time the suspension -;; is invoked +;; this code is only run the first time the suspension +;; is invoked ;;**************** (defun fixup-depends-prime (alg stream name indent var-name) (let ((depends (get-slot alg 'depends))) @@ -47,15 +47,15 @@ ;;**************** ;; fixup-depends-prime-decls - write declarations for temp depend variables -;; this code is only run the first time the suspension -;; is invoked +;; this code is only run the first time the suspension +;; is invoked ;;**************** (defun fixup-depends-prime-decls (alg stream name) (let ((depends (get-slot alg 'depends))) (dolist (dep depends) (cond ((equal name (cadr dep)) (cond ((eq (cadddr dep) 'TEMP) - (format stream "\t ~A ~A;~%" (car (cddddr dep)) + (format stream " ~A ~A;~%" (car (cddddr dep)) (car dep))))))))) (print 'fixup-depends-prime-decls) @@ -63,8 +63,8 @@ ;;**************** ;; fixup-substitutions-prime - substitute susp-> for for each -;; state variable in code, also substitute var-name for name -;; (this is the depended-on value) +;; state variable in code, also substitute var-name for name +;; (this is the depended-on value) ;;**************** (defun fixup-substitutions-prime (alg code name var-name) (dolist (state (get-slot alg 'state)) @@ -100,9 +100,9 @@ ;;**************** ;; fixup-depends - write code to declare and update depend variables -;; this is called at declaration time (the point where -;; declarations should be output), but also generates code -;; to be output after the depended-on variable is updated +;; this is called at declaration time (the point where +;; declarations should be output), but also generates code +;; to be output after the depended-on variable is updated ;;**************** (defun fixup-depends (alg stream name) (format stream "/* fixup-depends ~A */~%" name) @@ -112,16 +112,16 @@ (dolist (dep depends) (cond ((equal name (cadr dep)) (cond ((eq (cadddr dep) 'TEMP) - (format stream "\t\t~A ~A; ~%" (car (cddddr dep)) - (car dep)) + (format stream + " ~A ~A; ~%" (car (cddddr dep)) (car dep)) (setf fixup-code - (format nil "~A\t\t~A = ~A;~%" + (format nil "~A ~A = ~A;~%" fixup-code (car dep) (fixup-substitutions alg - (caddr dep) name var-name)))) + (caddr dep) name var-name)))) (t (setf fixup-code - (format nil "~A\t\t~A_reg = ~A;~%" + (format nil "~A ~A_reg = ~A;~%" fixup-code (car dep) (fixup-substitutions alg (caddr dep) name var-name)))))))) @@ -132,8 +132,8 @@ ;;**************** ;; fixup-substitutions - substitute _reg for for each -;; state variable in code, also substitute var-name for name -;; (this is the depended-on value) +;; state variable in code, also substitute var-name for name +;; (this is the depended-on value) ;;**************** (defun fixup-substitutions (alg code name var-name) (dolist (state (get-slot alg 'state)) @@ -212,7 +212,7 @@ ;(defun write-depend-decls (alg stream) ; (dolist (dep (get-slot alg 'depends)) ; (cond ((eq (cadddr dep) 'TEMP) -; (format stream "\t~A ~A; ~%" (car (cddddr dep)) (car dep)))))) +; (format stream " ~A ~A; ~%" (car (cddddr dep)) (car dep)))))) ;-------- (defun write-depend-decls (alg stream interp sound-names step-function) @@ -248,7 +248,7 @@ ; yes, at least sometimes, so we're leaving it in ; "atonev.alg" is a good test case to prove you can't comment this out (write-depend-decls alg stream interp sound-names step-function) - (format stream "\tsusp->started = true;~%") + (format stream " susp->started = true;~%") ;------------------------------ ; for each method @@ -264,32 +264,34 @@ ; NAME_cnt); ; (if a step function) ;-------------------- - (format stream "\t~A(~A, ~A_ptr, ~A_cnt);~%" + (format stream " ~A(~A, ~A_ptr, ~A_cnt);~%" (susp-check-fn name alg) name name name) (cond ((member (name-to-symbol name) internal-scaling) (format stream - "\tsusp->~A_x1_sample = (susp->~A_cnt--, *(susp->~A_ptr));~%" + " susp->~A_cnt--;~% ~ + susp->~A_x1_sample = *(susp->~A_ptr);~%" name name name)) (t (format stream - "\tsusp->~A_x1_sample = susp_fetch_sample(~A, ~A_ptr, ~A_cnt);~%" + " susp->~A_x1_sample = ~ + susp_fetch_sample(~A, ~A_ptr, ~A_cnt);~%" name name name name))) (setf is-step (member (name-to-symbol name) step-function)) (cond (is-step - (fixup-depends-prime alg stream name "\t" + (fixup-depends-prime alg stream name " " (strcat "susp->" name "_x1_sample"))))) ((eq method 'RAMP) ;-------------------- ; susp->NAME_pHaSe = 1.0; ;-------------------- - (format stream "\tsusp->~A_pHaSe = ~A;~%" name "1.0"))))) + (format stream " susp->~A_pHaSe = ~A;~%" name "1.0"))))) ;-------------------- ; *WATCH* ; show_samples(2,susp->NAME_x2,0); ;-------------------- ; (if *WATCH* -; (format stream "\tshow_samples(2,~A_x2,0);~%" name)) +; (format stream " show_samples(2,~A_x2,0);~%" name)) ;-------------------- ; } @@ -303,20 +305,20 @@ ;; show-samples-option ;; ;; Inputs: -;; stream: output stream for file -;; name: token to use for forming name +;; stream: output stream for file +;; name: token to use for forming name ;; Effect: -;; Writes sampling clause +;; Writes sampling clause ;;************ (defun show-samples-option (stream name) ;---------------------------- - ; else - ; { /* just show NAME */ - ; show_samples(1,NAME,NAME_ptr - NAME->samples); - ; } /* just show NAME */ + ; else + ; { /* just show NAME */ + ; show_samples(1,NAME,NAME_ptr - NAME->samples); + ; } /* just show NAME */ ;---------------------------- -; (format stream "\t show_samples(1, ~A, 0);~%\t} else {~%" name) -; (format stream "\t show_samples(1, ~A, ~A_ptr - ~A->samples);~%~%" +; (format stream " show_samples(1, ~A, 0);~% } else {~%" name) +; (format stream " show_samples(1, ~A, ~A_ptr - ~A->samples);~%~%" ; name name name) ) @@ -349,7 +351,7 @@ ; void NAME__fetch(a_susp, snd_list) ; register pwl_susp_type a_susp; ; snd_list_type snd_list; - ; { + ; { ; ANSI: ; void NAME__fetch(snd_susp_type a_susp, ; snd_list_type snd_list) @@ -423,7 +425,7 @@ (cond ((and (equal name (cadr dep)) (or (member method '(NONE SCALE)) interpolate-samples)) - (setf loop-prefix (format nil "~A\t ~A = ~A;~%" + (setf loop-prefix (format nil "~A ~A = ~A;~%" loop-prefix (car dep) (caddr dep)))))))) ;; computation of JOINT-DEPENDENCY, if applicable @@ -434,7 +436,7 @@ step-function) (dolist (stmt (cdr dep)) (setf joint-depend (strcat joint-depend - "\t " stmt "\n")))))) + " " stmt "\n")))))) ; this computes some additional declarations (compute-inner-loop alg (strcat loop-prefix joint-depend @@ -482,7 +484,7 @@ (format stream " ~A_x2_sample = *(susp->~A_ptr);~%" name name)) (t - (format stream + (format stream " ~A_x2_sample = susp_current_sample(~A, ~A_ptr);~%" name name name)))) ((eq method 'INTERP) @@ -513,18 +515,18 @@ ;---------------------------- ; while (cnt < max_sample_block_len) { /* outer loop */ ; /* first compute how many samples to generate in inner loop: */ - ; /* don't overflow the output sample block: */ + ; /* don't overflow the output sample block: */ ; togo = max_sample_block_len - cnt; ;---------------------------- (format stream "~% while (cnt < max_sample_block_len) { /* outer loop */~%") (format stream - "\t/* first compute how many samples to generate in inner loop: */~%") + " /* first compute how many samples to generate in inner loop: */~%") (format stream - "\t/* don't overflow the output sample block: */~%") + " /* don't overflow the output sample block: */~%") (format stream - "\ttogo = max_sample_block_len - cnt;~%~%") + " togo = max_sample_block_len - cnt;~%~%") ;; this loop gets ready to execute the INNER-LOOP (dotimes (n (length interp)) @@ -542,12 +544,12 @@ ; togo = min(togo, susp->NAME_cnt); ;----------------- (format stream - "\t/* don't run past the ~A input sample block: */~%" name) + " /* don't run past the ~A input sample block: */~%" name) (display "don't run past the ..." name (susp-check-fn name alg)) (format stream - "\t~A(~A, ~A_ptr, ~A_cnt);~%" + " ~A(~A, ~A_ptr, ~A_cnt);~%" (susp-check-fn name alg) name name name) - (format stream "\ttogo = min(togo, susp->~A_cnt);~%~%" name)) + (format stream " togo = min(togo, susp->~A_cnt);~%~%" name)) ((eq method 'INTERP)) ((and interpolate-samples (eq method 'RAMP)) ;----------------- @@ -564,46 +566,56 @@ ; NAME_x2_sample = susp_current_sample(NAME, NAME_ptr); ; } ; /* NAME_n gets number of samples before phase exceeds 1.0: */ - ; susp->NAME_n = 0.5 + (long) ((1.0 - susp->NAME_pHaSe) * susp->output_per_NAME); - ; togo = min(togo, susp->NAME_n); + ; susp->NAME_n = 0.5 + (int64_t) ((1.0 - susp->NAME_pHaSe) * susp->output_per_NAME); + ; togo = (int) min(togo, susp->NAME_n); ; NAME_DeLtA = (sample_type) ((NAME_x2_sample - susp->NAME_x1_sample) * susp->NAME_pHaSe_iNcR); ; NAME_val = (sample_type) (susp->NAME_x1_sample * (1.0 - susp->NAME_pHaSe) + ; NAME_x2_sample * susp->NAME_pHaSe); ;----------------- (format stream - "\t/* grab next ~A_x2_sample when phase goes past 1.0; */~%" name) + " /* grab next ~A_x2_sample when phase goes past ~ + 1.0; */~%" name) (format stream - "\t/* we use ~A_n (computed below) to avoid roundoff errors: */~%" name) - (format stream "\tif (susp->~A_n <= 0) {~%" name) - (format stream "\t susp->~A_x1_sample = ~A_x2_sample;~%" - name name) - (format stream "\t susp->~A_ptr++;~%" name); - (format stream "\t susp_took(~A_cnt, 1);~%" name); - (format stream "\t susp->~A_pHaSe -= 1.0;~%" name); - (format stream "\t ~A(~A, ~A_ptr, ~A_cnt);~%" + " /* we use ~A_n (computed below) to avoid roundoff ~ + errors: */~%" name) + (format stream " if (susp->~A_n <= 0) {~%" name) + (format stream " susp->~A_x1_sample = ~ + ~A_x2_sample;~%" name name) + (format stream " susp->~A_ptr++;~%" name); + (format stream " susp_took(~A_cnt, 1);~%" name); + (format stream " susp->~A_pHaSe -= 1.0;~%" name); + (format stream " ~A(~A, ~A_ptr, ~A_cnt);~%" (susp-check-fn name alg) name name name) (cond ((member (name-to-symbol name) internal-scaling) (format stream - "\t ~A_x2_sample = *(susp->~A_ptr);~%" name name)) + " ~A_x2_sample = *(susp->~A_ptr);~%" + name name)) (t (format stream - "\t ~A_x2_sample = susp_current_sample(~A, ~A_ptr);~%" + " ~A_x2_sample = ~ + susp_current_sample(~A, ~A_ptr);~%" name name name))) (format stream - "\t /* ~A_n gets number of samples before phase exceeds 1.0: */~%" + " /* ~A_n gets number of samples before phase ~ + exceeds 1.0: */~%" name) (format stream - "\t susp->~A_n = (long) ((1.0 - susp->~A_pHaSe) *~%" + " susp->~A_n = (int64_t) ~ + ((1.0 - susp->~A_pHaSe) *~%" name name) - (format stream "\t\t\t\t\tsusp->output_per_~A);~%\t}~%" name) - (format stream "\ttogo = min(togo, susp->~A_n);~%" name) - (format stream "\t~A_DeLtA = (sample_type) ((~A_x2_sample - susp->~A_x1_sample) * susp->~A_pHaSe_iNcR);~%" + (format stream " ~ + susp->output_per_~A);~% }~%" name) + (format stream " togo = (int) min(togo, susp->~A_n);~%" + name) + (format stream " ~A_DeLtA = (sample_type) ~ + ((~A_x2_sample - susp->~A_x1_sample) * susp->~A_pHaSe_iNcR);~%" name name name name) (format stream - "\t~A_val = (sample_type) (susp->~A_x1_sample * (1.0 - susp->~A_pHaSe) +~%" - name name name) - (format stream "\t\t ~A_x2_sample * susp->~A_pHaSe);~%~%" - name name)) + " ~A_val = (sample_type) ~ + (susp->~A_x1_sample * (1.0 - susp->~A_pHaSe) +~%" + name name name) + (format stream " ~A_x2_sample * ~ + susp->~A_pHaSe);~%~%" name name)) ((eq method 'RAMP) ;----------------- ; SLOW STEP FUNCTION @@ -614,44 +626,50 @@ ; ; susp_check_log_samples(NAME, NAME_ptr, NAME_cnt); ; susp->NAME_x1_sample = susp_fetch_sample(NAME, NAME_ptr, - ; NAME_cnt); + ; NAME_cnt); ; susp->NAME_pHaSe -= 1.0; ; /* NAME_n gets number of samples before phase ; exceeds 1.0: */ - ; susp->NAME_n = (long) ((1.0 - susp->NAME_pHaSe) * + ; susp->NAME_n = (int64_t) ((1.0 - susp->NAME_pHaSe) * ; susp->output_per_NAME); ; ; } - ; togo = min(togo, susp->NAME_n); + ; togo = (int) min(togo, susp->NAME_n); ; NAME_val = susp->NAME_x1_sample; ;----------------- (format stream - "\t/* grab next ~A_x1_sample when phase goes past 1.0; */~%" - name) + " /* grab next ~A_x1_sample when phase goes ~ + past 1.0; */~%" + name) (format stream - "\t/* use ~A_n (computed below) to avoid roundoff errors: */~%" - name) - (format stream "\tif (susp->~A_n <= 0) {~%" name) + " /* use ~A_n (computed below) to avoid roundoff ~ + errors: */~%" + name) + (format stream " if (susp->~A_n <= 0) {~%" name) (fixup-depends-prime-decls alg stream name) - (format stream "\t ~A(~A, ~A_ptr, ~A_cnt);~%" + (format stream " ~A(~A, ~A_ptr, ~A_cnt);~%" (susp-check-fn name alg) name name name) (format stream - "\t susp->~A_x1_sample = susp_fetch_sample(~A, ~A_ptr, ~A_cnt);~%" - name name name name) - (format stream "\t susp->~A_pHaSe -= 1.0;~%" name); + " susp->~A_x1_sample = ~ + susp_fetch_sample(~A, ~A_ptr, ~A_cnt);~%" + name name name name) + (format stream " susp->~A_pHaSe -= 1.0;~%" name); (format stream - "\t /* ~A_n gets number of samples before phase exceeds 1.0: */~%" + " /* ~A_n gets number of samples before phase ~ + exceeds 1.0: */~%" name) + (format stream + " susp->~A_n = (int64_t) ((1.0 - ~ + susp->~A_pHaSe) *~%" + name name) + (format stream " ~ + susp->output_per_~A);~%" name) + (fixup-depends-prime alg stream name " " + (strcat "susp->" name "_x1_sample")) + (format stream " }~%" name) + (format stream " togo = (int) min(togo, susp->~A_n);~%" name) (format stream - "\t susp->~A_n = (long) ((1.0 - susp->~A_pHaSe) *~%" - name name) - (format stream "\t\t\t\t\tsusp->output_per_~A);~%" name) - (fixup-depends-prime alg stream name "\t " - (strcat "susp->" name "_x1_sample")) - (format stream "\t}~%" name) - (format stream "\ttogo = min(togo, susp->~A_n);~%" name) - (format stream - "\t~A_val = susp->~A_x1_sample;~%" name name) )))) + " ~A_val = susp->~A_x1_sample;~%" name name) )))) ;--------------- ; see if there are joint-dependencies that should be output now @@ -664,7 +682,7 @@ step-function)) (dolist (stmt (cdr dep)) (setf joint-depend (strcat joint-depend - "\t" stmt "\n")))))) + " " stmt "\n")))))) (display "joint-depend before fixup" joint-depend) (setf joint-depend (fixup-substitutions-for-depends alg joint-depend)) (if joint-depend (format stream joint-depend)) @@ -674,79 +692,83 @@ ; if the teminate time is a MIN of some signals or AT some expression ; (i.e. specified at all) see if we're coming to the terminate cnt: ; - ; /* don't run past terminate time */ - ; if (susp->terminate_cnt != UNKNOWN && - ; susp->terminate_cnt <= susp->susp.current + cnt + togo) { - ; togo = susp->terminate_cnt - (susp->susp.current + cnt); + ; /* don't run past terminate time */ + ; if (susp->terminate_cnt != UNKNOWN && + ; susp->terminate_cnt <= susp->susp.current + cnt + togo) { + ; togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt)); ; if (togo < 0) togo = 0; // avoids rounding errors ; if (togo == 0) break; - ; } + ; } ;---------------- (cond ((terminate-check-needed terminate alg) (print-strings '( - "\t/* don't run past terminate time */\n" - "\tif (susp->terminate_cnt != UNKNOWN &&\n" - "\t susp->terminate_cnt <= susp->susp.current + cnt + togo) {\n" - "\t togo = susp->terminate_cnt - (susp->susp.current + cnt);\n" - "\t if (togo < 0) togo = 0; /* avoids rounding errros */\n" - "\t if (togo == 0) break;\n" - "\t}\n\n") stream))) + " /* don't run past terminate time */\n" + " if (susp->terminate_cnt != UNKNOWN &&\n" + " susp->terminate_cnt <= susp->susp.current + cnt + togo) {\n" + " togo = (int) (susp->terminate_cnt - " + "(susp->susp.current + cnt));\n" + " if (togo < 0) togo = 0; /* avoids rounding errros */\n" + " if (togo == 0) break;\n" + " }\n\n") stream))) ;---------------- ; if the logical-stop attribute is MIN of some signals or AT some expression ; see if we're coming to the logical stop: ; ; /* don't run past logical stop time */ - ; if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { - ; int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt); + ; if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) { + ; int64_t to_stop = susp->susp.log_stop_cnt - + ; (susp->susp.current + cnt); ; /* break if to_stop == 0 (we're at the logical stop) - ; * AND cnt > 0 (we're not at the beginning of the - ; * output block). - ; */ + ; * AND cnt > 0 (we're not at the beginning of the + ; * output block). + ; */ ; if (to_stop < 0) to_stop = 0; // avoids rounding errors - ; if (to_stop < togo) { - ; if (to_stop == 0) { - ; if (cnt) { - ; togo = 0; - ; break; - ; } else /* keep togo as is: since cnt == 0, we - ; * can set the logical stop flag on this - ; * output block - ; */ - ; susp->logically_stopped = true; - ; } else /* limit togo so we can start a new - ; * block at the LST - ; */ - ; togo = to_stop; - ; } - ; } + ; if (to_stop < togo) { + ; if (to_stop == 0) { + ; if (cnt) { + ; togo = 0; + ; break; + ; } else /* keep togo as is: since cnt == 0, we + ; * can set the logical stop flag on this + ; * output block + ; */ + ; susp->logically_stopped = true; + ; } else /* limit togo so we can start a new + ; * block at the LST + ; */ + ; togo = (int) to_stop; + ; } + ; } ;---------------- (cond (logical-stop (print-strings '( - "\n\t/* don't run past logical stop time */\n" - "\tif (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {\n" - "\t int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);\n" - "\t /* break if to_stop == 0 (we're at the logical stop)\n" - "\t * AND cnt > 0 (we're not at the beginning of the\n" - "\t * output block).\n" - "\t */\n" - "\t if (to_stop < 0) to_stop = 0; /* avoids rounding errors */\n" - "\t if (to_stop < togo) {\n" - "\t\tif (to_stop == 0) {\n" - "\t\t if (cnt) {\n" - "\t\t\ttogo = 0;\n" - "\t\t\tbreak;\n" - "\t\t } else /* keep togo as is: since cnt == 0, we\n" - "\t\t * can set the logical stop flag on this\n" - "\t\t * output block\n" - "\t\t */\n" - "\t\t\tsusp->logically_stopped = true;\n" - "\t\t} else /* limit togo so we can start a new\n" - "\t\t * block at the LST\n" - "\t\t */\n" - "\t\t togo = to_stop;\n" - "\t }\n" - "\t}\n\n") + "\n /* don't run past logical stop time */\n" + " if (!susp->logically_stopped && " + "susp->susp.log_stop_cnt != UNKNOWN) {\n" + " int64_t to_stop = susp->susp.log_stop_cnt - " + "(susp->susp.current + cnt);\n" + " /* break if to_stop == 0 (we're at the logical stop)\n" + " * AND cnt > 0 (we're not at the beginning of the\n" + " * output block).\n" + " */\n" + " if (to_stop < 0) to_stop = 0; /* avoids rounding errors */\n" + " if (to_stop < togo) {\n" + " if (to_stop == 0) {\n" + " if (cnt) {\n" + " togo = 0;\n" + " break;\n" + " } else /* keep togo as is: since cnt == 0, we\n" + " * can set the logical stop flag on this\n" + " * output block\n" + " */\n" + " susp->logically_stopped = true;\n" + " } else /* limit togo so we can start a new\n" + " * block at the LST\n" + " */\n" + " togo = (int) to_stop;\n" + " }\n" + " }\n\n") stream))) (cond (outer-loop @@ -758,11 +780,11 @@ ; *WATCH*: printf("ALG %x starting inner loop, n %d\n", susp, n); ;---------------------------- - (format stream "\tn = togo;~%") + (format stream " n = togo;~%") (if *watch* (format stream - "\tprintf(\"~A %x starting inner loop, n %d\\n\", susp, n);~%" - name)) + " printf(\"~A %x starting inner loop, n %d\\n\", ~ + susp, n);~%" name)) (dotimes (n (length interp)) (let ((name (nth n sound-names)) @@ -778,9 +800,9 @@ ((and (eq method 'INTERP) (eq n 0)) ;----------------- ; INTERP (first arg only) -; ; susp->NAME_cnt -= togo; +; ; susp->NAME_cnt -= togo; ;----------------- -; (format stream "\tsusp->~A_cnt -= togo;~%" name) +; (format stream " susp->~A_cnt -= togo;~%" name) )))) (print-strings (get-slot alg 'register-init) stream) @@ -789,7 +811,7 @@ ;---------------------------- (format stream - "\tif (n) do { /* the inner sample computation loop */~%") + " if (n) do { /* the inner sample computation loop */~%") ;;---------------------------- ;; write local declarations supplied by user @@ -812,7 +834,7 @@ (dolist (dep depends) (cond ((and (equal (cadr dep) name) (eq (cadddr dep) 'TEMP)) - (format stream "\t ~A ~A;~%" (car (cddddr dep)) + (format stream " ~A ~A;~%" (car (cddddr dep)) (car dep))))))))) ;; this loop writes code that runs in the INNER-LOOP and checks to see @@ -839,64 +861,73 @@ ; } ; ;----------------- - (format stream "\t if (~A_pHaSe_ReG >= 1.0) {~%" name) - (format stream "\t\t~A_x1_sample_reg = ~A_x2_sample;~%" - name name) - (format stream "\t\t/* pick up next sample as ~A_x2_sample: */~%" name) - (format stream "\t\tsusp->~A_ptr++;~%" name) - (format stream "\t\tsusp_took(~A_cnt, 1);~%" name) - (format stream "\t\t~A_pHaSe_ReG -= 1.0;~%" name) - (format stream "\t\t~A_break(~A, ~A_ptr, ~A_cnt, ~A_x2_sample);~%" + (format stream " if (~A_pHaSe_ReG >= 1.0) {~%" name) + (format stream " ~A_x1_sample_reg = ~ + ~A_x2_sample;~%" name name) + (format stream " /* pick up next sample ~ + as ~A_x2_sample: */~%" name) + (format stream " susp->~A_ptr++;~%" name) + (format stream " susp_took(~A_cnt, 1);~%" name) + (format stream " ~A_pHaSe_ReG -= 1.0;~%" name) + (format stream " ~A_break(~A, ~A_ptr, ~A_cnt, ~ + ~A_x2_sample);~%" (susp-check-fn name alg) name name name name) -; (format stream "\t\t~A_x2_sample = susp_current_sample(~A, ~A_ptr);~%" +; (format stream " ~A_x2_sample = ~ +; susp_current_sample(~A, ~A_ptr);~%" ; name name name) ; show_samples(2, susp->NAME_x2, susp->NAME_x2_ptr - - ; NAME_x2->block->samples); + ; NAME_x2->block->samples); ;----------------- -; (if *WATCH* -; (format stream "\t\tshow_samples(2,susp->~A_x2,susp->~A_x2_ptr - susp->~A_x2->block->samples);~%" -; name name name) +; (if *WATCH* +; (format stream " ~ +; show_samples(2,susp->~A_x2,susp->~A_x2_ptr - ~ +; susp->~A_x2->block->samples);~%" +; name name name) ; ) ;----------------- ; } ;----------------- - (format stream "\t }~%") + (format stream " }~%") ) ((eq method 'INTERP) ;----------------- ; STEP FUNCTION: ; ; if (susp->NAME_pHaSe >= 1.0) { - ; + ; ; /* pick up next sample as NAME_x1_sample */ ; susp->NAME_ptr++; ; susp_took(NAME_cnt, 1); ; susp->NAME_pHaSe -= 1.0; ; susp_check_XX_samples_break(NAME, NAME_ptr, NAME_cnt, NAME_x1_sample); ; NAME_x1_sample_reg = susp_current_sample(NAME, NAME_ptr); - ; + ; ; } ;----------------- - (format stream "\t if (~A_pHaSe_ReG >= 1.0) {~%" name) + (format stream " if (~A_pHaSe_ReG >= 1.0) {~%" name) (fixup-depends alg stream name) - (format stream "\t\t/* pick up next sample as ~A_x1_sample: */~%" name) - (format stream "\t\tsusp->~A_ptr++;~%" name) - (format stream "\t\tsusp_took(~A_cnt, 1);~%" name) - (format stream "\t\t~A_pHaSe_ReG -= 1.0;~%" name) - (format stream "\t\t~A_break(~A, ~A_ptr, ~A_cnt, ~A_x1_sample_reg);~%" + (format stream " /* pick up next sample as ~ + ~A_x1_sample: */~%" name) + (format stream " susp->~A_ptr++;~%" name) + (format stream " susp_took(~A_cnt, 1);~%" name) + (format stream " ~A_pHaSe_ReG -= 1.0;~%" name) + (format stream " ~A_break(~A, ~A_ptr, ~A_cnt, ~ + ~A_x1_sample_reg);~%" (susp-check-fn name alg) name name name name) - (format stream "\t\t~A_x1_sample_reg = susp_current_sample(~A, ~A_ptr);~%" + (format stream " ~A_x1_sample_reg = ~ + susp_current_sample(~A, ~A_ptr);~%" name name name) ; show_samples(2, susp->NAME_x2, susp->NAME_x2_ptr - - ; NAME_x2->block->samples); + ; NAME_x2->block->samples); ;----------------- -; (if *WATCH* -; (format stream "\t\tshow_samples(2,susp->~A_x2,susp->~A_x2_ptr - susp->~A_x2->block->samples);~%" -; name name name) +; (if *WATCH* +; (format stream " ~ +; show_samples(2,susp->~A_x2,susp->~A_x2_ptr - ~ +; susp->~A_x2->block->samples);~%" name name name) ; ) (let ((fixup-code (get-slot alg 'fixup-code))) (if fixup-code (format stream fixup-code))) @@ -904,7 +935,7 @@ ;----------------- ; } ;----------------- - (format stream "\t }~%"))))) + (format stream " }~%"))))) (write-inner-loop alg stream) (print-strings (get-slot alg 'register-cleanup) stream) @@ -922,18 +953,18 @@ ; NONE: ; susp_took(NAME_cnt, togo - n); ;----------------- - (format stream "\tsusp_took(~A_cnt, togo);~%" name)) + (format stream " susp_took(~A_cnt, togo);~%" name)) ((eq method 'INTERP)) ((eq method 'RAMP) ;----------------- ; RAMP: - ; susp->NAME_pHaSe += togo * susp->NAME_pHaSe_iNcR; - ; susp->NAME_n -= togo; + ; susp->NAME_pHaSe += togo * susp->NAME_pHaSe_iNcR; + ; susp->NAME_n -= togo; ;----------------- (format stream - "\tsusp->~A_pHaSe += togo * susp->~A_pHaSe_iNcR;~%" + " susp->~A_pHaSe += togo * susp->~A_pHaSe_iNcR;~%" name name) - (format stream "\tsusp->~A_n -= togo;~%" name) + (format stream " susp->~A_n -= togo;~%" name) )))) ;----------------------------- ; cnt += togo; @@ -942,7 +973,7 @@ ; snd_list->block_len = cnt; ;----------------------------- - (format stream "~A~%~A~%~%" "\tcnt += togo;" + (format stream "~A~%~A~%~%" " cnt += togo;" " } /* outer loop */") ;----------------------------- ; if terminate is not NONE (infinite), check for it as follows: @@ -959,14 +990,16 @@ (print-strings '( " /* test for termination */\n" " if (togo == 0 && cnt == 0) {\n" - "\tsnd_list_terminate(snd_list);\n") + " snd_list_terminate(snd_list);\n") stream) (if *watch* - (format stream "\tprintf(\"~A %x terminated.\\n\", susp);~%" name)) + (format stream + " printf(\"~A %x terminated.\\n\", susp);~%" + name)) (print-strings '( " } else {\n" - "\tsnd_list->block_len = cnt;\n" - "\tsusp->susp.current += cnt;\n" + " snd_list->block_len = cnt;\n" + " susp->susp.current += cnt;\n" " }\n") stream)) (t ;---------------- @@ -991,9 +1024,9 @@ (print-strings '( " /* test for logical stop */\n" " if (susp->logically_stopped) {\n" - "\tsnd_list->logically_stopped = true;\n" + " snd_list->logically_stopped = true;\n" " } else if (susp->susp.log_stop_cnt == susp->susp.current) {\n" - "\tsusp->logically_stopped = true;\n" + " susp->logically_stopped = true;\n" " }\n") stream))) ;---------------- diff --git a/lib-src/libnyquist/nyquist/tran/writetoss.lsp b/lib-src/libnyquist/nyquist/tran/writetoss.lsp index 67ebe278f..fd43c79ab 100644 --- a/lib-src/libnyquist/nyquist/tran/writetoss.lsp +++ b/lib-src/libnyquist/nyquist/tran/writetoss.lsp @@ -21,21 +21,21 @@ (format stream "~%~%void ~A_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)~%" alg-name) - (format stream " {~% ~A_susp_type susp = (~A_susp_type) a_susp;~%" + (format stream "{~% ~A_susp_type susp = (~A_susp_type) a_susp;~%" alg-name alg-name) ;;---------------- ;; long final_count = susp->susp.toss_cnt); ;; time_type final_time = susp->susp.t0; ;; FORMERLY, THIS WAS: ;; time_type final_time = susp->susp.t0 + final_count / susp->susp.sr; - ;; long n; + ;; int n; ;;---------------- (if *watch* (format stream " long final_count = susp->susp.toss_cnt;~%")) (format stream " time_type final_time = susp->susp.t0;~%") - (format stream " long n;~%~%") + (format stream " int n;~%~%") (cond (*watch* (format stream @@ -48,8 +48,8 @@ ;; ;; /* fetch samples from NAME up to final_time for this block of zeros */ ;; while ((ROUNDBIG((final_time - susp->NAME->t0) * susp->NAME->sr)) >= - ;; susp->NAME->current) - ;; susp_get_samples(NAME, NAME_ptr, NAME_cnt); + ;; susp->NAME->current) + ;; susp_get_samples(NAME, NAME_ptr, NAME_cnt); ;;------------------------------ (dolist (name sound-names) (format stream @@ -58,8 +58,8 @@ (format stream " while ((ROUNDBIG((final_time - susp->~A->t0) * susp->~A->sr)) >=~%" name name) - (format stream "\t susp->~A->current)~%" name) - (format stream "\tsusp_get_samples(~A, ~A_ptr, ~A_cnt);~%" + (format stream " susp->~A->current)~%" name) + (format stream " susp_get_samples(~A, ~A_ptr, ~A_cnt);~%" name name name)) ;;---------------- @@ -73,13 +73,14 @@ ;;---------------- ;; for each sound argument: ;; - ;; n = ROUNDBIG((final_time - susp->NAME->t0) * susp->NAME->sr - - ;; (susp->NAME->current - susp->NAME_cnt)); - ;; susp->NAME_ptr += n; - ;; susp_took(NAME_cnt, n); + ;; n = (int) ROUNDBIG((final_time - susp->NAME->t0) * susp->NAME->sr - + ;; (susp->NAME->current - susp->NAME_cnt)); + ;; susp->NAME_ptr += n; + ;; susp_took(NAME_cnt, n); ;;---------------- (dolist (name sound-names) - (format stream " n = ROUNDBIG((final_time - susp->~A->t0) * susp->~A->sr -~%" + (format stream " n = (int) ROUNDBIG((final_time - susp->~A->t0) * ~ + susp->~A->sr -~%" name name) (format stream " (susp->~A->current - susp->~A_cnt));~%" name name) @@ -87,7 +88,7 @@ (format stream " susp_took(~A_cnt, n);~%" name)) ;;---------------- - ;; susp->susp.fetch = susp->susp.keep_fetch; + ;; susp->susp.fetch = susp->susp.keep_fetch; ;; (*(susp->susp.fetch))(a_susp, snd_list); ;; } ;;---------------- diff --git a/lib-src/libnyquist/nyquist/xlisp/extern.c b/lib-src/libnyquist/nyquist/xlisp/extern.c index a9a2c8b6f..2fde32d66 100644 --- a/lib-src/libnyquist/nyquist/xlisp/extern.c +++ b/lib-src/libnyquist/nyquist/xlisp/extern.c @@ -92,8 +92,7 @@ LVAL cvextern(typeptr, instptr) /* exttype -- get the type of an EXTERN */ /**/ -LVAL exttype(x) - LVAL x; +LVAL exttype(LVAL x) { if (!(getdesc(x)->type_symbol)) { getdesc(x)->type_symbol = xlenter(getdesc(x)->type_name); diff --git a/lib-src/libnyquist/nyquist/xlisp/path.c b/lib-src/libnyquist/nyquist/xlisp/path.c index 0b69a3f9e..41babde8d 100644 --- a/lib-src/libnyquist/nyquist/xlisp/path.c +++ b/lib-src/libnyquist/nyquist/xlisp/path.c @@ -201,7 +201,7 @@ const char *find_in_xlisp_path(const char *fname) while (paths && *paths) { FILE *fp; const char *start; - int len; + intptr_t len; /* skip over separator */ while (*paths == os_sepchar || *paths == ';') paths++; diff --git a/lib-src/libnyquist/nyquist/xlisp/security.c b/lib-src/libnyquist/nyquist/xlisp/security.c index 9d7fa68c0..954948b78 100644 --- a/lib-src/libnyquist/nyquist/xlisp/security.c +++ b/lib-src/libnyquist/nyquist/xlisp/security.c @@ -4,7 +4,8 @@ */ #include -#if defined(UNIX) || defined(__APPLE__) || defined(__CYGWIN__) +#include "switches.h" +#if defined(UNIX) || defined(__APPLE__) #include #endif #ifdef WIN32 @@ -92,7 +93,7 @@ void find_full_path(const char *filename, char *fullname) goto error; } /* see if we need a separator (probably) */ - int len = strlen(fullname); + int len = (int) strlen(fullname); if (!file_sep(fullname[len - 1])) { fullname[len++] = '/'; if (len >= STRMAX) goto error; diff --git a/lib-src/libnyquist/nyquist/xlisp/xlbfun.c b/lib-src/libnyquist/nyquist/xlisp/xlbfun.c index 21039a96f..37ab60479 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlbfun.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlbfun.c @@ -318,7 +318,7 @@ LVAL xgensym(void) gsprefix[STRMAX] = '\0'; break; case FIXNUM: - gsnumber = getfixnum(x); + gsnumber = (int) getfixnum(x); break; default: xlerror("bad argument type",x); @@ -545,8 +545,6 @@ LVAL xvector(void) return (val); } -/* allow xerror, xcleanup, xtoplevel, and xcontinue to return nothing */ -/* #pragma warning(disable: 4035)*/ /* xerror - special form 'error' */ LVAL xerror(void) @@ -598,6 +596,8 @@ LVAL xbreak(void) return (NIL); } +#pragma warning(disable: 4716 4068) // return type and unknown pragma +#pragma clang diagnostic ignored "-Wreturn-type" /* xcleanup - special form 'clean-up' */ LVAL xcleanup(void) { diff --git a/lib-src/libnyquist/nyquist/xlisp/xlcont.c b/lib-src/libnyquist/nyquist/xlisp/xlcont.c index 6389bd301..03326a5b1 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlcont.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlcont.c @@ -978,7 +978,7 @@ LVAL xdotimes(void) /* get the control list (sym list result-expr) */ clist = xlgalist(); sym = match(SYMBOL,&clist); - cnt = evmatch(FIXNUM,&clist); n = getfixnum(cnt); + cnt = evmatch(FIXNUM,&clist); n = (int) getfixnum(cnt); argv = xlargv; argc = xlargc; diff --git a/lib-src/libnyquist/nyquist/xlisp/xldmem.c b/lib-src/libnyquist/nyquist/xlisp/xldmem.c index ad0fb3958..1e6205b00 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xldmem.c +++ b/lib-src/libnyquist/nyquist/xlisp/xldmem.c @@ -11,7 +11,7 @@ */ -/* #define DEBUG_MEM 1 */ +// #define DEBUG_MEM 1 #include "stdlib.h" #include "string.h" @@ -110,10 +110,14 @@ LVAL cvstring(const char *str) { LVAL val; xlsave1(val); + size_t len = strlen(str) + 1; + if (len > 0x7FFFFFFF) { + xlfail("string too long"); + } val = newnode(STRING); - val->n_strlen = strlen(str) + 1; + val->n_strlen = (int) len; val->n_string = stralloc(getslength(val)); - strcpy((char *) getstring(val),str); + strcpy((char *) getstring(val), str); xlpop(); return (val); } @@ -141,7 +145,10 @@ LVAL cvsymbol(const char *pname) * The bug is fixed by copying pname to the stack. */ LVAL val; - int len = strlen(pname) + 1; /* don't forget the terminating zero */ + size_t len = strlen(pname) + 1; /* don't forget the terminating zero */ + if (len > 0x7FFFFFFF) { /* how much can we put on stack? */ + xlfail("string too long"); + } char *local_pname_copy = (char *) alloca(len); memcpy(local_pname_copy, pname, len); xlsave1(val); @@ -485,7 +492,7 @@ LOCAL void sweep(void) if (xldmem_trace && ntype(p) == EXTERN && xldmem_trace == getinst(p)) { - printf("sweep: EXTERN node %lx is %smarked, points to %lx\n", + printf("sweep: EXTERN node %p is %smarked, points to %p\n", p, (p->n_flags & MARK ? "" : "un"), getinst(p)); } #endif @@ -523,9 +530,17 @@ LOCAL void sweep(void) rplacd(p,fnodes); fnodes = p; nfree += 1L; - } - else + } else { +#ifdef DEBUG_MEM + /* added to find why sample blocks are not being freed - who's got them? */ + if (ntype(p) == EXTERN && strcmp(getdesc(p)->type_name, "SOUND") == 0) { + long snd_list_len(void *); + printf("gc found but did not free extern %p sound_type %p list len %ld\n", + p, getinst(p), snd_list_len(getinst(p))); + } +#endif p->n_flags &= ~MARK; + } } } } @@ -613,7 +628,7 @@ LVAL xexpand(void) /* get the new number to allocate */ if (moreargs()) { num = xlgafixnum(); - n = getfixnum(num); + n = (int) getfixnum(num); } else n = 1; @@ -636,7 +651,7 @@ LVAL xalloc(void) /* get the new number to allocate */ num = xlgafixnum(); - n = getfixnum(num); + n = (int) getfixnum(num); /* make sure there aren't any more arguments */ xllastarg(); diff --git a/lib-src/libnyquist/nyquist/xlisp/xlfio.c b/lib-src/libnyquist/nyquist/xlisp/xlfio.c index a98fa137d..67a0f4113 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlfio.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlfio.c @@ -229,7 +229,7 @@ LVAL xrdint(void) /* get byte count */ if (moreargs()) { LVAL count = typearg(fixp); - n = getfixnum(count); + n = (int) getfixnum(count); if (n < 0) { n = -n; index = n - 1; @@ -277,7 +277,7 @@ LVAL xrdfloat(void) /* get byte count */ if (moreargs()) { LVAL count = typearg(fixp); - n = getfixnum(count); + n = (int) getfixnum(count); if (n < 0) { n = -n; index = 0; @@ -385,14 +385,14 @@ LVAL xwrint(void) int n = 4; int index = 3; /* where to start in array */ int incr = -1; /* how to step through array */ - int v; + int v; /* xwrint only allows up to 4 bytes, so int is enough */ /* get the int and file pointer and optional byte count */ val = xlgafixnum(); - v = getfixnum(val); + v = (int) getfixnum(val); fptr = (moreargs() ? xlgetfile() : getvalue(s_stdout)); if (moreargs()) { LVAL count = typearg(fixp); - n = getfixnum(count); + n = (int) getfixnum(count); index = n - 1; if (n < 0) { n = -n; @@ -440,7 +440,7 @@ LVAL xwrfloat(void) fptr = (moreargs() ? xlgetfile() : getvalue(s_stdout)); if (moreargs()) { LVAL count = typearg(fixp); - n = getfixnum(count); + n = (int) getfixnum(count); if (n < 0) { n = -n; index = 0; diff --git a/lib-src/libnyquist/nyquist/xlisp/xlftab.c b/lib-src/libnyquist/nyquist/xlisp/xlftab.c index cf8b3b9d7..d3acb34b1 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlftab.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlftab.c @@ -12,90 +12,8 @@ HISTORY */ -#include /* for memcpy */ #include "switches.h" #include "xlisp.h" -#ifndef NO_PROTOTYPES_IN_XLISP_H -/* external functions */ -extern LVAL - xbisubr(void),xbifsubr(void), - rmhash(void),rmquote(void),rmdquote(void),rmbquote(void),rmcomma(void), - clnew(void),clisnew(void),clanswer(void), - obisnew(void),obclass(void),obshow(void),obisa(void), - rmlpar(void),rmrpar(void),rmsemi(void), - xeval(void),xapply(void),xfuncall(void),xquote(void),xfunction(void),xbquote(void), - xlambda(void),xset(void),xsetq(void),xsetf(void),xdefun(void),xdefmacro(void), - xgensym(void),xmakesymbol(void),xintern(void), - xsymname(void),xsymvalue(void),xsymplist(void), - xget(void),xputprop(void),xremprop(void), - xhash(void),xmkarray(void),xaref(void), - xcar(void),xcdr(void), - xcaar(void),xcadr(void),xcdar(void),xcddr(void), - xcaaar(void),xcaadr(void),xcadar(void),xcaddr(void), - xcdaar(void),xcdadr(void),xcddar(void),xcdddr(void), - xcaaaar(void),xcaaadr(void),xcaadar(void),xcaaddr(void), - xcadaar(void),xcadadr(void),xcaddar(void),xcadddr(void), - xcdaaar(void),xcdaadr(void),xcdadar(void),xcdaddr(void), - xcddaar(void),xcddadr(void),xcdddar(void),xcddddr(void), - xcons(void),xlist(void),xappend(void),xreverse(void),xlast(void),xnth(void),xnthcdr(void), - xmember(void),xassoc(void),xsubst(void),xsublis(void),xlength(void),xsort(void), - xremove(void),xremif(void),xremifnot(void), - xmapc(void),xmapcar(void),xmapl(void),xmaplist(void), - xrplca(void),xrplcd(void),xnconc(void), - xdelete(void),xdelif(void),xdelifnot(void), - xatom(void),xsymbolp(void),xnumberp(void),xboundp(void),xnull(void),xlistp(void),xendp(void),xconsp(void), - xeq(void),xeql(void),xequal(void), - xcond(void),xcase(void),xand(void),x_or(void),xlet(void),xletstar(void),xif(void), - xprog(void),xprogstar(void),xprog1(void),xprog2(void),xprogn(void),xgo(void),xreturn(void), - xcatch(void),xthrow(void), - xerror(void),xcerror(void),xbreak(void), - xcleanup(void),xtoplevel(void),xcontinue(void),xerrset(void), - xbaktrace(void),xevalhook(void), - xdo(void),xdostar(void),xdolist(void),xdotimes(void), - xminusp(void),xzerop(void),xplusp(void),xevenp(void),xoddp(void), - xfix(void),xfloat(void), - xgcd(void),xadd(void),xsub(void),xmul(void),xdiv(void),xrem(void),xmin(void),xmax(void),xabs(void), - xadd1(void),xsub1(void),xlogand(void),xlogior(void),xlogxor(void),xlognot(void), - xsin(void),xcos(void),xtan(void),xatan(void),xexpt(void),xexp(void),xsqrt(void),xrand(void), xrealrand(void), - xlss(void),xleq(void),xequ(void),xneq(void),xgeq(void),xgtr(void), - xstrcat(void),xsubseq(void),xstring(void),xchar(void), - xread(void),xprint(void),xprin1(void),xprinc(void),xterpri(void), - xflatsize(void),xflatc(void), - xopen(void),xbopen(void),xclose(void),xrdchar(void),xpkchar(void),xwrchar(void),xreadline(void), - xrdint(void),xwrint(void),xrdfloat(void),xwrfloat(void), - xget_env(void), xload(void),xtranscript(void), - xtype(void),xquit(void),xexit(void),xpeek(void),xpoke(void),xaddrs(void), - xvector(void),xblock(void),xrtnfrom(void),xtagbody(void), - xpsetq(void),xflet(void),xlabels(void),xmacrolet(void),xunwindprotect(void),xpp(void), - xstrlss(void),xstrleq(void),xstreql(void),xstrneq(void),xstrgeq(void),xstrgtr(void), - xstrilss(void),xstrileq(void),xstrieql(void),xstrineq(void),xstrigeq(void),xstrigtr(void), - xupcase(void),xdowncase(void),xnupcase(void),xndowncase(void), - xtrim(void),xlefttrim(void),xrighttrim(void), - xuppercasep(void),xlowercasep(void),xbothcasep(void),xdigitp(void),xalphanumericp(void), - xcharcode(void),xcodechar(void),xchupcase(void),xchdowncase(void),xdigitchar(void), - xchrlss(void),xchrleq(void),xchreql(void),xchrneq(void),xchrgeq(void),xchrgtr(void), - xchrilss(void),xchrileq(void),xchrieql(void),xchrineq(void),xchrigeq(void),xchrigtr(void), - xintegerp(void),xfloatp(void),xstringp(void),xarrayp(void),xstreamp(void),xobjectp(void), - xwhen(void),xunless(void),xloop(void), - xsymfunction(void),xfboundp(void),xsend(void),xsendsuper(void), - xprogv(void),xrdbyte(void),xwrbyte(void),xformat(void), - xcharp(void),xcharint(void),xintchar(void), - xmkstrinput(void),xmkstroutput(void),xgetstroutput(void),xgetlstoutput(void), - xgetlambda(void),xmacroexpand(void),x1macroexpand(void), - xinfo(void), //Added by Ning Hu Apr.2001 - xsetdir(void), //Added by Ning Hu May.2001 - xbigendianp(void), - xtrace(void),xuntrace(void),xprofile(void),xstrsearch(void), xsetupconsole(void), - xechoenabled(void),xslider_read(void), - xget_user(void), // added by RBD, Jul 2007 - xfind_in_xlisp_path(void); // added by RBD, Jan 2008 -#endif - -/* functions specific to xldmem.c */ -LVAL xgc(void),xexpand(void),xalloc(void),xmem(void); -#ifdef SAVERESTORE -LVAL xsave(void),xrestore(void); -#endif /* include system dependant definitions */ #include "osdefs.h" @@ -115,7 +33,7 @@ LVAL xstoprecordio(void); #endif /* the function table */ -FUNDEF init_funtab[] = { +FUNDEF funtab[] = { /* read macro functions */ { NULL, S, rmhash }, /* 0 */ @@ -489,7 +407,7 @@ FUNDEF init_funtab[] = { { "GET-ENV", S, xget_env }, /* 308 */ { "GET-RUN-TIME", S, xgetruntime }, /* 309 */ { "RANDOM-SEED", S, xsrand }, /* 310 */ - +{ "GET-REAL-TIME", S, xgetrealtime }, /* 311 */ #ifdef MACINTOSH #include "macptrs.h" #endif @@ -500,32 +418,7 @@ FUNDEF init_funtab[] = { {0,0,0} /* end of table marker */ -}; - -FUNDEF *funtab = init_funtab; -static size_t szfuntab = sizeof(init_funtab) / sizeof(*init_funtab); - -int xlbindfunctions(const FUNDEF *functions, size_t nfunctions) -{ - /* This is written very generally, imposing no fixed upper limit on the - growth of the table. But perhaps a lightweight alternative with such a - limit could be conditionally compiled. - */ - - /* malloc, not realloc, to leave old table unchanged in case of failure */ - FUNDEF *newfuntab = malloc((szfuntab + nfunctions) * sizeof(FUNDEF)); - if (!newfuntab) - return FALSE; - memcpy(newfuntab, funtab, (szfuntab - 1) * sizeof(FUNDEF)); - memcpy(newfuntab + szfuntab - 1, functions, nfunctions * sizeof(FUNDEF)); - FUNDEF sentinel = { 0, 0, 0 }; - newfuntab[szfuntab + nfunctions - 1] = sentinel; - funtab = newfuntab; - szfuntab += nfunctions; - return TRUE; - - /* To do: deallocate funtab when XLisp runtime shuts down */ -} +}; /* xnotimp does not return anything on purpose, so disable * "no return value" warning diff --git a/lib-src/libnyquist/nyquist/xlisp/xlimage.c b/lib-src/libnyquist/nyquist/xlisp/xlimage.c index e4ec77027..a4e793323 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlimage.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlimage.c @@ -182,7 +182,7 @@ int xlisave(const char *fname) /* xlirestore - restore a saved memory image */ int xlirestore(const char *fname) { - extern FUNDEF *funtab; + extern FUNDEF funtab[]; char fullname[STRMAX+1]; unsigned char *cp; int n,i,max,type; diff --git a/lib-src/libnyquist/nyquist/xlisp/xlinit.c b/lib-src/libnyquist/nyquist/xlisp/xlinit.c index 889f6ef78..5a92610ef 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlinit.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlinit.c @@ -41,10 +41,10 @@ extern LVAL a_fixnum,a_flonum,a_string,a_stream,a_object; extern LVAL a_vector,a_closure,a_char,a_ustream,a_extern; extern LVAL s_gcflag,s_gchook; extern LVAL s_search_path; -extern FUNDEF *funtab; +extern FUNDEF funtab[]; /* forward declarations */ -FORWARD LOCAL void initwks(); +FORWARD LOCAL void initwks(void); /* xlinit - xlisp initialization routine */ diff --git a/lib-src/libnyquist/nyquist/xlisp/xlisp.c b/lib-src/libnyquist/nyquist/xlisp/xlisp.c index 856a74603..c1e0d6110 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlisp.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlisp.c @@ -51,7 +51,7 @@ extern char buf[]; extern FILE *tfp; /* external routines */ -extern FILE *osaopen(); +extern FILE *osaopen(const char *name, const char *mode); #ifdef USE_RANDOM @@ -86,7 +86,7 @@ long xlrand (long range) { } long xlsrand(long seed) { - srand(seed); + srand((unsigned int) seed); return seed; } diff --git a/lib-src/libnyquist/nyquist/xlisp/xlisp.h b/lib-src/libnyquist/nyquist/xlisp/xlisp.h index 6bbf324e4..63566e8dc 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlisp.h +++ b/lib-src/libnyquist/nyquist/xlisp/xlisp.h @@ -13,13 +13,6 @@ HISTORY /* system specific definitions */ -#ifndef __XLISP__ -#define __XLISP__ - -#ifdef __cplusplus -extern "C" { -#endif - #include /* needed for getenv(); note that this was a problem for PMAX implementation, but I assume PMAX is obsolete now. - RBD 16apr04 */ @@ -43,8 +36,17 @@ extern "C" { /* for the Win32 environment */ #ifdef WIN32 #define NNODES 2000 -#define AFMT "%lx" -#define OFFTYPE long +#define AFMT "%p" +// TRY 64bit-ints throughout XLisp even on 32-bit Windows +// #ifdef _WIN64 +#define OFFTYPE long long +#define FIXTYPE long long +#define IFMT "%lld" +#define ICNV(n) atoll(n) +// #else +// #define OFFTYPE long +// #define IFMT "%ld" +// #endif /* #define SAVERESTORE */ #define XL_LITTLE_ENDIAN #define _longjmp longjmp @@ -152,7 +154,9 @@ extern long ptrtoabs(); #endif /* Linux on Pentium */ -#if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__) +#if defined(__linux__) || defined(__GLIBC__) +#define AFMT "%p" +#include #include #if __BYTE_ORDER == __LITTLE_ENDIAN #define XL_LITTLE_ENDIAN @@ -161,10 +165,10 @@ extern long ptrtoabs(); #endif #endif -/* Apple CC */ +/* Apple CC (xcode, macOS, macintosh) */ #ifdef __APPLE__ #define NNODES 2000 -#define AFMT "%lx" +#define AFMT "%p" #define OFFTYPE long #define NIL (void *)0 /* #define SAVERESTORE */ @@ -374,7 +378,7 @@ void dbg_gc_xlsave(LVAL *n); /* function definition structure */ typedef struct { - const char *fd_name; /* function name */ + char *fd_name; /* function name */ int fd_type; /* function type */ LVAL (*fd_subr)(void); /* function entry point */ } FUNDEF; @@ -665,7 +669,7 @@ LVAL xgetstroutput(void); LVAL xgetlstoutput(void); LVAL xformat(void); LVAL xlistdir(void); - +LVAL xbigendianp(void); /* xlimage.c */ @@ -679,13 +683,6 @@ void xlinit(void); void xlsymbols(void); -/* xlftab.c */ -/* returns true on success, - false if table limits would be exceeded and the table remains unchanged - Call this, any number of times, before calling xlisp_main_init - */ -int xlbindfunctions(const FUNDEF *functions, size_t nfunctions); - /* xlio.c */ int xlgetc(LVAL fptr); @@ -837,7 +834,9 @@ LVAL xequ(void); LVAL xneq(void); LVAL xgeq(void); LVAL xgtr(void); - +LVAL xrealrand(void); +LVAL xtan(void); +LVAL xatan(void); /* xlobj.c */ @@ -992,21 +991,15 @@ LVAL xpeek(void); LVAL xpoke(void); LVAL xaddrs(void); LVAL xgetruntime(void); +LVAL xprofile(void); +LVAL xquit(void); -/* macstuff, unixstuff, winstuff */ +/* macstuff, unixstuff, winstuff, osstuff */ +LVAL xgetrealtime(void); extern const char os_pathchar; extern const char os_sepchar; -/* security.c */ -extern char *secure_read_path; -extern char *safe_write_path; -extern int run_time_limit; -extern int run_time; -extern int memory_limit; -#define SAFE_NYQUIST (safe_write_path != NULL) -int ok_to_open(const char *filename, const char *mode); - void osinit(const char *banner); void oserror(const char *msg); void osfinish(void); @@ -1030,6 +1023,19 @@ void osdir_list_finish(void); LVAL xosc_enable(void); LVAL xget_temp_path(void); LVAL xfind_in_xlisp_path(void); +LVAL xsetupconsole(void); +LVAL xechoenabled(void); +LVAL xget_user(void); + +/* security.c */ + +extern char *secure_read_path; +extern char *safe_write_path; +extern int run_time_limit; +extern int run_time; +extern int memory_limit; +#define SAFE_NYQUIST (safe_write_path != NULL) +int ok_to_open(const char *filename, const char *mode); /* These are now implemented in path.c -dmazzoni */ const char *return_xlisp_path(void); @@ -1042,10 +1048,3 @@ void localinit(void); void localsymbols(void); void print_local_gc_info(void); void local_toplevel(void); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/lib-src/libnyquist/nyquist/xlisp/xllist.c b/lib-src/libnyquist/nyquist/xlisp/xllist.c index 510e59fbe..633f1731d 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xllist.c +++ b/lib-src/libnyquist/nyquist/xlisp/xllist.c @@ -405,14 +405,12 @@ LVAL xremove(void) /* xremif - built-in function 'remove-if' */ LVAL xremif(void) { - LVAL remif(); return (remif(TRUE)); } /* xremifnot - built-in function 'remove-if-not' */ LVAL xremifnot(void) { - LVAL remif(); return (remif(FALSE)); } @@ -760,14 +758,12 @@ LVAL xdelete(void) /* xdelif - built-in function 'delete-if' */ LVAL xdelif(void) { - LVAL delif(); return (delif(TRUE)); } /* xdelifnot - built-in function 'delete-if-not' */ LVAL xdelifnot(void) { - LVAL delif(); return (delif(FALSE)); } @@ -822,7 +818,6 @@ LOCAL LVAL delif(int tresult) /* xsort - built-in function 'sort' */ LVAL xsort(void) { - LVAL sortlist(); LVAL list,fcn; /* protect some pointers */ @@ -856,7 +851,6 @@ LVAL xsort(void) /* sortlist - sort a list using quicksort */ LOCAL LVAL sortlist(LVAL list, LVAL fcn) { - LVAL gluelists(); LVAL smaller,pivot,larger; /* protect some pointers */ diff --git a/lib-src/libnyquist/nyquist/xlisp/xlmath.c b/lib-src/libnyquist/nyquist/xlisp/xlmath.c index 410bb1143..316a29c9e 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlmath.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlmath.c @@ -115,7 +115,7 @@ LOCAL LVAL binary(int fcn) switch (mode) { case 'I': mode = 'F'; - fval = ival; + fval = (double) ival; case 'F': fval = atan(fval); break; diff --git a/lib-src/libnyquist/nyquist/xlisp/xlobj.c b/lib-src/libnyquist/nyquist/xlisp/xlobj.c index 6713849f3..e5164107f 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlobj.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlobj.c @@ -88,7 +88,7 @@ void xladdivar(LVAL cls, const char *var) /* xladdmsg - add a message to a class */ void xladdmsg(LVAL cls, const char *msg, int offset) { - extern FUNDEF *funtab; + extern FUNDEF funtab[]; LVAL mptr; /* enter the message selector */ diff --git a/lib-src/libnyquist/nyquist/xlisp/xlprin.c b/lib-src/libnyquist/nyquist/xlisp/xlprin.c index 3c9968cf2..42dd29682 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlprin.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlprin.c @@ -21,7 +21,7 @@ /* external variables */ extern LVAL s_printcase,k_downcase,k_const,k_nmacro; extern LVAL s_ifmt,s_ffmt; -extern FUNDEF *funtab; +extern FUNDEF funtab[]; extern char buf[]; LOCAL void putsymbol(LVAL fptr, char *str, int escflag); @@ -209,7 +209,7 @@ LOCAL void putqstring(LVAL fptr, LVAL str) for (p = getstring(str); (ch = *p) != '\0'; ++p) /* check for a control character */ - if (ch < 040 || ch == '\\' || ch > 0176 /* || ch == '"' */) { + if (ch < 040 || ch == '\\' || ch > 0176 || ch == '"') { xlputc(fptr,'\\'); switch (ch) { case '\011': @@ -248,7 +248,7 @@ LOCAL void putqstring(LVAL fptr, LVAL str) void putatm(LVAL fptr, const char *tag, LVAL val) { snprintf(buf, STRMAX, "#<%s: #", tag); xlputstr(fptr,buf); - sprintf(buf,AFMT,(long unsigned int)val); xlputstr(fptr,buf); + sprintf(buf,AFMT,val); xlputstr(fptr,buf); xlputc(fptr,'>'); } @@ -257,7 +257,7 @@ LOCAL void putsubr(LVAL fptr, const char *tag, LVAL val) { snprintf(buf, STRMAX, "#<%s-%s: #", tag, funtab[getoffset(val)].fd_name); xlputstr(fptr,buf); - sprintf(buf,AFMT,(long unsigned int)val); xlputstr(fptr,buf); + sprintf(buf,AFMT,val); xlputstr(fptr,buf); xlputc(fptr,'>'); } @@ -270,7 +270,7 @@ LOCAL void putclosure(LVAL fptr, LVAL val) else strcpy(buf,"#'); /* xlputstr(fptr,"\nName: "); xlprint(fptr,getname(val),TRUE); diff --git a/lib-src/libnyquist/nyquist/xlisp/xlread.c b/lib-src/libnyquist/nyquist/xlisp/xlread.c index 03ac55806..9419dd9e7 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlread.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlread.c @@ -37,11 +37,13 @@ extern LVAL k_sescape,k_mescape; extern char buf[]; /* external routines */ -extern FILE *osaopen(); +extern FILE *osaopen(const char *name, const char *mode); /* on the NeXT, atof is a macro in stdlib.h */ -#if !defined(atof) && !defined(_WIN32) - extern double atof(); -#endif +/* Is this a mistake? atof is declared in stdlib.h, but it is never a macro: + #if !defined(atof) && !defined(_WIN32) + extern double atof(const char *); + #endif +*/ #ifndef __MWERKS__ #if !defined(ITYPE) && !defined(_WIN32) extern ITYPE; @@ -886,14 +888,17 @@ int xlisnumber(char *str, LVAL *pval) p++; /* check for a string of digits */ - while (isdigit(*p)) - p++, dl++; - + while (isdigit(*p)) { + p++; + dl++; + } /* check for a decimal point */ if (*p == '.') { p++; - while (isdigit(*p)) - p++, dr++; + while (isdigit(*p)) { + p++; + dr++; + } } /* check for an exponent */ @@ -905,8 +910,10 @@ int xlisnumber(char *str, LVAL *pval) p++; /* check for a string of digits */ - while (isdigit(*p)) - p++, dr++; + while (isdigit(*p)) { + p++; + dr++; + } } /* make sure there was at least one digit and this is the end */ @@ -925,7 +932,7 @@ int xlisnumber(char *str, LVAL *pval) /* defmacro - define a read macro */ void defmacro(int ch, LVAL type, int offset) { - extern FUNDEF *funtab; + extern FUNDEF funtab[]; LVAL subr; subr = cvsubr(funtab[offset].fd_subr,funtab[offset].fd_type,offset); setelement(getvalue(s_rtable),ch,cons(type,subr)); diff --git a/lib-src/libnyquist/nyquist/xlisp/xlstr.c b/lib-src/libnyquist/nyquist/xlisp/xlstr.c index fe5123466..9e9d1e893 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlstr.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlstr.c @@ -365,7 +365,7 @@ LVAL xstring(void) buf[1] = '\0'; return (cvstring(buf)); case FIXNUM: - buf[0] = getfixnum(arg); + buf[0] = (char)getfixnum(arg); buf[1] = '\0'; return (cvstring(buf)); default: @@ -461,7 +461,7 @@ LVAL xcodechar(void) { LVAL arg; int ch; - arg = xlgafixnum(); ch = getfixnum(arg); + arg = xlgafixnum(); ch = (int) getfixnum(arg); xllastarg(); return (ch >= 0 && ch <= 127 ? cvchar(ch) : NIL); } @@ -491,7 +491,7 @@ LVAL xdigitchar(void) { LVAL arg; int n; - arg = xlgafixnum(); n = getfixnum(arg); + arg = xlgafixnum(); n = (int) getfixnum(arg); xllastarg(); return (n >= 0 && n <= 9 ? cvchar(n + '0') : NIL); } diff --git a/lib-src/libnyquist/nyquist/xlisp/xlsys.c b/lib-src/libnyquist/nyquist/xlisp/xlsys.c index 2d5293cb3..dd1836a62 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlsys.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlsys.c @@ -49,8 +49,8 @@ extern LVAL k_verbose,k_print; extern LVAL s_true; /* external routines */ -extern FILE *osaopen(); -extern LVAL exttype(); +extern FILE *osaopen(const char *name, const char *mode); +extern LVAL exttype(LVAL x); /* xget_env - get the value of an environment variable */ LVAL xget_env(void) @@ -147,7 +147,7 @@ LVAL xbaktrace(void) if (moreargs()) { num = xlgafixnum(); - n = getfixnum(num); + n = (int) getfixnum(num); } else n = -1; @@ -157,7 +157,7 @@ LVAL xbaktrace(void) } /* xquit - get out of read/eval/print loop */ -LVAL xquit() +LVAL xquit(void) { xllastarg(); xl_main_loop = FALSE; @@ -224,7 +224,7 @@ LVAL xaddrs(void) #endif /* PEEK_AND_POKE */ /* xprofile - turn profiling on and off */ -LVAL xprofile() +LVAL xprofile(void) { LVAL flag, result; @@ -246,7 +246,7 @@ FILE *debug_input_fp = NULL; FILE *to_input_buffer = NULL; FILE *read_by_xlisp = NULL; -LVAL xstartrecordio() +LVAL xstartrecordio(void) { to_input_buffer = NULL; if (ok_to_open("to-input-buffer.txt", "w")) @@ -261,7 +261,7 @@ LVAL xstartrecordio() } -LVAL xstoprecordio() +LVAL xstoprecordio(void) { if (to_input_buffer) fclose(to_input_buffer); if (read_by_xlisp) fclose(read_by_xlisp); @@ -275,6 +275,6 @@ LVAL xstoprecordio() /* xgetruntime - get current run_time */ LVAL xgetruntime(void) { - /* return the value at that address */ + /* return the value of run_time variable as integer */ return cvfixnum((FIXTYPE) run_time); }