1. 21 Oct, 2020 2 commits
    • Joel K. Pettersson's avatar
      Add time type, refactor. Update devtests/, add notes/. · 2fb3d664
      Joel K. Pettersson authored
      Add time.h with SSG_Time type and flags, replacing the main
      script.h and program.h time_ms variables, and
      the default time flag and infinite time magic
      number. Also refactor a little in parser, and
      fix warnings when building.
      No noted functional change.
      A lead-up to more clean-up.
      
      Design idea from the 2020-06 "mgensys" changes.
      
      Todo: Unbreak 2011 feature, which is
      tested by devtests/defaulttime*.sgs.
      The problems come with the maintained sgensys design.
      In part, parsing is subtly broken when multiple operators are
      placed on one line. In part, timing code needs revisiting, as
      in 2020-06 "mgensys". More, to move all "voice" handling from
      the parser is needed for a clean and reliable design.
      
      Set version to v0.2-dev.
      
      Change log:
       * 2020-10-18: Add SSG_Time type, time.h header,
             use in script.h and program.h types.
             Replace default time flag and use of
             SSG_TIME_INF (except the latter kept
             in the generator). Fix warnings in parser
             using saugns v0.3.4 change and refactor a
             little. Also move SSG_MS_IN_SAMPLES()
             from math.h to time.h.
             Set version to v0.2-dev.
       * 2020-10-19: IDEAS -> notes/, add notes/TODO.
             (Copy 1/2 2011 TODO items from mgensys.)
             Replace the old magic value in generator.
       * 2020-10-20: Clean up devtests/:
             devtests/newconcept -> notes/modidea2012
             devtests/script3.sgs -> devtests/defaulttime0.sgs
             add new devtests/defaulttime1.sgs
             devtests/testnewsyntax*.sgs -> devtests/testbindtomulti*.sgs
             devtests/warning-* -> devtests/warning/*
      2fb3d664
    • Joel K. Pettersson's avatar
      Rename project to 'ssndgen' from 'sgensys'. · 0d905cd9
      Joel K. Pettersson authored
      Change SGS prefix to SSG throughout code.
      
      Also:
       * Reindent parser.c (the only remaining file).
       * Update .gitignore for the 'got' tool.
      
      Change log:
       * 2018-10-25: Rename to 'ssndgen'. Change SGS prefix to SSG.
       * 2018-10-27: Update .gitignore.
       * 2020-10-18: Re-apply change on top of former v0.2.13.
             Reindent parser.c (only remaining file).
       * 2020-10-21: .gitignore update from 2020-06 "mgensys".
         Old branch:
          - 2020-01-17: Update .gitignore for got tool.
      0d905cd9
  2. 18 Oct, 2020 1 commit
    • Joel K. Pettersson's avatar
      Change modulation syntax & ramp usage. · 88aa59eb
      Joel K. Pettersson authored
      Syntax changes:
       * For AM and FM parameters, parse the second value
         after a ',' and the modulator list after an
         appended '~', rather than second value and/or
         modulator list after a leading '!'.
         (E.g., for FM, "fX,Y~[...]" instead of "fX f!Y[...]",
         where X and Y are numbers or numerical expressions.
         Any of X, Y, or [...] can be left out now as before.)
       * Allow value ramp values for the second frequency and
         amplitude. Make the syntax consistent in this regard.
       * Make the phase & PM syntax slightly more permissive.
         For consistency with the new AM & FM syntax, have 'p'
         allow phase followed by PM modulator list in one go.
      
      Add position-updating skip function for ramp,
      similar to run function except there's no output.
      Use to update second freq and amp ramps in generator
      without generating samples when no FM or AM is done.
      
      Update scripts and README.
      
      This resolved the "todo" regarding dynfreq/dynamp
      ratio flags.
      
      Change log:
       * 2019-08-04: Set version to v0.2.13.
             Move syntax changes and parser fixes
             down from v0.3.1:
         Old branch:
          - 2019-07-18: Change AM & FM syntax.
                Make 'p' more permissive for consistency.
          - 2019-07-20: Use ramps for second freq, amp.
                TODO: Fill in the missing pieces in
                generator for fully consistent handling.
          - 2019-07-21: Simplify addition in generator.
                Remove incomplete and unneeded extra code.
                Clarify remaining added TODOs.
          - 2019-07-30: Add SAU_Ramp_skip(), use in generator.
                Remove now-resolved new TODOs.
       * 2019-08-06: parser: Add missing lines to backport
             (matching commits for later versions),
             v0.2.13 now functions as expected.
       * 2019-08-07: Move 08-06 Makefile -ffast-math portability fix
             to v0.2.3 and v0.2.4.
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-22: Fix missing default time adjustment
             for amp2 and freq2 ramps. Adjust details to
             avoid inf. time.
       * 2019-12-25: Merge clean-up and ramp changes as of 12-25.
         Old branch:
          - 2019-12-24: Move down clean-up change from v0.3.3b.
                Merge ramp default time changes.
       * 2020-01-03: Fix generator crash due to
             not counting FREQ2 and AMP2 values
             correctly, by merging the cleanup. (Remove counting.)
       * 2020-07-23: Merge renaming in ramp module.
       * 2020-07-26: Keep version at v0.2-beta.
             Change ramp module to ISC license, clean up comments.
         Old branch:
          - 2019-08-16: Re-order ramp run & skip function params.
      88aa59eb
  3. 22 Aug, 2020 1 commit
    • Joel K. Pettersson's avatar
      Change 'r' syntax. Refactor parser & parseconv. · 3725178c
      Joel K. Pettersson authored
      Syntax change: Disable multiplicative inverse for 'r',
      change description from "frequency ratio" to
      "relative frequency". It's more intuitive to handle
      n:m carrier-modulator frequency ratios as (m/n) values
      than (n/m) values, when actually adjusting them.
      (With multiplicative inverse, a higher value meant a
      lower frequency; now, a higher value means a higher
      frequency.) This reverses a change from 2011-03-04.
      
      Update README.
      
      Refactoring changes:
       * Further refactoring of the file module, part 2.
       * Remove parser SCOPE_SAME (unused since 2012).
       * Small flag handling change for parser end of event.
       * Small mempool performance improvement.
         Remove its dependence on arrtype.
       * Modularize parseconv a bit. Split out some
         types into parseconv.h, move voice graph traversal
         code into voicegraph.c.
      
      Change log:
       * 2019-07-04: Merge down 'r' syntax change.
         Old branch:
          - 2019-07-04: v0.3.1-beta: Begin syntax tweaks.
                Disable multiplicative inverse for 'r'.
                Update scripts and README.
       * 2019-07-31: README typo fix & ramp.c comment fix.
       * 2019-08-03: Fix description of 'r' syntax wrt freq ratio.
       * 2020-01-04: Move down clean-ups:
         Old branch:
          - 2019-07-11: (From v0.3.1) Microflensing.
                parser: Remove unused mul_inv option from scan_num(),
                use a SAU__noinline to help clang keep size down.
          - 2019-12-14: parser: Remove SCOPE_SAME (unused since 2012).
       * 2020-07-23: Move in mempool update
             from 2020-06 "mgensys" experiment.
         Old branch:
          - 2020-02-04: Minor mempool performance improvement using
                a first_i start for binary search, increased
                past non-free blocks on each block addition.
                Add MGS_MEM_DEBUG flag to common.h and mempool.c,
                for debug-friendly memory handling. Makes mempool
                calloc every allocation. This allows full testing
                of memory use with e.g. OpenBSD "vm.malloc_conf=S".
       * 2020-08-21: Move down file module changes.
         Old branch:
          - 2019-09-12: Merge down 08-24 file module refactoring,
                with finishing touch.
          - 2020-01-03: Merge -pedantic change for file.c.
          - 2020-07-23: Change file module to ISC license.
       * 2020-08-22: Move down parseconv refactoring.
         Old branch:
          - 2019-12-31: Split voicegraph from scriptconv,
                also adding builder.h. Renaming and refactoring.
          - 2020-01-01: Add missing SAU_ prefix for VoiceGraph type.
          - 2020-01-04: Move down split voicegraph from scriptconv
                from v0.3.6d - making it a split from parseconv.
                Keep it simple and without functional change.
                Rename the new header parseconv.h instead.
      3725178c
  4. 20 Aug, 2020 1 commit
    • Joel K. Pettersson's avatar
      Basic ramp curve changes. Refactor more. · 6fd6b818
      Joel K. Pettersson authored
      Ramp curve changes:
       * Rename the old 'exp' and 'log'
         to 'esd' (exponentially saturate or decay) and
         to 'lsd' (logarithmically saturate or decay),
         respectively. (The 'esd' type is the most
         natural-sounding for envelope-like use.)
       * Add new 'exp' and 'log' which internally
         select one of 'esd' or 'lsd' depending on whether
         the curve rises or falls, in order to behave much
         more like people would expect
         from curves named 'exp' and 'log'.
      
      Update scripts and README for changes,
      add "engine_rumble.sgs"
      and "hearingrange.sgs" (sweep from 20 Hz to 20 kHz), and
      move devtests/drum.sgs to examples/unnamed3.sgs.
      
      Refactoring changes:
       * Further refactoring of the file module, part 1.
       * Split the generator's mixing code
         into a mixer module (without functional change).
       * Use DJB2 hash (with length addition) in symtab.
         A little better than the old DIY hash.
         No significant functional change.
      
      Reindent generator.c.
      
      Change log:
       * 2019-05-28: Reindent generator.c.
       * 2019-06-16: Merge back refactoring,
             keep old buf size in generator.
         Old branch:
          - 2019-06-13: Split out mixer module from generator.c.
       * 2019-06-18: Update generator buf size to
             match new older version.
       * 2019-06-30: Merge down slope->ramp and curve changes,
             along with script updates and a symtab hash change.
             Set version to v0.2.12.
         Old branch:
          - 2019-06-22: Begin v0.3.1-beta.
          - 2019-06-27: Rename 'exp'/'log' slope types
                to 'esd'/'lsd', add new 'exp'/'log' types which
                select 'esd' or 'lsd' for increase/decrease.
                Update scripts for changes, add "engine_rumble.sau",
                move devtests/drum.sau to examples/unnamed3.sau, and
                add "freqrange.sau" (sweep from 20 Hz to 20 kHz).
          - 2019-06-28: Change "slope change type" to "curve type"
                in script naming and parser, for consistency.
                Use DJB2 hash (with length addition) in symtab.
                Set version to v0.3.1. Update comments in slope.c.
                Rename "freqrange.sau" to "hearingrange.sau".
          - 2019-06-30: Rename slope module to ramp.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
       * 2019-09-12: Move down clean-up change from v0.3.2.
         Old branch:
          - 2019-08-22: Break out SAU_File_end() function.
       * 2019-12-12: Fix indentation in generator.c.
       * 2019-12-25: Merge ramp default time changes.
       * 2020-01-03: Merge clean-up changes.
       * 2020-07-23: Merge ramp & generator changes.
       * 2020-07-26: Keep version at v0.2-beta.
       * 2020-08-21: Split out the above from
             'r' syntax changes and more.
      6fd6b818
  5. 26 Jul, 2020 1 commit
    • Joel K. Pettersson's avatar
      Rework audio mixing. Refactor generator. · b298b124
      Joel K. Pettersson authored
      Use floating-point processing in generator
      internally, until writing 16-bit output,
      instead of mixing float and int buffers.
      For PM phase offsets, get 32-bit int values
      from float buffer, instead of 16-bit values.
      Rework mixing, add clipping for audio output.
      
      Move oscillator sample block fill code
      to osc.c (from generator.c). Move lut,
      coeff fields to SGS_Osc type, from the
      types in generator.c.
      
      Change default sample rate to 96000 Hz,
      undoing the 2012-02-10 change to 44100 Hz.
      
      Change log:
       * 2018-11-09: Complete changing generator to use float
             internally. Rework mixing, clip output.
             Move script.h and ptrlist to builder/.
             Complete branch merging.
       * 2018-11-11: Minor refactoring in generator.
             Minor comment clean-up.
       * 2019-05-28: Merge refactoring.
         Old branch:
          - 2019-02-07: Move osc block running to osc.c
                (split from generator.c).
       * 2020-07-23: Split out after ramp and other refactoring.
             Merge renaming in ramp module.
             Replace osc module with newer version
             from the 2020-06 "mgensys" experiment,
             refactoring generator for moving coeff
             and lut fields to SGS_Osc. Also update
             wave module.
       * 2020-07-26: Reduce diff with 2020-06 "mgensys" experiment,
             changing default sample rate to 96000 Hz (was 44100 Hz
             after 2012-02-10). Also use ISC license header for the
             common module and math.h, to keep permissive code free
             from dependence on non-permissive code; and use it for
             audiodev and wavfile modules as well.
             Keep version at v0.2-beta.
      b298b124
  6. 23 Jul, 2020 6 commits
    • Joel K. Pettersson's avatar
      Crudely anti-alias 'sqr' & 'saw' waves, remove 'shh'. · cbadf526
      Joel K. Pettersson authored
      Wave type changes:
       * 'sqr' - Improve square wave quality
         by using a rounded step, replacing values
         with tanh upscaled-sine values,
         with 4*32 = 128 of 2048 samples smoothed.
       * 'saw' - Use adjusted version of the same
         technique for anti-aliased sawtooth wave,
         taking up 2*(58+6) = 128 of 2048 samples.
         (First 1 and middle 11 samples zero-filled.)
         Change slope to decreasing, for
         consistency with other wave types;
         amp. or freq. can be negative
         in order to get an increasing saw.
       * 'shh' - Removed. Too similar to old 'saw',
         and no point in keeping it as-is.
      
      (Also remove commented-out 'szhhr' wave type.)
      
      The 'sqr' and 'saw' changes greatly reduce
      aliasing while keeping them sounding fairly
      bright (but no longer attempting to
      represent ideal squares and sawtooths).
      They now lack the ear-splitting "bite" of real
      square and sawtooth waves (but otherwise sound
      as expected) at low frequencies,
      while at medium ones sounding quite good.
      
      Change log:
       * 2019-09-11: wave: Replace square wave step
             with tanh upscaled-sine values.
       * 2019-09-12: wave: 'sqr' - Further tweaks and
             aliasing reduction with 4*32 values replaced
             in 2048 value sqr LUT. Keep square wave fairly bright.
             'saw' - Similarly use tanh upscaled-triangle
             values for a smooth 'saw' step, taking up
             1/32 of the saw LUT values.
             Change 'saw' slope to decreasing.
             Remove 'shh' wave.
             Remove commented-out 'szhhr' code.
             Set version to v0.3.3.
       * 2019-09-23: Change 'saw' to use tanh upscaled-sine
             for aliasing reduction after figuring out
             different adjustments which make it better.
       * 2019-10-03: Further tweaks to bring sawtooth
             anti-aliasing up to par with square wave.
             Double length and scaling as for square,
             but move one zero sample from the middle
             to the beginning (the trick needed).
       * 2019-10-08: Move down to after v0.2.13.
             Set version to v0.2.14.
       * 2020-07-23: Move down to before v0.2.11.
             Keep version at v0.2-beta.
      cbadf526
    • Joel K. Pettersson's avatar
      Rework ramp module. Refactor uses and more. · cc97ac05
      Joel K. Pettersson authored
      Refactor ramp parameters and their uses:
       * Remove the old SGS_Ramp type,
         renaming the SGS_RampParam type to SGS_Ramp.
       * Separate the ramp fill functions from the
         type and its uses. (E.g. future envelope support
         could use the fill functions with a different
         data structure and surrounding logic.)
       * New SGS_Ramp_run() function fully replaces
         parameter running function in generator.c.
       * Remove voice & operator attr fields and flags;
         these are now fully replaced by the SGS_Ramp
         flags and code.
       * Cleaner code for handling ramp data in parser
         and generator.
      
      Todo: Since earlier, dynfreq/dynamp parameter
      ratio flags are ignored; to correct handling.
      For now, they are simply removed.
      
      Improve -p printout, extending info for 'f' parameter
      and adding it for 'a' on each main per-operator line.
      
      Also refactor more modules:
       * Make arrtype add method return pointer to item
         in current array allocation, for initialization.
         Rename arrtype SGS_UInt8Arr to SGS_ByteArr.
       * Refactor mempool using arrtype, and initialize
         allocated memory to zero bytes.
         Split SGS_MemPool_memdup() from SGS_MemPool_alloc().
       * De-const-ify ptrlist item void pointers.
       * Refactor symtab, without functional change.
      
      Change log:
       * 2018-11-08: Refactor mempool using arrtype.
             Move wave module to program/.
             Split SGS_MemPool_memdup()
             from SGS_MemPool_alloc().
             Fix Makefile.
       * 2019-01-14: Complete branch merging.
             Minor clean-up.
             Set version to v0.5.0.
       * 2019-05-10: Merge changes.
             Undo file moves.
       * 2019-05-13: Place after new v0.4.4.
       * 2019-05-17: Merge refactoring of slope parameter handling,
             and accompanying changes, with adjustments.
             Merge param module into slope module, and
             re-rename SGS_TimedParam type to SGS_Slope.
             Also refactor symtab, without functional change.
         Old branch:
          - 2018-11-27: Refactor timed param handling,
                replacing the SGS_Slope type with use of
                SGS_TimedParam, and more fully moving out
                code for parameter "running" from generator.
                Remove "attr" fields and flags.
                Improve -p printout (more 'f', added 'a', info).
          - 2018-12-01: Add SGS_TimedParam_ENABLED(),
                refactor parser and generator handling of flags.
       * 2019-05-28: Merge refactoring.
         Old branch:
          - 2019-02-10: Rename SAU_UInt8Arr to SAU_ByteArr.
       * 2019-06-05: Merge diff after v0.2.3 syntax change.
       * 2019-06-13: Set version to v0.3.0.
       * 2019-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-06-18: Split out v0.2.9, place after v0.2.10.
       * 2019-06-22: Comment clean-up in mempool.c.
             Set version to v0.2.11.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
       * 2019-09-12: Move down renaming of slope module to ramp.
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-24: Merge clean-up changes for v0.2.5.
             Adapt v0.2.5 changes to use 'S t' as
             default time placeholder for ramps.
       * 2019-12-25: Fix partial ramp update (using the new flag),
             after renaming it (flip to _SET instead of _DEFAULT).
       * 2020-01-03: Move down a few clean-up changes:
         Old branch:
          - 2020-01-01: Make arrtype add method return pointer to item
                in current array allocation, for initialization.
                In mempool, use new return value of arrtype add.
          - 2020-01-03: Compile with -pedantic, remove warnings.
                Minor style diff in mempool.c.
                Remove the generator value-by-value ramp copying.
                De-const-ify ptrlist item void pointers.
       * 2020-01-29: Build without -pedantic
             after fixing most warnings. System libraries
             and differing C versions make -pedantic and -std=c??
             generate spurious warnings on some systems.
       * 2020-07-22: Split out the above from
             generator changes for mixing and further modularization.
             Keep version at v0.2-beta.
             Redo naming in ramp module.
      cc97ac05
    • Joel K. Pettersson's avatar
      Add 'hold' ramp curve. Refactor scanning & ramp params. · 42c67254
      Joel K. Pettersson authored
      Recognize 'hold' ramp curve in scripts.
      Use new SGS_RampParam type for ramp parameters
      in script.h and program.h types.
      
      Break out PScanner struct from SGS_Parser.
      Refactoring without functional change,
      in preparation for merge with test scanner.
       * Move line num changes into basic scan_* functions.
       * Rearrange code, placing PScanner above Parser.
       * Rename scan_char() to scan_getc(),
         add scan_stashc() for next_c logic.
       * Add ScanLookup struct, stored in parser and pointed
         to by its scanner; preparation for future redesign,
         where the parser needs to associate additional data
         with the scanner.
       * Replace parser string matching
         using new SGS_SymTab_pool_stra()
         and string pool pointer comparison.
      
      Redesign test scanner. A start for bridging the design
      gap for the parser:
       * Separate getc and nospace version of getc
         (both types will be needed by the parser).
       * Break out update_cframe() and set_prevc(),
         use in get functions.
       * Renaming and minor tweaks.
      
      Simplify the file module (and change SGS_File_AFTER_EOF()
      to work regardless of whether pos was masked).
      No functional change for uses.
      
      Change log:
       * 2018-11-09: Rename slope-using params and their flags.
       * 2018-11-14: Add builder/script/param.h with
             type SGS_TimedParam, use in script.h types.
             Add slope change type 'hold'
             (by enabling and renaming 'state').
       * 2018-11-22: Move builder/script/param.h to program/param.h.
             Use SGS_TimedParam in program.h types, handling
             conversion directly in generator (removing
             the small added function from parseconv).
             Remove obsolete *_SLOPE parameter flags,
             keeping attribute *_SLOPE flags for now.
             Complete branch merging.
       * 2018-11-23: Refactor scanning code in parser,
             in preparation for merge with test scanner.
       * 2019-05-10: Merge changes.
             Adjust parser refactoring for new file code
             (slightly simplifying it).
             Move out param.h from builder/.
       * 2019-05-13: Place before new v0.5.0.
             Increase version to v0.4.4.
             Merge further parser refactoring (and polish it),
             along with some test scanner changes.
         Old branch:
          - 2018-12-04: Replace parser string matching
                using new SGS_SymTab_pool_stra()
                and string pool pointer comparison.
                Complete branch merging.
          - 2018-12-06: scanner: Rename old SGS_Scanner_getc() to
                SGS_Scanner_getc_nospace(), adding a more
                space-preserving function with the old name.
                Some further renaming and tweaks.
          - 2018-12-13: scanner: Break out update_cframe() and
                set_prevc(), use in get functions,
                and further changes.
       * 2019-05-15: Merge param.h into program.h.
             Rename SGS_TimedParam to SGS_SlopeParam.
       * 2019-05-26: Merge file module clean-up back.
             Update comments, refactor a bit more.
         Old branch:
          - 2019-05-24: Simplify file module.
       * 2019-05-27: Avoid future problems by
             ensuring SGS_File_AFTER_EOF()
             works after mask applied to pos.
       * 2019-06-05: Merge parser diff after v0.2.3 syntax change.
       * 2019-06-13: Set version to v0.2.9.
       * 2019-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-06-18: Place after new v0.2.9, set version to v0.2.10.
       * 2019-09-12: Merge diff for renaming slope module to ramp.
             Further rename SGS_SlopeParam to SGS_RampParam.
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-24: Adapt v0.2.5 changes to
             use 'S t' as default time placeholder for ramps.
       * 2020-07-13: Keep version at v0.2-beta.
      42c67254
    • Joel K. Pettersson's avatar
      Support running multiple scripts. Use larger output buffer. · 38975267
      Joel K. Pettersson authored
      Support multiple script files or strings per command-line
      invocation. Also make corresponding changes to the
      'test-builder' program. (Use SGS_PtrList in main module,
      builder, and renderer for lists. Combine the old behavior
      with running through a batch of things at each stage.)
      
      Use 256 ms of audio output buffering in renderer.
      Fixes stuttering on NetBSD 8 (which requires >= 128 ms
      of buffering for consistently smooth playback).
      The extra 128 ms is for the sake of portability.
      (All non-NetBSD systems I personally use have however
      worked fine with the old 1024 sample buffering.)
      
      While at it, also increase the generator's internal
      buffer length from the ancient value of 256 samples
      to 1024. (This is simply a performance vs. memory
      use trade-off. The number of buffers could potentially
      grow into the hundreds or thousands for extreme input.
      This increases memory use fairly conservatively.)
      
      Const-ify pointers to non-modified SGS_Program instances.
      
      Change log:
       * 2019-06-04: Move multiple script args support back
             to v0.5.0, use the old version number.
         Old branch:
          - 2019-02-10: Support multiple script paths per
                command-line invocation. Also make corresponding
                changes to the 'test-builder' program.
                Move ptrlist to main dir (out of builder/).
                Increase version to v0.6.1.
                Const-ify non-modified SAU_Program pointers.
          - 2019-05-28: Merge support for multiple script args,
                and refactoring. Combine with support
                for -e <string> in the simplest way.
                Set version to v0.5.2. Update README.
          - 2019-05-29: Tweak usage notice.
       * 2019-06-18: Merge audio buffering changes.
             Move it all back to after v0.2.8,
             set version to v0.2.9.
         Old branch:
          - 2019-06-13: Increase generator buffer length
                from 256 samples to 1024 samples.
          - 2019-06-14: Change renderer output buffer
                sizing to remove stuttering on NetBSD.
                (Use 256 ms instead of 1024 samples.)
                Refactor the code in the process.
                Increase version to v0.3.2.
       * 2019-02-09: Merge changes for renderer.c,
             fixing crash on opening several files when
             only some failed to open.
             Simplify usage notice.
         Old branch:
          - 2019-06-22: Minor refactoring in renderer.c.
          - 2020-02-03: Add missing NULL checks in renderer.c;
                check for NULL programs, as is supposed to be done.
       * 2020-07-13: Keep version at v0.2-beta.
      38975267
    • Joel K. Pettersson's avatar
      Use restrict keyword. Update test code & split out as program. · 6a4457fe
      Joel K. Pettersson authored
      Use restrict keyword for pointer function parameters
      throughout code. For now, this is the only use.
      Makes for a minor size and speed improvement.
      The design has been checked for safety with this,
      though something could have been missed.
      
      Various smaller updates for test lexer and scanner code.
      
      Split out usage of the test lexer and test scanner
      into the separate 'test-builder' program,
      built with 'make test'.
      
      Also add install/uninstall targets to Makefile.
      
      Change log:
       * 2018-11-18: Reduce lexer char switch cases to values 0-127,
             use default for the identical rest.
             Reduce scanner char handler array to 128 values,
             use entry for 0 when char > 127.
       * 2018-11-19: Move test lexer use to
             separate 'test-builder' program,
             instead of conditionally compiling it into sgensys.
             Add (unused) SGS_Scanner_handle_char1comments()
             for first-character-only line comment openers.
       * 2018-11-22: Move test scanner use to
             'test-builder' program.
             Complete branch merging.
       * 2018-11-23: Add SGS_Scanner_close().
       * 2018-11-28: Use restrict keyword.
             For now, only add to function argument pointers.
             Reduces size of the binary somewhat,
             and produces very marginal speed-up.
       * 2019-05-06: Move back to after new v0.4.2.
             Increase version to v0.4.3.
             Change test scanner file handling,
             write new SGS_Scanner_open().
             Copy scanner file handling to lexer.
             Update test-builder for new code.
       * 2019-05-10: Tweak usage notice.
             Fix missing part of scanner.c merge.
       * 2019-06-13: Set version to v0.2.8. Re-merge tidying.
       * 2019-06-22: Makefile: add install/uninstall targets.
       * 2019-09-12: Merge diff for renaming slope module to ramp.
       * 2020-07-13: Keep version at v0.2-beta.
      6a4457fe
    • Joel K. Pettersson's avatar
      Add -e string evaluation option. Add test scanner. · 18c2d4d7
      Joel K. Pettersson authored
      Support direct evaluation of a string argument with
      a new -e option. E.g., ./sgensys -e "Osin f643 t1"
      will run (play) a 643 Hz oscillator for 1 second.
      
      Add experimental test scanner, a reworking of
      the test lexer; a draft for future redesign,
      as in breaking up the tasks of the lexer
      and/or an intermediate parser redesign.
      
      Add file module string open/read/close code,
      and change sgensys, builder, parser, lexer to use it.
      Also add support to file for creating nested instances,
      in preparation for future nested file usage.
      
      Updates to the test lexer.
      
      Change log:
       * 2019-04-24: Add file module string open/read/close code.
       * 2019-04-25: Name changes in file.
       * 2019-04-29: Move back to after new v0.4.0.
       * 2019-04-30: Add -e string evaluation option.
             Also change file module to support nested (linked)
             instances, in preparation for future addition
             of nested file usage (prepend/predefine arg,
             file includes from file, etc.).
             Increase version to v0.4.1.
             Merge test lexer changes,
             with some final tweaks.
         Old branch:
          - 2018-11-04: Import updated test lexer code.
                (Drop new test scanner for now.)
          - 2018-11-09: Silence warnings in test lexer.
          - 2018-11-15: Use SGS_File_skipline() in test lexer.
          - 2018-11-16: Debug test lexer, also a few clean-ups
                and performance tweaks.
          - 2018-11-18: Minor fixes and tweaks for test lexer.
          - 2018-11-19: Minor clean-up in test lexer.
          - 2019-01-14: Use SGS_File_trynewline() in test lexer.
       * 2019-05-04: Add test scanner module,
             merging tidied up basic version.
         Old branch:
          - 2018-03-25: Add scanner module (incomplete)
                for use in parser (next) and lexer (later).
          - 2018-04-07: Some debugging and improvements
                for test scanner.
          - 2018-04-13: Improve test scanner design and
                add C-style comment support.
          - 2018-11-05: Complete branch merging.
                (Add the postponed test scanner.)
                Minor clean-up in test scanner.
          - 2018-11-09: Silence warnings in test scanner.
          - 2018-11-15: Use SGS_File_skipspace(),
                SGS_File_skipline(), in test scanner.
          - 2018-11-18: Properly check scanner EOF status for error.
          - 2018-11-19: Renaming and minor changes in test scanner.
                Use symtab in scanner symbol string reading.
          - 2019-01-14: Use SGS_File_trynewline() in test scanner.
       * 2019-05-08: Tweak usage notice.
       * 2019-05-10: Add -e quick test to README.
             Fix parser string matching when item
             ends with end of file marker
             (as happens with -e "Osin").
             Fix missing part of scanner.c merge.
       * 2019-06-13: Set version to v0.2.7.
             Merge minor code tidying for lexer.c, scanner.c.
       * 2020-02-09: Simplify usage notice.
       * 2020-07-13: Keep version at v0.2-beta.
      18c2d4d7
  7. 20 Jul, 2020 5 commits
    • Joel K. Pettersson's avatar
      Add file module, use for scanning. · 7ccbb953
      Joel K. Pettersson authored
      Rework scanning in the parser using new low-level code
      grown out of the work on the test lexer, and further changes:
       * Split out file reading code from the lexer,
         elaborating it into the new file module.
       * Replace character-level reading in the parser,
         while preserving the old structure;
         name functions directly using SGS_File read_*(),
         and scanning functions using SGS_Parser scan_*().
       * Use newer SGS_File functions for number reading
         (replacing quick-and-dirty old code).
       * Rework label string reading, and use
         SGS_File_skipstr() for truncated labels.
      
      Change log:
       * 2018-02-27: Split out reader module
             from lexer, also use in old parser.
       * 2018-03-01: Rename SGS_READ_*() macros to SGS_READER_*().
       * 2018-03-09: Add SGS_READER_TESTC()
             and SGS_READER_TESTCGET() macros
             replacing testc() and testgetc()
             functions in parser.c.
       * 2018-03-14: Rename reader module to fread.
       * 2018-03-17: Add SGS_FREAD_RETC(), minor parser refactoring.
       * 2018-10-23: Refactor fread, rename to file.
       * 2018-11-02: Re-add end marker logic to file module.
       * 2018-11-04: Add -v version number, initially at v0.5.0.
       * 2018-12-29: Complete branch merging.
             Minor naming adjustments for parser code.
             Move SGS_File buf array to end of struct,
             reducing the binary size.
       * 2019-01-10: Merge newer file module and more back.
             Reduce differences with newer version by replacing
             obsoleted functions in the parser. Also replace less
             functional dummy code with newer calls in the lexer.
         Old branch:
          - 2018-03-25: Rename reader TESTCGET macro to TRYC,
                add SETC/SETC_NOCHECK for use in test scanner.
          - 2018-04-07: Rework reader module
                into cbuf, stream, and streamf.
          - 2018-11-04: Merge file module
                with code from stream/streamf.
          - 2018-11-11: Add SGS_File_getstr()
                and SGS_File_getint(),
                use in scanning/parsing code.
          - 2018-11-16: Shorten SGS_File_get* function names.
                Add SGS_File_getd(), use in parser
                and refactor scanning of numbers.
                Refactor SGS_File_geti().
                Add SGS_File_skipspace(), SGS_File_skipline().
                Adjust SGS_File_gets() length param to match use.
          - 2018-11-19: Fix SGS_File_geti()
                edge case for reading negative int.
          - 2018-11-29: Refactor cbuf and file modules.
                Reduces binary size.
          - 2018-12-15: Merge cbuf module back
                into file module.
                Add and use SGS_File_skips().
          - 2018-12-21: Fix for changed file module code.
          - 2018-12-30: Change uint32_t to size_t
                for string lengths.
                Simplify SGS_File_AT/AFTER_EOF() macros.
          - 2019-01-08: Add SGS__noinline macro
                for GCC/clang noinline attribute,
                use to keep clang from inlining
                scan_warning() in parser (saving ~4KB).
                Add SGS_File_trynewline().
          - 2019-01-10: Change file module position handling.
                Wrap position to within buffer area boundary on each
                operation which checks the call position, before the
                call. Use wrapped call positions. Makes ungets safe.
       * 2019-01-11: Set version to v0.4.0.
             (Reserve higher for after improved audio mixing.)
             A few comment, macro improvements in file module.
       * 2019-05-04: Rename SGS_File_gets()/skips()
             to SGS_File_getstr()/skipstr().
             Use create/destroy functions in parser and lexer,
             fixing previous merge.
       * 2019-06-05: Merge parser diff after v0.2.3 syntax change.
       * 2019-06-13: Place after new v0.2.5, set version to v0.2.6.
       * 2019-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-09-12: Merge diff for renaming slope module to ramp.
       * 2019-12-24: Move clean-up change down from v0.2.12.
             Also remove junk "case '{'" from some prior rebasing.
         Old branch:
          - 2019-07-18: Use isinf() for infinite-number checks.
                Replace "fabs(x) == INFINITY" with "isinf(x)".
       * 2020-02-09: Merge num.exp. fix for successive subtractions.
       * 2020-07-13: Keep version at v0.2-beta.
      7ccbb953
    • Joel K. Pettersson's avatar
      Add ramp module, refactor parser & generator. Fixes. · ae0220b3
      Joel K. Pettersson authored
      Bugfixes:
       * Adjust which flags the parser checks to
         allow/disallow nesting-dependent 'r' and 'i'
         syntax elements, correcting handling for
         label references. Also make the parser use
         flags to cleanly guard against wrong end_*()
         processing for nested ParseLevel instances.
       * Add checks in parser to reject infinite numbers
         and expressions containing them.
       * For ramp default time duration, carry over
         'S t' default time instead of using a fixed
         1 second default. Changes default time for
         panning, and for operator ramps where the
         operator previously had infinite time set.
      
      Clean-ups:
       * Turn Valit (VALue ITeration) types and code
         from program.h and generator.c into the new
         ramp module and SGS_Ramp type.
       * Simplify parse level SDPL_IN_* "location".
         Replace flags and macros with a simple enum state.
         No functional change, as only one flag was set at
         a time.
       * Use size_t for string and buffer lengths.
      
      Change wave LUTs from 16-bit int to float
      (refactoring osc & updating generator).
      No significant quality difference in the output,
      as mixing is still 16-bit.
      
      Change log:
       * 2019-06-13: Merge various clean-ups, and the change of
             wave LUTs from 16-bit int to float.
             Set version to v0.2.5.
         Old branch:
          - 2018-07-30: Change "http" to "https" in
                heading license comment.
          - 2018-11-06: Break out slope from program/generator.
                Change wave LUTs from int16_t to float.
                Refactor osc, update generator.
          - 2019-04-30: Place after new v0.4.1.
                Increase version to v0.4.2.
                Bring in README update.
          - 2018-12-29: Add check for infinite numbers in parser,
                refactor reading of multiplicative inverse numbers.
          - 2018-12-30: Change uint32_t to size_t for string lengths.
          - 2019-01-11: Complete merge of uint32_t -> size_t changes.
          - 2019-05-04: Add SGS__malloclike()
                to SGS_create_*() functions where missing.
          - 2019-05-17: Add missing #pragma once to slope.h.
          - 2019-06-05: Merge README diff after v0.2.3 syntax change.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
       * 2019-09-12: Rename slope module to ramp.
             (For cleaner diffs and old versions.)
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-22: Merge composite timing fix.
       * 2019-12-24: Move down clean-up changes
             from v0.2.6, v0.2.12, and v0.3.1d.
             Also change default time for ramp, using a flag
             instead of placeholder value, and using the 'S t'
             value instead of a fixed 1 second.
         Old branch:
          - 2018-12-29: Complete branch merging.
                Simplify parse level SDPL_IN_* "location",
                replacing flags and macros with a simple enum
                state, as only one flag was set at a time.
          - 2019-07-18: Use isinf() for infinite-number checks.
                Use isnan() for portable NAN checks in parser.
          - 2019-09-12: Merge down to v0.2.12.
          - 2019-12-21: Change which flags are checked to
                allow/disallow 'r' (rel. freq.) and 'i' (inf. time),
                fixing syntax for "@label" references. Update README.
                Change parser to use flags to cleanly guard
                against wrong end_*() processing for nested
                ParseLevel instances.
       * 2020-07-13: Keep version at v0.2-beta.
      ae0220b3
    • Joel K. Pettersson's avatar
      Add arrtype module, rework parseconv. Replace symtab. · 368905f2
      Joel K. Pettersson authored
      Part 1 of redesigning parseconv and generator as
      planned in 2013. Traverse graph before generator,
      determining which operators to use and how to use
      them. Not complete, the generator still using the
      old recursive algorithm. Simplifies some code in
      generator.
      
      Do a clean-up rewrite of parseconv.c, using the
      new arrtype (generic array) module for its simple
      dynamically-sized arrays.
      
      Calculate duration of script/program and
      include in program struct.
      Duration now printed with -p option.
      
      Changes include:
       * Use an array of operator data instances per
         event, instead of splitting events with several.
       * Fully separate voice & operator parameter flags
         (which were already stored separately during
         parse), renaming enums. Also separate the enums
         for voice & operator "attr" values (which were
         already stored separately).
       * Rename various types, fields, and flags in program.h.
         Use SGS_P* names for all voice and operator constants.
       * Change time types to uint32_t from int32_t, setting
         SGS_TIME_INF to UINT32_MAX instead of -1. (Infinite
         time is handled as a special value for nested
         operators, as of 2012-01-23. This reverses the type
         change from unsigned to signed done then.)
       * Make voice and operator IDs unsigned, replacing the
         use of -1 for no ID with named enums.
      
      Also replace the old symtab placeholder with the new
      hash table, and update label handling in the parser.
      Remove obsolete parser string alloc/free code
      (reversing a 2012-01-12 change).
      
      Script syntax: Labels can now only contain
      alphanumeric characters and '_'. Any other character
      will end and follow the label.
      
      Change log:
       * 2018-10-29: Complete branch merging.
             Further program module changes.
             Use partially-done redesign in generator.
             Further rename flags and fields.
         Old branch:
          - 2013-08-05: Redesign sketch #1 (non-working)
                for program & generator.
          - 2014-10-05: Redesign sketch #2 (still non-working)
                for program.c, and minor change in parser.c.
          - 2018-02-14: Redesign sketch #3 (non-working),
                adding interpreter and turning
                new generator version into renderer
                for its results.
          - 2018-02-16: Style change for new interpreter.
          - 2018-02-24: Rename program module to builder,
                splitting header.
          - 2018-07-01: Add some code to interpreter.
                Also change builder to count op & voice
                data struct instances, for one-off
                allocation of corresponding result structs
                in interpreter.
          - 2018-07-02: Use unsigned values for time
                except when negative times are needed.
                Also make voice and operator IDs unsigned.
          - 2018-07-26: Undo renaming program to builder.
                Simplistically assign block IDs in
                interpreter module. Prepare for merge
                with program module.
          - 2018-07-27: Redesign sketch #4. Turn old program module
                into imp (intermediate program). Turn useful
                code from interpreter into new program
                module. Unlink renderer from build.
          - 2018-07-29: Build list of operator references (new type)
                per-voice in program module.
                Create garr (generic array) module,
                use in imp & program modules.
          - 2018-08-21: Merge imp back into program.
                General round of fixes and clean-ups.
                Use partially-done redesign in generator.
                Remove leftover files with redesign sketches.
          - 2018-08-23: Flense redesign sketch traces
                from generator.
       * 2018-10-31: Turn old GRAPH voice
             parameter into SDEV flag.
             Correct fix in mempool.c.
             Give -p printout prettier heading part.
             Refactor parser scan code.
       * 2018-11-02: Minor refactoring of parser scan code.
       * 2019-06-07: Merge minimal redesign changes from old v0.4.0.
             Adjust old parser code to work without new file module,
             and re-do trivial clean-up.
             Increase version to v0.3.2.
             Re-add bugfix for too-long label (max index was one
             too high), and add debug script for too-long label.
         Old branch:
          - 2018-03-14: Fully replace old symtab code with the new,
                and parser clean-ups.
          - 2018-06-30: Change string pointer type used in
                symtab calls from char to void, add length args.
          - 2018-08-29: Minor mempool clean-up.
          - 2018-09-11: Refactor garr (generic array) module.
          - 2018-10-23: Fix mempool bug introduced with refactoring.
          - 2018-10-27: Rename garr to arrtype. Correct README.
       * 2019-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-06-30: Update -p printout details
             to match June syntax changes.
       * 2020-07-13: Merge back as intermediate change.
             Keep version at v0.2-beta.
      368905f2
    • Joel K. Pettersson's avatar
      General clean-up. More syntax changes. Reorganize code. · ecd1f13c
      Joel K. Pettersson authored
      Script syntax changes:
       * Label referencing: From ":label" to "@label".
       * Compound value (e.g. gradual value change,
         arg value with subvalues): From "[...]" to "{...}".
       * PM modulator list prefix: Change from "p*" to "p+".
         (I.e., a list uses "p+[]". More fitting, as PM amounts
         to adding the amplitude of modulator(s) to the phase.)
       * Add downscaling of output amplitude by voice count
         by default. Using "S a" disables it.
       * Allow 'a' (amplitude) parameter for AM and FM modulators.
         (Previously disallowed within "a![]" and "f![]"/"r![]".)
       * Numerical expressions: Further change parsing
         for correctness and consistency.
          - Fix bug disallowing sign before a nested '(' after '('.
          - Fix result of several subtractions in succession.
          - Fix handling of '^' (to the power of) priority,
            truly binding it more closely than other operators.
          - Only allow arithmetic inside parentheses.
            (Previously allowed without parentheses when
            no whitespace separated parts of the expression.)
          - Only allow number sign within parentheses.
            (Previously '-' sign was allowed without parentheses.
            This frees up '-' for new future uses.)
          - Allow '+' as sign (not only as operator)
            in addition to '-'.
       * Multiple operator binding: From "{...}" to
         nesting syntax prefixed by '@', i.e. "@[...]".
      
      Todo:
       * Make multiple operator binding functional.
         (It has been a "todo" since it was added.)
      
      Wave type changes:
       * Make 'saw' (saw wave) increasing instead of decreasing.
         (Negative frequency or amplitude gives a decreasing saw.)
      
      Reorganize code:
       * Move parser.c, program.c, and the lexer and symtab modules
         to builder/, splitting out builder.c and renaming files:
          - parser.h -> script.h (parser output).
          - program.c -> parseconv.c.
         Place conditionally-compiled test use of lexer in builder.c.
       * Move generator and osc to renderer/,
         splitting out renderer.c from sgensys.c.
       * Create common module, moving the old sgensys.h contents
         to common.h. Add and use utility functions:
          - SGS_warning(), SGS_error(): now used for warnings
            and errors (when the format is suitable).
          - SGS_memdup(), SGS_strdup(): moved from parser.c.
      
      Consistent type and function naming:
       * Rename each "SGSType" to "SGS_Type".
       * For function and macro names including a type,
         use same (mixed) case as in type.
      
      Further clean-ups:
       * Use size_t for event IDs, uint32_t for operator IDs,
         uint16_t for voice IDs.
       * Rename parser struct types, flags, and functions.
         Name types "SGS_Script*", flags "SGS_S*".
       * In parser result (SGS_Script),
         include options set in script and script name.
       * Add circular reference guard for operators in generator to
         avoid crashes due to incompletely supported features.
       * Refactor generator memory handling.
         Also somewhat simplify memory handling in program module.
       * Add -p option for printing script info after loading.
         No longer print the program "debug info" unless -p used.
      
      Change log:
       * 2018-04-13: Rename parser struct types and flags.
       * 2018-04-18: Simplify memory management in program
             and generator. Implement downscaling
             of amplitude by voice count by default.
       * 2018-06-02: Undo faulty simplification in parser code, and
             some further renaming. Add circular reference
             guard for operators in generator, and some
             further clean-ups.
       * 2018-06-30: Rename types from "SGSName" to "SGS_Name".
             Rename corresponding functions and macros
             to use same (mixed) case in included type
             name.
       * 2018-09-11: Create common module, refactor warnings and
             errors. Move memdup from parser to common.
       * 2018-10-04: Further renaming of parser structs and flags.
             Some additional tidying.
       * 2018-10-15: Reorganize code, moving parser.c, program.c,
             and symtab to builder/. Rename program.c to
             parseconv.c, split out builder module.
             Further flag renaming in parser.c.
             Add -p option for printing program info.
       * 2018-10-16: Move lexer to builder/. Update headers, comments.
             Move lexer test invocation to builder.c.
             Complete branch merging.
             Split out renderer module from sgensys.c.
             Move audiodev, wavfile, generator, and osc
             to renderer/.
             Some code tidying.
       * 2018-10-17: Move audiodev and wavfile out from renderer/.
             Make "saw" wave increasing instead of decreasing.
             Replace renderer.h and builder.h with
             combined sgensys.h.
       * 2018-10-18: Enable 'a' parameter for
             "f!<>"/"r!<>" and "a!<>".
       * 2018-10-23: Change PM list syntax from "p*<>" to "p+<>".
       * 2018-12-25: Further changes to numerical expression
             parsing for correctness and consistency.
             Add warning for '(' without closing ')'.
             Remove extra linebreak from file open error.
       * 2019-06-05: Merge syntax changes.
             Increase version to v0.3.1.
             Clean up a few scripts.
       * 2019-06-13: Set version to v0.2.4.
       * 2019-06-16: Backport further simple syntax changes.
         Old branch:
          - 2019-02-08: Fix inconsistent indentation
                in a few scripts.
          - 2019-06-13: Three simple syntax changes.
                Label ref: from ":label" to "@label".
                Subvalues: from within "[...]" to "{...}".
                Mul. op.b: from within "{...}" to "@[...]".
       * 2019-06-30: Update -p printout details
             to match June syntax changes.
       * 2019-08-07: Move back Makefile -ffast-math portability fix.
             Also update unusable 'devtests/newconcept' script.
         Old branch:
          - 2019-08-06: Fix parsing when -ffast-math breaks isnan().
                Only build some files with -ffast-math.
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-22: Merge composite timing fix.
       * 2020-02-09: num.exp. parsing:
             Fix result of several subtractions in succession.
       * 2020-07-13: Keep version at v0.2-beta.
      ecd1f13c
    • Joel K. Pettersson's avatar
      Change scope nesting syntax. Parsing and other fixes. · 5e995054
      Joel K. Pettersson authored
      Change scope nesting syntax from "<...>" to "[...]".
      ('<' and '>' are now unused. "[...]" is now used both for
      lists of objects, and arguments with several sub-values.)
      
      Bugfixes:
       * Numerical expression parsing:
         Fix really old bug which prevented evaluation
         of "Y" in an expression of the form "((X)Y)".
       * Parsing on systems where -ffast-math breaks NAN checks:
         Portability requires limiting the use of -ffast-math.
         (Only use -ffast-math for files with float-heavy code
         which needs performance and ignores non-finite values.)
       * WAV file output:
         Correct byte length in header,
         was channel-count times too large.
         (Avoid double multiplication.)
       * 'S a' (Set amplitude multiplier):
         Apply multiplier to amplitude valit/ramp target,
         not only the normal or initial value.
         (This was missed a long time ago.)
       * Fix edge case for composite event timing,
         adding and checking a flag for the existence of
         composite follow-ons before assigning infinite time.
      
      Add -v version number, initially at v0.2-beta.
      
      Change log:
       * 2018-12-21: Fix two outdated scripts in devtests/.
             Fix really old bug in parsing of numerical
             expressions with nested parentheses, which
             prevented "Y" in an expression of the form
             ((X)Y) from being evaluated.
       * 2019-06-05: Change scope nesting syntax
             from "<...>" to "[...]".
             Add -v version, initially at v0.3.0.
       * 2019-06-13: Set version to v0.2.3.
       * 2019-06-30: Update debug printout details
             to match June syntax changes.
       * 2019-08-07: Move back Makefile -ffast-math portability fix.
             Also update unusable 'devtests/newconcept' script.
         Old branch:
          - 2019-08-06: Fix parsing when -ffast-math breaks isnan().
                Only build some files with -ffast-math.
       * 2019-09-14: wavfile.c bugfix - avoid double multiplication:
             Correct byte length in header,
             was channel-count times too large. (Bug from 2012.)
       * 2019-12-21: Move back fix to apply 'S a' multiplier
             to valit/ramp target, not only initial value.
       * 2019-12-22: Add and check flag for composite event timing,
             to prevent assigning infinite time when a next composite
             exists.
       * 2020-07-13: Set version to v0.2-beta.
      5e995054
  8. 11 Jul, 2020 10 commits
    • Joel K. Pettersson's avatar
      Add/rename wave types. Change PM syntax. Reorganize scripts. · 0dca761e
      Joel K. Pettersson authored
      Change PM modulator list syntax from "p!<>" to "p*<>".
      Since semantics differ for PM lists vs. AM and FM lists,
      make this clearer in the syntax.
      (For PM lists, modulator amplitudes are summed,
      while for AM and FM lists, they are multiplied.)
      
      Split osc module into osc and wave. Wave type changes:
       * Add 'sha' (half-frequency absolute sine).
       * Add 'szh' (half-zero'd sine).
       * Add 'shh' (first quarter of sine).
       * Rename 'srs' (square root of sine) to 'ssr'.
      
      Move wave type names from parser to wave module.
      
      Reorganize example and test scripts. Move some old and useful
      scripts from devtests/ to examples/tests/. Rename scripts,
      add descriptions to some of them, modify a few, remove a few
      which are useless, and add more wavetype testing.
      
      Change log:
       * 2018-04-18: Move wave type names to osc module, add new
                     'sab' wave type, rename 'srs' to 'ssr'.
                     Reorganize and update example and test scripts.
       * 2018-06-02: Add 'shw' and 'shr' wave types, and
                     further LUT init code changes.
       * 2018-06-30: Split osc module into wave and osc.
       * 2018-09-12: Rename wavetypes
                     ("sab"->"sah", "shw"->"szh", "shr"->"szhhr").
       * 2018-09-27: Rename wave type 'sah'->'sha',
                     add 'shh', comment out 'szhhr'.
       * 2018-09-29: Rename debug #define switches in sgensys.h.
       * 2018-10-16: Update headers, heading comments, for added code.
                     Complete branch merging.
       * 2018-10-19: Change PM list syntax from "p!<>" to "p*<>".
       * 2020-07-11: Merge into current branch
                     to provide fuller history.
      0dca761e
    • Joel K. Pettersson's avatar
      Support sndio. Parser & "program" refactoring. · 409a76d6
      Joel K. Pettersson authored
      Support sndio and use on OpenBSD. Fixes audio on newer OpenBSD.
      Clean up the Linux audio code. Improve audiodev error messages.
      
      Program & parser changes:
       * Rework the SGSNodeList parser code into the SGSPtrList
         type, split out into the ptrlist module.
       * Return parser result in new SGSParserResult type. Add
         parser module method for destroying it, instead of it
         being implemented in program module. Add missing list
         clearing.
       * Rename voice and operator parameter flags
         from SGS_* to SGS_P_*.
      
      Further edit usage notice.
      
      Makefile changes: compile with -std=c99,
      add missing header dependencies.
      
      Change log:
       * 2018-02-16: Renamed voice and operator parameter flags
                     from SGS_* to SGS_P_*.
       * 2018-02-19: Split out ptrarr module from parser, reworking
                     node list code and its uses.
       * 2018-02-20: Makefile changes:
                     add -Werror=implicit-function-declaration,
                     list more header dependencies.
       * 2018-03-10: Change ptrarr to work more like old nodelist,
                     re-adding case for < 2 items and needed macros.
       * 2018-08-23: Makefile: use -std=c99. Adjust audiodev.
       * 2018-09-09: Add sndio support, use on OpenBSD.
                     Fixes audio on newer OpenBSD.
                     Move audiodev implementation files to audiodev/.
       * 2018-09-11: DragonFly portability fix:
                     On DragonFly, cannot build audiodev with
                     _POSIX_C_SOURCE defined (needed on Linux),
                     only define _POSIX_C_SOURCE on Linux,
                     in audiodev.c instead of in Makefile.
       * 2018-09-20: Replace ptrarr with cleaned-up ptrlist.
                     Fixes and clean-ups for parser, program,
                     as well as some addititional tidying.
       * 2018-10-12: audiodev code tidying, and
                     fix typo which broke Linux build.
                     Some further code tidying.
       * 2019-04-18: Merge into current branch
                     to provide fuller history.
       * 2019-04-26: Remove useless uint typedef.
      409a76d6
    • Joel K. Pettersson's avatar
      Use modern types. Rework osc. Handle audiodev srate changes. · e95dc1f8
      Joel K. Pettersson authored
      Use stdint.h and stdbool.h types instead of ushort, uchar,
      and uint (and usually int) throughout all code. Universally
      use 32-bit IDs and counters for voices and operators.
      
      Rework the oscillator module:
       * Increment phase after each sample instead of before.
       * Move wave type enum (SGS_WAVE_*) to osc.h, use to
         index array of LUTs.
       * Replace extra value at end of LUTs with use of bitmask.
         Bump LUT values from 1024 to 2048.
       * Correct saw wave LUT initialization off-by-one
         indexing error. Also improve init code for other LUTs.
       * Remove unused SGSOsc_RUN*() variants.
         Renamings, a few new macros, improved comments.
       * Add wave type test script, examples/test-wavetypes.sgs.
      
      Remove math.h SET_I2FV() macro (x86/x86-64 fast float-to-int
      rounding). Replaced with lrint()/lrintf(), which nowadays is
      inlined to fast code when compiling with -O > 0
      and -ffast-math. This removes all inline assembly.
      
      Change audiodev and main module, retrieving and using modified
      sample rate when changed by the audio device. Handle resulting
      difference in sample rates for device and file outputs by
      generating audio twice if needed. Also improve audio
      output-related error and warning messages. Tweak usage notice.
      
      Split sgensys.h into sgensys.h (common type definitions),
      generator.h (new) and program.h (relevant lines moved over).
      
      Also rename some functions, do minor refactoring, improve
      commenting here and there.
      
      Change log:
       * 2017-12-03: Replace types in many cases. Quick first pass.
                     Remove sgensys.h. Program module still largely
                     not updated.
       * 2018-02-05: Replace more types. Rewrite and readd sgensys.h.
                     Rename some functions. Minor refactoring.
                     Improve audio output handling. Program module
                     updated.
       * 2018-02-06: Oscillator module changes. Use SGS_WAVE_* enums
                     to index LUTs. Correct saw wave LUT. Inc phase
                     after sample instead of before. Renamings, macro
                     clean-ups.
       * 2018-02-08: Undo minor changes for SGSNodeList (parser) that
                     are better redone with a real redesign. Rename
                     a few more functions. Tweak messages in sgensys.c.
       * 2018-02-09: Remove math.h inline assembly, leaving none.
       * 2018-02-19: Replace a ';' with a ',' in heading comments.
       * 2018-02-22: Extend oscillator LUTs to 4096 values from 1024.
                     Some further renamings, init code improvements,
                     and smaller macro improvements.
                     Update COPYING file. (FSF link updates.)
       * 2018-02-23: Add examples/test-wavetypes.sgs.
       * 2018-03-14: Fix allocation size in generator.c. Use
                     offsetof(), avoid allocation failure which
                     resulted from unsigned value wrapping around
                     upon (zero flag count - 1).
       * 2018-09-27: Reduce osc LUTs to 2048 values (no point in
                     4096 with 16-bit int and lerp). Some more
                     osc module tidying.
       * 2019-04-17: Merge into current branch
                     to provide fuller history.
      e95dc1f8
    • Joel K. Pettersson's avatar
      Disable lexer testing. Clean-ups and portability fixes. · 01087e78
      Joel K. Pettersson authored
      Disable test lexer and re-enable normal output by default,
      adding a #define switch in sgensys.h to switch between the
      old parser and the test lexer.
      
      Some clean-ups for the test lexer, symtab code, and
      other parts of the program. Make the test lexer handle
      line comment ('#'), and change its buffered reading to
      make multiple character ungetting possible.
      
      Portability fixes:
       * Makefile and linking: Correct sh syntax.
         Check in Makefile for three uname -s cases:
          - Linux
          - OpenBSD or NetBSD
          - other ("generic UNIX")
         Unbreaks building on FreeBSD and DragonFly.
         Also reorder linking CC args for portability.
       * ALSA: Add missing call to snd_pcm_drain().
      
      Re-remove GNUmakefile and simply use Makefile.
      
      Change log:
       * 2017-11-27: Some cleanups for lexer and symtab modules.
                     Add debug #define for hash table in symtab.c
                     (for testing collisions).
       * 2018-01-21: Make lexer handle line comments ('#').
                     Source fix for ALSA.
                     Correct Makefile sh syntax
                     and reorder CC args for linking.
       * 2018-02-04: Fix program.c typo / memory init bug.
       * 2018-02-08: Only include LFLAGS addition
                     for OpenBSD and NetBSD on those systems.
                     Unbreaks building on FreeBSD and DragonFly.
       * 2018-02-12: Change buffered reading in the lexer.
       * 2018-02-13: Rearranging of and renamings in lexer code.
                     Add debug #define for lexer (for silent-enough
                     output to measure time to process file).
                     Move debug #define switches to sgensys.h.
       * 2018-02-14: Disable lexer, re-enable parser and output.
                     Insert #define switch in sgensys.h to toggle.
       * 2018-02-19: Replace a ';' with a ',' in heading comments.
       * 2018-02-22: Update COPYING file. (FSF link updates.)
       * 2018-05-01: Replace README with rewritten version from
                     04-16. Similar to newer versions, but with
                     references to added features removed.
       * 2018-09-19: In program.c, remove two unused functions,
                     and two useless conditionals, one broken.
       * 2018-10-25: Fix parser string matching bug
                     (not impacting the current uses).
       * 2019-01-19: Complete branch merging.
                     Correct README wording in one place.
                     Re-remove GNUmakefile and simply use Makefile.
      01087e78
    • Joel K. Pettersson's avatar
      2014-10-12: Test lexer branch. (Revert previous.) · 270a4e3d
      Joel K. Pettersson authored
      Add quick test version of a lexer module, used
      in place of the parser. (Normal output is disabled.)
      Experimental work towards loose plans for
      a new scripting language and a fuller redesign.
      
      Beginning of new symbol table implementation.
      Implemented string pool/string interning with a simple
      hash table. Used by the test lexer but not integrated
      with the old code.
      
      Added memory pool module (mempool.c), used for string
      storage in the new symbol table code. It is meant for
      large numbers of small allocations. Internally they are
      stored in arrays sized after the system's memory page size.
      Upon destruction, everything stored is freed.
      
      Fix build on OpenBSD (and NetBSD) using conditional
      compilation in audiodev_oss.c and an LFLAGS addition.
      (Note: This broke building on DragonFly and FreeBSD,
      fixed in newer versions.)
      
      (The .gitignore file is replaced with that used for
      all old snapshots.)
      
      Change log:
       * 2014-09-18: First quick test version of lexer module.
       * 2014-09-20: Add new symtab code. Add mempool module.
                     Second quick test version of lexer module.
                     Replace normal output with lexer testing.
                     Implemented string interning for symtab.
       * 2014-10-11: Portability fix for OSS on OpenBSD and NetBSD.
       * 2014-10-12: Mempool module debugged.
                     Test hash collisions in symtab module.
                     Third quick test version of lexer module.
                     Add GNUmakefile with debug build options.
      270a4e3d
    • Joel K. Pettersson's avatar
      2014-10-05: Redesign draft branch. (Non-functional.) · 8f117b56
      Joel K. Pettersson authored
      Non-functional draft for redesigning the
      program module and audio generator. The
      idea is to traverse the voice and operator
      graphs before the generator, assigning
      block IDs for the generator audio I/O
      buffers before they are used.
      
      The old design limits what the generator
      is able to do, preventing full implementation
      of the existing script syntax. Buffer IDs
      properly pre-assigned would allow the
      generator to run through a flat list of what
      to generate, output buffers being filled and
      re-used as inputs in the pre-scheduled order.
      
      (The 2013 version of program.c re-added as an
      extra file, the extra/earlier 2014 version in
      the 2014 snapshot renamed.)
      
      Change log:
       * 2013-08-05: Redesign sketch #1 (non-working)
                     for program & generator.
       * 2014-10-05: Redesign sketch #2 (still non-working)
                     for program.c, and minor change in parser.c.
      8f117b56
    • Joel K. Pettersson's avatar
      2013-08-03: Add ALSA support. "Program" fix. mv tests/. · 28a57638
      Joel K. Pettersson authored
      Add ALSA support, splitting out system audio support
      from the main module to the new audiodev module.
      Further rework main module, expanding command-line options.
      
      Indentation style changed to tabs in new code, as well as
      the wavfile module. (Having planned redesigning of sgensys,
      the indentation style was changed to tabs for new or "clean"
      modules after this, while those to be rewritten or further
      reworked still use 2 spaces.)
      
      Moved tests/ to devtests/. (This snapshot contains the
      scripts missing in and readded to the last 4 snapshots.)
      
      Change log:
       * 2013-02-28: ALSA support added. Reworked sgensys.c.
                     Reindented sgensys.c, audiodev and wavfile
                     modules.
       * 2013-03-04: Add -c command-line option to stop after
                     processing a script, before sound generation.
                     Re-add tests/ as devtests/.
       * 2013-08-03: Add '.' to heading comments.
      28a57638
    • Joel K. Pettersson's avatar
      2012-04-02: "Program" bugfix. · 7f156e91
      Joel K. Pettersson authored
      Program module: Skip calling operator_alloc_inc() for multiple
      operator nodes, as used for the '{}' syntax. Fail crashlessly.
      7f156e91
    • Joel K. Pettersson's avatar
      2012-04-01: [Release] Bugfixes and further work on "program". · 3b35ef2e
      Joel K. Pettersson authored
      Program module: Rework output event and operator allocation.
      Handling of nodes for multiple operator binding still missing.
      
      Sound generator: Place voice update code after operator update
      code, since buffer calculations take place during voice updates
      and may be altered by operator updates.
      
      (Originally released at Gna! as sgensys-20120401.tgz, without
      tests/.)
      3b35ef2e
    • Joel K. Pettersson's avatar
      2012-03-28: Operator alloc. after parse. · e660574b
      Joel K. Pettersson authored
      Assign operator IDs after parsing rather than during, adding
      operator allocation code analogous to the voice allocation code
      for "program" construction.
      
      Parser: Also remove an unneeded scope conditional
      for multiple operator binding.
      e660574b
  9. 09 Jul, 2020 13 commits
    • Joel K. Pettersson's avatar
      2012-03-08: Rework "program" output event allocation. · 973696c6
      Joel K. Pettersson authored
      Output event allocation reworked, maintaining a list of all
      events and eliminating the counting pass for operators which
      was used to determine the number of events.
      973696c6
    • Joel K. Pettersson's avatar
      2012-03-05: [Release] Further work on parser and "program". · 262c00af
      Joel K. Pettersson authored
      Make SGSNodeList more elaborate and refactor parser and
      "program" using it. Further parser changes for the unfinished
      multiple operator binding feature. As-yet unused beginning of
      "program" code to more fully handle operator allocation.
      
      Sound generator timing fix.
      
      (Originally released at Gna! as sgensys-20120305.tgz, without
      tests/.)
      262c00af
    • Joel K. Pettersson's avatar
      2012-02-26: Fixes, part 4. Source licensing info added. · dedbff7d
      Joel K. Pettersson authored
      Parser fix for added, incomplete multiple operator
      binding feature, and minor refactoring.
      
      Copyright notices and LGPL-3.0+ info added to source files.
      (README.COPYRIGHT, added to this repository for earlier versions
      lacking this, removed with this commit.)
      
      tests/ script changes. (Taken from later working dir because tests/
      missing in tarball, but no scripts dated later than 2012-02-20.)
      dedbff7d
    • Joel K. Pettersson's avatar
      8da606ba
    • Joel K. Pettersson's avatar
      2012-02-07: Fixes, part 3. · 4ed175b9
      Joel K. Pettersson authored
      Parser fixes and minor refactoring.
      
      Sound generator fix for handling of voices and panning.
      4ed175b9
    • Joel K. Pettersson's avatar
      2012-02-01: Fixes, part 2. Bugs. Fix and move test scripts. · 01439e36
      Joel K. Pettersson authored
      Parser fixes for new design and timing.
      
      Sound generator corrected, adjacency indexing
      was outdated (only changed elsewhere).
      
      Update remaining scripts with outdated syntax.
      Script files in main dir moved to "tests/".
      01439e36
    • Joel K. Pettersson's avatar
      2012-01-23: Fixes, part 1. Infinite (linked) modulator time. · 1fd7f9bf
      Joel K. Pettersson authored
      Add and use 'ti' (infinite time) for nested operators by
      default. Such operators play whenever their carrier(s) do.
      This change was deemed the best solution for allowing both
      carrier-linked modulator duration and, cleanly, shorter.
      
      Parser: More changes related to new design and to timing.
      
      Some script changes, including update a few with outdated
      syntax.
      
      Larger README update.
      1fd7f9bf
    • Joel K. Pettersson's avatar
      2012-01-12: Redesign. Readd '{}' op. bind. Syntax changes. · 9f90c1f1
      Joel K. Pettersson authored
      Some parser refactoring and experimental changes.
      Re-enable planned operator binding '{}' syntax,
      change nesting syntax to '<>'. Reorder code.
      
      Fix for voice allocation.
      
      Move string copying out of symbol table,
      make it simply store pointer.
      
      Syntax changes:
       - Use '<>' to list modulators rather than '{}', as in
         'a!<...>', 'f!<...>' or 'r!<...>', or 'p!<...>'.
       - Remove '-' syntax for PM modulators. Replaced with 'p!<...>'.
       - Add '{...}' for binding several operators as one object to
         manipulate. Used to e.g. link several carriers to one or more
         modulators.
      
      Update various test scripts.
      9f90c1f1
    • Joel K. Pettersson's avatar
      2011-12-13: Voice alloc. after parse. Syntax change. · ac8dee74
      Joel K. Pettersson authored
      Allocate voices after parsing, instead of trying to
      track and assign voice IDs during. Merge VoiceData into
      EventNode.
      
      Script syntax: Rename 'b' (panning, applies to the voice) to 'P'.
      ac8dee74
    • Joel K. Pettersson's avatar
      2011-12-04: Undo parser redesign, postpone '{}' op. bind. · d3ba21fc
      Joel K. Pettersson authored
      Undo the 2011-09-26 redesign, preserving some of the new code
      and further updating the parser, while postponing support for
      the new '{}' operator binding syntax.
      
      Improve comments for sound generator, tiny code style clean-up.
      d3ba21fc
    • Joel K. Pettersson's avatar
      2011-11-27: New '{}' operator binding syntax, part 2. · ecf4ce9f
      Joel K. Pettersson authored
      Further parser changes to support new '{}' operator
      binding syntax.
      
      Sound generator clean-up. Improve comments.
      ecf4ce9f
    • Joel K. Pettersson's avatar
      2011-10-11: New '{}' operator binding syntax, part 1. · eebea39d
      Joel K. Pettersson authored
      Initial work to support new '{}' syntax for binding operators
      together as a single object. This is to allow carrier-modulator
      linkages to be M:N, and not just 1:N (as in adding a list of
      modulators to a single carrier).
      eebea39d
    • Joel K. Pettersson's avatar
      2011-09-26: Parser redesign. Complete sound buffer counting. · c868b3fb
      Joel K. Pettersson authored
      Redesign parser, changing NodeData and its uses and replacing
      *_event(), *_voice(), *_operator() functions with restructured
      code. Big refactoring, breaking out various smaller nd_*()
      functions. Add and use NodeList type.
      
      Flesh out sound buffer counting in sound generator.
      c868b3fb