1. 23 Aug, 2019 1 commit
    • Joel K. Pettersson's avatar
      Scanner & parser clean-up. Macro renaming. · b64a0a3b
      Joel K. Pettersson authored
      Redesign scanner:
       * 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.
      
      Use the new way of filtering whitespace in parser.
      Also refactor parser scan_time() and its uses.
      
      Further testing of line and char position numbering
      needed, but now better than it was in v0.3.0.
      
      Change naming of keyword-like macros to sauCamelCaseName:
       * Rename compiler attribute SAU__* macros.
       * Rename ArrType SAU_DEF_* macros.
      
      Increase version to v0.3.1, with suffix 'c'.
      
      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-07-29: parser: refactor scan_time() and its uses.
       * 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-16: Re-order ramp run & skip function params.
       * 2019-08-17: Remove scanner ws levels between ALL and NONE.
             (Not needed in current program.)
             Increase version suffix to 'c'.
       * 2019-08-23: Add sauNoinline to scan_time().
      b64a0a3b
  2. 18 Aug, 2019 1 commit
    • Joel K. Pettersson's avatar
      Rename project to 'saugns' from 'sgensys'. · 1631a7bb
      Joel K. Pettersson authored
      Rename the program from 'sgensys'
      to 'saugns' (Scriptable AUdio GeNeration System).
      Change SGS prefix to SAU throughout code.
      
      Rename scripts from *.sgs
      to *.sau, naming the language SAU (Scriptable AUdio).
      
      Update descriptions in README.
      
      Set version suffix to 'b'.
      
      Change log:
       * 2018-10-25: Rename to 'ssndgen'. Change SGS prefix to SSG.
       * 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-01-27: Fix inconsistent indentation in some files.
       * 2019-07-04: Update for newer code. Tag "v0.3.0".
       * 2019-08-06: Update for newer code.
       * 2019-08-18: Increase version suffix to 'b'.
      1631a7bb
  3. 07 Aug, 2019 12 commits
    • Joel K. Pettersson's avatar
      Use the new scanner. Extend comment syntax. Clean-up. · 8aaf38a4
      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
      refactored.
      
      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.
      
      Increase version to v0.3.0.
      
      Reindent parser.c (the only remaining file).
      
      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.
      8aaf38a4
    • Joel K. Pettersson's avatar
      Change AM/FM/PM syntax & handling. Parser fixes. · 0bcdbdc3
      Joel K. Pettersson authored
      Syntax changes:
       * For AM and FM parameters, parse the second value
         after a ',' and the modulator list after an
         appended '~', rather than second value and/or
         modulator list after a leading '!'.
         (E.g., for FM, "fX,Y~[...]" instead of "fX f!Y[...]",
         where X and Y are numbers or numerical expressions.
         Any of X, Y, or [...] can be left out now as before.)
       * Allow value ramp values for the second frequency and
         amplitude. Make the syntax consistent in this regard.
       * Make the phase & PM syntax slightly more permissive.
         For consistency with the new AM & FM syntax, have 'p'
         allow phase followed by PM modulator list in one go.
      
      Add position-updating skip function for ramp,
      similar to run function except there's no output.
      Use to update second freq and amp ramps in generator
      without generating samples when no FM or AM is done.
      
      Parsing fixes and further tweaks:
       * Do more complete checks for infinite numbers.
       * Use standard is-functions for NAN, infinity checks.
       * Small flag handling change for parser end of event.
      
      Increase version to v0.2.13.
      
      Update scripts and README.
      
      This resolved the "todo" regarding dynfreq/dynamp
      ratio flags.
      
      Change log:
       * 2019-08-04: Move syntax changes and parser fixes
             down from v0.3.1:
         Old branch:
          - 2019-07-11: Microflensing.
                parser: Remove unused mul_inv option from scan_num(),
                use a SAU__noinline to help clang keep size down.
          - 2019-07-18: Change AM & FM syntax.
                Make 'p' more permissive for consistency.
                Use isinf() for infinite-number checks.
                Replace "fabs(x) == INFINITY" with "isinf(x)".
                Use isnan() for portable NAN checks in parser.
          - 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.
      0bcdbdc3
    • Joel K. Pettersson's avatar
      Rename slope to ramp, change curves. Change 'r'. Clean-up. · d92abae0
      Joel K. Pettersson authored
      Rename slope module to ramp, and change curves:
       * 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'.
      
      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 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.
      
      Clean-up:
       * 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.
      
      Increase version to v0.2.12.
      
      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-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.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
      d92abae0
    • Joel K. Pettersson's avatar
      Rework audio mixing. Refactor slope params. Clean-up. · 89a2f54b
      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.
      Also move oscillator block running to osc.c
      (split from generator.c).
      
      Further refactor slope parameters and their uses:
       * Remove the old SGS_Slope type,
         renaming the SGS_SlopeParam type to SGS_Slope.
       * Separate the slope 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_Slope_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_Slope
         flags and code.
       * Cleaner code for handling slope 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 mempool using arrtype, and initialize
         allocated memory to zero bytes.
         Split SGS_MemPool_memdup() from SGS_MemPool_alloc().
       * Refactor symtab, without functional change.
       * Rename arrtype SGS_UInt8Arr to SGS_ByteArr.
       * Minor refactoring in renderer.c.
      
      Increase version to v0.2.11.
      
      Change log:
       * 2018-11-08: Refactor mempool using arrtype.
             Move wave module to program/.
             Split SGS_MemPool_memdup()
             from SGS_MemPool_alloc().
             Fix Makefile.
       * 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-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-07: Move osc block running to osc.c
                (split from generator.c).
          - 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: Merge back bugfix for generator timing.
             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.
             Minor refactoring in renderer.c.
             Set version to v0.2.11.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
      89a2f54b
    • Joel K. Pettersson's avatar
      Refactor scanning, slope params. Add 'hold' slope type. · 867c7140
      Joel K. Pettersson authored
      Recognize 'hold' slope change type in scripts.
      Use new SGS_SlopeParam type for timed 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.
      
      Increase version to v0.2.10.
      
      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.
      867c7140
    • Joel K. Pettersson's avatar
      Support multiple script args. Use larger output buffer. · f0ca3c07
      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.
      
      Increase version to v0.2.9.
      
      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.
      f0ca3c07
    • Joel K. Pettersson's avatar
      Use restrict keyword. Update and split out test code. · f728a350
      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.
      
      Increase version to v0.2.8.
      
      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.
      f728a350
    • Joel K. Pettersson's avatar
      Add -e string execution option. Add test scanner. · d205f602
      Joel K. Pettersson authored
      Support direct execution of a string argument with
      a new -e option. E.g., ./sgensys -e "Osin f643 t1"
      will run (play) a 643Hz 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.
      
      Increase version to v0.2.7.
      
      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 execution 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.
      d205f602
    • Joel K. Pettersson's avatar
      Rework scanning. Use new file buffer module. · d20fad09
      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.
       * 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.
      
      Increase version to v0.2.6.
      
      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.
             Simplify parse level SDPL_IN_* "location",
             replacing flags and macros with a simple enum
             state, as only one flag was set at a time.
             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.
      d20fad09
    • Joel K. Pettersson's avatar
      Basic redesigns for symtab, parseconv, generator. · 88020b0b
      Joel K. Pettersson authored
      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). Labels can now only
      contain alphanumeric characters and '_'.
      
      Also check for and reject infinite numbers in parser.
      Use size_t for string and buffer lengths.
      
      Part 1 of redesign for parseconv & generator
      (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, but a start and replaces
      some code in generator.
      
      Also 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.
      
      Further do a clean-up rewrite of parseconv.c,
      using the new arrtype (generic array) module for its
      simple dynamically-sized arrays.
      
      Changes include:
       * Calculate duration of script/program and
         include in program struct.
         Duration now printed with -p option.
       * 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).
       * Turn Valit (VALue ITeration) types and code
         from program.h and generator.c into the new
         slope module and SGS_Slope type.
       * 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.
      
      (Extracted from redesign work.)
      
      Increase version to v0.2.5.
      
      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-07-30: Change "http" to "https" in
                heading license comment.
          - 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-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-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-06-16: Adjust parser for new v0.2.4 syntax changes.
       * 2019-06-30: Update -p printout details
             to match June syntax changes.
       * 2019-08-07: Merge Makefile -ffast-math portability fix.
      88020b0b
    • Joel K. Pettersson's avatar
      General clean-up. Basic syntax changes. Reorganize code. · a0191707
      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 handling of '^' (to the power of) priority,
            truly binding it more closely than other operators.
          - Only allow arithmetic inside parentheses.
            (Previously allowed without parentheses when
            no whitespace separated parts of the expression.)
          - Only allow number sign within parentheses.
            (Previously '-' sign was allowed without parentheses.
            This frees up '-' for new future uses.)
          - Allow '+' as sign (not only as operator)
            in addition to '-'.
       * Multiple operator binding: From "{...}" to
         nesting syntax prefixed by '@', i.e. "@[...]".
      
      Todo:
       * Make multiple operator binding functional.
         (It has been a "todo" since it was added.)
      
      Wave type changes:
       * Make 'saw' (saw wave) increasing instead of decreasing.
         (Negative frequency or amplitude gives a decreasing saw.)
      
      Reorganize code:
       * Move parser.c, program.c, and the lexer and symtab modules
         to builder/, splitting out builder.c and renaming files:
          - parser.h -> script.h (parser output).
          - program.c -> parseconv.c.
         Place conditionally-compiled test use of lexer in builder.c.
       * Move generator and osc to renderer/,
         splitting out renderer.c from sgensys.c.
       * Create common module, moving the old sgensys.h contents
         to common.h. Add and use utility functions:
          - SGS_warning(), SGS_error(): now used for warnings
            and errors (when the format is suitable).
          - SGS_memdup(), SGS_strdup(): moved from parser.c.
      
      Consistent type and function naming:
       * Rename each "SGSType" to "SGS_Type".
       * For function and macro names including a type,
         use same (mixed) case as in type.
      
      Further clean-ups:
       * Use size_t for event IDs, uint32_t for operator IDs,
         uint16_t for voice IDs.
       * Rename parser struct types, flags, and functions.
         Name types "SGSScript*", flags "SGS_S*".
       * In parser result (SGSScript),
         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.
      
      Increase version to v0.2.4.
      
      Change log:
       * 2018-04-13: Rename parser struct types and flags.
       * 2018-04-18: Simplify memory management in program
             and generator. Implement downscaling
             of amplitude by voice count by default.
       * 2018-06-02: Undo faulty simplification in parser code, and
             some further renaming. Add circular reference
             guard for operators in generator, and some
             further clean-ups.
       * 2018-06-30: Rename types from "SGSName" to "SGS_Name".
             Rename corresponding functions and macros
             to use same (mixed) case in included type
             name.
       * 2018-09-11: Create common module, refactor warnings and
             errors. Move memdup from parser to common.
       * 2018-10-04: Further renaming of parser structs and flags.
             Some additional tidying.
       * 2018-10-15: Reorganize code, moving parser.c, program.c,
             and symtab to builder/. Rename program.c to
             parseconv.c, split out builder module.
             Further flag renaming in parser.c.
             Add -p option for printing program info.
       * 2018-10-16: Move lexer to builder/. Update headers, comments.
             Move lexer test invocation to builder.c.
             Complete branch merging.
             Split out renderer module from sgensys.c.
             Move audiodev, wavfile, generator, and osc
             to renderer/.
             Some code tidying.
       * 2018-10-17: Move audiodev and wavfile out from renderer/.
             Make "saw" wave increasing instead of decreasing.
             Replace renderer.h and builder.h with
             combined sgensys.h.
       * 2018-10-18: Enable 'a' parameter for
             "f!<>"/"r!<>" and "a!<>".
       * 2018-10-23: Change PM list syntax from "p*<>" to "p+<>".
       * 2018-12-25: Further changes to numerical expression
             parsing for correctness and consistency.
             Add warning for '(' without closing ')'.
             Remove extra linebreak from file open error.
       * 2019-06-05: Merge syntax changes.
             Increase version to v0.3.1.
             Clean up a few scripts.
       * 2019-06-13: Set version to v0.2.4.
       * 2019-06-16: Backport further simple syntax changes.
         Old branch:
          - 2019-02-08: Fix inconsistent indentation
                in a few scripts.
          - 2019-06-13: Three simple syntax changes.
                Label ref: from ":label" to "@label".
                Subvalues: from within "[...]" to "{...}".
                Mul. op.b: from within "{...}" to "@[...]".
       * 2019-06-30: Update -p printout details
             to match June syntax changes.
       * 2019-08-07: Move back Makefile -ffast-math portability fix.
             Also update unusable 'devtests/newconcept' script.
         Old branch:
          - 2019-08-06: Fix parsing when -ffast-math breaks isnan().
                Only build some files with -ffast-math.
      a0191707
    • Joel K. Pettersson's avatar
      Add 3 wave types. Basic syntax changes. Reorganize scripts. · 87f68544
      Joel K. Pettersson authored
      Script syntax changes:
       * Scope nesting syntax: Change from "<...>" to "[...]".
         ('<' and '>' are now unused. "[...]" is now used both for
         lists of objects, and arguments with several sub-values.)
       * PM modulator list prefix: Change from "p!" to "p*".
         (I.e., a list uses "p*[]". Since semantics differ for PM
         lists vs. AM and FM lists, make this clearer in the syntax.
         For PM lists, modulator amplitudes are summed,
         while for AM and FM lists, they are multiplied.)
       * Numerical expressions:
         Fix really old bug which prevented evaluation
         of "Y" in an expression of the form "((X)Y)".
      
      Fix parsing when -ffast-math breaks NAN checks.
      Portability requires limiting the use of -ffast-math.
      (Only use -ffast-math for renderer-related code
      which needs performance and ignores non-finite values.)
      
      Split osc module into osc and wave. Wave type changes:
       * Add 'sha' (half-frequency absolute sine).
       * Add 'szh' (half-zero'd sine).
       * Add 'shh' (first quarter of sine).
       * Rename 'srs' (square root of sine) to 'ssr'.
      
      Move wave type names from parser to wave module.
      
      Add -v version number, initially at v0.2.3.
      
      Reorganize example and test scripts. Move some old and useful
      scripts from devtests/ to examples/tests/. Rename scripts,
      add descriptions to some of them, modify a few, remove a few
      which are useless, and add more wave type testing.
      
      Change log:
       * 2018-04-18: Move wave type names to osc module, add new
             'sab' wave type, rename 'srs' to 'ssr'.
             Reorganize and update example and test scripts.
       * 2018-06-02: Add 'shw' and 'shr' wave types, and
             further LUT init code changes.
       * 2018-06-30: Split osc module into wave and osc.
       * 2018-09-12: Rename wave types
             ("sab"->"sah", "shw"->"szh", "shr"->"szhhr").
       * 2018-09-27: Rename wave type 'sah'->'sha',
             add 'shh', comment out 'szhhr'.
       * 2018-09-29: Rename debug #define switches in sgensys.h.
       * 2018-10-16: Update headers, heading comments, for added code.
             Complete branch merging.
       * 2018-10-19: Change PM list syntax from "p!<>" to "p*<>".
       * 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.
      87f68544
  4. 27 May, 2019 21 commits
    • Joel K. Pettersson's avatar
      Support sndio. Parser & program refactoring. · aa182c69
      Joel K. Pettersson authored
      Support sndio and use on OpenBSD. Fixes audio on newer OpenBSD.
      Clean up the Linux audio code. Improve audiodev error messages.
      
      Program & parser changes:
       * Rework the SGSNodeList parser code into the SGSPtrList
         type, split out into the ptrlist module.
       * Return parser result in new SGSParserResult type. Add
         parser module method for destroying it, instead of it
         being implemented in program module. Add missing list
         clearing.
       * Rename voice and operator parameter flags
         from SGS_* to SGS_P_*.
      
      Further edit usage notice.
      
      Makefile changes: compile with -std=c99,
      add missing header dependencies.
      
      Change log:
       * 2018-02-16: Renamed voice and operator parameter flags
                     from SGS_* to SGS_P_*.
       * 2018-02-19: Split out ptrarr module from parser, reworking
                     node list code and its uses.
       * 2018-02-20: Makefile changes:
                     add -Werror=implicit-function-declaration,
                     list more header dependencies.
       * 2018-03-10: Change ptrarr to work more like old nodelist,
                     re-adding case for < 2 items and needed macros.
       * 2018-09-09: Add sndio support, use on OpenBSD.
                     Fixes audio on newer OpenBSD.
                     Move audiodev implementation files to audiodev/.
       * 2018-09-20: Replace ptrarr with cleaned-up ptrlist.
                     Fixes and clean-ups for parser, program,
                     as well as some addititional tidying.
       * 2018-10-12: Makefile change: use -std=c99.
                     audiodev code tidying, and
                     fix typo which broke Linux build, and
                     add C99 conditional compile fix.
                     Some further code tidying.
       * 2019-04-18: Merge into current branch
                     to provide fuller history.
       * 2019-04-26: Remove useless uint typedef.
      aa182c69
    • Joel K. Pettersson's avatar
      Use modern types. Rework osc. Handle audiodev srate changes. · bf6a82b8
      Joel K. Pettersson authored
      Use stdint.h and stdbool.h types instead of ushort, uchar,
      and uint (and usually int) throughout all code. Universally
      use 32-bit IDs and counters for voices and operators.
      
      Rework the oscillator module:
       * Increment phase after each sample instead of before.
       * Move wave type enum (SGS_WAVE_*) to osc.h, use to
         index array of LUTs.
       * Replace extra value at end of LUTs with use of bitmask.
         Bump LUT values from 1024 to 2048.
       * Correct saw wave LUT initialization off-by-one
         indexing error. Also improve init code for other LUTs.
       * Remove unused SGSOsc_RUN*() variants.
         Renamings, a few new macros, improved comments.
       * Add wave type test script, examples/test-wavetypes.sgs.
      
      Remove math.h SET_I2FV() macro (x86/x86-64 fast float-to-int
      rounding). Replaced with lrint()/lrintf(), which nowadays is
      inlined to fast code when compiling with -O > 0
      and -ffast-math. This removes all inline assembly.
      
      Change audiodev and main module, retrieving and using modified
      sample rate when changed by the audio device. Handle resulting
      difference in sample rates for device and file outputs by
      generating audio twice if needed. Also improve audio
      output-related error and warning messages. Tweak usage notice.
      
      Split sgensys.h into sgensys.h (common type definitions),
      generator.h (new) and program.h (relevant lines moved over).
      
      Also rename some functions, do minor refactoring, improve
      commenting here and there.
      
      Change log:
       * 2017-12-03: Replace types in many cases. Quick first pass.
                     Remove sgensys.h. Program module still largely
                     not updated.
       * 2018-02-05: Replace more types. Rewrite and readd sgensys.h.
                     Rename some functions. Minor refactoring.
                     Improve audio output handling. Program module
                     updated.
       * 2018-02-06: Oscillator module changes. Use SGS_WAVE_* enums
                     to index LUTs. Correct saw wave LUT. Inc phase
                     after sample instead of before. Renamings, macro
                     clean-ups.
       * 2018-02-08: Undo minor changes for SGSNodeList (parser) that
                     are better redone with a real redesign. Rename
                     a few more functions. Tweak messages in sgensys.c.
       * 2018-02-09: Remove math.h inline assembly, leaving none.
       * 2018-02-19: Replace a ';' with a ',' in heading comments.
       * 2018-02-22: Extend oscillator LUTs to 4096 values from 1024.
                     Some further renamings, init code improvements,
                     and smaller macro improvements.
                     Update COPYING file. (FSF link updates.)
       * 2018-02-23: Add examples/test-wavetypes.sgs.
       * 2018-03-14: Fix allocation size in generator.c. Use
                     offsetof(), avoid allocation failure which
                     resulted from unsigned value wrapping around
                     upon (zero flag count - 1).
       * 2018-09-27: Reduce osc LUTs to 2048 values (no point in
                     4096 with 16-bit int and lerp). Some more
                     osc module tidying.
       * 2019-04-17: Merge into current branch
                     to provide fuller history.
      bf6a82b8
    • Joel K. Pettersson's avatar
      Disable lexer testing. Clean-ups and portability fixes. · 40e802ba
      Joel K. Pettersson authored
      Disable test lexer and re-enable normal output by default,
      adding a #define switch in sgensys.h to switch between the
      old parser and the test lexer.
      
      Some clean-ups for the test lexer, symtab code, and
      other parts of the program. Make the test lexer handle
      line comment ('#'), and change its buffered reading to
      make multiple character ungetting possible.
      
      Portability fixes:
       * Makefile and linking: Correct sh syntax.
         Check in Makefile for three uname -s cases:
          - Linux
          - OpenBSD or NetBSD
          - other ("generic UNIX")
         Unbreaks building on FreeBSD and DragonFly.
         Also reorder linking CC args for portability.
       * ALSA: Add missing call to snd_pcm_drain().
      
      Re-remove GNUmakefile and simply use Makefile.
      
      Change log:
       * 2017-11-27: Some cleanups for lexer and symtab modules.
                     Add debug #define for hash table in symtab.c
                     (for testing collisions).
       * 2018-01-21: Make lexer handle line comments ('#').
                     Source fix for ALSA.
                     Correct Makefile sh syntax
                     and reorder CC args for linking.
       * 2018-02-04: Fix program.c typo / memory init bug.
       * 2018-02-08: Only include LFLAGS addition
                     for OpenBSD and NetBSD on those systems.
                     Unbreaks building on FreeBSD and DragonFly.
       * 2018-02-12: Change buffered reading in the lexer.
       * 2018-02-13: Rearranging of and renamings in lexer code.
                     Add debug #define for lexer (for silent-enough
                     output to measure time to process file).
                     Move debug #define switches to sgensys.h.
       * 2018-02-14: Disable lexer, re-enable parser and output.
                     Insert #define switch in sgensys.h to toggle.
       * 2018-02-19: Replace a ';' with a ',' in heading comments.
       * 2018-02-22: Update COPYING file. (FSF link updates.)
       * 2018-05-01: Replace README with rewritten version from
                     04-16. Similar to newer versions, but with
                     references to added features removed.
       * 2018-09-19: In program.c, remove two unused functions,
                     and two useless conditionals, one broken.
       * 2018-10-25: Fix parser string matching bug
                     (not impacting the current uses).
       * 2019-01-19: Complete branch merging.
                     Correct README wording in one place.
                     Re-remove GNUmakefile and simply use Makefile.
      40e802ba
    • Joel K. Pettersson's avatar
      2014-10-12: Test lexer branch. (Revert previous.) · 24bb8417
      Joel K. Pettersson authored
      Add quick test version of a lexer module, used
      in place of the parser. (Normal output is disabled.)
      Experimental work towards loose plans for
      a new scripting language and a fuller redesign.
      
      Beginning of new symbol table implementation.
      Implemented string pool/string interning with a simple
      hash table. Used by the test lexer but not integrated
      with the old code.
      
      Added memory pool module (mempool.c), used for string
      storage in the new symbol table code. It is meant for
      large numbers of small allocations. Internally they are
      stored in arrays sized after the system's memory page size.
      Upon destruction, everything stored is freed.
      
      Fix build on OpenBSD (and NetBSD) using conditional
      compilation in audiodev_oss.c and an LFLAGS addition.
      (Note: This broke building on DragonFly and FreeBSD,
      fixed in newer versions.)
      
      (The .gitignore file is replaced with that used for
      all old snapshots.)
      
      Change log:
       * 2014-09-18: First quick test version of lexer module.
       * 2014-09-20: Add new symtab code. Add mempool module.
                     Second quick test version of lexer module.
                     Replace normal output with lexer testing.
                     Implemented string interning for symtab.
       * 2014-10-11: Portability fix for OSS on OpenBSD and NetBSD.
       * 2014-10-12: Mempool module debugged.
                     Test hash collisions in symtab module.
                     Third quick test version of lexer module.
                     Add GNUmakefile with debug build options.
      24bb8417
    • Joel K. Pettersson's avatar
      2014-10-05: Redesign draft branch. (Non-functional.) · 5891cee0
      Joel K. Pettersson authored
      Non-functional draft for redesigning the
      program module and audio generator. The
      idea is to traverse the voice and operator
      graphs before the generator, assigning
      block IDs for the generator audio I/O
      buffers before they are used.
      
      The old design limits what the generator
      is able to do, preventing full implementation
      of the existing script syntax. Buffer IDs
      properly pre-assigned would allow the
      generator to run through a flat list of what
      to generate, output buffers being filled and
      re-used as inputs in the pre-scheduled order.
      
      (The 2013 version of program.c re-added as an
      extra file, the extra/earlier 2014 version in
      the 2014 snapshot renamed.)
      
      Change log:
       * 2013-08-05: Redesign sketch #1 (non-working)
                     for program & generator.
       * 2014-10-05: Redesign sketch #2 (still non-working)
                     for program.c, and minor change in parser.c.
      5891cee0
    • Joel K. Pettersson's avatar
      2013-08-03: Add ALSA support. "Program" fix. mv tests/. · 8ad7de9a
      Joel K. Pettersson authored
      Add ALSA support, splitting out system audio support
      from the main module to the new audiodev module.
      Further rework main module, expanding command-line options.
      
      Fix bug in program module.
      
      Indentation style changed to tabs in new code, as well as
      the wavfile module. (Having planned redesigning of sgensys,
      the indentation style was changed to tabs for new or "clean"
      modules after this, while those to be rewritten or further
      reworked still use 2 spaces.)
      
      Moved tests/ to devtests/. (This snapshot contains the
      scripts missing in and readded to the last 4 snapshots.)
      
      Change log:
       * 2012-04-02: Add check in program.c for multiple operator
                     node before call to operator_alloc_inc().
       * 2013-02-28: ALSA support added. Reworked sgensys.c.
                     Reindented sgensys.c, audiodev and wavfile
                     modules.
       * 2013-03-04: Add -c command-line option to stop after
                     processing a script, before sound generation.
                     Re-add tests/ as devtests/.
       * 2013-08-03: Add '.' to heading comments.
      8ad7de9a
    • Joel K. Pettersson's avatar
      2012-04-01: [Release] Operator alloc. after parse. Fixes. · ce890f1b
      Joel K. Pettersson authored
      Assign operator IDs after parsing rather than during, adding
      operator allocation code analogous to the voice allocation code
      for "program" construction.
      
      Event construction is not yet fully functional for multiple
      operator nodes.
      
      Sound generator: Place voice update code after operator update
      code, since the buffer count is handled during voice updates
      and may be altered by operator updates.
      
      (Originally released at Gna! as sgensys-20120401.tgz, without
      tests/.)
      ce890f1b
    • Joel K. Pettersson's avatar
      2012-03-08: Rework "program" output event allocation. · f3c4c98e
      Joel K. Pettersson authored
      Output event allocation reworked, maintaining a list of all
      events and eliminating the counting pass for operators which
      was used to determine the number of events.
      f3c4c98e
    • Joel K. Pettersson's avatar
      2012-03-05: [Release] Further work on parser and "program". · aa6d601b
      Joel K. Pettersson authored
      Make SGSNodeList more elaborate and refactor parser and
      "program" using it. Further parser changes to take multiple
      operator binding into account. As-yet unused beginning of
      "program" code to more fully handle operator allocation.
      
      Sound generator timing fix.
      
      (Originally released at Gna! as sgensys-20120305.tgz, without
      tests/.)
      aa6d601b
    • Joel K. Pettersson's avatar
      2012-02-26: Fixes, part 3. Source licensing info added. · 97963d74
      Joel K. Pettersson authored
      Parser fix for multiple operator binding, and minor refactoring.
      
      Copyright notices and LGPL-3.0+ info added to source files.
      (README.COPYRIGHT, added to this repository for earlier versions
      lacking this, removed with this commit.)
      
      tests/ script changes. (Taken from later working dir because tests/
      missing in tarball, but no scripts dated later than 2012-02-20.)
      97963d74
    • Joel K. Pettersson's avatar
      6d82032d
    • Joel K. Pettersson's avatar
      2012-02-07: Fixes, part 2. · 1fe21637
      Joel K. Pettersson authored
      Parser fixes and minor refactoring.
      
      Sound generator fix for handling of voices and panning.
      1fe21637
    • Joel K. Pettersson's avatar
      2012-02-01: Fixes, part 1. Move and fix test scripts. · ac2ddab9
      Joel K. Pettersson authored
      Parser fixes for new design and timing.
      
      Add and use 'ti' (infinite time) for nested operators by default.
      Such operators play whenever their carrier(s) do.
      
      Sound generator corrected, adjacency indexing
      was outdated (only changed elsewhere).
      
      Script files in main dir moved to "tests/".
      Update scripts with outdated syntax.
      ac2ddab9
    • Joel K. Pettersson's avatar
      2012-01-12: Redesign. Readd '{}' op. bind. Syntax changes. · 75ebd50c
      Joel K. Pettersson authored
      Some parser refactoring and experimental changes.
      Re-enable operator binding with '{}',
      change nesting syntax to '<>'. Reorder code.
      
      Fix for voice allocation.
      
      Move string copying out of symbol table,
      make it simply store pointer.
      
      Syntax changes:
       - Use '<>' to list modulators rather than '{}', as in
         'a!<...>', 'f!<...>' or 'r!<...>', or 'p!<...>'.
       - Remove '-' syntax for PM modulators. Replaced with 'p!<...>'.
       - Add '{...}' for binding several operators as one object to
         manipulate. Used to e.g. link several carriers to one or more
         modulators.
      
      Update various test scripts.
      75ebd50c
    • Joel K. Pettersson's avatar
      2011-12-13: Voice alloc. after parse. Syntax change. · 42c46f26
      Joel K. Pettersson authored
      Allocate voices after parsing, instead of trying to
      track and assign voice IDs during. Merge VoiceData into
      EventNode.
      
      Script syntax: Rename 'b' (panning, applies to the voice) to 'P'.
      42c46f26
    • Joel K. Pettersson's avatar
      2011-12-04: Undo parser redesign, postpone '{}' op. bind. · 3390b97b
      Joel K. Pettersson authored
      Undo the 2011-09-26 redesign, preserving some of the new code
      and further updating the parser, while postponing support for
      the new '{}' operator binding syntax.
      
      Improve comments for sound generator, tiny code style clean-up.
      3390b97b
    • Joel K. Pettersson's avatar
      2011-11-27: New '{}' operator binding syntax, part 2. · 6139de6d
      Joel K. Pettersson authored
      Further parser changes to support new '{}' operator
      binding syntax.
      
      Sound generator clean-up. Improve comments.
      6139de6d
    • Joel K. Pettersson's avatar
      2011-10-11: New '{}' operator binding syntax, part 1. · 241c3e95
      Joel K. Pettersson authored
      Initial work to support new '{}' syntax for binding operators
      together as a single object. This is to allow carrier-modulator
      linkages to be M:N, and not just 1:N (as in adding a list of
      modulators to a single carrier).
      241c3e95
    • Joel K. Pettersson's avatar
      2011-09-26: Parser redesign. Complete sound buffer counting. · dc53953c
      Joel K. Pettersson authored
      Redesign parser, changing NodeData and its uses and replacing
      *_event(), *_voice(), *_operator() functions with restructured
      code. Big refactoring, breaking out various smaller nd_*()
      functions. Add and use NodeList type.
      
      Flesh out sound buffer counting in sound generator.
      dc53953c
    • Joel K. Pettersson's avatar
      2011-08-01: Fixes for parsing and timing. · 790f0c43
      Joel K. Pettersson authored
      Parser fixes for compound steps
      and numerical expression parsing.
      Fixes for silence ('s') and timing.
      
      Fix syntax in an outdated test script.
      790f0c43
    • Joel K. Pettersson's avatar
      2011-07-28: Voice & operator graph structure. Syntax change. · d7bcbc8a
      Joel K. Pettersson authored
      Redesign: The sound "program" uses an operator graph for each
      voice, each operator specifying its modulators using an adjacency
      list. Event data is also split into a main struct keeping track
      of timing, linked to accompanying voice and/or operator updates.
      
      Script syntax: Rename '/' (delay time) to '\'. The old meaning
      of '\' is scrapped, 's' (silence) providing what it did when
      combined with '\'.
      d7bcbc8a
  5. 11 May, 2019 5 commits
    • Joel K. Pettersson's avatar
      2011-06-04: Redesign. Script syntax changes. · 6e0a989f
      Joel K. Pettersson authored
      Separate parser and "program" event types. Parser now uses its
      own "EventNode" suitable for parsing internally, replaced in the
      output with a cleaned-up event struct better adapted for the
      sound generator.
      
      Script syntax changes:
       - 'W' (wave) became 'O' (operator, i.e. oscillator with
         attached configuration options).
       - 'n' (frequency as note) removed, notes may now be set to 'f'.
       - 'b' (balance or panning) added.
       - 'srs' (square root of sine) wave type added.
       - 'p!{...}' (PM modulator list) replaced by '-' (PM linking)
         optionally combined with '<>' (subscope), as in '<-...>'.
      6e0a989f
    • Joel K. Pettersson's avatar
      2011-05-08: Add "VALueITeration" syntax, part 2. · ac6862b0
      Joel K. Pettersson authored
      Rename subvalue 's' (shape of change) to 'c' (change type).
      Change type values are:
       - 'lin' (linear)
       - 'exp' (exponential)
       - 'log' (logarithmic)
      
      'exp' and 'log' are not truly exponential or logarithmic,
      respectively, but instead use polynomial approximations
      developed "by ear" to sound "smooth" and natural. (The real
      curves do not have a finite length smooth ending.)
      
      Refactor sound generator handling of parameter value buffers.
      ac6862b0
    • Joel K. Pettersson's avatar
      2011-05-06: Add "VALueITeration" syntax, part 1. More. · 0172f15e
      Joel K. Pettersson authored
      Parameters can now be set to "[...]", with sub-parameters
      deciding how the value changes over a specific time. This
      provides minimal envelope support and is done ahead of
      adding full-fledged ADSR support in the language.
      
      Sub-parameters:
       - 's' (shape of change, only "l" (linear) currently done)
       - 't' (time to reach target value)
       - 'v' (target value)
      
      Supported for amplitude, frequency, and panning.
      
      Also change frequency ('f') to accept note values, both directly
      and for 'v' inside '[]'. (This change broke note values for 'n',
      which is now obsolete.)
      0172f15e
    • Joel K. Pettersson's avatar
      2011-05-02: Support frequency as note. · 4d1b3d68
      Joel K. Pettersson authored
      Note frequencies in C-major scale are specified using 'n';
      the value is the upper-case letter of the note, optionally
      followed by 's' (sharp) or 'f' (flat), and then optionally
      the octave number.
      
      Currently, just tuning is used, with A4=444hz by default.
      'S' parameter 'n' sets A4 tuning frequency.
      
      "Subnotes" between two notes, in an "inner octave", supported
      with a prefix for the value (lower case letter of note).
      (Subnotes, unlike notes, cannot currently be sharp nor flat.)
      4d1b3d68
    • Joel K. Pettersson's avatar
      2011-04-26: Add compound step syntax. · bceaf2e6
      Joel K. Pettersson authored
      Use ';' as separator between timed steps for an operation.
      
      Steps in the input handled by the parser no longer always
      correspond to the linear order of the resulting event list.
      The event list is "flattened" after parsing.
      
      Rename scripts from .mgs to .sgs.
      bceaf2e6