1. 21 Jun, 2021 5 commits
    • Joel K. Pettersson's avatar
      Simplify down voice handling closer to parser end. · d53a6064
      Joel K. Pettersson authored
      Move pan field from voice/event data to op data nodes
      (before the interp/prealloc types). In parser, only add
      one carrier per event. The changes combine to fix the
      old pan bug giving several operators on the same line
      in one go the same value (setting it for one setting it
      for all). Thus, now truly works like mgensys 2020-06.
      Remove voice parameters, except in program.h types, where
      SAU_PVOP_GRAPH is needed to pass info to interp/prealloc.
      Simplify back fairly recent parseconv/scriptconv tracking
      and fields a little.
      Re-enable disabled call in parser to
      split an op. event after time shift.
    • Joel K. Pettersson's avatar
    • Joel K. Pettersson's avatar
      Refactor audiodev module more. · 5c19ef1b
      Joel K. Pettersson authored
    • Joel K. Pettersson's avatar
      Support AUDIODEV env variable. · 24c2b5f5
      Joel K. Pettersson authored
      Check for the AUDIODEV environment variable,
      using it to override the default device name
      regardless of which type (ALSA, OSS, ...) is
      used. Similar to handling in other software,
      e.g. SoX and SDL. Empty strings are ignored.
      For OSS only, also check OSS_AUDIODEV if the
      AUDIODEV variable wasn't used, or "default".
      Credit to Art Nikpal (@hyphop at GitHub) for
      the basic idea, and SoX code as a reference.
      Further refactor player/audiodev code a bit.
      Update man page.
    • Joel K. Pettersson's avatar
      Add man page. Split README. Makefile changes. · bf12b99d
      Joel K. Pettersson authored
      Add a saugns(1) man page for installation.
      Split README into README and doc/README.SAU,
      the latter installed under share/doc/saugns/.
      Install examples/* to share/examples/saugns,
      instead of share/saugns.
      Several possibilities exist for where the
      man page should be added/removed. Do something
      very simple and hopefully sensible:
       * If "man" exists under the install/uninstall
         prefix, use it.
       * Else, go with "share/man" under the prefix.
      Some systems (e.g. OpenBSD) do not use compressed
      man pages for official packages, while others do.
      Add simple check for this less significant detail:
       * If "/usr/share/man" exists,
         compress man page if and only if
         it contains compressed man page(s).
       * Else, compress man page if and only if
         install location contains compressed man page(s).
      Change log:
       * 2019-09-07: Add a man page for installation.
             Split README into README and doc/README.SAU.
             Install examples to share/examples/saugns,
             and doc to share/doc/saugns,
             instead of examples to share/saugns.
       * 2019-09-09: Clean up man page.
             Move saugns.1 file to man/.
             Handle man dir possibilities
             more portably in Makefile.
       * 2019-09-13: Update README.
       * 2019-12-14: Handle whether or not to gzip man page
             upon install (always done before),
             according to whether the install location
             or "/usr/share/man" (takes priority if found)
             contains gzipped man pages.
       * 2019-12-21: Update 'doc/README.SAU' on "@label".
       * 2020-02-09: Update man page for simplified usage notice.
       * 2020-07-23: Update man page.
       * 2020-09-19: Update 'doc/README.SAU' on channel mixing.
       * 2021-01-08: Update README to refer to website
             and mention permissive licensing of individual files.
       * 2021-06-20: Update README note on platforms.
  2. 18 Jun, 2021 21 commits
    • Joel K. Pettersson's avatar
      Rework '#' & 'Q' comment syntax. Reorganize scripts. · 88b6e8ef
      Joel K. Pettersson authored
      Syntax changes:
       - Change '#' line comment to '#!'.
       - Remove 'Q' (quit) keyword, re-add as '#Q'.
      Add and use '#'-override in parser. A start
      for implementing a simple preprocessor.
      Update README and scripts.
      Move some more contents from devtests/,
      and prune and and clean up a little.
      Add examples/sounds/, reorganize scripts
      in examples/ a little.
      Change log:
       * 2019-08-21: Change '#'-handling, replace old 'Q'.
             Add and use SAU_File_end() for '#Q'.
             Update README and scripts.
       * 2019-08-22: Debug file module changes, tidy up.
       * 2019-08-24: Further refactor file module.
             Now use SAU_Scanner_close() for '#Q',
             as SAU_File_close() now behaves as expected.
             Set version to v0.3.2.
       * 2019-09-12: Move file module refactoring
             down to v0.2.13, with finishing touch.
             Increase version suffix to 'b'.
       * 2019-10-08: Increase version suffix to 'c'.
             (Rebased on top of new v0.2.14.)
       * 2019-11-04: Reorganize scripts.
       * 2020-07-26: Keep version at v0.3-dev.
    • Joel K. Pettersson's avatar
      Scanner & parser clean-up. Macro renaming. · 635d8c6a
      Joel K. Pettersson authored
      Redesign scanner, and use the new way of
      filtering whitespace in parser. Further
      testing of line and char position numbering
      needed, but now better than it was in v0.3.0.
       * Add whitespace filtering level setting.
         Setting the level replaces the whitespace filtering
         functions in the table for the scanner instance.
       * Remove "nospace" versions of get/try functions.
         Simplify get function. Remove old space-skipping
         inline functions.
      Change naming of keyword-like macros to sauCamelCaseName:
       * Rename compiler attribute SAU__* macros.
       * Rename ArrType SAU_DEF_* macros.
      Change log:
       * 2019-07-07: scanner: Add ws filter level setting.
             Remove nospace versions of functions.
             Use next design. Consistent for filtering,
             even if changed. Clear up ws types naming,
             really fill in everything. Tidying.
       * 2019-07-09: Scanner flag fix.
             (Recommitted after fixing the fix.)
             Set version to v0.3.1.
       * 2019-07-11: Microflensing.
             scanner: Remove "RAW" (NULL-pointer) ws level,
             rename "PASS" to "ALL" and make it the default
             (instead of "RED1").
       * 2019-08-05: Place after new v0.3.0,
             with July syntax changes split out into v0.2.13.
       * 2019-08-06: FreeBSD portability fix:
             Fix parsing when -ffast-math breaks NAN checks.
             (Only build some files with -ffast-math.)
             Increase version suffix to 'b'.
             Move Makefile change down to v0.2.13.
       * 2019-08-15: Naming: SAU__* -> sau* (and make "*" CamelCase)
             mixer: add missing sauMalloclike
             Naming: SAU_DEF_* -> sau* (arrtype)
       * 2019-08-17: Remove scanner ws levels between ALL and NONE.
             (Not needed in current program.)
             Increase version suffix to 'c'.
       * 2019-09-12: Increase version suffix to 'd'.
       * 2019-10-31: (Rebased on top of new v0.2.15.)
       * 2019-12-24: Merge ramp and v0.2.5-related changes.
       * 2019-12-31: Add some missing sauMalloclike.
       * 2020-01-03: Merge arrtype changes.
       * 2020-01-04: Merge split voicegraph from scriptconv.
       * 2020-02-09: Refactor num.exp. parsing.
       * 2020-07-26: Keep version at v0.3-dev.
       * 2020-11-12: Merged changes obsoleting the following:
         Old branch:
          - 2019-07-29: parser: refactor scan_time() and its uses.
          - 2019-08-23: Add sauNoinline to scan_time().
          - 2019-08-24: Naming in saugns.c, test-builder.c.
          - 2020-07-23: Extract refactoring to
                use passed mempool in symtab, and symtab refactoring.
    • Joel K. Pettersson's avatar
      Rename project to 'saugns' from 'ssndgen'. · e817e54a
      Joel K. Pettersson authored
      Rename the program from 'ssndgen'
      to 'saugns' (Scriptable AUdio GeNeration System).
      Change SSG prefix to SAU throughout code.
      Rename scripts from *.sgs
      to *.sau, naming the language SAU (Scriptable AUdio).
      Update descriptions in README.
      Set version to v0.3-dev.
      Change log:
       * 2018-12-05: Rename to 'saugns'. Change SGS prefix to SAG.
       * 2019-01-21: Update for newer code. Change prefix to AGS.
       * 2019-01-22: Bump copyright years. Change prefix to SAU.
             Rename scripts from *.sgs to *.sau, polish README.
       * 2019-07-04: Update for newer code. Tag "v0.3.0".
       * 2019-08-18: Increase version suffix to 'b'.
       * 2019-12-25: Update for newer code.
       * 2020-01-03: Increase version suffix to 'c'.
       * 2020-02-09: Update for newer code. Tag "v0.3.6e-2".
       * 2020-07-26: Update for newer code. Set version to v0.3-dev.
       * 2020-10-21: Update to latest code, on top of new 'ssndgen'.
         Old branch:
          - 2018-10-25: Rename to 'ssndgen'. Change SGS prefix to SSG.
          - 2019-01-27: Fix inconsistent indentation in some files.
       * 2021-06-18: Update to latest code.
    • Joel K. Pettersson's avatar
      Add help module, expand -h with <topic>. Cli clean-up. · b86fc768
      Joel K. Pettersson authored
      Tweak usage notice for conciseness.
      Change the -h option to list topics
      available with -h <topic>. For now,
      only other lists are available, the
      first built-in help consisting of a
      'wave' type list and a 'ramp' list.
      Parser warnings now use the new code for
      listing valid items. But a meta-list, of
      the lists to be available with -h, needs
      manual extension in help.c when more are
      added. All lists are in the same format.
      Change cli argument parsing to allow a flag to be followed
      by its argument without a space in-between. Recognize "--"
      as meaning no further strings are flags. Uses SSG_getopt()
      derived from Christopher Wellons's public domain getopt().
      Should fix the old cli non-POSIX annoyances & limitations.
      Change log:
       * 2020-01-18: Add help module, expand -h.
             Simple code for printing out name array,
             used for wave module. Easily extended to
             print out more lists in the same format.
       * 2020-02-16: Split out "Common options" usage line.
       * 2020-07-23: Move to saugns
             from the 2020-06 "mgensys" experiment.
             Replace 'noise' help type with 'ramp'.
         Old branch:
          - 2020-02-10: Add noise module with noise names,
                and add help type.
       * 2020-11-20: Move to ssndgen v0.2-dev.
       * 2020-12-20: List 'help' help type in itself.
             Change -h to also list normal usage info
             unless a topic is named.
       * 2021-01-08: Add SSG_getopt() and use in ssndgen.c.
             Change common module license from ISC to 0BSD.
             Add and use SSG_IS_ASCIIVISIBLE() from parser.
             Point the user to pass -h on cli option error.
    • Joel K. Pettersson's avatar
      Makefile changes. Rework ramp module. Improve performance. · 6039eef5
      Joel K. Pettersson authored
      Makefile changes to selectively use -O3.
      Following benchmarking (repeated running
      of example/ scripts with -m to time it),
      this can have a benefit anywhere from no
      to more than 42%, depending on compiler,
      etc. (It seems to matter more with GCC.)
      Use -Os where it matters most, currently
      the parser; remove SSG__noinline from it
      as it's then (finally) no longer needed.
      Move ramp mulbuf use into fill functions
      (and clean up their code a bit). Impact?
      From none on some systems to turning a loss
      with -O3 around into an above-10% speed-up,
      on an older OpenBSD laptop with clang 10.0.
      Always handle/allow NULL mulbuf in ramp.
      (Note: Moved down after benchmarks using
      v0.3.8 saugns scripts. Different scripts
      e.g. the old, would change the numbers.)
      Change log:
       * 2021-01-12: Makefile changes to selectively use -O3 and -Os.
             ramp: Move mulbuf use into fill functions, improving the
             performance with clang 10. SSG_Ramp_run() mulbuf NULL
             checks to allow calls with missing mulbuf in the future.
       * 2021-01-15: Add noinline attribute for SSG_Ramp_fill_hold(),
             document necessity with clang where inlining hurt x86
             performance (costing half the 10% speed-up on the laptop
             with i386 OpenBSD, fixed with the use of SSG__noinline).
       * 2021-01-16: Tidy ramp.c and correct the comment on clang.
    • Joel K. Pettersson's avatar
      Tweak parser design. Fix timing bug. Revise mempool again. · 4c1a9875
      Joel K. Pettersson authored
      Simplify memory handling by using the mempool
      for all allocations of parse data nodes. This
      allows removal of all freeing traversal code.
      Change parser and post-parse group-from/to to
      mgensys 2020-06-style parse duration sub-node
      holding equivalent pointers, with cleaner use
      in parser. Fix for the test defaulttime2.sgs.
      Resolves "todo" about timing and that bug,
      though there's more to do to replace voice
      handling in the parser, and more redesign.
      Except for a small performance boost, the mempool has been
      much the same since 2014, until now. Change to use dynamic
      sizing of memory blocks, double the size after every power
      of two block count reached. Use 512 as default start size.
      Performance seems basically unchanged running my old test.
      (Changes probably cancelled out as fewer blocks are made.)
      Change log:
       * 2019-11-11: Set version to v0.3.4-beta.
       * 2019-12-02: Set version to v0.3.4.
       * 2019-12-03: Use mempool in parser
                for all parse result allocation.
                Increase version suffix to 'b'.
       * 2019-12-30: Remove unused SAU_ScriptOpData label field.
       * 2020-07-26: Keep version at v0.3-dev.
       * 2020-12-21: Reduce to parser and script.h changes only.
       * 2020-12-22: Move down to ssndgen v0.2-dev.
       * 2020-12-28: Use mgensys 2020-06-style parse duration
             sub-node for timing, devtests/defaulttime1.sgs now
             works. Remove 2011 TODO item and file in notes/.
       * 2020-12-29: Move devtests/defaulttime*.sgs
             to examples/tests/, comment the expected behavior.
       * 2021-01-10: Flatten types in mempool. Refactor to place
             new allocation pointer array for freeing separately
             and change sizing per block, inceasing it once each
             new power of two number of blocks has been reached.
       * 2021-01-12: Tweak mempool. Adjust mempool heuristic for
             skipping fully-used blocks to increase threshold if
             proportion below 2/3 of blocks and increase default
             block start size from 128 to 512. Simplify away the
             extra pointer per block and separate array, growing
             allocations downward instead.
    • Joel K. Pettersson's avatar
      Move some logic from parser to parseconv, refactor more. · 068a61a1
      Joel K. Pettersson authored
      Separate enums and flag handling
      for parse data types and resulting script data types.
      As part of this, replace the setting in the parser of
      LATER_USED flags with handling in parseconv. Changes:
       * Remove code to set LATER_USED flags from parser.
       * In parseconv, keep track of previous data node
         for each operator and voice time-wise. Build a
         flat prev_use and next_use list for operators,
         and the equivalent in event nodes for voices.
      Also refactor scriptconv and program.h types:
       * Remove the SSG_POPP_ADJCS flag (done "todo"),
         replacing all checks using other information.
       * Include prev pointer for program voice and op
         data nodes. Use to distinguish changed fields
         not covered by parameter flags.
       * All op list (e.g. modulator) pointers are now
         non-NULL in program nodes.
      Note: This version fixes the v0.3.6 scriptconv changes
      for no ADJCS flag, the tagged version ignored clearing
      of modulator lists in scripts.
      Todo: The old, handle nodes representing multiple
      operator objects. For now, move flag handling
      and bailing out from scriptconv to parseconv.
      Add 'devtests/ref-unused_node.sgs' to test handling of
      updates to operators removed in the same event in which
      they were introduced. Leave this test in though filtering
      away of such operators is skipped in this re-done version.
      Change log:
       * 2019-12-07: Set version to v0.3.5-beta.
       * 2019-12-11: Move LATER_USED flag setting to parseconv,
             part 1. Remove from parser. In parseconv, add array
             to track "context" of operator data; set flags and
             also change op_prev to point to time-wise previous
             in output (instead of parser-assigned previous).
             Causes crash, debugging remains.
       * 2019-12-12: Fix crash (due to invalid use of pointers
             to array entries realloc'd after). Replace array
             with use of mempool borrowed from converted parse.
             Simplifies the added code.
             Set version to v0.3.5.
         Old branch:
          - 2019-12-11: Move LATER_USED flag setting to parseconv,
                part 2. Use same type of handling for event data,
                allowing setting vo_prev according to linearized
                event list. Crash still not debugged.
       * 2019-12-13: Separate script data flags
             from parse data flags.
       * 2019-12-22: Check in parseconv for updates for operator
             nodes which weren't processed before (because the list
             in which they were created was cleared in the same
             event), ignoring such nodes. Fix crash in versions
             v0.3.5 and v0.3.5b. Merge composite timing fix.
             Add 'devtests/ref-unused_node.sau', which tests this.
       * 2019-12-26: Remove SAU_POPP_ADJCS flag,
             replace checks using other information.
       * 2019-12-27: Set version to v0.3.6.
       * 2020-07-26: Keep version at v0.3-dev.
       * 2020-10-08: Re-apply after splitting out change still
             using the old ptrlist module and moving down most
             redesign, except the SAU_POPP_ADJCS flag removal.
       * 2020-12-22: Move down to ssndgen v0.2-dev, redoing it
             with some changes. (A bit simpler, and refactor.)
             The filtering away of unused operators is absent.
       * 2020-12-23: Use program op data prev field to make -p
             printouts terse again, given all op list pointers
             now non-NULL. (Now again list modulator list when
             non-blank and changed in update or operator new.)
       * 2020-12-28: Allow parseconv to include update nodes
             for carriers in opgraphs, now currently unused.
    • Joel K. Pettersson's avatar
      Change panning/channel mixing syntax. Parser clean-up. · cb103d0b
      Joel K. Pettersson authored
      Syntax changes:
       * Replace panning 'P' keyword with channel mixing parameter
         'c' and 'S c' for default. The scale changes from 0.0-1.0
         left-right to (-1.0) left, 0.0 center, 1.0 right. And the
         letters 'C', 'L', and 'R' become named constants for 0.0,
         (-1.0), and 1.0.
      The panning or "channel mixing syntax" is now the same as in
      the 2020-06 "mgensys" version, replacing the 'P' (2011-12-13)
      syntax and earlier 'b' (2011-04-10) variant.
      Adjust SSG_Scanner_getd() to call a callback if provided for
      named constant reading, using this both for the new channel
      C/L/R constants and the old note syntax code after conversion.
      Update README.
      Change log:
       * 2020-08-25: Add, use parameter flag masks.
       * 2020-09-18: Rebase, tweak previous change.
       * 2020-09-19: Refactor parser scan_ramp() to
             handle both multi-value and state cases.
             Add callback to SAU_Scanner_getd() for named constants.
             Port 2020-06 "mgensys" channel mixing syntax.
             Move devtests/panning.sau to examples/tests/.
             Update README.
       * 2020-09-21: Tidy up changed scanner code.
             Add handling for sign before named constant.
             (Redone for consistency, not currently used.)
       * 2020-10-03: Make scanner always call numconst_f when given,
             simply check return length. Remove useless warning when
             note syntax callback called for non-note characters.
       * 2020-12-21: Move down to ssndgen v0.2-dev.
    • Joel K. Pettersson's avatar
      Add reflist module, use for script.h types. · 452c99da
      Joel K. Pettersson authored
      Import nodelist module from saugns v0.3.6d,
      change to make doubly linked,
      allow dropping the last item,
      count items, and more tweaks.
      Rename to reflist and license permissively.
      This heavier list was grown from now-replaced parser types
      for each of the lists of operator data nodes. Using a list
      type and a generic reference item type with each reference
      item pointing to a separate data node, all allocations for
      the list itself use the mempool.
      Use reflist module in parseconv.
      Make parseconv handling of node sublists more generic,
      deal with specific modulator lists only in scriptconv:
       * Include a linked mod_lists list in script data,
         with one list per parse data nest_scopes scope.
       * Loop through lists in scriptconv, keep the last
         per modulator use type per node, use on update.
      All data from parseconv is now held in a mempool.
      Change log:
       * 2020-01-20: Add nodelist from saugns v0.3.6d.
             Adjust the nodelist code.
         Old branch:
          - 2019-12-01: For parser, use new op ref type,
                op list wrapper type, instead of ptrlist.
          - 2019-12-02: Move label and link_type fields
                to op ref type, and refactoring.
                Set version to v0.3.4.
          - 2019-12-20: Split out some functions
                in parser & parseconv.
                Split op ref link type into
                op list type and op ref mode.
          - 2019-12-21: Clean up, and changes
                moved back for v0.3.5b.
          - 2019-12-22: Rebase after v0.3.5c.
                Set version to v0.3.6-beta.
                Further reduce differences.
                Tidy up new code in parser.
          - 2019-12-29: Turn (v0.3.6-beta2) parser
                op list and ref code into nodelist module.
                (Not to be confused with the really old code
                which was reworked into ptrarr, a.k.a. ptrlist).
       * 2020-01-28: Expand nodelist, make it doubly-linked,
             add drop function mirroring the add function.
             Add item count (for convenience) to nodelist.
             Drop the new_refs field, use a flag for shallow status.
       * 2020-02-10: nodelist: Change unshallow
             to allow truncating copy.
       * 2020-12-02: Move to ssndgen v0.2-dev
             from the 2020-06 "mgensys" experiment.
       * 2020-12-15: Rename to reflist, change naming in the code.
       * 2020-12-21: Freshly and minimalistically change parseconv
             (and scriptconv) to use reflist in place of ptrarr in
             script.h types.
       * 2020-12-22: Tidy, minor changes for correctness.
       * 2020-12-24: Merge more simply redone changes to move the
             logic for specific modulator lists from parseconv to
         Old branch:
          - 2019-12-30: Set version to v0.3.6b.
                Extend the v0.3.6 redesign another logical step,
                making parseconv handling of operator sublists
                generic, moving specifics to scriptconv.
          - 2019-12-31: Move the new comment on op list updates.
                Adjust comment on ignored nodes in parseconv;
                nodes in unused lists are no longer optimized away.
                Set version to v0.3.6c.
          - 2020-07-26: Keep version at v0.3-dev.
          - 2020-12-04: Merge parser & parseconv refactoring.
                Preserve re-added list filtering in parseconv,
                as shown with -p on 'devtests/ref-unused_node.sau'.
          - 2020-12-24: Simplify & remove parseconv list filtering.
    • Joel K. Pettersson's avatar
      Use the new scanner. Extend comment syntax. Clean-up. · 30075723
      Joel K. Pettersson authored
      Make the test scanner functional for use in the parser
      and change the parser to use the scanner module.
      (The scanner is now also used in the test lexer,
      replacing much of it.)
      C-style and C++-style comments are now supported
      (in addition to '#' line comments and the use of 'Q').
      The parser's old PScanner and warning printouts are
      replaced. Warnings now provide not only line, but also
      character, numbering. Most direct use of the file module
      is replaced. String and number reading is also further
      Scanner design changes include:
       * Flesh out design for tracking line and character positions.
         A fixed number of multiple ungets in a row are supported,
         using a circular buffer for scan frames, advanced each get.
       * Add pointer parameter to warning/error message functions
         for optionally overriding position info. (E.g. copy earlier
         position, use it when warning after more scan calls.)
       * Add number-reading functions (wrappers around those of
         the file module).
       * Add further space-skipping reading functions.
      Further refactoring:
       * Always check for NULL pointer in type
         destroy_*() functions, remove checks where called.
       * Minor code style changes for consistency.
      Use new comment styles in scripts.
      Change log:
       * 2019-05-15: Use the new scanner.
             Initial merge after changes as of v0.4.4.
             Adapt: Preserve use of symtab in scanner,
             remove wrapper function around string reading
             in parser. Let scanner handle file opening,
             replacing v0.4.1 additions in builder.c.
             Some comment and code clean-ups.
         Old branch:
          - 2018-12-17: scanner: Some renaming and clean-ups.
                Add, use, flag for overwriting scan frame next get.
          - 2018-12-18: scanner: Add advance_frame(), used to
                handle scan frames for symbol string reading.
          - 2018-12-19: Use scanner module in parser.
                Add SGS_Scanner_geti(), SGS_Scanner_getd().
                Debug line and char numbering.
                Move symtab use from scanner to parser,
                move string buffer from scanner to parser,
                refactor string reading in parser.
                Rename SGS_Scanner_unget()
                back to SGS_Scanner_ungetc().
                Add quick handling for unfiltered characters
                to SGS_Scanner_tryc() and SGS_Scanner_tryc_nospace().
                Move reading of SGS_SCAN_C_LNBRK
                flag out from SGS_Scanner_tryc_nospace().
                Add scanner statistics printing #define
                to common.h and #if'd counters in scanner.c.
                Refactor parser time number scanning.
                Further clean-ups in parser.
          - 2018-12-21: Comment and other minor clean-ups.
                Update README.
          - 2019-01-05: Complete branch merging.
                Use SGS_Scanner_getc_nospace() in parser.
                Clean up printing of no label warning in parser,
                silencing warning about non-const format string.
                Refactor parser uses of scan_symafind(),
                moving warning printouts into it.
          - 2019-01-09: Use scanner in lexer.
                Add SGS_SCAN_S_QUIET flag, use in lexer
                for SGS_LEXER_QUIET compile-time mode.
                Note: File module needs design change
                for safe unget, crash preventing code
                added to scanner in the meantime.
                Complete branch merging.
          - 2019-01-10: Complete branch merging.
                Remove obsolete debug code in scanner
                (file module now fixed).
          - 2019-01-11: Set version to v0.6.0.
                Clean-up in lexer. Use SGS_Scanner_getc_nospace().
          - 2019-01-15: Restructure parser code to
                reduce differences with previous version.
                No functional change.
       * 2019-05-17: Some tidying for last branch merge.
       * 2019-05-19: parser: Avoid duplicating code for name of
             script for string as file, copy name from file object.
       * 2019-05-24: Set version to v0.5.1.
             scanner: Name changes.
             in general: Always check for NULL pointer in type
             destroy_*() functions, remove checks where called.
             Minor code style changes for consistency.
       * 2019-05-28: Merge refactoring.
             Reindent parser.c (and adjust comments).
         Old branch:
          - 2019-02-08: Refactor parser warnings for
                EOF before closing character, and closing
                character without opening character.
       * 2019-06-04: Move refactoring back to v0.5.1,
             use old version number.
       * 2019-06-05: Merge parser diff after v0.2.3 syntax change.
       * 2019-06-07: Update debug script for too-long label
             for new scanner (new max length is 255).
       * 2019-06-13: Set version to v0.3.1.
       * 2019-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-06-20: Set version to v0.3.0.
       * 2019-06-30: Place after the split-out v0.2.12.
             Update comment style used in scripts.
       * 2019-07-04: Update for v0.2.12 'r' syntax change.
       * 2019-08-05: Update for v0.2.13 syntax changes.
       * 2019-10-08: Place after new v0.2.14.
       * 2019-10-31: Place after new v0.2.15.
       * 2019-12-21: Merge 'S a' multiplier apply-to-ramp fix.
       * 2019-12-22: Merge composite timing fix.
       * 2019-12-24: Merge changes related to v0.2.5 & v0.2.13.
       * 2019-12-25: Merge ramp default time changes.
       * 2020-02-09: Merge num.exp. fix for successive subtractions.
       * 2020-07-23: Merge renaming in ramp module.
       * 2020-07-26: Set version to v0.2-dev.
       * 2020-10-21: Move to ssndgen v0.2-dev, merge parser changes.
    • Joel K. Pettersson's avatar
      Rework parser scope handling, add a test syntax. · 04aaa753
      Joel K. Pettersson authored
      Make parser handling of data node scopes simpler
      and more generic, moving specifics to parseconv.
      Handle node sub-scope node lists by creating new
      lists when going down a level in the parser, and
      appending the resulting lists to the linked list
      for such in the current parent node:
       * Use a linked node scope type with node range and use_type.
       * Replace parse data pointers fmods, pmods, and amods,
         with nest_scopes, appending each new scope set to it.
       * For each update to an operator, the new parseconv
         code keeps the last modulator list set per type.
      Clean up parser code a bit further. Simplify away the
      SDPL_IN_* "location" enum, and some old parse_level()
      flags. Use a single function pointer for both roles.
      Syntax changes:
       * Allow use of '<>' as a generic subscope with few
         effects, similar to in older "mgensys" versions.
         Replaces the generic '[]' separate from the list
         parameters, added in v0.3.6 & removed in v0.3.8.
         Not yet documented and mostly for testing though
         seems mostly harmless; could be developed into a
         feature, with significant semantics, or dropped.
      Todo: Further reworking/complementing of ParseLevel
      fields and functions for data across nested scopes.
      One detail, replace ParseLevel last_event field and
      uses, with something properly designed for nesting.
      Change log:
       * 2019-12-24: Replace parse data pointers fmod_list,
             pmod_list, and amod_list, with nest_lists,
             making the op list type a linked list.
             All nodes are thus included by the simplified
             parser code, and sorted out into the specific
             lists by new parseconv code.
       * 2019-12-25: Rebase. Tidy up diff.
             Set version to v0.3.6-beta.
       * 2019-12-27: Tidy up some code.
             Add a few sauNoinline to functions. (In one case,
             parser end_event(), prevents clang from growing
             binary size after code simplification.)
             Make undocumented general use of '[]' subscope work.
             (A bug from 2012 resulted in broken event sequences.)
       * 2019-12-29: parseconv: Remove unneeded code.
             (The copy_op_list() call always set the olp pointer to
             NULL, so the list updating can be greatly simplified.)
       * 2020-07-26: Keep version at v0.3-dev.
       * 2020-12-04: Merge parser & parseconv refactoring.
             Redo the list design change for the parser using
             the new simpler code as a foundation. Use a linked
             wrapper type for the "node range" type. Differences
             are similar in size.
       * 2020-12-16: Move down to ssndgen v0.2-dev, simplify.
       * 2020-12-17: Tidy up scope handling a bit further in the
             parser code. (This version should fix parser memory
             leaks without using the mempool for its nodes yet.)
             Further simplify away the old "location" values,
             use a function pointer combining their role with
             the now-removed DEFERRED_* flags.
             Add '<>' to replace generic '[]'.
       * 2020-12-18: script.h: Use SSG_NodeRange
             for SSG_ScriptEvData op_all.
       * 2020-12-19: Tidy changes for parser a little,
             ensure behavior the same after 12-17 change.
       * 2020-12-26: Fix scope checks after '<>'-addition.
       * 2020-12-29: Rename SSG_NodeScope to SSG_ParseSublist.
    • Joel K. Pettersson's avatar
      Refactor parser and parseconv. · 9ee2718f
      Joel K. Pettersson authored
      Basic parser clean-up:
       * Refactor numerical expression parsing.
       * Fix bug in handling of deferred step.
       * Reduce differences with saugns v0.3.x.
       * Refactor ramp scanning and value flags.
       * Replace the NL_* flags with SSG_POP_*.
      Further refactor parser:
       * Replace ptrarr use with SSG_NodeRange and range_next pointer.
       * Include pointers to, not instances of, modulator lists.
       * Move copying of old modulator lists to parseconv.
       * Only include new, no copied, data in nodes.
      Move setting of the NEW_OPGRAPH and NEW_CARRIER
      flags from parser to parseconv.
      Parseconv optimization: Merge event flattening pass
      into event conversion pass.
      This is a simplified version of part of the v0.3.6 parser
      redesign. Instead of using a node list type with separate
      linked list, add a specialized type pointing to first and
      last nodes only, and include a next pointer in the nodes.
      Add 'devtests/pm-addremaddrem.sgs' (which
      tests adding and clearing PM modulators).
      Change log:
       * 2020-12-01: Parser no copy data, only include new.
       * 2020-12-02: Move down parser fix, adding a missing clear
             for the DEFERRED_STEP flag. (From v0.3.4 where error
             appeared if still missing.)
             Also move down refactoring,
             reduce diff, and go beyond:
         Old branch:
          - 2020-02-09: Refactor num.exp. parsing.
          - 2020-09-19: Refactor parser scan_ramp() to
                handle both multi-value and state cases.
       * 2020-12-04: Replace ptrarr in parser with
             simple SSG_NodeRange. Re-add ptrarr
             soft-copy logic in parseconv. Allocate
             parser's modulator "lists" when set. Fix bug tested by
             devtests/pm-addremaddrem.sgs, from v0.3.6b.
             Replace the NL_* flags with SSG_POP_*.
             Move down clean-ups from v0.3.4 and v0.3.5:
         Old branch:
          - 2019-11-01: Assign the NEW_OPGRAPH and NEW_CARRIER
                flags in parseconv instead of parser.
          - 2019-12-07: parseconv: Merge event flattening pass
                into event conversion pass.
    • Joel K. Pettersson's avatar
      Merge voicegraph code into prealloc. · c2f80252
      Joel K. Pettersson authored
      Move everything in builder/voicegraph to interp/prealloc.
      Adjust data structures a little. Adapt printout code, and
      in turn the player/player code using it.
      Todo: The main and remaining part of the redesign planned
      in 2013, expanding the code to schedule audio buffer use,
      prior to audio generation, so that it can then use a flat
      ordered list of what to generate and what input it needs,
      instead of the old graph traversal code limited to trees.
      Change log:
       * 2020-11-22: Merge voicegraph into prealloc.
       * 2020-11-24: Tidy non-NULL carrier op lists.
       * 2020-12-21: Init op lists only on (re)init,
             not for every voice or op state update.
       * 2020-12-23: Comment out the
             unused SSG_OAS_* flags.
    • Joel K. Pettersson's avatar
      Refactor symtab and more. Reorganize code. · 1a993a3e
      Joel K. Pettersson authored
      Refactor symtab. Make various small other changes.
      Reorganize code:
       * Rename ptrlist to ptrarr.
       * Move all in builder/
         except builder.c and scriptconv
         to reader/.
       * Rename interp/generator to interp/interp.
       * Rename 'test-builder' to 'test-scan',
         built with `make tests` (previously `make test`).
      This moves down remaining old reorganization changes
      from the current saugns v0.3.x commits.
      Reorder Makefile dependency names alphabetically.
      Change log:
       * 2020-10-09: Rename ptrlist to ptrarr.
       * 2020-11-14: Move most builder/ files to reader/.
             Remove builder/ modules from test-builder linkage,
             rename to test-scan. Clean up name/ver in cli strings.
             Clean up Makefile.
       * 2020-11-16: Flense a little.
             .gitignore update.
             Move discard_programs() to SSG_discard() in builder.c.
       * 2020-11-20: Upgrade symtab and adapt the parser, redo:
             (Leave mempool usage and messages, for now.)
         Old branch:
          - 2019-12-27: symtab: For varying TabItem size,
                 use sizeof and key[] instead of offsetof and key[1].
                 (Resulting object file identical.)
          - 2020-01-22: Import saugns v0.3.6d symtab. Use in parser.
                Replace parser strfind() using symtab pool pointers.
                Use mempool for parser and program nodes.
                Add MGS_LangOpt for pool wave_names in parser & program,
                make symtab pool_stra store additional end NULL pointer,
                remove useless name arr count for parser pool stra uses.
                Adjust parser messages ("label" -> "named value", etc.).
          - 2020-01-26: Remove symtab get/set functions,
                rename types, expose MGS_SymStr type - used directly
                in parser to simplify code.
          - 2020-02-02: Adjust for newer code.
          - 2020-07-23: Move to saugns
                from the 2020-06 "mgensys" experiment.
                Re-do adapting to use modified symtab.
       * 2020-11-23: Rename generator to interp.
       * 2021-06-18: Undo reordering of a few lines in
             player.c to fix check for WAV file.
    • Joel K. Pettersson's avatar
      Refactor scriptconv and program.h types. · 85873efb
      Joel K. Pettersson authored
      Refactor scriptconv and program.h types, using simpler
      types and mempool for all produced data. Replace types
      SSG_ProgramOpGraph and SSG_ProgramOpAdjcs with the new
      SSG_ProgramOpList (like the old graph type).
      Add and use "mpmemdup" methods for arrtype and ptrlist
      replacing ordinary "memdup" and traversal for freeing.
      Extracted from saugns v0.3.6 changes, separating their
      more basic clean-ups from changes to replace node list
      Todo: Remove the SSG_POPP_ADJCS flag (done in v0.3.6).
      Flag removal best done later, then deceptively simple.
      Change log:
       * 2019-12-26: Remove SAU_POPP_ADJCS flag,
             replace checks using other information.
             Replace SAU_ProgramOpGraph and SAU_ProgramOpAdjcs
             types with SAU_ProgramOpList, simplify code.
       * 2019-12-27: Add a sauNoinline in scriptconv.c.
       * 2020-10-07: Merge with changes from after new node list
             code was added and used, preserving old ptrlist usage.
         Old branch:
          - 2019-12-31: Renaming and refactoring.
                Add and use arrtype "mpmemdup" for scriptconv
                and voicegraph arrays, removing all but one free.
          - 2020-01-01: Add and use ptrlist "mpmemdup"; simplify,
                turn SAU_ProgramEvent array into array of pointers.
          - 2020-01-03: Merge de-const-ify ptrlist void pointers.
          - 2020-01-04: Move down from later v0.3.6 commits.
          - 2020-02-27: Remove const from parameters for arrtype
                memdup functions.
          - 2020-07-26: ISC-relicense arrtype, ptrlist, nodelist.
       * 2020-10-08: Re-add SAU_POPP_ADJCS flag, reduce diff.
             This effectively splits the v0.3.6 redesign into
             two parts.
       * 2020-10-09: Move down to sgensys v0.2-beta.
       * 2020-10-21: Move to ssndgen v0.2-dev.
       * 2020-10-27: Merge generator flensing.
    • Joel K. Pettersson's avatar
      Split scriptconv stage from parseconv. Fix edge case. · 6be806fb
      Joel K. Pettersson authored
      Part 2 of redesign for parseconv & generator
      (planned in 2013). Not exactly as originally
      thought of, but as a basic preparation, split
      parser output representation from script data
      representation which is later converted to
      the internal audio generation "program".
      Fixes output for updates to operators created in
      lists cleared in the same event. The updates are
      now made to the right (unused) operator, instead
      of to the wrong operator.
      Design changes:
       * The parser is still mostly the same, with
         a very small simplification.
       * The old parseconv has become scriptconv,
         with minor adjustments for input data changes.
       * New parseconv mostly copies parser output,
         but leaves flat per-event operator list.
       * Now scriptconv prints all, not one, errors
         when checking validity of the produced data.
      Todo: More refactoring, further redesign
      (for which the door is now open).
      Change log:
       * 2019-10-16: Placeholder for separating stages.
       * 2019-10-23: Split parseconv module into
             parseconv and scriptconv.
       * 2019-10-25: Minimal cleanup.
       * 2019-10-26: Fill in more, still not functional.
       * 2019-10-27: Make functional.
             Set version to v0.3.3.
       * 2019-10-28: Fix 'test-builder' build.
       * 2019-10-31: Move down to after v0.2.14.
             Set version to v0.2.15.
       * 2019-12-12: In parseconv, remove unneeded typecast.
             In scriptconv, update commented-out operator re-use
             code, copied from voice re-use code. (Now compiles,
             but still not functional.)
       * 2019-12-22: Merge composite timing fix.
             Merge add missing default time adjustment
             for amp2 and freq2 ramps.
       * 2019-12-24: Merge ramp and v0.2.5-related changes.
       * 2019-12-25: Merge ramp default time changes.
       * 2020-01-04: Merge split voicegraph
             from parseconv/scriptconv, and adapt some
             refactoring of scriptconv, including make
             output verification print every error, not one.
             Simplify allocation,
             turn SAU_ProgramEvent array into array of pointers.
             Update naming where "parse" should be "script".
       * 2020-07-23: Merge renaming in ramp module.
             Adjust for rearrangement of other changes.
             Set version to v0.2.14.
       * 2020-07-26: Keep version at v0.2-beta.
       * 2020-10-21: Move to ssndgen v0.2-dev.
    • Joel K. Pettersson's avatar
      Split prealloc module for generator. Change -p timing. · 362dafd9
      Joel K. Pettersson authored
      Command-line behavior: Print -p info for each script just prior
      to generating audio for it if done, instead of printing for all
      before generating for all.
      Option flag enum and handling is moved out to ssndgen.h and the
      builder/builder.c and player/player.c code.
      Move initialization code from generator.c
      to the new prealloc module. Like runalloc
      in the 2020-06 "mgensys" version, but not
      as elaborate, the moved code being small.
      Preparation for moving code "down" from
      parseconv, to the generator before run.
      Change log:
       * 2020-10-26: Add runalloc module (placeholder)
             and use in generator, as in 'old-dev_202006' branch.
       * 2020-10-27: Rename to prealloc.
       * 2020-11-12: Group -p info printing with
             other per-script output generation.
       * 2020-11-21: Move the init code.
       * 2021-01-10: Fix prealloc.c -pedantic warning.
    • Joel K. Pettersson's avatar
      Flense generator. Reorganize code. Fix for -r 1 hangs. · a762a1a0
      Joel K. Pettersson authored
      Flense generator, simplifying away most "event data"
      and using what's allocated at the previous stage. In
      the future, some data and code can be moved from the
      program types to the generator, ending up in-between
      the layers as part of pre-allocation code, e.g. move
      The basic main idea is very old, not new. Now the
      stubbornly kept premature abstraction of the past
      is gone in the generator.
      Compared to the flat 2020-06 "mgensys" design, reduces
      differences in part. But here, in a more multi-layered
      design, there's already specialized data types for the
      "updates" to be done, use those instead of duplicating
      data with the generator's own types.
      Now uses mempool for all allocation in generator.
      Reorganize code:
       * Move builder.c into builder/.
       * Rename renderer/ to interp/.
       * Move renderer.c (renamed player.c)
         and the audiodev and wavfile code
         into player/.
      Add minimum per-channel buffer length
      (currently 1 sample) in player.c, fix
      hang when -r 1 looped a 0-length run.
      Also change ramp run and skip functions to accept
      NULL pos for jumping ahead in time to goal value.
      Expand IDEAS file (design ideas) and rename to IDEAS.md.
      Change log:
       * 2020-10-24: Silence implicit conversion warning in osc.c,
             add (float) before INT32_MAX.
       * 2020-10-26: Add runalloc module (placeholder)
             and use in generator, as in 'old-dev_202006' branch.
       * 2020-10-27: Make ramp SSG_Ramp_skip()
             skip all remaining values if pos is NULL. Simple but
             may remain unused without a new use-idea.
             Flense generator, simplifying away most "event data"
             and using what's allocated at the previous stage.
             Remove runalloc module for now, for simpler diff.
             Now uses mempool for all allocation in generator.
       * 2020-11-11: Merge part-new code reorganization.
             Use saugns v0.3.5 IDEAS.md with update for changes.
             Adjust SSG_Ramp_run() for consistency when pos NULL.
         Old branch:
          - 2019-12-12: Move builder.c into builder/.
          - 2019-12-15: Move audiodev and wavfile into renderer/.
                Move old files from renderer/ to interp/.
                Expand IDEAS file, rename to IDEAS.md.
          - 2020-07-22: Rename renderer to player.
          - 2020-11-09: Naming in player/player.c.
       * 2020-12-14: Ensure output buffer holds >= 1 sample, fix
             hang with -r 1 when 0 samples were ran in run loop.
    • Joel K. Pettersson's avatar
      Add time type, refactor. Update devtests/, add notes/. · ad6876a3
      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 default time scaling when '|' is used in
      devtests/defaulttime1.sgs. This bug remains after some
      simple fixes. (Fixed in a later v0.3.8 commit with the
      2020-06 "mgensys" design idea of the duration sub-node
      for parser-produced events.) Another related change to
      make is to move all implicit "voice" handling from the
      parser 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/*
       * 2020-12-28: Uncomment the trailing '|' in defaulttime1.sgs,
             to trigger and test the remaining bug after rebase.
    • Joel K. Pettersson's avatar
      Rename project to 'ssndgen' from 'sgensys'. · 84741bce
      Joel K. Pettersson authored
      Change SGS prefix to SSG throughout code.
       * 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.
       * 2020-12-17: Re-apply on top of debug change.
       * 2020-12-31: Re-apply on top of further work.
    • Joel K. Pettersson's avatar
      Change modulation syntax and ramp usage. Debug '[]' syntax. · 4c341410
      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.
       * Disallow '[]' lists separate from those assigned
         to list parameters. Was undocumented and useless
         and could cause crashes. A more general list can
         be added as a real feature later. What's removed
         was actually a hold-over from an ancient "allows
         more free whitespace use" feature (broken by the
         time of the 2012 releases).
      Add clear parse warning messages for rejected
      (wrongly placed) scope opening characters.
      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.
       * 2020-12-17: Keep '[]' for lists only, remove undocumented use.
       * 2021-06-18: Add 'sqr_am_2m.sgs' script (from 2021-01-14)
             under new dir examples/tests/long/ for long duration.
  3. 31 May, 2021 13 commits
    • Joel K. Pettersson's avatar
      Split voicegraph code. Refactor further. Change 'r' syntax. · d3de8d81
      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 (and parse_level() return value)
         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.
       * 2020-12-28: parser: Flense parse_level() return value
             and 'endscope' flag, both unused without SCOPE_SAME.
    • Joel K. Pettersson's avatar
      Basic ramp curve changes. Refactor more. Debug timing code. · 5371afd8
      Joel K. Pettersson authored
      Backport minor changes for timing code, which fix the worst
      though not all known little bugs in script handling. For an
      example see devtests/script3.sgs, which now plays properly.
      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.
       * 2020-12-28: Take care of the low-hanging fruit in
             fixing remaining timing bugs. Remove bug-inducing
             lines in group_events(), disable a call for \
             which doesn't work properly.
    • Joel K. Pettersson's avatar
      Rework audio mixing. Refactor generator. · 3d74d99d
      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.
    • Joel K. Pettersson's avatar
      Rework ramp module. Refactor uses and more. · 3bcb9da8
      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.
    • Joel K. Pettersson's avatar
      Crudely anti-alias 'sqr' & 'saw' waves, remove 'shh'. · cbcb9f94
      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.
    • Joel K. Pettersson's avatar
      Add 'hold' ramp curve. Refactor scanning & ramp params. · 6bd174f3
      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.
    • Joel K. Pettersson's avatar
      Support running multiple scripts. Use larger output buffer. · a2d17d9e
      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.
    • Joel K. Pettersson's avatar
      Use restrict keyword. Update test code & split out as program. · e052fdf2
      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.
    • Joel K. Pettersson's avatar
      Add -e string evaluation option. Add test scanner. · 774d180e
      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.
    • Joel K. Pettersson's avatar
      Add file module, use for scanning. · 40c09f6d
      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.
    • Joel K. Pettersson's avatar
      Add ramp module, refactor parser & generator. Fixes. · c131bc2c
      Joel K. Pettersson authored
       * 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.
       * 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.
    • Joel K. Pettersson's avatar
      Add arrtype module, rework parseconv. Replace symtab. · 7dee1d28
      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
      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.
    • Joel K. Pettersson's avatar
      Further syntax changes. More bugfixes. Reorganize code. · e6503c8d
      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. "@[...]".
       * 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
       * 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.
  4. 31 Dec, 2020 1 commit
    • Joel K. Pettersson's avatar
      Change scope nesting syntax. Parsing and other fixes. · 9a1f0afa
      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.)
       * 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
       * 2020-07-13: Set version to v0.2-beta.