diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe4d4579e..115571cf1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build furnace on: push: - branches: master + branches: [master, esfm-contest] pull_request: branches: master diff --git a/CMakeLists.txt b/CMakeLists.txt index f1941a02b..5a3f8e641 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -492,6 +492,8 @@ extern/opl/opl3.c extern/YM3812-LLE/fmopl2.c extern/YMF262-LLE/fmopl3.c extern/YMF276-LLE/fmopn2.c +extern/ESFMu/esfm.c +extern/ESFMu/esfm_registers.c src/pch.cpp @@ -700,6 +702,7 @@ src/engine/platform/pv1000.cpp src/engine/platform/k053260.cpp src/engine/platform/ted.cpp src/engine/platform/c140.cpp +src/engine/platform/esfm.cpp src/engine/platform/pcmdac.cpp src/engine/platform/dummy.cpp @@ -779,6 +782,7 @@ src/gui/doAction.cpp src/gui/editing.cpp src/gui/editControls.cpp src/gui/effectList.cpp +src/gui/exportOptions.cpp src/gui/findReplace.cpp src/gui/fmPreview.cpp src/gui/gradient.cpp diff --git a/README.md b/README.md index 213c55e8c..5abdc8127 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ for other operating systems, you may [build the source](#developer-info). - Casio PV-1000 - TIA used in Atari 2600 - POKEY used in Atari 8-bit computers - - Game Boy + - **Game Boy** + - including SOFTWARE ENVELOPES (zombie mode) - Virtual Boy - modern/fantasy: - Commander X16 VERA @@ -360,7 +361,7 @@ you should only save as .dmf if you're really sure, because the DefleMask format --- # footnotes -copyright (C) 2021-2023 tildearrow and contributors. +copyright (C) 2021-2024 tildearrow and contributors. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. diff --git a/TODO.md b/TODO.md index 06951982a..f1918edef 100644 --- a/TODO.md +++ b/TODO.md @@ -1,15 +1,12 @@ # to-do -- add cheat code to insert bruno time (blank) - -# THE REAL TO-DO LIST - +- finish color import improvements (settings refactor) +- new undo stuff +- fix some bugs - finish auto-clone once you have done all of this (maybe not the first one), release 0.6.1 -Furnace is like alcohol... - # and then - new oscilloscope renderer - custom code that uses texture and fixes two issues: too many vertices, and broken anti-aliasing diff --git a/demos/arcade/ComicPartytrack20.fur b/demos/arcade/ComicPartytrack20.fur new file mode 100644 index 000000000..6cd8fbd9c Binary files /dev/null and b/demos/arcade/ComicPartytrack20.fur differ diff --git a/demos/arcade/Eternal_Forest_TaitoArcade.fur b/demos/arcade/Eternal_Forest_TaitoArcade.fur index e15c1f9ce..448276a66 100644 Binary files a/demos/arcade/Eternal_Forest_TaitoArcade.fur and b/demos/arcade/Eternal_Forest_TaitoArcade.fur differ diff --git a/demos/esfm/pcbend.fur b/demos/esfm/pcbend.fur new file mode 100644 index 000000000..033e8c0e5 Binary files /dev/null and b/demos/esfm/pcbend.fur differ diff --git a/demos/misc/fragments_turbosound.fur b/demos/misc/fragments_turbosound.fur new file mode 100644 index 000000000..61064a7fc Binary files /dev/null and b/demos/misc/fragments_turbosound.fur differ diff --git a/demos/misc/vortex_opm.fur b/demos/misc/vortex_opm.fur new file mode 100644 index 000000000..5fd6a1a84 Binary files /dev/null and b/demos/misc/vortex_opm.fur differ diff --git a/demos/multichip/ComicPartytrack20.fur b/demos/multichip/ComicPartytrack20.fur deleted file mode 100644 index 61a6aee5a..000000000 Binary files a/demos/multichip/ComicPartytrack20.fur and /dev/null differ diff --git a/demos/nes/christmas-fever.fur b/demos/nes/christmas-fever.fur new file mode 100644 index 000000000..874530242 Binary files /dev/null and b/demos/nes/christmas-fever.fur differ diff --git a/demos/specs2/su_memory.fur b/demos/specs2/su_memory.fur deleted file mode 100644 index ff030dbe7..000000000 Binary files a/demos/specs2/su_memory.fur and /dev/null differ diff --git a/doc/2-interface/MIDI-value-input-1.png b/doc/2-interface/MIDI-value-input-1.png new file mode 100644 index 000000000..4e5df7be8 Binary files /dev/null and b/doc/2-interface/MIDI-value-input-1.png differ diff --git a/doc/2-interface/MIDI-value-input-2.png b/doc/2-interface/MIDI-value-input-2.png new file mode 100644 index 000000000..5173a2ded Binary files /dev/null and b/doc/2-interface/MIDI-value-input-2.png differ diff --git a/doc/2-interface/settings.md b/doc/2-interface/settings.md index 3571e7dd6..f65f23fcb 100644 --- a/doc/2-interface/settings.md +++ b/doc/2-interface/settings.md @@ -123,22 +123,21 @@ settings are saved when clicking the **OK** or **Apply** buttons at the bottom o - **Note input**: enables note input. disable if you intend to use this device only for binding actions. - **Velocity input**: enables velocity input when entering notes in the pattern. - **Map MIDI channels to direct channels**: when enabled, notes from MIDI channels will be mapped to channels rather than the cursor position. +- **Program change pass-through**: when enabled, program change events are sent to each channel as instrument change commands. + - this option is only available when the previous one is enabled. - **Map Yamaha FM voice data to instruments**: when enabled, Furnace will listen for any transmitted Yamaha SysEx patches. - this option is only useful if you have a Yamaha FM synthesizer (e.g. TX81Z). - selecting a voice or using the "Voice Transmit?" option will send a patch, and Furnace will create a new instrument with its data. - this may also be triggered by clicking on "Receive from TX81Z" in the instrument editor (OPZ only). - **Program change is instrument selection**: changes the current instrument when a program change event is received. + - this option is not available when "Program change pass-through" is enabled. - **Value input style**: changes the way values are entered when the pattern cursor is not in the Note column. the following styles are available: - **Disabled/custom**: no value input through MIDI. - **Two octaves (0 is C-4, F is D#5)**: maps keys in two octaves to single nibble input. the layout is: - - ` - octave n -- octave n+1 -` - - ` 1 3 6 8 A D F # # # ` - - `0 2 4 5 7 9 B C E # # # # #` + ![two octaves layout 1](MIDI-value-input-1.png) - **Raw (note number is value)**: the note number becomes the input value. not useful if you want to input anything above 7F. - **Two octaves alternate (lower keys are 0-9, upper keys are A-F)**: maps keys in two octaves, but with a different layout: - - ` - octave n -- octave n+1 -` - - ` A B C D E F # # # # ` - - `0 1 2 3 4 5 6 7 8 9 # # # #` + ![two octaves layout 2](MIDI-value-input-2.png) - **Use dual control change (one for each nibble)**: maps two control change events to the nibbles of a value. - **CC of upper nibble**: select the CC number that will change the upper nibble. - **CC of lower nibble**: select the CC number that will change the lower nibble. @@ -149,6 +148,7 @@ settings are saved when clicking the **OK** or **Apply** buttons at the bottom o - **Control**: select the CC number that will change the value. - **Per-column control change**: when enabled, you can map several control change events to a channel's columns. - **Volume curve**: adjust the velocity to volume curve. + - the default is 2.0, which matches General MIDI standard. - **Actions**: this allows you to bind note input and control change events to actions. - **`+`** button: adds a new action. - window-with-arrow button: new action with learning! press a button or move a slider/knob/something on your device. @@ -498,7 +498,7 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Rounded window corners** - **Rounded buttons** - **Rounded menu corners** -- **Borders around widgets**: draws thin borders on buttons, checkboxes, text widgets, and the like. +- **Borders around widgets**: draws borders on buttons, checkboxes, text widgets, and the like. @@ -509,6 +509,7 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Import** - **Export** - **Reset defaults** +- **Guru mode**: exposes all color options (instead of accent colors). - **General** - **Color scheme type:** - **Dark** diff --git a/doc/3-pattern/effects.md b/doc/3-pattern/effects.md index c76826c02..8182d4c93 100644 --- a/doc/3-pattern/effects.md +++ b/doc/3-pattern/effects.md @@ -93,6 +93,7 @@ not all chips support these effects. - this effect is currently incomplete. - `F5xx`: **Disable macro.** - `F6xx`: **Enable macro.** +- `F7xx`: **Restart macro.** - see macro table at the end of this document for possible values. additionally, [each chip has its own effects](../7-systems/README.md). diff --git a/doc/4-instrument/README.md b/doc/4-instrument/README.md index 56386082a..1ba003c13 100644 --- a/doc/4-instrument/README.md +++ b/doc/4-instrument/README.md @@ -1,186 +1,222 @@ -# instrument editor - -the instrument editor always starts with this section: - -![top of instrument editor](instrument-editor-top.png) - -- top-left numeric dropdown: instrument selector. -- folder icon: open an instrument file. -- save icon: save current instrument as a file. - - right-clicking gives the option to save a .dmp format DefleMask preset. -- **Name**: instrument name. -- **Type**: the system for which the instrument is intended. - - if changed, all applicable settings and macros will remain as they are. numbers will not be adjusted. - -## instrument types - -the following instrument types are available: - -- [SN76489/Sega PSG](psg.md) - for use with TI SN76489 and derivatives like Sega Master System's PSG. -- [FM (OPN)](fm-opn.md) - for use with YM2612, YM2203, YM2608, YM2610 and YM2610B. -- [Game Boy](game-boy.md) - for use with Game Boy APU. -- [C64](c64.md) - for use with Commodore 64 SID. -- [Generic Sample](sample.md) for controlling Amiga and other sample channels/chips like YM2612's Channel 6 PCM mode, NES channel 5, Sega PCM, X1-010 and PC Engine's sample playback mode. -- [PC Engine](pce.md) - for use with PC Engine's wavetable synthesizer. -- [AY-3-8910/SSG](ay8910.md) - for use with AY-3-8910 PSG sound source and SSG portion in YM2610. -- [AY8930](ay8930.md) - for use with Microchip AY8930 E-PSG sound source. -- [TIA](tia.md) - for use with Atari 2600 chip. -- [SAA1099](saa.md) - for use with Philips SAA1099 PSG sound source. -- [VIC](vic.md) - for use with VIC-20 sound chip. -- [PET](pet.md) - for use with Commodore PET. -- [VRC6](vrc6.md) - for use with VRC6's PSG sound source. -- [FM (OPLL)](fm-opll.md) - for use with YM2413. -- [FM (OPL)](fm-opll.md) - for use with YM3526 (OPL), YM3812 (OPL2) and YMF262 (OPL3). -- [FDS](fds.md) - for use with Famicom Disk System sound source. -- [Virtual Boy](virtual-boy.md) - for use with Virtual Boy. -- [Namco 163](n163.md) - for use with Namco 163. -- [Konami SCC/Bubble System WSG](scc.md) - for use with Konami SCC and Wavetable portion in Bubble System's sound hardware. -- [FM (OPZ)](fm-opz.md) - for use with YM2414. -- [POKEY](pokey.md) - for use with Atari 8-bit computers and their POKEY sound source. -- [Beeper](beeper.md) - for use with PC Speaker and ZX Spectrum Beeper (SFX-like engine). -- [WonderSwan](wonderswan.md) - for use with WonderSwan's wavetable synthesizer. -- [Atari Lynx](lynx.md) - for use with Atari Lynx handheld console. -- [VERA](vera.md) - for use with Commander X16 VERA. -- [Seta/Allumer X1-010](x1_010.md) - for use with Wavetable portion in Seta/Allumer X1-010. -- [ES5506](es5506.md) - for use with Ensoniq ES5506 sound chip. -- [SNES](snes.md) - for use with SNES. -- [Sound Unit](su.md) - for use with Sound Unit chip. -- [Namco WSG](wsg.md) - for use with Namco WSG wavetable chips, including C15 and C30. -- [FM (OPM)](fm-opm.md) - for use with YM2151. -- [NES](nes.md) - for use with NES. -- [MSM6258](msm6258.md) - for use with MSM6258 sample chip. -- [MSM6295](msm6295.md) - for use with MSM6295 sample chip. -- [ADPCM-A](adpcm-a.md) - for use with ADPCM-A sample chip. -- [ADPCM-B](adpcm-b.md) - for use with ADPCM-B sample chip. -- [SegaPCM](segapcm.md) - for use with SegaPCM sample chip. -- [QSound](qsound.md) - for use with QSound sample chip. -- [YMZ280B](ymz280b.md) - for use with YMZ280B sample chip. -- [RF5C68](rf5c68.md) - for use with RF5C68 sample chip. -- [MSM5232](msm5232.md) - for use with MSM5232 PSG sound source. -- [T6W28](t6w28.md) - for use with Toshiba T6W28 PSG sound source. -- [K007232](k007232.md) - for use with K007232 sample chip. -- [GA20](ga20.md) - for use with GA20 sample chip. -- [Pokémon Mini/QuadTone](pokemini.md) - for use with these systems. -- [SM8521](sm8521.md) - for use with SM8521 chip, used in Tiger Game.com. -- [PV-1000](pv1000.md) - for use with Casio PV-1000. -- [K053260](k053260.md) - for use with K053260 sample chip. -- [TED](ted.md) - for use with Commodore Plus/4 and Commodore 16's TED chip. -- [C140](c140.md) - for use with C140 sample chip. -- [C219](c219.md) - for use with C219 sample chip. - -## macros - -macros are incredibly versatile tools for automating instrument parameters. - -after creating an instrument, open the Instrument Editor and select the "Macros" tab. there may be multiple macro tabs to control individual FM operators and such. - -![macro view](macroview.png) - -the very first numeric entry sets the visible width of the bars in sequence-type macros. the scrollbar affects the view of all macros at once. there's a matching scrollbar at the bottom underneath all the macros. - -each macro has two buttons on the left. -- macro type (explained below). -- timing editor, which pops up a small dialog: - - **Step Length (ticks)**: determines how many ticks pass before each change of value. default is 1. - - **Delay**: delays the start of the macro until this many ticks have passed. default is 0. - - the button is highlighted if either of these is set differently from default. -- release mode. this determines how macro release is handled: - - **Active**: jumps to release position. - - **Passive**: does not jump to release position. if release position hasn't been reached yet, there will be a delay. - -## macro types - -every macro can be defined though one of three methods, selectable with the leftmost button under the macro type label: - -- ![sequence](macro-button-seq.png) **Sequence:** displayed as a bar graph, this is a sequence of numeric values. -- ![ADSR](macro-button-ADSR.png) **ADSR:** this is a traditional ADSR envelope, defined by the rate of increase and decrease of value over time. -- ![LFO](macro-button-LFO.png) **LFO:** the Low Frequency Oscillator generates a repeating wave of values. - -### sequence - -![sequence macro editor](macro-seq.png) - -![clipped sequence macro editor](macro-seq-clip.png) - -![bitmask sequence macro editor](macro-seq-bitmask.png) - -the number between the macro type label and the macro type button is the macro length in steps. the `-` and `+` buttons change the length of the macro. start out by adding at least a few steps. - -the values of the macro can be drawn in the "bar graph" box. -- arpeggio and pitch macros may have values above or below the visible area; small chevrons will be shown until they are scrolled into view. -- bitmask-style macros show labels for each of their bits, and these are edited as toggles. - -arpeggio macros have a short bar for setting whether to interpret the values as being "relative" or "fixed". -- by default, values are offsets **relative** to the note. -- if clicked on, a value becomes **fixed** and will be played at its corresponding note without regard to the note entered into the pattern. - - values are counted from `C-0`. for example, a fixed value of 48 produces a `C-4` note. - - fixed values are especially useful for noise instruments with preset periods. - -below this is a short bar that controls macro loop and release. -- click to set the start point of a loop; the end point is the last value or release point. it appears as half-height bars. right-click to remove the loop. -- shift-click to set the release point. when played, the macro will hold here until the note is released. it appears as a full-height bar. right-click to remove the release point. - -finally, the sequence of values can be directly edited in the text box at the bottom. -- the loop start is entered as a `|`. -- the release point is entered as a `/`. -- in arpeggio macros, a value starting with a `@` is a fixed value as described above. -- in bitmask-style macros, the values are added up in binary and converted to decimal. see [the hexadecimal guide](../1-intro/hex.md) for more info. - -in all cases except bitmask macros, right-clicking on the graph opens up an editing menu: -- **copy**: copies the macro. -- **paste**: pastes the macro in the clipboard. -- **clear**: clears the macro. -- **clear contents**: resets all values to 0. -- **offset**: - - **X**: slides the data "horizontally" within the macro, filling the gap with zeroes. data moved past the start or end is lost. - - **Y**: increases or decreases all values, clipping them if they would move past the allowed range. -- **scale**: - - **X**: stretches the macro. - - **Y**: multiplies all values by the scale factor, clipping them if they would exceed the allowed range. -- **randomize**: replaces all values with random values between **Min** and **Max**. - -### ADSR - -![ADSR macro editor](macro-ADSR.png) - -- **Bottom** and **Top** determine the range of outputs generated by the macro. (Bottom can be larger than Top to invert the envelope!) All outputs will be between these two values. -- Attack, Decay, Sustain, SusDecay, and Release accept inputs between 0 to 255. these are scaled to the distance between Bottom and Top. -- **Attack** is how much the value moves toward Top with each tick. -- **Hold** sets how many ticks to stay at Top before Decay. -- **Decay** is how much the value moves to the Sustain level. -- **Sustain** is how far from Bottom the value stays while the note is held. -- **SusTime** is how many ticks to stay at Sustain until SusDecay. -- **SusDecay** is how much the value moves toward Bottom with each tick while the note is held. -- **Release** is how much the value moves toward Bottom with each tick after the note is released. - -![macro ADSR chart](macro-ADSRchart.png) - -### LFO - -![LFO macro editor](macro-LFO.png) - -- **Bottom** and **Top** determine the range of values generated by the macro. (Bottom can be larger than Top to invert the waveform!) -- **Speed** is how quickly the values change - the frequency of the oscillator. -- **Phase** is which part of the waveform the macro will start at, measured in 1/1024 increments. -- **Shape** is the waveform used. triangle is the default, and Saw and Square are exactly as they say. - - - -## wavetable - -this tab appears for PC Engine, FDS, Namco WSG, and other wavetable-based instruments. - -![wavetable tab](wavetable.png) - -when **Enable synthesizer** is off, the wavetable used for the instrument may be selected by creating a Waveform macro with a single value. - -to use the wavetable synthesizer, refer to [the wavetable synthesizer section](wavesynth.md). - - -## sample - -this tab appears for Generic PCM DAC, Amiga and SNES. - -![sample tab](sample-map.png) - -see the [Generic Sample section](sample.md) for more information. +# instrument editor + +the instrument editor allows you to edit instruments. +it can be activated by double-clicking on an instrument in the instrument list. + +alternatively, window > instrument editor displays it. + +## main + +![top of instrument editor](instrument-editor-top.png) + +**TODO: add descriptions to buttons in the image. it really needs them.** + +- **Instrument Selector**: displays a list of instruments in the song. +- **Open**: open an instrument file. +- **Save**: save current instrument to a file. + - right-click to see additional options, such as saving in DefleMask preset format (.dmp). +- **Name**: changes the instrument name. +- **Type**: changes the instrument type (usually chip-specific). + - if changed, all applicable settings and macros will remain unchanged. + - you may have to adjust them afterwards. + +## instrument types + +the following instrument types are available: + +- [SN76489/Sega PSG](psg.md) - for use with TI SN76489 and derivatives like Sega Master System's PSG. +- [FM (OPN)](fm-opn.md) - for use with YM2612, YM2203, YM2608, YM2610 and YM2610B. +- [Game Boy](game-boy.md) - for use with Game Boy APU. +- [C64](c64.md) - for use with Commodore 64 SID. +- [Generic Sample](sample.md) for controlling Amiga and other sample channels/chips like YM2612's Channel 6 PCM mode, NES channel 5, Sega PCM, X1-010 and PC Engine's sample playback mode. +- [PC Engine](pce.md) - for use with PC Engine's wavetable synthesizer. +- [AY-3-8910/SSG](ay8910.md) - for use with AY-3-8910 PSG sound source and SSG portion in YM2610. +- [AY8930](ay8930.md) - for use with Microchip AY8930 E-PSG sound source. +- [TIA](tia.md) - for use with Atari 2600 chip. +- [SAA1099](saa.md) - for use with Philips SAA1099 PSG sound source. +- [VIC](vic.md) - for use with VIC-20 sound chip. +- [PET](pet.md) - for use with Commodore PET. +- [VRC6](vrc6.md) - for use with VRC6's PSG sound source. +- [FM (OPLL)](fm-opll.md) - for use with YM2413. +- [FM (OPL)](fm-opll.md) - for use with YM3526 (OPL), YM3812 (OPL2) and YMF262 (OPL3). +- [FM (ESFM)](fm-esfm.md) - for use with ESFM. +- [FDS](fds.md) - for use with Famicom Disk System sound source. +- [Virtual Boy](virtual-boy.md) - for use with Virtual Boy. +- [Namco 163](n163.md) - for use with Namco 163. +- [Konami SCC/Bubble System WSG](scc.md) - for use with Konami SCC and Wavetable portion in Bubble System's sound hardware. +- [FM (OPZ)](fm-opz.md) - for use with YM2414. +- [POKEY](pokey.md) - for use with Atari 8-bit computers and their POKEY sound source. +- [Beeper](beeper.md) - for use with PC Speaker and ZX Spectrum Beeper (SFX-like engine). +- [WonderSwan](wonderswan.md) - for use with WonderSwan's wavetable synthesizer. +- [Atari Lynx](lynx.md) - for use with Atari Lynx handheld console. +- [VERA](vera.md) - for use with Commander X16 VERA. +- [Seta/Allumer X1-010](x1_010.md) - for use with Wavetable portion in Seta/Allumer X1-010. +- [ES5506](es5506.md) - for use with Ensoniq ES5506 sound chip. +- [SNES](snes.md) - for use with SNES. +- [Sound Unit](su.md) - for use with Sound Unit chip. +- [Namco WSG](wsg.md) - for use with Namco WSG wavetable chips, including C15 and C30. +- [FM (OPM)](fm-opm.md) - for use with YM2151. +- [NES](nes.md) - for use with NES. +- [MSM6258](msm6258.md) - for use with MSM6258 sample chip. +- [MSM6295](msm6295.md) - for use with MSM6295 sample chip. +- [ADPCM-A](adpcm-a.md) - for use with ADPCM-A sample chip. +- [ADPCM-B](adpcm-b.md) - for use with ADPCM-B sample chip. +- [SegaPCM](segapcm.md) - for use with SegaPCM sample chip. +- [QSound](qsound.md) - for use with QSound sample chip. +- [YMZ280B](ymz280b.md) - for use with YMZ280B sample chip. +- [RF5C68](rf5c68.md) - for use with RF5C68 sample chip. +- [MSM5232](msm5232.md) - for use with MSM5232 PSG sound source. +- [T6W28](t6w28.md) - for use with Toshiba T6W28 PSG sound source. +- [K007232](k007232.md) - for use with K007232 sample chip. +- [GA20](ga20.md) - for use with GA20 sample chip. +- [Pokémon Mini/QuadTone](pokemini.md) - for use with these systems. +- [SM8521](sm8521.md) - for use with SM8521 chip, used in Tiger Game.com. +- [PV-1000](pv1000.md) - for use with Casio PV-1000. +- [K053260](k053260.md) - for use with K053260 sample chip. +- [TED](ted.md) - for use with Commodore Plus/4 and Commodore 16's TED chip. +- [C140](c140.md) - for use with C140 sample chip. +- [C219](c219.md) - for use with C219 sample chip. + +## macros + +macros are incredibly versatile tools for automating instrument parameters. + +after creating an instrument, open the Instrument Editor and select the "Macros" tab. there may be multiple macro tabs to control individual FM operators and such. + +![macro view](macroview.png) + +the very first numeric entry sets the visible width of the bars in sequence-type macros. the scrollbar affects the view of all macros at once. there is a matching scrollbar at the bottom underneath all the macros. + +each macro has the following parameters: +- macro type (explained below) +- timing options: + - **Step Length (ticks)**: determines the number of ticks between macro steps. default is 1. + - **Delay**: delays the macro until this many ticks have elapsed. default is 0. + - the button is highlighted if either of these parameters is set to non-default values. +- release mode: determines how macro release (`===` or `REL` in the pattern) is handled: + - **Active**: jumps to release position on release. + - **Passive**: does not jump to release position. this will result in delay if release position has not been reached yet. + +## macro types + +there are three macro types: + +- ![sequence](macro-button-seq.png) **Sequence:** a sequence of numeric values. +- ![ADSR](macro-button-ADSR.png) **ADSR:** this is an attack/decay/sustain/release envelope. +- ![LFO](macro-button-LFO.png) **LFO:** Low Frequency Oscillator. + +### sequence + +this is the most basic macro type. when the instrument is played, every value in the macro will be output sequentially, from left to right. + +![sequence macro editor](macro-seq.png) + +![clipped sequence macro editor](macro-seq-clip.png) + +![bitmask sequence macro editor](macro-seq-bitmask.png) + +**TODO: once again, text in the image. this sucks.** + +the Length field allows you to set the number of steps in the sequence. + +the sequence view allows you to edit the macro. +- press and hold the left mouse button to start drawing. release to stop drawing. +- press and hold the right mouse button to draw a line. + - the start point will be set to the cursor position. + - move the cursor to change the end point. + - release to finish drawing the line. + +the sequence view may be adjusted using the following combinations: +- hold Ctrl and use the scroll wheel to zoom horizontally. +- hold Ctrl-Shift and use the scroll wheel to zoom vertically. +- the scrollbar at the right allows you to scroll vertically (if possible). +- you may hold Shift and use the scroll wheel to scroll vertically as well. + +right-click on the sequence view to open a menu: +- **copy**: copy this macro to clipboard. +- **paste**: pastes the macro. +- **clear**: clears the macro. +- **clear contents**: resets all values to 0. +- **offset**: + - **X**: slides the data "horizontally" within the macro, filling the gap with zeroes. data moved past the start or end is lost. + - **Y**: increases or decreases all values, clipping them if they would move past the allowed range. +- **scale**: + - **X**: stretches the macro. + - **Y**: multiplies all values by the scale factor, clipping them if they would exceed the allowed range. +- **randomize**: replaces all values with random values between **Min** and **Max**. + +arpeggio and pitch macros may have values above or below the visible area. indicators will be shown until they are scrolled into view. + +bitmask-style macros show labels for each of their bits. these are edited as toggles. +- drawing lines is not possible in these macros. + +under the sequence view there is a bar that allows you to set loop and release points. +- click to set the loop start point; the end point is the last step or release point. + - right-click to remove the loop point. +- shift-click to set the release point. + - the macro will stop at the release point until the note is released (`===` or `REL`). + - if the loop point is set, and it is placed before the release point, the macro will loop until note release instead. + - shift-right-click to remove the release point. + +arpeggio macros have an additional bar under the sequence view to set steps to "relative" or "fixed": +- by default, step values are offsets **relative** to the note. +- if clicked on, a step value becomes **fixed** and will be played at its corresponding note without regard to the currently playing note. + - values are counted from `C-0`. for example, a fixed value of 48 produces a `C-4` note. + - fixed values are especially useful for noise or percussion. + +the sequence can be edited in the text input field at the very bottom. the following symbols have special meanings: +- `|`: loop point. +- `/`: release point. +- in arpeggio macros, `@` prefixed to a value indicates that it is a fixed value as described above. + +in bitmask-style macros, the values are added up in binary and converted to decimal. + +### ADSR + +![ADSR macro editor](macro-ADSR.png) + +- **Bottom** and **Top** determine the macro's output range (Bottom can be larger than Top to invert the envelope!). all outputs will be between these two values. +- Attack, Decay, Sustain, SusDecay, and Release accept inputs between 0 to 255. these are scaled to the distance between Bottom and Top. + - the output starts at Bottom. + - **Attack** is how much the output moves toward Top with each tick. + - **Hold** sets how many ticks to stay at Top before Decay. + - **Decay** is how much the output moves to the Sustain level. + - **Sustain** is how far from Bottom the value stays while the note is on. + - **SusTime** is how many ticks to stay at Sustain until SusDecay. + - **SusDecay** is how much the output moves toward Bottom with each tick while the note is on. + - **Release** is how much the output moves toward Bottom with each tick after the note is released. + +![macro ADSR chart](macro-ADSRchart.png) + +### LFO + +![LFO macro editor](macro-LFO.png) + +- **Bottom** and **Top** determine the macro's output range (Bottom can be larger than Top to invert the waveform!). +- **Speed** is how quickly the LFO position moves. +- **Phase** defines the starting LFO position, measured in 1/1024 increments. +- **Shape** is the waveform of the LFO. there are three waveforms: + - Triangle: Bottom > Top > Bottom. + - Saw: moves from Bottom to Top, and then jumps back to Bottom. + - Square: alternates between Bottom and Top. + + + +## wavetable + +this tab appears for PC Engine, FDS, Namco WSG, and other wavetable-based instruments. + +![wavetable tab](wavetable.png) + +when **Enable synthesizer** is off, the wavetable used for the instrument may be selected by creating a Waveform macro with a single value. + +to use the wavetable synthesizer, refer to [the wavetable synthesizer section](wavesynth.md). + + +## sample + +this tab appears for Generic PCM DAC, Amiga and SNES. + +![sample tab](sample-map.png) + +see the [Generic Sample section](sample.md) for more information. diff --git a/doc/4-instrument/beeper.md b/doc/4-instrument/beeper.md index 18fca296d..75c61d6ae 100644 --- a/doc/4-instrument/beeper.md +++ b/doc/4-instrument/beeper.md @@ -1,9 +1,9 @@ -# beeper instrument editor - -used in PC Speaker and ZX Spectrum (SFX-like engine). - -- **Volume**: on-off volume sequence. -- **Arpeggio**: pitch sequence. -- **Pulse Width**: pulse width sequence. - - only on ZX Spectrum. -- **Pitch**: fine pitch. +# beeper instrument editor + +used in PC Speaker and ZX Spectrum (SFX-like engine). + +- **Volume**: on-off volume sequence. +- **Arpeggio**: pitch sequence. +- **Pulse Width**: pulse width sequence. + - only on ZX Spectrum. +- **Pitch**: fine pitch. diff --git a/doc/4-instrument/fm-esfm.md b/doc/4-instrument/fm-esfm.md new file mode 100644 index 000000000..50fdec3d8 --- /dev/null +++ b/doc/4-instrument/fm-esfm.md @@ -0,0 +1,77 @@ +# ESFM instrument editor + +the ESFM editor is divided into 6 tabs: + +- **FM**: for controlling the basic parameters of FM sound source. +- **Macros (OP1)**: for macros controlling FM parameters of operator 1. +- **Macros (OP2)**: for macros controlling FM parameters of operator 2. +- **Macros (OP3)**: for macros controlling FM parameters of operator 3. +- **Macros (OP4)**: for macros controlling FM parameters of operator 4. +- **Macros**: for other macros (volume/arp/pitch/pan/noise mode). + +## FM + +ESFM is four-operator, but it is different from the rest of FM chips. + +the concept of an algorithm does not exist in ESFM. instead, modulation routing is arbitrary, with each operator having output level and modulation input parameters. + +these apply to the instrument as a whole: +- **OP4 Noise Mode**: determines the mode used to produce noise in operator 4. + - Normal: noise is disabled. + - Snare: takes the snare noise generation mode from OPL. square + noise. + - HiHat: ring modulates with operator 3 and adds noise. + - Top: ring modulates with operator 3 and double pitch modulation input. + - this mode is not emulated correctly. subject to change! + +these apply to each operator: +- the crossed-arrows button can be dragged to rearrange operators. +- **Amplitude Modulation (AM)**: makes the operator affected by LFO tremolo. +- **Sustain flag (SUS)**: when enabled, value of Sustain Level is in effect. +- **AM Depth (AMD)**: when enabled, LFO tremolo is deeper. +- **Attack Rate (AR)**: determines the rising time for the sound. the bigger the value, the faster the attack (0 to 15). +- **Decay Rate (DR)**: determines the diminishing time for the sound. the higher the value, the shorter the decay. it's the initial amplitude decay rate (0 to 15). +- **Sustain Level (SL)**: determines the point at which the sound ceases to decay and changes to a sound having a constant level. the sustain level is expressed as a fraction of the maximum level (0 to 15). +- **Release Rate (RR)**: determines the rate at which the sound disappears after note off. the higher the value, the shorter the release (0 to 15). + +- **Total Level (TL)**: represents the envelope’s highest amplitude, with 0 being the largest and 63 (decimal) the smallest. a change of one unit is about 0.75 dB. +- **Output Level (OL)**: determines the volume at which the operator will be output. +- **Modulation Input (MI)**: determines how much to take from the previous operator for modulation. + - this controls feedback level in the case of operator 1. +- **Key Scale Level (KSL)**: also known as "Level Scale". determines the degree to which the amplitude decreases according to the pitch. + +![FM ADSR chart](FM-ADSRchart.png) + +- **Key Scale Rate (KSR)**: also known as "Rate Scale". determines the degree to which the envelope execution speed increases according to the pitch. +- **Frequency Multiplier (MULT)**: sets the coarse pitch offset in relation to the note (0 to 15). 0 is -1 octave, 1 is 0 octaves, 2 is 1 octave, 3 is 1 octave 7 semitones, and so on. + - note that values 11, 13 and 14 behave as 10, 12 and 12 respectively. +- **Waveform Select (WS)**: changes the waveform of the operator (0 to 7). +- **Vibrato (VIB)**: makes the operator affected by LFO vibrato. +- **FM Depth (FMD)**: when enabled, vibrato is deeper. + +- **Tune**: sets the coarse tune of the operator. +- **Detune**: sets the fine tune of the operator. + +- **Left (L)**: output on the left channel. +- **Right (R)**: output on the right channel. + +### fixed frequency mode + +each operator has a Fixed Frequency mode. once enabled, the operator runs at the specified frequency regardless of the note. + +## macros + +these macros allow you to control several parameters of FM per tick. + +## OP1-OP4 Macros + +all parameters are listed above. + +## Macros + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **OP4 Noise Mode**: noise mode sequence. +- **Panning**: enables output on left/right channels. +- **Pitch**: fine pitch. + - **Relative**: when enabled, pitch changes are relative to the current pitch. +- **Phase Reset**: restarts all operators and resets the waveform to its start. diff --git a/doc/4-instrument/msm5232.md b/doc/4-instrument/msm5232.md index 31c10320e..0c7648afe 100644 --- a/doc/4-instrument/msm5232.md +++ b/doc/4-instrument/msm5232.md @@ -1,16 +1,16 @@ -# MSM5232 instrument editor - -the instrument editor for MSM5232 consists of these macros: - -- **Volume**: volume sequence. - - only has effect when the envelope mode of a group is set to External. -- **Arpeggio**: pitch sequence. -- **Group Ctrl**: group control sequence: - - **sustain**: enable sustain mode. - - **2'**: enable 2' overtone. - - **4'**: enable 4' overtone. - - **8'**: enable 8' overtone. - - **16'**: enable 16' overtone. -- **Group Attack**: set attack rate of group. -- **Group Decay**: set decay rate of group. -- **Noise**: toggle noise mode. +# MSM5232 instrument editor + +the instrument editor for MSM5232 consists of these macros: + +- **Volume**: volume sequence. + - only has effect when the envelope mode of a group is set to External. +- **Arpeggio**: pitch sequence. +- **Group Ctrl**: group control sequence: + - **sustain**: enable sustain mode. + - **2'**: enable 2' overtone. + - **4'**: enable 4' overtone. + - **8'**: enable 8' overtone. + - **16'**: enable 16' overtone. +- **Group Attack**: set attack rate of group. +- **Group Decay**: set decay rate of group. +- **Noise**: toggle noise mode. diff --git a/doc/4-instrument/nes.md b/doc/4-instrument/nes.md index 64f5c0d08..742fc2109 100644 --- a/doc/4-instrument/nes.md +++ b/doc/4-instrument/nes.md @@ -1,52 +1,52 @@ -# NES instrument editor - -the NES instrument editor consists of two tabs. - -## DPCM - -this tab is somewhat similar to [the Sample instrument editor](sample.md), but it has been tailored for use with NES' DPCM channel. - -- **Sample**: specifies which sample should be assigned to the instrument. -- **Use sample map**: enables mapping different samples to notes. see next section for more information. - - when this option is disabled, 16 notes (from C-0 to D#1 and repeating) will map to the DPCM channel's 16 possible pitches. - -### sample map - -the sample map allows you to set a sample for each note. - -after enabling this option, a table appears with the contents of the sample map. -- the first column represents the input note. -- the second column allows you to type in a sample number for each note. - - you may press Delete to clear it. -- the third one is used to set the DPCM pitch at which the specified sample will play. - - for possible values, refer to the table below. - - you may press Delete to clear it. if no value is specified, the last pitch is used. -- the fourth column allows you to set the initial delta counter value when playing the sample. - - this is an hexadecimal number. - - the range is `00` to `7F`. - - you may press Delete to clear it. if no value is specified, the delta counter isn't altered. -- the fifth and last column provides a combo box for selecting a sample. - -you may right-click anywhere in the number, pitch and delta columns for additional options: -- **set entire map to this pitch**: sets the DPCM pitch of all notes to the selected cell's. -- **set entire map to this delta counter value**: sets the initial delta counter value of all notes to the selected cell's. -- **set entire map to this sample**: sets the sample number of all notes to the selected cell's. -- **reset pitches**: resets the sample map's DPCM pitches to defaults (15). -- **clear delta counter values**: removes all delta counter values from the map. -- **clear map samples**: removes all samples from the map. - -## Macros - -- **Volume**: volume sequence. -- **Arpeggio**: pitch sequence. -- **Duty/Noise**: duty cycle and noise mode. - - pulse duty cycles: - - `0`: 12.5% - - `1`: 25% - - `2`: 50% - - `3`: 75% - - noise modes: - - `0`: long noise - - `1`: short noise -- **Pitch**: fine pitch. -- **Phase Reset**: trigger restart of waveform. +# NES instrument editor + +the NES instrument editor consists of two tabs. + +## DPCM + +this tab is somewhat similar to [the Sample instrument editor](sample.md), but it has been tailored for use with NES' DPCM channel. + +- **Sample**: specifies which sample should be assigned to the instrument. +- **Use sample map**: enables mapping different samples to notes. see next section for more information. + - when this option is disabled, 16 notes (from C-0 to D#1 and repeating) will map to the DPCM channel's 16 possible pitches. + +### sample map + +the sample map allows you to set a sample for each note. + +after enabling this option, a table appears with the contents of the sample map. +- the first column represents the input note. +- the second column allows you to type in a sample number for each note. + - you may press Delete to clear it. +- the third one is used to set the DPCM pitch at which the specified sample will play. + - for possible values, refer to the table below. + - you may press Delete to clear it. if no value is specified, the last pitch is used. +- the fourth column allows you to set the initial delta counter value when playing the sample. + - this is an hexadecimal number. + - the range is `00` to `7F`. + - you may press Delete to clear it. if no value is specified, the delta counter isn't altered. +- the fifth and last column provides a combo box for selecting a sample. + +you may right-click anywhere in the number, pitch and delta columns for additional options: +- **set entire map to this pitch**: sets the DPCM pitch of all notes to the selected cell's. +- **set entire map to this delta counter value**: sets the initial delta counter value of all notes to the selected cell's. +- **set entire map to this sample**: sets the sample number of all notes to the selected cell's. +- **reset pitches**: resets the sample map's DPCM pitches to defaults (15). +- **clear delta counter values**: removes all delta counter values from the map. +- **clear map samples**: removes all samples from the map. + +## Macros + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **Duty/Noise**: duty cycle and noise mode. + - pulse duty cycles: + - `0`: 12.5% + - `1`: 25% + - `2`: 50% + - `3`: 75% + - noise modes: + - `0`: long noise + - `1`: short noise +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. diff --git a/doc/4-instrument/pokemini.md b/doc/4-instrument/pokemini.md index ceec01a1c..3368c2506 100644 --- a/doc/4-instrument/pokemini.md +++ b/doc/4-instrument/pokemini.md @@ -1,8 +1,8 @@ -# Pokémon Mini/QuadTone instrument editor - -used in these two chips/systems. these macros are available: - -- **Volume**: volume sequence. -- **Arpeggio**: pitch sequence. -- **Pulse Width**: pulse width sequence. -- **Pitch**: fine pitch. +# Pokémon Mini/QuadTone instrument editor + +used in these two chips/systems. these macros are available: + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **Pulse Width**: pulse width sequence. +- **Pitch**: fine pitch. diff --git a/doc/4-instrument/pokey.md b/doc/4-instrument/pokey.md index 8b3ac7fc4..091e8f45a 100644 --- a/doc/4-instrument/pokey.md +++ b/doc/4-instrument/pokey.md @@ -1,25 +1,25 @@ -# Atari POKEY instrument editor - -the instrument editor for POKEY consists of these macros: - -- **Volume**: volume sequence. -- **Arpeggio**: pitch sequence. -- **AUDCTL**: audio control register sequence: - - **poly9**: reduces size of LFSR. only on noise waveforms! - - **high1**: runs channel 1 at 1.79MHz. - - **high3**: runs channel 3 at 1.79MHz. - - **16-bit 1+2**: enables 16-bit frequency mode by combining channels 1 and 2. - - **16-bit 3+4**: enables 16-bit frequency mode by combining channels 3 and 4. - - **filter 1+3**: applies a high-pass "filter" by combining channels 1 and 3. - - **filter 2+4**: applies a high-pass "filter" by combining channels 2 and 4. - - **15KHz**: runs channels at 15KHz. -- **Waveform**: wave selection sequence: - - 0: harsh noise (poly5+17) - - 1: square buzz (poly5) - - 2: weird noise (poly4+5) - - 3: square buzz (poly5) - - 4: soft noise (poly17) - - 5: square - - 6: bass (poly4) - - 7: buzz (poly4) -- **Pitch**: fine pitch. +# Atari POKEY instrument editor + +the instrument editor for POKEY consists of these macros: + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **AUDCTL**: audio control register sequence: + - **poly9**: reduces size of LFSR. only on noise waveforms! + - **high1**: runs channel 1 at 1.79MHz. + - **high3**: runs channel 3 at 1.79MHz. + - **16-bit 1+2**: enables 16-bit frequency mode by combining channels 1 and 2. + - **16-bit 3+4**: enables 16-bit frequency mode by combining channels 3 and 4. + - **filter 1+3**: applies a high-pass "filter" by combining channels 1 and 3. + - **filter 2+4**: applies a high-pass "filter" by combining channels 2 and 4. + - **15KHz**: runs channels at 15KHz. +- **Waveform**: wave selection sequence: + - 0: harsh noise (poly5+17) + - 1: square buzz (poly5) + - 2: weird noise (poly4+5) + - 3: square buzz (poly5) + - 4: soft noise (poly17) + - 5: square + - 6: bass (poly4) + - 7: buzz (poly4) +- **Pitch**: fine pitch. diff --git a/doc/4-instrument/psg.md b/doc/4-instrument/psg.md index 6b09e534f..aac9260c1 100644 --- a/doc/4-instrument/psg.md +++ b/doc/4-instrument/psg.md @@ -1,15 +1,15 @@ -# Sega PSG instrument editor - -the instrument editor for Sega PSG (SMS, and other TI SN76489 derivatives) consists of these macros: - -- **Volume**: volume sequence. -- **Arpeggio**: pitch sequence. -- **Duty**: noise mode. - - `0`: short noise; preset frequencies. - - `1`: long noise; preset frequencies. - - `2`: short noise; use channel 3 for frequency. - - `3`: long noise; use channel 3 for frequency. -- **Panning**: output for left and right channels. - - only on Game Gear! -- **Pitch**: fine pitch. -- **Phase Reset**: trigger restart of waveform. +# Sega PSG instrument editor + +the instrument editor for Sega PSG (SMS, and other TI SN76489 derivatives) consists of these macros: + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **Duty**: noise mode. + - `0`: short noise; preset frequencies. + - `1`: long noise; preset frequencies. + - `2`: short noise; use channel 3 for frequency. + - `3`: long noise; use channel 3 for frequency. +- **Panning**: output for left and right channels. + - only on Game Gear! +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. diff --git a/doc/4-instrument/t6w28.md b/doc/4-instrument/t6w28.md index 8343733bd..3d548408e 100644 --- a/doc/4-instrument/t6w28.md +++ b/doc/4-instrument/t6w28.md @@ -1,13 +1,13 @@ -# T6W28 instrument editor - -the instrument editor for T6W28 consists of these macros: - -- **Volume**: volume sequence. -- **Arpeggio**: pitch sequence. -- **Noise Type**: noise type sequence: - - `0`: short noise - - `1`: long noise -- **Panning (left)**: output level for left channel. -- **Panning (right)**: output level for right channel. -- **Pitch**: fine pitch. -- **Phase Reset**: trigger restart of waveform. +# T6W28 instrument editor + +the instrument editor for T6W28 consists of these macros: + +- **Volume**: volume sequence. +- **Arpeggio**: pitch sequence. +- **Noise Type**: noise type sequence: + - `0`: short noise + - `1`: long noise +- **Panning (left)**: output level for left channel. +- **Panning (right)**: output level for right channel. +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. diff --git a/doc/7-systems/README.md b/doc/7-systems/README.md index a8387d85e..4c1d09f98 100644 --- a/doc/7-systems/README.md +++ b/doc/7-systems/README.md @@ -108,8 +108,9 @@ this is the full list of chips that Furnace supports. - [VRC6](vrc6.md) - [WonderSwan](wonderswan.md) - [X1-010](x1-010.md) -- [VRC7, Y8950, YM3526, YM3812 and YMF262 (OPL)](opl.md) -- [YM2413 (OPLL)](opll.md) +- [Y8950, YM3526, YM3812 and YMF262 (OPL)](opl.md) +- [ESFM](esfm.md) +- [VRC7 and YM2413 (OPLL)](opll.md) - [YM2414 (OPZ)](opz.md) - [YM2151 (OPM)](ym2151.md) - [YM2203 (OPN)](ym2203.md) diff --git a/doc/7-systems/dac.md b/doc/7-systems/dac.md index 7639495ea..74a9c7df7 100644 --- a/doc/7-systems/dac.md +++ b/doc/7-systems/dac.md @@ -1,13 +1,13 @@ -# Generic PCM DAC - -a sample channel, with freely selectable rate, mono/stereo and bit depth settings. - -with it, you can emulate PCM DACs found in Williams arcade boards, Sound Blasters, MSX TurboR, Atari STe, NEC PC-9801-86, among others. - -## effects - -none yet. - -## info - -this chip uses the [Generic Sample](../4-instrument/sample.md) instrument editor. +# Generic PCM DAC + +a sample channel, with freely selectable rate, mono/stereo and bit depth settings. + +with it, you can emulate PCM DACs found in Williams arcade boards, Sound Blasters, MSX TurboR, Atari STe, NEC PC-9801-86, among others. + +## effects + +none yet. + +## info + +this chip uses the [Generic Sample](../4-instrument/sample.md) instrument editor. diff --git a/doc/7-systems/es5506.md b/doc/7-systems/es5506.md index d6ddb9d79..ff4eb1db3 100644 --- a/doc/7-systems/es5506.md +++ b/doc/7-systems/es5506.md @@ -1,46 +1,46 @@ -# Ensoniq ES5506 (OTTO) - -sample-based synthesis chip used in a bunch of Taito arcade machines and PC sound cards like Soundscape Elite. a variant of it was the heart of the well-known Gravis Ultrasound. - -it has a whopping 32 channels of 16-bit PCM and: - -- real time digital filters -- linear interpolation -- loop start and stop positions for each voice (bidirectional and reverse looping) -- internal volume multiplication and stereo panning -- hardware support for short envelopes - -## effects - -- `10xx`: **set waveform.** -- `11xx`: **set filter mode.** values are `0` through `3`. -- `120x`: **set pause (bit 0).** pauses the sample until the bit is unset; it will then resume where it left off. -- `14xx`: **set filter coefficient K1 low byte.** -- `15xx`: **set filter coefficient K1 high byte.** -- `16xx`: **set filter coefficient K2 low byte.** -- `17xx`: **set filter coefficient K2 high byte.** -- `18xx`: **set filter coefficient K1 slide up.** -- `19xx`: **set filter coefficient K1 slide down.** -- `1Axx`: **set filter coefficient K2 slide up.** -- `1Bxx`: **set filter coefficient K2 slide down.** -- `20xx`: **set envelope count.** -- `22xx`: **set envelope left volume ramp.** -- `23xx`: **set envelope right volume ramp.** -- `24xx`: **set envelope filter coefficient K1 ramp.** -- `25xx`: **set envelope filter coefficient K1 ramp (slower).** -- `26xx`: **set envelope filter coefficient K2 ramp.** -- `27xx`: **set envelope filter coefficient K2 ramp (slower).** -- `3xxx`: **set coarse filter coefficient K1.** -- `4xxx`: **set coarse filter coefficient K2.** -- `81xx`: **set panning (left channel).** -- `82xx`: **set panning (right channel).** -- `88xx`: **set panning (rear channels).** -- `89xx`: **set panning (rear left channel).** -- `8Axx`: **set panning (rear right channel).** -- `9xxx`: **set sample offset.** - - resets sample position to `xxx * 0x100`. -- `DFxx`: **set sample playback direction.** - -## info - -this chip uses the [ES5506](../4-instrument/es5506.md) instrument editor. +# Ensoniq ES5506 (OTTO) + +sample-based synthesis chip used in a bunch of Taito arcade machines and PC sound cards like Soundscape Elite. a variant of it was the heart of the well-known Gravis Ultrasound. + +it has a whopping 32 channels of 16-bit PCM and: + +- real time digital filters +- linear interpolation +- loop start and stop positions for each voice (bidirectional and reverse looping) +- internal volume multiplication and stereo panning +- hardware support for short envelopes + +## effects + +- `10xx`: **set waveform.** +- `11xx`: **set filter mode.** values are `0` through `3`. +- `120x`: **set pause (bit 0).** pauses the sample until the bit is unset; it will then resume where it left off. +- `14xx`: **set filter coefficient K1 low byte.** +- `15xx`: **set filter coefficient K1 high byte.** +- `16xx`: **set filter coefficient K2 low byte.** +- `17xx`: **set filter coefficient K2 high byte.** +- `18xx`: **set filter coefficient K1 slide up.** +- `19xx`: **set filter coefficient K1 slide down.** +- `1Axx`: **set filter coefficient K2 slide up.** +- `1Bxx`: **set filter coefficient K2 slide down.** +- `20xx`: **set envelope count.** +- `22xx`: **set envelope left volume ramp.** +- `23xx`: **set envelope right volume ramp.** +- `24xx`: **set envelope filter coefficient K1 ramp.** +- `25xx`: **set envelope filter coefficient K1 ramp (slower).** +- `26xx`: **set envelope filter coefficient K2 ramp.** +- `27xx`: **set envelope filter coefficient K2 ramp (slower).** +- `3xxx`: **set coarse filter coefficient K1.** +- `4xxx`: **set coarse filter coefficient K2.** +- `81xx`: **set panning (left channel).** +- `82xx`: **set panning (right channel).** +- `88xx`: **set panning (rear channels).** +- `89xx`: **set panning (rear left channel).** +- `8Axx`: **set panning (rear right channel).** +- `9xxx`: **set sample offset.** + - resets sample position to `xxx * 0x100`. +- `DFxx`: **set sample playback direction.** + +## info + +this chip uses the [ES5506](../4-instrument/es5506.md) instrument editor. diff --git a/doc/7-systems/esfm.md b/doc/7-systems/esfm.md new file mode 100644 index 000000000..bd53589a4 --- /dev/null +++ b/doc/7-systems/esfm.md @@ -0,0 +1,101 @@ +# ESS ESFM + +an enhanced version of Yamaha's OPL3, adding many features which weren't present on the original chip, such as 4-op on all channels, coarse/fine detune, per-op panning, envelope delay, noise generator and advanced modulation routing (no more algorithms!). + +the technology was present in many of ESS' sound cards (the ES1xxx series in particular). + +## effects + +- `10xy`: **set AM depth.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is either `0` (1dB, shallow) or `1` (4.8dB, deep). +- `12xx`: **set operator 1 level.** +- `13xx`: **set operator 2 level.** +- `14xx`: **set operator 3 level.** +- `15xx`: **set operator 4 level.** +- `16xy`: **set multiplier of operator.** + - `x` is the operator (1-4). + - `y` is the new MULT value.. +- `17xy`: **set vibrato depth.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is either `0` (normal) or `1` (double). +- `19xx`: **set attack of all operators.** +- `1Axx`: **set attack of operator 1.** +- `1Bxx`: **set attack of operator 2.** +- `1Cxx`: **set attack of operator 3.** +- `1Dxx`: **set attack of operator 4.** +- `20xy`: **set panning of operator 1.** + - `x` determines whether to output on left. + - `y` determines whether to output on right. +- `21xy`: **set panning of operator 2.** + - `x` determines whether to output on left. + - `y` determines whether to output on right. +- `22xy`: **set panning of operator 3.** + - `x` determines whether to output on left. + - `y` determines whether to output on right. +- `23xy`: **set panning of operator 4.** + - `x` determines whether to output on left. + - `y` determines whether to output on right. +- `24xy`: **set output level of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `25xy`: **set modulation input level of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `26xy`: **set envelope delay of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `27xx`: **set operator 4 noise mode.** + - `0`: noise off + - `1`: square + noise + - `2`: ring mod from operator 3 + noise + - `3`: ring mod from operator 3 + double pitch modulation input + - note: emulation issues. subject to change! +- `2Axy`: **set waveform of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `2Exx`: **enable envelope hard reset.** +- `2Fxy`: **set fixed frequency block (octave).** + - `x` is the operator from 1 to 4. + - `y` is the block/octave from 0 to 7. +- `3xyy`: **set fixed frequency f-num.** + - `x` contains operator number and high bits of f-num may be any of the following: + - `0` to `3` for operator 1 + - `4` to `7` for operator 2 + - `8` to `B` for operator 3 + - `C` to `F` for operator 4 + - `y` are the lower bits of f-num. +- `40xx`: **set operator 1 detune.** +- `41xx`: **set operator 1 detune.** +- `42xx`: **set operator 1 detune.** +- `43xx`: **set operator 1 detune.** +- `50xy`: **set AM of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` determines whether AM is on. +- `51xy`: **set SL of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `52xy`: **set RR of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `53xy`: **set VIB of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` determines whether VIB is on. +- `54xy`: **set KSL of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` is the value. +- `55xy`: **set SUS of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` determines whether SUS is on. +- `56xx`: **set DR of all operators.** +- `57xx`: **set DR of operator 1.** +- `58xx`: **set DR of operator 2.** +- `59xx`: **set DR of operator 3.** +- `5Axx`: **set DR of operator 4.** +- `5Bxy`: **set KSR of operator.** + - `x` is the operator from 1 to 4. a value of `0` means "all operators". + - `y` determines whether KSR is on. + +## info + +this chip uses the [FM (ESFM)](../4-instrument/fm-esfm.md) instrument editor. diff --git a/doc/7-systems/n163.md b/doc/7-systems/n163.md index a810f8106..78cc2562c 100644 --- a/doc/7-systems/n163.md +++ b/doc/7-systems/n163.md @@ -6,7 +6,7 @@ it has 256 nibbles (128 bytes) of internal RAM which is shared between channel s wavetables are variable in size and may be allocated anywhere in RAM. at least 128 nibbles (64 bytes) can be dedicated to waves, with more available if not all channels are used - waveform RAM area becomes smaller as more channels are activated, since channel registers consume 8 bytes for each channel. -Namco 163 uses time-division multiplexing for its output. this means that only one channel is output per sample (like OPLL and OPN2). therefore, its sound quality gets worse as more channels are activated. +Namco 163 uses time-division multiplexing (TDM) for its output. this means that only one channel is output per sample (like OPLL and OPN2). therefore, its sound quality gets worse as more channels are activated. ## waveform load position versus waveform position @@ -39,6 +39,13 @@ if the waveform changes (e.g. ins change, wave macro or wave synth), or the **lo - make sure to use `21xx` first! - `21xx`: **set position for 20xx.** +## chip options + +- **Initial channel limit**: sets the number of channels that will be active. higher values reduce volume and make TDM artifacts more noticeable. +- **Disable hissing**: remove TDM artifacts by mixing. sacrifices some accuracy! +- **Scale frequency to wave length**: automatically adjusts note frequency to account for differing waveform lengths. + - if disabled, note frequencies ignore waveveform length. this is how FamiTracker behaves. + ## info this chip uses the [Namco 163](../4-instrument/n163.md) instrument editor. diff --git a/doc/7-systems/opll.md b/doc/7-systems/opll.md index 2cf068c13..4de890b22 100644 --- a/doc/7-systems/opll.md +++ b/doc/7-systems/opll.md @@ -15,8 +15,8 @@ the YM2413 is equipped with the following features: - a drum/percussion mode, replacing the last 3 voices with 5 rhythm channels, with drum mode tones hard-defined in the chip itself, like FM instruments. only pitch might be altered. - drum mode works like following: FM channel 7 is for Kick Drum, which is a normal FM channel but routed through mixer twice for 2× volume, like all drum sounds. FM channel 8 splits to Snare, Drum, and Hi-Hat. Snare Drum is the carrier and it works with a special 1 bit noise generator combined with a square wave, all possible by overriding phase-generator with some different synthesis method. Hi-Hat is the modulator and it works with the noise generator and also the special synthesis. channel 9 splits to Top-Cymbal and Tom-Tom, Top-Cymbal is the carrier and only has the special synthesis, while Tom-Tom is basically a 1op wave. - special synthesis mentioned already is: 5 square waves are gathered from 4×, 64× and 128× the pitch of channel 8 and 16× and 64× the pitch of channel 9 and they go through a process where 2 HH bits OR'd together, then 1 HH and 1 TC bit OR'd, then the two TC bits OR'd together, and those 3 results get XOR'd. -- 1 user-definable patch (this patch can be changed throughout the course of the song) -- 15 pre-defined patches which can all be used at the same time +- **1 user-definable patch (this patch can be changed throughout the course of the song)** +- **15 pre-defined patches which can all be used at the same time** - support for ADSR on both the modulator and the carrier - sine and half-sine based FM synthesis - 9 octave note control diff --git a/doc/8-advanced/chanosc.md b/doc/8-advanced/chanosc.md index 720b550fe..6a2cd27ed 100644 --- a/doc/8-advanced/chanosc.md +++ b/doc/8-advanced/chanosc.md @@ -33,6 +33,7 @@ right-clicking the view will display the configuration view shown above: - `%v`: volume (decimal) - `%V`: volume (percentage) - `%b`: volume (hex) + - `%l`: new line - `%%`: percent sign click on OK to return to the main view. diff --git a/doc/README.md b/doc/README.md index 9870cb925..be719e561 100644 --- a/doc/README.md +++ b/doc/README.md @@ -27,7 +27,7 @@ the index follows. ## information -copyright © 2023 tildearrow and other authors. +copyright © 2024 tildearrow and other authors. this documentation is under the [Creative Commons Attribution 3.0 Unported](https://creativecommons.org/licenses/by/3.0/) license. you may reproduce, modify and/or distribute this documentation provided this copyright notice (including license and attribution) is present and any necessary disclaimers whether modifications have been made. diff --git a/extern/ESFMu/.gitignore b/extern/ESFMu/.gitignore new file mode 100644 index 000000000..7cb2b78a0 --- /dev/null +++ b/extern/ESFMu/.gitignore @@ -0,0 +1 @@ +test_scripts/* diff --git a/extern/ESFMu/LICENSE b/extern/ESFMu/LICENSE new file mode 100644 index 000000000..8000a6faa --- /dev/null +++ b/extern/ESFMu/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random + Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/extern/ESFMu/README.md b/extern/ESFMu/README.md new file mode 100644 index 000000000..5e04ef6fb --- /dev/null +++ b/extern/ESFMu/README.md @@ -0,0 +1,67 @@ +# ESFMu + +An emulator for the ESS "ESFM" enhanced OPL3 clone, based on Nuke.YKT's **Nuked OPL3** and reverse-engineering efforts from the community. + +## Acknowledgements + +I'd like to thank: + +- **Nuke.YKT** + - Developer of **Nuked OPL3**, which was the basis for **ESFMu**'s code and also a great learning resource on Yamaha FM synthesis for myself. + - Nuke.YKT also gives shoutouts on behalf of **Nuked OPL3** to: + >- MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): + > - Feedback and Rhythm part calculation information. + >- forums.submarine.org.uk(carbon14, opl3): + > - Tremolo and phase generator calculation information. + >- OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): + > - OPL2 ROMs. + >- siliconpr0n.org(John McMaster, digshadow): + > - YMF262 and VRC VII decaps and die shots. +- **rainwarrior** + - For performing the initial research on ESFM drivers and documenting ESS's patent on native mode operator organization. +- **jwt27** + - For kickstarting the ESFM research project and compiling rainwarrior's findings and more in an accessible document ("ESFM Demystified"). +- **pachuco/CatButts** + - For documenting ESS's patent on ESFM's feedback implementation, which was vital in getting **ESFMu**'s sound output to be accurate. +- And everybody who helped out with real hardware testing + +## Usage + +To use **ESFMu**: + +- include the **esfm.h** header file into your source code +- include the **esfm.c** and **esfm_registers.c** files into your build and link process +- declare or allocate a variable of type `esfm_chip` somewhere in your code - this will hold the chip's state +- use the function interface defined in **esfm.h** to interact with the `esfm_chip` structure + +## Function interface + +If you're familiar with **Nuked OPL3**, you'll find many similarities in the function interface provided by **ESFMu**. There are a few things to point out, however: + +### Buffered writes + +Just like **Nuked OPL3**, **ESFMu** offers buffered register writes. However, it offers them in two flavors: "legacy" and fast. + +The fast buffered register writes (`ESFM_write_reg_buffered_fast`) are recommended, since they offer minimal latency which is close to the behavior you'd get with the actual ESS drivers on Windows. + +The "legacy" buffered register writes are only recommended for specific cases, such as programs seeking for a shortcut to emulate the write delays from some sound drivers. + +### Port-level access + +Unlike **Nuked OPL3**, **ESFMu** actually allows port-level access to the ESFM interface. This is relevant because the ESFM port interface is actually modal, meaning that its behavior changes depending on whether the chip is set to emulation (OPL3 compatibility) mode or native (ESFM) mode. + +Using port-level access allows for applications to not need to keep track of whether the chip is in native mode or not, nor to perform the port handling logic on their side. + +Applications that use the register-level access, on the other hand, need to take care to either stick to only one of the operating modes (either native or emulation), or handle the port mapping logic on their own side. + +### Register readback + +ESFM allows for register contents to be read back through its ports, and **ESFMu** implements this functionality, both via dedicated register read functions and via the port read interface. + +Note that in ESFM, register contents can only be read back when the chip is set to native (ESFM) mode, not when the chip is in emulation mode (i.e. OPL3 compatibility mode). + +## Licensing + +**ESFMu** is highly based on **Nuked OPL3**, which is licensed under the GNU Lesser General Public License version 2.1 or later. Therefore, **ESFMu** is licensed under the same license. + +If you'd like to obtain a grant to use **ESFMu** under different terms, you should get in contact with [Nuke.YKT](https://github.com/nukeykt) (author of **Nuked OPL3**) as well as with [Kagamiin~](https://github.com/Kagamiin) (yours truly). diff --git a/extern/ESFMu/esfm.c b/extern/ESFMu/esfm.c new file mode 100644 index 000000000..277927096 --- /dev/null +++ b/extern/ESFMu/esfm.c @@ -0,0 +1,1246 @@ +/* + * ESFMu: emulator for the ESS "ESFM" enhanced OPL3 clone + * Copyright (C) 2023 Kagamiin~ + * + * This file includes code and data from the Nuked OPL3 project, copyright (C) + * 2013-2023 Nuke.YKT. Its usage, modification and redistribution is allowed + * under the terms of the GNU Lesser General Public License version 2.1 or + * later. + * + * ESFMu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 + * of the License, or (at your option) any later version. + * + * ESFMu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with ESFMu. If not, see . + */ + +/* + * ESFMu wouldn't have been possible without the hard work and dedication of + * the retro computer hardware research and preservation community. + * + * I'd like to thank: + * - Nuke.YKT + * Developer of Nuked OPL3, which was the basis for ESFMu's code and + * also a great learning resource on Yamaha FM synthesis for myself. + * Nuke.YKT also gives shoutouts on behalf of Nuked OPL3 to: + * - MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): + * Feedback and Rhythm part calculation information. + * - forums.submarine.org.uk(carbon14, opl3): + * Tremolo and phase generator calculation information. + * - OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): + * OPL2 ROMs. + * - siliconpr0n.org(John McMaster, digshadow): + * YMF262 and VRC VII decaps and die shots. + * - rainwarrior + * For performing the initial research on ESFM drivers and documenting + * ESS's patent on native mode operator organization. + * - jwt27 + * For kickstarting the ESFM research project and compiling rainwarrior's + * findings and more in an accessible document ("ESFM Demystified"). + * - pachuco/CatButts + * For documenting ESS's patent on ESFM's feedback implementation, which + * was vital in getting ESFMu's sound output to be accurate. + * - And everybody who helped out with real hardware testing + */ + +#include "esfm.h" +#include +#include +#include +#include +#include + +/* + * Log-scale quarter sine table extracted from OPL3 ROM; taken straight from + * Nuked OPL3 source code. + * TODO: Extract sine table from ESFM die scans... does ESFM even use a sine + * table? Patent documents give a hint to a possible method of generating sine + * waves using some sort of boolean logic wizardry (lol) + */ +static const uint16_t logsinrom[256] = { + 0x859, 0x6c3, 0x607, 0x58b, 0x52e, 0x4e4, 0x4a6, 0x471, + 0x443, 0x41a, 0x3f5, 0x3d3, 0x3b5, 0x398, 0x37e, 0x365, + 0x34e, 0x339, 0x324, 0x311, 0x2ff, 0x2ed, 0x2dc, 0x2cd, + 0x2bd, 0x2af, 0x2a0, 0x293, 0x286, 0x279, 0x26d, 0x261, + 0x256, 0x24b, 0x240, 0x236, 0x22c, 0x222, 0x218, 0x20f, + 0x206, 0x1fd, 0x1f5, 0x1ec, 0x1e4, 0x1dc, 0x1d4, 0x1cd, + 0x1c5, 0x1be, 0x1b7, 0x1b0, 0x1a9, 0x1a2, 0x19b, 0x195, + 0x18f, 0x188, 0x182, 0x17c, 0x177, 0x171, 0x16b, 0x166, + 0x160, 0x15b, 0x155, 0x150, 0x14b, 0x146, 0x141, 0x13c, + 0x137, 0x133, 0x12e, 0x129, 0x125, 0x121, 0x11c, 0x118, + 0x114, 0x10f, 0x10b, 0x107, 0x103, 0x0ff, 0x0fb, 0x0f8, + 0x0f4, 0x0f0, 0x0ec, 0x0e9, 0x0e5, 0x0e2, 0x0de, 0x0db, + 0x0d7, 0x0d4, 0x0d1, 0x0cd, 0x0ca, 0x0c7, 0x0c4, 0x0c1, + 0x0be, 0x0bb, 0x0b8, 0x0b5, 0x0b2, 0x0af, 0x0ac, 0x0a9, + 0x0a7, 0x0a4, 0x0a1, 0x09f, 0x09c, 0x099, 0x097, 0x094, + 0x092, 0x08f, 0x08d, 0x08a, 0x088, 0x086, 0x083, 0x081, + 0x07f, 0x07d, 0x07a, 0x078, 0x076, 0x074, 0x072, 0x070, + 0x06e, 0x06c, 0x06a, 0x068, 0x066, 0x064, 0x062, 0x060, + 0x05e, 0x05c, 0x05b, 0x059, 0x057, 0x055, 0x053, 0x052, + 0x050, 0x04e, 0x04d, 0x04b, 0x04a, 0x048, 0x046, 0x045, + 0x043, 0x042, 0x040, 0x03f, 0x03e, 0x03c, 0x03b, 0x039, + 0x038, 0x037, 0x035, 0x034, 0x033, 0x031, 0x030, 0x02f, + 0x02e, 0x02d, 0x02b, 0x02a, 0x029, 0x028, 0x027, 0x026, + 0x025, 0x024, 0x023, 0x022, 0x021, 0x020, 0x01f, 0x01e, + 0x01d, 0x01c, 0x01b, 0x01a, 0x019, 0x018, 0x017, 0x017, + 0x016, 0x015, 0x014, 0x014, 0x013, 0x012, 0x011, 0x011, + 0x010, 0x00f, 0x00f, 0x00e, 0x00d, 0x00d, 0x00c, 0x00c, + 0x00b, 0x00a, 0x00a, 0x009, 0x009, 0x008, 0x008, 0x007, + 0x007, 0x007, 0x006, 0x006, 0x005, 0x005, 0x005, 0x004, + 0x004, 0x004, 0x003, 0x003, 0x003, 0x002, 0x002, 0x002, + 0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000 +}; + +/* + * Inverse exponent table extracted from OPL3 ROM; taken straight from + * Nuked OPL3 source code. + * TODO: Verify if ESFM uses an exponent table or if it possibly uses another + * method to skirt around Yamaha's patents? + */ +static const uint16_t exprom[256] = { + 0x7fa, 0x7f5, 0x7ef, 0x7ea, 0x7e4, 0x7df, 0x7da, 0x7d4, + 0x7cf, 0x7c9, 0x7c4, 0x7bf, 0x7b9, 0x7b4, 0x7ae, 0x7a9, + 0x7a4, 0x79f, 0x799, 0x794, 0x78f, 0x78a, 0x784, 0x77f, + 0x77a, 0x775, 0x770, 0x76a, 0x765, 0x760, 0x75b, 0x756, + 0x751, 0x74c, 0x747, 0x742, 0x73d, 0x738, 0x733, 0x72e, + 0x729, 0x724, 0x71f, 0x71a, 0x715, 0x710, 0x70b, 0x706, + 0x702, 0x6fd, 0x6f8, 0x6f3, 0x6ee, 0x6e9, 0x6e5, 0x6e0, + 0x6db, 0x6d6, 0x6d2, 0x6cd, 0x6c8, 0x6c4, 0x6bf, 0x6ba, + 0x6b5, 0x6b1, 0x6ac, 0x6a8, 0x6a3, 0x69e, 0x69a, 0x695, + 0x691, 0x68c, 0x688, 0x683, 0x67f, 0x67a, 0x676, 0x671, + 0x66d, 0x668, 0x664, 0x65f, 0x65b, 0x657, 0x652, 0x64e, + 0x649, 0x645, 0x641, 0x63c, 0x638, 0x634, 0x630, 0x62b, + 0x627, 0x623, 0x61e, 0x61a, 0x616, 0x612, 0x60e, 0x609, + 0x605, 0x601, 0x5fd, 0x5f9, 0x5f5, 0x5f0, 0x5ec, 0x5e8, + 0x5e4, 0x5e0, 0x5dc, 0x5d8, 0x5d4, 0x5d0, 0x5cc, 0x5c8, + 0x5c4, 0x5c0, 0x5bc, 0x5b8, 0x5b4, 0x5b0, 0x5ac, 0x5a8, + 0x5a4, 0x5a0, 0x59c, 0x599, 0x595, 0x591, 0x58d, 0x589, + 0x585, 0x581, 0x57e, 0x57a, 0x576, 0x572, 0x56f, 0x56b, + 0x567, 0x563, 0x560, 0x55c, 0x558, 0x554, 0x551, 0x54d, + 0x549, 0x546, 0x542, 0x53e, 0x53b, 0x537, 0x534, 0x530, + 0x52c, 0x529, 0x525, 0x522, 0x51e, 0x51b, 0x517, 0x514, + 0x510, 0x50c, 0x509, 0x506, 0x502, 0x4ff, 0x4fb, 0x4f8, + 0x4f4, 0x4f1, 0x4ed, 0x4ea, 0x4e7, 0x4e3, 0x4e0, 0x4dc, + 0x4d9, 0x4d6, 0x4d2, 0x4cf, 0x4cc, 0x4c8, 0x4c5, 0x4c2, + 0x4be, 0x4bb, 0x4b8, 0x4b5, 0x4b1, 0x4ae, 0x4ab, 0x4a8, + 0x4a4, 0x4a1, 0x49e, 0x49b, 0x498, 0x494, 0x491, 0x48e, + 0x48b, 0x488, 0x485, 0x482, 0x47e, 0x47b, 0x478, 0x475, + 0x472, 0x46f, 0x46c, 0x469, 0x466, 0x463, 0x460, 0x45d, + 0x45a, 0x457, 0x454, 0x451, 0x44e, 0x44b, 0x448, 0x445, + 0x442, 0x43f, 0x43c, 0x439, 0x436, 0x433, 0x430, 0x42d, + 0x42a, 0x428, 0x425, 0x422, 0x41f, 0x41c, 0x419, 0x416, + 0x414, 0x411, 0x40e, 0x40b, 0x408, 0x406, 0x403, 0x400 +}; + +/* + * Frequency multiplier table multiplied by 2; taken straight from Nuked OPL3 + * source code. + */ +static const uint8_t mt[16] = { + 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 20, 24, 24, 30, 30 +}; + +/* + * This is used during the envelope generation to apply KSL to the envelope by + * determining how much to shift right the keyscale attenuation value before + * adding it to the envelope level. + */ +static const uint8_t kslshift[4] = { + 8, 1, 2, 0 +}; + +/* + * This encodes which emulation mode channels are the secondary channel in a + * 4-op channel pair (where the entry is non-negative), and which is the + * corresponding primary channel for that secondary channel. + */ +static const int emu_4op_secondary_to_primary[18] = +{ + -1, -1, -1, 0, 1, 2, -1, -1, -1, + -1, -1, -1, 9, 10, 11, -1, -1, -1 +}; + +/* + * Envelope generator dither table, taken straight from Nuked OPL3 source code. + */ +static const uint8_t eg_incstep[4][4] = { + { 0, 0, 0, 0 }, + { 1, 0, 0, 0 }, + { 1, 0, 1, 0 }, + { 1, 1, 1, 0 } +}; + +typedef int13(*envelope_sinfunc)(uint10 phase, uint10 envelope); + +/* ------------------------------------------------------------------------- */ +static uint12 +ESFM_envelope_calc_exp(uint16 level) +{ + if (level > 0x1fff) + { + level = 0x1fff; + } + return (exprom[level & 0xff] << 1) >> (level >> 8); +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin0(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + int13 neg = 1; + phase &= 0x3ff; + if (phase & 0x200) + { + neg = -1; + } + if (phase & 0x100) + { + out = logsinrom[(phase & 0xff) ^ 0xff]; + } + else + { + out = logsinrom[phase & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)) * neg; +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin1(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + phase &= 0x3ff; + if (phase & 0x200) + { + out = 0x1000; + } + else if (phase & 0x100) + { + out = logsinrom[(phase & 0xff) ^ 0xff]; + } + else + { + out = logsinrom[phase & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)); +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin2(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + phase &= 0x3ff; + if (phase & 0x100) + { + out = logsinrom[(phase & 0xff) ^ 0xff]; + } + else + { + out = logsinrom[phase & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)); +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin3(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + phase &= 0x3ff; + if (phase & 0x100) + { + out = 0x1000; + } + else + { + out = logsinrom[phase & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)); +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin4(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + int13 neg = 1; + phase &= 0x3ff; + if ((phase & 0x300) == 0x100) + { + neg = -1; + } + if (phase & 0x200) + { + out = 0x1000; + } + else if (phase & 0x80) + { + out = logsinrom[((phase ^ 0xff) << 1) & 0xff]; + } + else + { + out = logsinrom[(phase << 1) & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)) * neg; +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin5(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + phase &= 0x3ff; + if (phase & 0x200) + { + out = 0x1000; + } + else if (phase & 0x80) + { + out = logsinrom[((phase ^ 0xff) << 1) & 0xff]; + } + else + { + out = logsinrom[(phase << 1) & 0xff]; + } + return ESFM_envelope_calc_exp(out + (envelope << 3)); +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin6(uint10 phase, uint10 envelope) +{ + int13 neg = 1; + phase &= 0x3ff; + if (phase & 0x200) + { + neg = -1; + } + return ESFM_envelope_calc_exp(envelope << 3) * neg; +} + +/* ------------------------------------------------------------------------- */ +static int13 +ESFM_envelope_calc_sin7(uint10 phase, uint10 envelope) +{ + uint16 out = 0; + int13 neg = 1; + phase &= 0x3ff; + if (phase & 0x200) + { + neg = -1; + phase = (phase & 0x1ff) ^ 0x1ff; + } + out = phase << 3; + return ESFM_envelope_calc_exp(out + (envelope << 3)) * neg; +} + +/* ------------------------------------------------------------------------- */ +static const envelope_sinfunc envelope_sin[8] = +{ + ESFM_envelope_calc_sin0, + ESFM_envelope_calc_sin1, + ESFM_envelope_calc_sin2, + ESFM_envelope_calc_sin3, + ESFM_envelope_calc_sin4, + ESFM_envelope_calc_sin5, + ESFM_envelope_calc_sin6, + ESFM_envelope_calc_sin7 +}; + +/* ------------------------------------------------------------------------- */ +static void +ESFM_envelope_calc(esfm_slot *slot) +{ + uint8 nonzero; + uint8 rate; + uint5 rate_hi; + uint2 rate_lo; + uint4 reg_rate = 0; + uint4 ks; + uint8 eg_shift, shift; + bool eg_off; + uint9 eg_rout; + int16 eg_inc; + bool reset = 0; + bool key_on; + bool key_on_signal; + + key_on = *slot->in.key_on; + if (!slot->chip->native_mode) + { + int pair_primary_idx = emu_4op_secondary_to_primary[slot->channel->channel_idx]; + if (pair_primary_idx >= 0) + { + esfm_channel *pair_primary = &slot->channel->chip->channels[pair_primary_idx]; + if (pair_primary->emu_mode_4op_enable) + { + key_on = *pair_primary->slots[0].in.key_on; + } + } + else if ((slot->channel->channel_idx == 7 || slot->channel->channel_idx == 8) + && slot->slot_idx == 1) + { + key_on = slot->channel->key_on_2; + } + } + + slot->in.eg_output = slot->in.eg_position + (slot->t_level << 2) + + (slot->in.eg_ksl_offset >> kslshift[slot->ksl]); + if (slot->tremolo_en) + { + uint8 tremolo; + if (slot->chip->native_mode) + { + tremolo = slot->channel->chip->tremolo >> ((!slot->tremolo_deep << 1) + 2); + } + else + { + tremolo = slot->channel->chip->tremolo >> ((!slot->chip->emu_tremolo_deep << 1) + 2); + } + slot->in.eg_output += tremolo; + } + + if (slot->in.eg_delay_run && slot->in.eg_delay_counter < 32768) + { + slot->in.eg_delay_counter++; + } + + // triggers on key-on edge + if (key_on && !slot->in.key_on_gate) + { + slot->in.eg_delay_run = 1; + slot->in.eg_delay_counter = 0; + slot->in.eg_delay_transitioned_01 = 0; + slot->in.eg_delay_transitioned_01_gate = 0; + slot->in.eg_delay_transitioned_10 = 0; + slot->in.eg_delay_transitioned_10_gate = 0; + slot->in.eg_delay_counter_compare = 0; + if (slot->env_delay > 0) + { + slot->in.eg_delay_counter_compare = 256 << slot->env_delay; + } + } + else if (!key_on) + { + slot->in.eg_delay_run = 0; + } + + // TODO: is this really how the chip behaves? Can it only transition the envelope delay once? Am I implementing this in a sane way? I feel like this is a roundabout hack. + if ((slot->in.eg_delay_transitioned_10 && !slot->in.eg_delay_transitioned_10_gate) || + (slot->in.eg_delay_transitioned_01 && !slot->in.eg_delay_transitioned_01_gate) + ) + { + slot->in.eg_delay_counter_compare = 0; + if (slot->env_delay > 0) + { + slot->in.eg_delay_counter_compare = 256 << slot->env_delay; + } + if (slot->in.eg_delay_transitioned_10) + { + slot->in.eg_delay_transitioned_10_gate = 1; + } + if (slot->in.eg_delay_transitioned_01) + { + slot->in.eg_delay_transitioned_01_gate = 1; + } + } + + if (key_on && ((slot->in.eg_delay_counter >= slot->in.eg_delay_counter_compare) || !slot->chip->native_mode)) + { + key_on_signal = 1; + } else { + key_on_signal = 0; + } + + if (key_on && slot->in.eg_state == EG_RELEASE) + { + + if ((slot->in.eg_delay_counter >= slot->in.eg_delay_counter_compare) || !slot->chip->native_mode) + { + reset = 1; + reg_rate = slot->attack_rate; + } + else + { + reg_rate = slot->release_rate; + } + } + else + { + switch (slot->in.eg_state) + { + case EG_ATTACK: + reg_rate = slot->attack_rate; + break; + case EG_DECAY: + reg_rate = slot->decay_rate; + break; + case EG_SUSTAIN: + if (!slot->env_sustaining) + { + reg_rate = slot->release_rate; + } + break; + case EG_RELEASE: + reg_rate = slot->release_rate; + break; + } + } + slot->in.key_on_gate = key_on; + slot->in.phase_reset = reset; + ks = slot->in.keyscale >> ((!slot->ksr) << 1); + nonzero = (reg_rate != 0); + rate = ks + (reg_rate << 2); + rate_hi = rate >> 2; + rate_lo = rate & 0x03; + if (rate_hi & 0x10) + { + rate_hi = 0x0f; + } + eg_shift = rate_hi + slot->chip->eg_clocks; + shift = 0; + if (nonzero) + { + if (rate_hi < 12) + { + if (slot->chip->eg_tick) + { + switch (eg_shift) + { + case 12: + shift = 1; + break; + case 13: + shift = (rate_lo >> 1) & 0x01; + break; + case 14: + shift = rate_lo & 0x01; + break; + default: + break; + } + } + } + else + { + shift = (rate_hi & 0x03) + + eg_incstep[rate_lo][slot->chip->global_timer & 0x03]; + if (shift & 0x04) + { + shift = 0x03; + } + if (!shift) + { + shift = slot->chip->eg_tick; + } + } + } + eg_rout = slot->in.eg_position; + eg_inc = 0; + eg_off = 0; + /* Instant attack */ + if (reset && rate_hi == 0x0f) + { + eg_rout = 0x00; + } + /* Envelope off */ + if ((slot->in.eg_position & 0x1f8) == 0x1f8) + { + eg_off = 1; + } + if (slot->in.eg_state != EG_ATTACK && !reset && eg_off) + { + eg_rout = 0x1ff; + } + switch (slot->in.eg_state) + { + case EG_ATTACK: + if (slot->in.eg_position == 0) + { + slot->in.eg_state = EG_DECAY; + } + else if (key_on_signal && shift > 0 && rate_hi != 0x0f) + { + eg_inc = ~slot->in.eg_position >> (4 - shift); + } + break; + case EG_DECAY: + if ((slot->in.eg_position >> 4) == slot->sustain_lvl) + { + slot->in.eg_state = EG_SUSTAIN; + } + else if (!eg_off && !reset && shift > 0) + { + eg_inc = 1 << (shift - 1); + } + break; + case EG_SUSTAIN: + case EG_RELEASE: + if (!eg_off && !reset && shift > 0) + { + eg_inc = 1 << (shift - 1); + } + break; + } + slot->in.eg_position = (eg_rout + eg_inc) & 0x1ff; + /* Key off */ + if (reset) + { + slot->in.eg_state = EG_ATTACK; + } + if (!key_on_signal) + { + slot->in.eg_state = EG_RELEASE; + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_phase_generate(esfm_slot *slot) +{ + esfm_chip *chip; + uint10 f_num; + uint32 basefreq; + bool rm_xor, n_bit; + uint23 noise; + uint10 phase; + + chip = slot->chip; + f_num = slot->f_num; + if (slot->vibrato_en) + { + int8_t range; + uint8_t vibpos; + + range = (f_num >> 7) & 7; + vibpos = chip->vibrato_pos; + + if (!(vibpos & 3)) + { + range = 0; + } + else if (vibpos & 1) + { + range >>= 1; + } + range >>= !slot->vibrato_deep; + + if (vibpos & 4) + { + range = -range; + } + f_num += range; + } + basefreq = (f_num << slot->block) >> 1; + phase = (uint10)(slot->in.phase_acc >> 9); + if (slot->in.phase_reset) + { + slot->in.phase_acc = 0; + } + slot->in.phase_acc += (basefreq * mt[slot->mult]) >> 1; + slot->in.phase_acc &= (1 << 19) - 1; + slot->in.phase_out = phase; + /* Noise mode (rhythm) sounds */ + noise = chip->lfsr; + if (slot->slot_idx == 3 && slot->rhy_noise) + { + esfm_slot *prev_slot = &slot->channel->slots[2]; + + chip->rm_hh_bit2 = (phase >> 2) & 1; + chip->rm_hh_bit3 = (phase >> 3) & 1; + chip->rm_hh_bit7 = (phase >> 7) & 1; + chip->rm_hh_bit8 = (phase >> 8) & 1; + + chip->rm_tc_bit3 = (prev_slot->in.phase_out >> 3) & 1; + chip->rm_tc_bit5 = (prev_slot->in.phase_out >> 5) & 1; + + rm_xor = (chip->rm_hh_bit2 ^ chip->rm_hh_bit7) + | (chip->rm_hh_bit3 ^ chip->rm_tc_bit5) + | (chip->rm_tc_bit3 ^ chip->rm_tc_bit5); + + switch(slot->rhy_noise) + { + case 1: + // SD + slot->in.phase_out = (chip->rm_hh_bit8 << 9) + | ((chip->rm_hh_bit8 ^ (noise & 1)) << 8); + break; + case 2: + // HH + slot->in.phase_out = rm_xor << 9; + if (rm_xor ^ (noise & 1)) + { + slot->in.phase_out |= 0xd0; + } + else + { + slot->in.phase_out |= 0x34; + } + break; + case 3: + // TC + slot->in.phase_out = (rm_xor << 9) | 0x80; + break; + } + } + + n_bit = ((noise >> 14) ^ noise) & 0x01; + chip->lfsr = (noise >> 1) | (n_bit << 22); +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_phase_generate_emu(esfm_slot *slot) +{ + esfm_chip *chip; + uint3 block; + uint10 f_num; + uint32 basefreq; + bool rm_xor, n_bit; + uint23 noise; + uint10 phase; + int pair_primary_idx; + + chip = slot->chip; + block = slot->channel->slots[0].block; + f_num = slot->channel->slots[0].f_num; + + pair_primary_idx = emu_4op_secondary_to_primary[slot->channel->channel_idx]; + if (pair_primary_idx >= 0) + { + esfm_channel *pair_primary = &slot->channel->chip->channels[pair_primary_idx]; + if (pair_primary->emu_mode_4op_enable) + { + block = pair_primary->slots[0].block; + f_num = pair_primary->slots[0].f_num; + } + } + + if (slot->vibrato_en) + { + int8_t range; + uint8_t vibpos; + + range = (f_num >> 7) & 7; + vibpos = chip->vibrato_pos; + + if (!(vibpos & 3)) + { + range = 0; + } + else if (vibpos & 1) + { + range >>= 1; + } + range >>= !chip->emu_vibrato_deep; + + if (vibpos & 4) + { + range = -range; + } + f_num += range; + } + basefreq = (f_num << block) >> 1; + phase = (uint10)(slot->in.phase_acc >> 9); + if (slot->in.phase_reset) + { + slot->in.phase_acc = 0; + } + slot->in.phase_acc += (basefreq * mt[slot->mult]) >> 1; + slot->in.phase_acc &= (1 << 19) - 1; + slot->in.phase_out = phase; + + /* Noise mode (rhythm) sounds */ + noise = chip->lfsr; + // HH + if (slot->channel->channel_idx == 7 && slot->slot_idx == 0) + { + chip->rm_hh_bit2 = (phase >> 2) & 1; + chip->rm_hh_bit3 = (phase >> 3) & 1; + chip->rm_hh_bit7 = (phase >> 7) & 1; + chip->rm_hh_bit8 = (phase >> 8) & 1; + } + // TC + if (slot->channel->channel_idx == 8 && slot->slot_idx == 1) + { + chip->rm_tc_bit3 = (phase >> 3) & 1; + chip->rm_tc_bit5 = (phase >> 5) & 1; + } + if (chip->emu_rhy_mode_flags & 0x20) + { + rm_xor = (chip->rm_hh_bit2 ^ chip->rm_hh_bit7) + | (chip->rm_hh_bit3 ^ chip->rm_tc_bit5) + | (chip->rm_tc_bit3 ^ chip->rm_tc_bit5); + if (slot->channel->channel_idx == 7) + { + if (slot->slot_idx == 0) { + // HH + slot->in.phase_out = rm_xor << 9; + if (rm_xor ^ (noise & 1)) + { + slot->in.phase_out |= 0xd0; + } + else + { + slot->in.phase_out |= 0x34; + } + } + else if (slot->slot_idx == 1) + { + // SD + slot->in.phase_out = (chip->rm_hh_bit8 << 9) + | ((chip->rm_hh_bit8 ^ (noise & 1)) << 8); + } + } + else if (slot->channel->channel_idx == 8 && slot->slot_idx == 1) + { + // TC + slot->in.phase_out = (rm_xor << 9) | 0x80; + } + } + + n_bit = ((noise >> 14) ^ noise) & 0x01; + chip->lfsr = (noise >> 1) | (n_bit << 22); +} + +/** + * TODO: Figure out what's ACTUALLY going on inside the real chip! + * This is not accurate at all, but it's the closest I was able to get with + * empirical testing (and it's closer than nothing). + */ +/* ------------------------------------------------------------------------- */ +static int16 +ESFM_slot3_noise3_mod_input_calc(esfm_slot *slot) +{ + esfm_channel *channel = slot->channel; + envelope_sinfunc wavegen = envelope_sin[channel->slots[2].waveform]; + int16 phase; + int13 output_buf = *channel->slots[1].in.mod_input; + int i; + + // Go through previous slots' partial results and recalculate outputs + // (we skip slot 0 because its calculation happens at the end, not at the beginning) + for (i = 1; i < 3; i++) + { + // double the pitch + phase = channel->slots[i].in.phase_acc >> 8; + if (channel->slots[i].mod_in_level) + { + phase += output_buf >> (7 - channel->slots[i].mod_in_level); + } + output_buf = wavegen((uint10)(phase & 0x3ff), channel->slots[i].in.eg_output); + } + + return output_buf >> (8 - slot->mod_in_level); +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_slot_generate(esfm_slot *slot) +{ + envelope_sinfunc wavegen = envelope_sin[slot->waveform]; + int16 phase = slot->in.phase_out; + if (slot->mod_in_level) + { + if (slot->slot_idx == 3 && slot->rhy_noise == 3) + { + phase += ESFM_slot3_noise3_mod_input_calc(slot); + } + else + { + phase += *slot->in.mod_input >> (7 - slot->mod_in_level); + } + } + slot->in.output = wavegen((uint10)(phase & 0x3ff), slot->in.eg_output); + if (slot->output_level) + { + int13 output_value = slot->in.output >> (7 - slot->output_level); + slot->channel->output[0] += output_value & slot->out_enable[0]; + slot->channel->output[1] += output_value & slot->out_enable[1]; + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_slot_generate_emu(esfm_slot *slot) +{ + esfm_chip *chip = slot->chip; + envelope_sinfunc wavegen = envelope_sin[ + slot->waveform & (chip->emu_newmode != 0 ? 0x07 : 0x03)]; + bool rhythm_slot_double_volume = (slot->chip->emu_rhy_mode_flags & 0x20) != 0 + && slot->channel->channel_idx >= 6 && slot->channel->channel_idx < 9; + int16 phase = slot->in.phase_out; + int14 output_value; + + phase += *slot->in.mod_input & slot->in.emu_mod_enable; + slot->in.output = wavegen((uint10)(phase & 0x3ff), slot->in.eg_output); + output_value = (slot->in.output & slot->in.emu_output_enable) << rhythm_slot_double_volume; + if (chip->emu_newmode) + { + slot->channel->output[0] += output_value & slot->channel->slots[0].out_enable[0]; + slot->channel->output[1] += output_value & slot->channel->slots[0].out_enable[1]; + } + else + { + slot->channel->output[0] += output_value; + slot->channel->output[1] += output_value; + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_slot_calc_feedback(esfm_slot *slot) +{ + esfm_chip *chip = slot->chip; + uint32 basefreq, phase_offset; + uint3 block; + uint10 f_num; + int13 in1 = 0, in2 = 0, wave_out; + int16 phase, phase_feedback; + uint19 regressed_phase; + int iter_counter; + envelope_sinfunc wavegen; + + if (slot->mod_in_level) + { + if (chip->native_mode) + { + wavegen = envelope_sin[slot->waveform]; + } + else + { + wavegen = envelope_sin[slot->waveform & (0x03 | (0x02 << (chip->emu_newmode != 0)))]; + } + f_num = slot->f_num; + block = slot->block; + basefreq = (f_num << block) >> 1; + phase_offset = (basefreq * mt[slot->mult]) >> 1; + + for (iter_counter = 28; iter_counter >= 0; iter_counter--) + { + regressed_phase = (uint19)((uint32)slot->in.phase_acc - iter_counter * phase_offset) & ((1 << 19) - 1); + phase = (int16)(regressed_phase >> 9); + phase_feedback = (in1 + in2) >> 2; + phase += phase_feedback >> (7 - slot->mod_in_level); + wave_out = wavegen((uint10)(phase & 0x3ff), slot->in.eg_output); + in2 = in1; + in1 = wave_out; + } + + // TODO: Figure out - is this how the ESFM chip does it, like the + // patent literally says? (it's really hacky...) + // slot->in.output = wave_out; + + // This would be the more canonical way to do it, reusing the rest of + // the synthesis pipeline to finish the calculation: + if (chip->native_mode) + { + slot->in.feedback_buf = phase_feedback; + } + else + { + slot->in.feedback_buf = phase_feedback >> (7 - slot->mod_in_level); + } + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_process_channel(esfm_channel *channel) +{ + int slot_idx; + channel->output[0] = channel->output[1] = 0; + for (slot_idx = 0; slot_idx < 4; slot_idx++) + { + esfm_slot *slot = &channel->slots[slot_idx]; + ESFM_envelope_calc(slot); + ESFM_phase_generate(slot); + if(slot_idx > 0) + { + ESFM_slot_generate(slot); + } + } + // ESFM feedback calculation takes a large number of clock cycles, so + // defer slot 0 generation to the end + // TODO: verify this behavior on real hardware + ESFM_slot_calc_feedback(&channel->slots[0]); + ESFM_slot_generate(&channel->slots[0]); +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_process_channel_emu(esfm_channel *channel) +{ + int slot_idx; + channel->output[0] = channel->output[1] = 0; + for (slot_idx = 0; slot_idx < 2; slot_idx++) + { + esfm_slot *slot = &channel->slots[slot_idx]; + ESFM_envelope_calc(slot); + ESFM_phase_generate_emu(slot); + if(slot_idx > 0) + { + ESFM_slot_generate_emu(slot); + } + } + // ESFM feedback calculation takes a large number of clock cycles, so + // defer slot 0 generation to the end + // TODO: verify this behavior on real hardware + if (channel->slots[0].in.mod_input == &channel->slots[0].in.feedback_buf) + { + ESFM_slot_calc_feedback(&channel->slots[0]); + } + ESFM_slot_generate_emu(&channel->slots[0]); +} + +/* ------------------------------------------------------------------------- */ +static int16_t +ESFM_clip_sample(int32 sample) +{ + // TODO: Supposedly, the real ESFM chip actually overflows rather than + // clipping. Verify that. + if (sample > 32767) + { + sample = 32767; + } + else if (sample < -32768) + { + sample = -32768; + } + return (int16_t)sample; +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_update_timers(esfm_chip *chip) +{ + // Tremolo + if ((chip->global_timer & 0x3f) == 0x3f) + { + chip->tremolo_pos = (chip->tremolo_pos + 1) % 210; + if (chip->tremolo_pos < 105) + { + chip->tremolo = chip->tremolo_pos; + } + else + { + chip->tremolo = (210 - chip->tremolo_pos); + } + } + + // Vibrato + if ((chip->global_timer & 0x3ff) == 0x3ff) + { + chip->vibrato_pos = (chip->vibrato_pos + 1) & 0x07; + } + + chip->global_timer = (chip->global_timer + 1) & 0x3ff; + + // Envelope generator dither clocks + chip->eg_clocks = 0; + if (chip->eg_timer) + { + uint8 shift = 0; + while (shift < 36 && ((chip->eg_timer >> shift) & 1) == 0) + { + shift++; + } + + if (shift <= 12) + { + chip->eg_clocks = shift + 1; + } + } + + if (chip->eg_tick || chip->eg_timer_overflow) + { + if (chip->eg_timer == (1llu << 36) - 1) + { + chip->eg_timer = 0; + chip->eg_timer_overflow = 1; + } + else + { + chip->eg_timer++; + chip->eg_timer_overflow = 0; + } + } + + chip->eg_tick ^= 1; +} + +#define KEY_ON_REGS_START (18 * 4 * 8) +/* ------------------------------------------------------------------------- */ +int +ESFM_reg_write_chan_idx(esfm_chip *chip, uint16_t reg) +{ + int which_reg = -1; + if (chip->native_mode) + { + bool is_key_on_reg = reg >= KEY_ON_REGS_START && reg < (KEY_ON_REGS_START + 20); + if (is_key_on_reg) + { + which_reg = reg - KEY_ON_REGS_START; + } + } + else + { + uint8_t reg_low = reg & 0xff; + bool high = reg & 0x100; + bool is_key_on_reg = reg_low >= 0xb0 && reg_low < 0xb9; + if (is_key_on_reg) + { + which_reg = (reg_low & 0x0f) + high * 9; + } + } + + return which_reg; +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_update_write_buffer(esfm_chip *chip) +{ + esfm_write_buf *write_buf; + bool note_off_written[20]; + bool bassdrum_written = false; + int i; + for (i = 0; i < 20; i++) + { + note_off_written[i] = false; + } + while((write_buf = &chip->write_buf[chip->write_buf_start]), + write_buf->valid && write_buf->timestamp <= chip->write_buf_timestamp) + { + int is_which_note_on_reg = + ESFM_reg_write_chan_idx(chip, write_buf->address); + if (is_which_note_on_reg >= 0) + { + if ((chip->native_mode && (write_buf->data & 0x01) == 0) + || (!chip->native_mode && (write_buf->data & 0x20) == 0) + ) + { + // this is a note off command; note down that we got note off for this channel + note_off_written[is_which_note_on_reg] = true; + } + else + { + // this is a note on command; have we gotten a note off for this channel in this cycle? + if (note_off_written[is_which_note_on_reg]) + { + // we have a conflict; let the note off be processed first and defer the + // rest of the buffer to the next cycle + break; + } + } + } + if ((chip->native_mode && write_buf->address == 0x4bd) + || (!chip->native_mode && (write_buf->address & 0xff) == 0xbd) + ) + { + // bassdrum register write (rhythm mode note-on/off control) + // have we already written to the bassdrum register in this cycle + if (bassdrum_written) { + // we have a conflict + break; + } + bassdrum_written = true; + } + + write_buf->valid = 0; + ESFM_write_reg(chip, write_buf->address, write_buf->data); + chip->write_buf_start = (chip->write_buf_start + 1) % ESFM_WRITEBUF_SIZE; + } + + chip->write_buf_timestamp++; +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_generate(esfm_chip *chip, int16_t *buf) +{ + int channel_idx; + + chip->output_accm[0] = chip->output_accm[1] = 0; + for (channel_idx = 0; channel_idx < 18; channel_idx++) + { + esfm_channel *channel = &chip->channels[channel_idx]; + if (chip->native_mode) + { + ESFM_process_channel(channel); + } + else + { + ESFM_process_channel_emu(channel); + } + + chip->output_accm[0] += channel->output[0]; + chip->output_accm[1] += channel->output[1]; + } + + buf[0] = ESFM_clip_sample(chip->output_accm[0]); + buf[1] = ESFM_clip_sample(chip->output_accm[1]); + + ESFM_update_timers(chip); + ESFM_update_write_buffer(chip); +} + +/* ------------------------------------------------------------------------- */ +int16_t +ESFM_get_channel_output_native(esfm_chip *chip, int channel_idx) +{ + int16_t result; + int32_t temp_mix = 0; + int i; + + if (channel_idx < 0 || channel_idx >= 18) + { + return 0; + } + + for (i = 0; i < 4; i++) + { + esfm_slot *slot = &chip->channels[channel_idx].slots[i]; + + if (slot->output_level) + { + int13 output_value = slot->in.output >> (7 - slot->output_level); + temp_mix += output_value & slot->out_enable[0]; + temp_mix += output_value & slot->out_enable[1]; + } + } + + if (temp_mix > 32767) + { + temp_mix = 32767; + } + else if (temp_mix < -32768) + { + temp_mix = -32768; + } + result = temp_mix; + return result; +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_generate_stream(esfm_chip *chip, int16_t *sndptr, uint32_t num_samples) +{ + uint32_t i; + + for (i = 0; i < num_samples; i++) + { + ESFM_generate(chip, sndptr); + sndptr += 2; + } +} diff --git a/extern/ESFMu/esfm.h b/extern/ESFMu/esfm.h new file mode 100644 index 000000000..f410558eb --- /dev/null +++ b/extern/ESFMu/esfm.h @@ -0,0 +1,310 @@ +/* + * ESFMu: emulator for the ESS "ESFM" enhanced OPL3 clone + * Copyright (C) 2023 Kagamiin~ + * + * ESFMu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 + * of the License, or (at your option) any later version. + * + * ESFMu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with ESFMu. If not, see . + */ + +/* + * ESFMu wouldn't have been possible without the hard work and dedication of + * the retro computer hardware research and preservation community. + * + * I'd like to thank: + * - Nuke.YKT + * Developer of Nuked OPL3, which was the basis for ESFMu's code and + * also a great learning resource on Yamaha FM synthesis for myself. + * Nuke.YKT also gives shoutouts on behalf of Nuked OPL3 to: + * - MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): + * Feedback and Rhythm part calculation information. + * - forums.submarine.org.uk(carbon14, opl3): + * Tremolo and phase generator calculation information. + * - OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): + * OPL2 ROMs. + * - siliconpr0n.org(John McMaster, digshadow): + * YMF262 and VRC VII decaps and die shots. + * - rainwarrior + * For performing the initial research on ESFM drivers and documenting + * ESS's patent on native mode operator organization. + * - jwt27 + * For kickstarting the ESFM research project and compiling rainwarrior's + * findings and more in an accessible document ("ESFM Demystified"). + * - pachuco/CatButts + * For documenting ESS's patent on ESFM's feedback implementation, which + * was vital in getting ESFMu's sound output to be accurate. + * - And everybody who helped out with real hardware testing + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _esfm_slot esfm_slot; +typedef struct _esfm_slot_internal esfm_slot_internal; +typedef struct _esfm_channel esfm_channel; +typedef struct _esfm_chip esfm_chip; + + +void ESFM_init (esfm_chip *chip); +void ESFM_write_reg (esfm_chip *chip, uint16_t address, uint8_t data); +void ESFM_write_reg_buffered (esfm_chip *chip, uint16_t address, uint8_t data); +void ESFM_write_reg_buffered_fast (esfm_chip *chip, uint16_t address, uint8_t data); +void ESFM_write_port (esfm_chip *chip, uint8_t offset, uint8_t data); +uint8_t ESFM_readback_reg (esfm_chip *chip, uint16_t address); +uint8_t ESFM_read_port (esfm_chip *chip, uint8_t offset); +void ESFM_generate(esfm_chip *chip, int16_t *buf); +void ESFM_generate_stream(esfm_chip *chip, int16_t *sndptr, uint32_t num_samples); +int16_t ESFM_get_channel_output_native(esfm_chip *chip, int channel_idx); + + +// These are fake types just for syntax sugar. +// Beware of their underlying types when reading/writing to them. +#ifndef __NO_ESFM_FAST_TYPES +#ifndef __ESFM_FAST_TYPES +#define __ESFM_FAST_TYPES +#endif +#endif + +#ifdef __ESFM_FAST_TYPES + +typedef uint_fast8_t flag; +typedef uint_fast8_t uint2; +typedef uint_fast8_t uint3; +typedef uint_fast8_t uint4; +typedef uint_fast8_t uint5; +typedef uint_fast8_t uint6; +typedef uint_fast8_t uint8; +typedef uint_fast16_t uint9; +typedef uint_fast16_t uint10; +typedef uint_fast16_t uint11; +typedef uint_fast16_t uint12; +typedef uint_fast16_t uint16; +typedef uint_fast32_t uint19; +typedef uint_fast32_t uint23; +typedef uint_fast32_t uint32; +typedef uint_fast64_t uint36; + +typedef int_fast16_t int13; +typedef int_fast16_t int14; +typedef int_fast16_t int16; +typedef int_fast32_t int32; + +#else +typedef uint8_t flag; +typedef uint8_t uint2; +typedef uint8_t uint3; +typedef uint8_t uint4; +typedef uint8_t uint5; +typedef uint8_t uint6; +typedef uint8_t uint8; +typedef uint16_t uint9; +typedef uint16_t uint10; +typedef uint16_t uint11; +typedef uint16_t uint12; +typedef uint16_t uint16; +typedef uint32_t uint19; +typedef uint32_t uint23; +typedef uint32_t uint32; +typedef uint64_t uint36; + +typedef int16_t int13; +typedef int16_t int14; +typedef int16_t int16; +typedef int32_t int32; + +#endif + +enum eg_states +{ + EG_ATTACK, + EG_DECAY, + EG_SUSTAIN, + EG_RELEASE +}; + + +typedef struct _esfm_write_buf +{ + uint64_t timestamp; + uint16_t address; + uint8_t data; + flag valid; + +} esfm_write_buf; + +typedef struct _emu_slot_channel_mapping +{ + int channel_idx; + int slot_idx; + +} emu_slot_channel_mapping; + +typedef struct _esfm_slot_internal +{ + uint9 eg_position; + uint9 eg_ksl_offset; + uint10 eg_output; + + uint4 keyscale; + + int13 output; + int13 emu_output_enable; + int13 emu_mod_enable; + int13 feedback_buf; + int13 *mod_input; + + uint19 phase_acc; + uint10 phase_out; + flag phase_reset; + flag *key_on; + flag key_on_gate; + + uint2 eg_state; + flag eg_delay_run; + flag eg_delay_transitioned_10; + flag eg_delay_transitioned_10_gate; + flag eg_delay_transitioned_01; + flag eg_delay_transitioned_01_gate; + uint16 eg_delay_counter; + uint16 eg_delay_counter_compare; + +} esfm_slot_internal; + +struct _esfm_slot +{ + // Metadata + esfm_channel *channel; + esfm_chip *chip; + uint2 slot_idx; + + // Register data + int13 out_enable[2]; + uint10 f_num; + uint3 block; + uint3 output_level; + // a.k.a. feedback level in emu mode + uint3 mod_in_level; + + uint6 t_level; + uint4 mult; + uint3 waveform; + // Only for 4th slot + uint2 rhy_noise; + + uint4 attack_rate; + uint4 decay_rate; + uint4 sustain_lvl; + uint4 release_rate; + + flag tremolo_en; + flag tremolo_deep; + flag vibrato_en; + flag vibrato_deep; + flag emu_connection_typ; + flag env_sustaining; + flag ksr; + uint2 ksl; + uint3 env_delay; + // overlaps with env_delay bit 0 + // TODO: check if emu mode only uses this, or if it actually overwrites the channel field used by native mode + flag emu_key_on; + + // Internal state + esfm_slot_internal in; +}; + +struct _esfm_channel +{ + esfm_chip *chip; + esfm_slot slots[4]; + uint5 channel_idx; + int16 output[2]; + flag key_on; + flag emu_mode_4op_enable; + // Only for 17th and 18th channels + flag key_on_2; + flag emu_mode_4op_enable_2; +}; + +#define ESFM_WRITEBUF_SIZE 1024 +#define ESFM_WRITEBUF_DELAY 2 + +struct _esfm_chip +{ + esfm_channel channels[18]; + int32 output_accm[2]; + uint_fast16_t addr_latch; + + flag emu_wavesel_enable; + flag emu_newmode; + flag native_mode; + + flag keyscale_mode; + + // Global state + uint36 eg_timer; + uint10 global_timer; + uint8 eg_clocks; + flag eg_tick; + flag eg_timer_overflow; + uint8 tremolo; + uint8 tremolo_pos; + uint8 vibrato_pos; + uint23 lfsr; + + flag rm_hh_bit2; + flag rm_hh_bit3; + flag rm_hh_bit7; + flag rm_hh_bit8; + flag rm_tc_bit3; + flag rm_tc_bit5; + + // 0xbd register in emulation mode, exposed in 0x4bd in native mode + // ("bass drum" register) + uint8 emu_rhy_mode_flags; + + flag emu_vibrato_deep; + flag emu_tremolo_deep; + + uint8 timer_reload[2]; + uint8 timer_counter[2]; + flag timer_enable[2]; + flag timer_mask[2]; + flag timer_overflow[2]; + flag irq_bit; + + // Halts the envelope generators from advancing. + flag test_bit_eg_halt; + /* + * Activates some sort of waveform test mode that amplifies the output volume greatly + * and continuously shifts the waveform table downwards, possibly also outputting the + * waveform's derivative? (it's so weird!) + */ + flag test_bit_distort; + // Appears to attenuate the output by about 3 dB. + flag test_bit_attenuate; + // Resets all phase generators and holds them in the reset state while this bit is set. + flag test_bit_phase_stop_reset; + + esfm_write_buf write_buf[ESFM_WRITEBUF_SIZE]; + size_t write_buf_start; + size_t write_buf_end; + uint64_t write_buf_timestamp; +}; + +#ifdef __cplusplus +} +#endif diff --git a/extern/ESFMu/esfm_registers.c b/extern/ESFMu/esfm_registers.c new file mode 100644 index 000000000..d87a5944f --- /dev/null +++ b/extern/ESFMu/esfm_registers.c @@ -0,0 +1,1003 @@ +/* + * ESFMu: emulator for the ESS "ESFM" enhanced OPL3 clone + * Copyright (C) 2023 Kagamiin~ + * + * This file includes code and data from the Nuked OPL3 project, copyright (C) + * 2013-2023 Nuke.YKT. Its usage, modification and redistribution is allowed + * under the terms of the GNU Lesser General Public License version 2.1 or + * later. + * + * ESFMu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 + * of the License, or (at your option) any later version. + * + * ESFMu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with ESFMu. If not, see . + */ + +/* + * ESFMu wouldn't have been possible without the hard work and dedication of + * the retro computer hardware research and preservation community. + * + * I'd like to thank: + * - Nuke.YKT + * Developer of Nuked OPL3, which was the basis for ESFMu's code and + * also a great learning resource on Yamaha FM synthesis for myself. + * Nuke.YKT also gives shoutouts on behalf of Nuked OPL3 to: + * - MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh): + * Feedback and Rhythm part calculation information. + * - forums.submarine.org.uk(carbon14, opl3): + * Tremolo and phase generator calculation information. + * - OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): + * OPL2 ROMs. + * - siliconpr0n.org(John McMaster, digshadow): + * YMF262 and VRC VII decaps and die shots. + * - rainwarrior + * For performing the initial research on ESFM drivers and documenting + * ESS's patent on native mode operator organization. + * - jwt27 + * For kickstarting the ESFM research project and compiling rainwarrior's + * findings and more in an accessible document ("ESFM Demystified"). + * - pachuco/CatButts + * For documenting ESS's patent on ESFM's feedback implementation, which + * was vital in getting ESFMu's sound output to be accurate. + * - And everybody who helped out with real hardware testing + */ + +#include "esfm.h" +#include +#include +#include +#include + + +/* + * Table of KSL values extracted from OPL3 ROM; taken straight from Nuked OPL3 + * source code. + * TODO: Check if ESFM uses the same KSL values. + */ + +static const int16 kslrom[16] = { + 0, 32, 40, 45, 48, 51, 53, 55, 56, 58, 59, 60, 61, 62, 63, 64 +}; + +/* + * This maps the low 5 bits of emulation mode address to an emulation mode + * slot; taken straight from Nuked OPL3. Used for decoding certain emulation + * mode address ranges. + */ +static const int8_t ad_slot[0x20] = { + 0, 1, 2, 3, 4, 5, -1, -1, 6, 7, 8, 9, 10, 11, -1, -1, + 12, 13, 14, 15, 16, 17, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; + +/* + * This maps an emulation mode slot index to a tuple representing the + * corresponding native mode channel and slot. + */ +static const emu_slot_channel_mapping emu_slot_map[36] = +{ + { 0, 0}, { 1, 0}, { 2, 0}, { 0, 1}, { 1, 1}, { 2, 1}, + { 3, 0}, { 4, 0}, { 5, 0}, { 3, 1}, { 4, 1}, { 5, 1}, + { 6, 0}, { 7, 0}, { 8, 0}, { 6, 1}, { 7, 1}, { 8, 1}, + { 9, 0}, {10, 0}, {11, 0}, { 9, 1}, {10, 1}, {11, 1}, + {12, 0}, {13, 0}, {14, 0}, {12, 1}, {13, 1}, {14, 1}, + {15, 0}, {16, 0}, {17, 0}, {15, 1}, {16, 1}, {17, 1} +}; + +/* + * This encodes which emulation mode channels are the secondary channel in a + * 4-op channel pair (where the entry is non-negative), and which is the + * corresponding primary channel for that secondary channel. + */ +static const int emu_4op_secondary_to_primary[18] = +{ + -1, -1, -1, 0, 1, 2, -1, -1, -1, + -1, -1, -1, 9, 10, 11, -1, -1, -1 +}; + +/* + * This encodes the operator outputs to be enabled or disabled for + * each 4-op algorithm in emulation mode. + * Indices: FM+FM, FM+AM, AM+FM, AM+AM (lower channel MSB, upper channel LSB) + * Values: enable OP1, OP2, OP3, OP4 + */ +static const bool emu_4op_alg_output_enable[4][4] = +{ + {0, 0, 0, 1}, + {0, 1, 0, 1}, + {1, 0, 0, 1}, + {1, 0, 1, 1} +}; + +/* + * This encodes the operator interconnections to be enabled or disabled for + * each 4-op algorithm in emulation mode. + * Indices: FM+FM, FM+AM, AM+FM, AM+AM (lower channel MSB, upper channel LSB) + * Values: enable OP1FB, OP1->2, OP2->3, OP3->4 + */ +static const bool emu_4op_alg_mod_enable[4][4] = +{ + {1, 1, 1, 1}, + {1, 1, 0, 1}, + {1, 0, 1, 1}, + {1, 0, 1, 0} +}; + + +/* ------------------------------------------------------------------------- */ +static void +ESFM_emu_rearrange_connections(esfm_channel *channel) +{ + int secondary_to_primary; + + secondary_to_primary = emu_4op_secondary_to_primary[channel->channel_idx]; + if (secondary_to_primary >= 0) + { + esfm_channel *pair_primary = &channel->chip->channels[secondary_to_primary]; + if (pair_primary->emu_mode_4op_enable) + { + // always work from primary channel in pair when dealing with 4-op + channel = pair_primary; + } + } + + if (channel->emu_mode_4op_enable && (channel->channel_idx % 9) < 3 && channel->chip->emu_newmode) + { + esfm_channel *secondary = &channel->chip->channels[channel->channel_idx + 3]; + uint2 algorithm = ((channel->slots[0].emu_connection_typ != 0) << 1) + | (secondary->slots[0].emu_connection_typ != 0); + int i; + + secondary->slots[0].in.mod_input = &channel->slots[1].in.output; + + for (i = 0; i < 2; i++) + { + channel->slots[i].in.emu_mod_enable = + emu_4op_alg_mod_enable[algorithm][i] ? ~((int13) 0) : 0; + channel->slots[i].in.emu_output_enable = + emu_4op_alg_output_enable[algorithm][i] ? ~((int13) 0) : 0; + + secondary->slots[i].in.emu_mod_enable = + emu_4op_alg_mod_enable[algorithm][i + 2] ? ~((int13) 0) : 0; + secondary->slots[i].in.emu_output_enable = + emu_4op_alg_output_enable[algorithm][i + 2] ? ~((int13) 0) : 0; + } + } + else if ((channel->chip->emu_rhy_mode_flags & 0x20) != 0 + && (channel->channel_idx == 7 || channel->channel_idx == 8)) + { + channel->slots[0].in.emu_mod_enable = 0; + channel->slots[1].in.emu_mod_enable = 0; + channel->slots[0].in.emu_output_enable = ~((int13) 0); + channel->slots[1].in.emu_output_enable = ~((int13) 0); + } + else + { + channel->slots[0].in.mod_input = &channel->slots[0].in.feedback_buf; + + channel->slots[0].in.emu_mod_enable = ~((int13) 0); + channel->slots[0].in.emu_output_enable = + (channel->slots[0].emu_connection_typ != 0) ? ~((int13) 0) : 0; + channel->slots[1].in.emu_output_enable = ~((int13) 0); + channel->slots[1].in.emu_mod_enable = + (channel->slots[0].emu_connection_typ != 0) ? 0 : ~((int13) 0); + } +} + + +/* ------------------------------------------------------------------------- */ +static void +ESFM_emu_to_native_switch(esfm_chip *chip) +{ + size_t channel_idx, slot_idx; + for (channel_idx = 0; channel_idx < 18; channel_idx++) + { + for (slot_idx = 0; slot_idx < 4; slot_idx++) + { + esfm_channel *channel = &chip->channels[channel_idx]; + esfm_slot *slot = &channel->slots[slot_idx]; + + if (slot_idx == 0) + { + slot->in.mod_input = &slot->in.feedback_buf; + } + else + { + esfm_slot *prev_slot = &channel->slots[slot_idx - 1]; + slot->in.mod_input = &prev_slot->in.output; + } + } + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_native_to_emu_switch(esfm_chip *chip) +{ + size_t channel_idx; + for (channel_idx = 0; channel_idx < 18; channel_idx++) + { + ESFM_emu_rearrange_connections(&chip->channels[channel_idx]); + } +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_slot_update_keyscale(esfm_slot *slot) +{ + if (slot->slot_idx > 0 && !slot->chip->native_mode) + { + return; + } + + int16 ksl = (kslrom[slot->f_num >> 6] << 2) - ((0x08 - slot->block) << 5); + if (ksl < 0) + { + ksl = 0; + } + slot->in.eg_ksl_offset = ksl; + slot->in.keyscale = (slot->block << 1) + | ((slot->f_num >> (8 + !slot->chip->keyscale_mode)) & 0x01); +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_emu_channel_update_keyscale(esfm_channel *channel) +{ + int secondary_to_primary; + + secondary_to_primary = emu_4op_secondary_to_primary[channel->channel_idx]; + if (secondary_to_primary >= 0) + { + esfm_channel *pair_primary = &channel->chip->channels[secondary_to_primary]; + if (pair_primary->emu_mode_4op_enable) + { + // always work from primary channel in pair when dealing with 4-op + channel = pair_primary; + } + } + + ESFM_slot_update_keyscale(&channel->slots[0]); + channel->slots[1].in.eg_ksl_offset = channel->slots[0].in.eg_ksl_offset; + channel->slots[1].in.keyscale = channel->slots[0].in.keyscale; + + if (channel->emu_mode_4op_enable && (channel->channel_idx % 9) < 3 && channel->chip->emu_newmode) + { + int i; + esfm_channel *secondary = &channel->chip->channels[channel->channel_idx + 3]; + secondary->slots[0].f_num = channel->slots[0].f_num; + secondary->slots[0].block = channel->slots[0].block; + + for (i = 0; i < 2; i++) + { + secondary->slots[i].in.eg_ksl_offset = channel->slots[0].in.eg_ksl_offset; + secondary->slots[i].in.keyscale = channel->slots[0].in.keyscale; + } + } +} + +/* ------------------------------------------------------------------------- */ +static inline uint8_t +ESFM_slot_readback (esfm_slot *slot, uint8_t register_idx) +{ + uint8_t data = 0; + switch (register_idx & 0x07) + { + case 0x00: + data |= (slot->tremolo_en != 0) << 7; + data |= (slot->vibrato_en != 0) << 6; + data |= (slot->env_sustaining != 0) << 5; + data |= (slot->vibrato_en != 0) << 4; + data |= slot->mult & 0x0f; + break; + case 0x01: + data |= slot->ksl << 6; + data |= slot->t_level & 0x3f; + break; + case 0x02: + data |= slot->attack_rate << 4; + data |= slot->decay_rate & 0x0f; + break; + case 0x03: + data |= slot->sustain_lvl << 4; + data |= slot->release_rate & 0x0f; + break; + case 0x04: + data = slot->f_num & 0xff; + break; + case 0x05: + data |= slot->env_delay << 5; + data |= (slot->block & 0x07) << 2; + data |= (slot->f_num >> 8) & 0x03; + break; + case 0x06: + data |= (slot->tremolo_deep != 0) << 7; + data |= (slot->vibrato_deep != 0) << 6; + data |= (slot->out_enable[1] != 0) << 5; + data |= (slot->out_enable[0] != 0) << 4; + data |= (slot->mod_in_level & 0x07) << 1; + data |= slot->emu_connection_typ & 0x01; + break; + case 0x07: + data |= slot->output_level << 5; + data |= (slot->rhy_noise & 0x03) << 3; + data |= slot->waveform & 0x07; + break; + } + return data; +} + +/* ------------------------------------------------------------------------- */ +static inline void +ESFM_slot_write (esfm_slot *slot, uint8_t register_idx, uint8_t data) +{ + switch (register_idx & 0x07) + { + case 0x00: + slot->tremolo_en = (data & 0x80) != 0; + slot->vibrato_en = (data & 0x40) != 0; + slot->env_sustaining = (data & 0x20) != 0; + slot->ksr = (data & 0x10) != 0; + slot->mult = data & 0x0f; + break; + case 0x01: + slot->ksl = data >> 6; + slot->t_level = data & 0x3f; + ESFM_slot_update_keyscale(slot); + break; + case 0x02: + slot->attack_rate = data >> 4; + slot->decay_rate = data & 0x0f; + break; + case 0x03: + slot->sustain_lvl = data >> 4; + slot->release_rate = data & 0x0f; + break; + case 0x04: + slot->f_num = (slot->f_num & 0x300) | data; + ESFM_slot_update_keyscale(slot); + break; + case 0x05: + if (slot->env_delay < (data >> 5)) + { + slot->in.eg_delay_transitioned_01 = 1; + } + else if (slot->env_delay > (data >> 5)) + { + slot->in.eg_delay_transitioned_10 = 1; + } + slot->env_delay = data >> 5; + slot->emu_key_on = (data >> 5) & 0x01; + slot->block = (data >> 2) & 0x07; + slot->f_num = (slot->f_num & 0xff) | ((data & 0x03) << 8); + ESFM_slot_update_keyscale(slot); + break; + case 0x06: + slot->tremolo_deep = (data & 0x80) != 0; + slot->vibrato_deep = (data & 0x40) != 0; + slot->out_enable[1] = (data & 0x20) ? ~((int13) 0) : 0; + slot->out_enable[0] = (data & 0x10) ? ~((int13) 0) : 0; + slot->mod_in_level = (data >> 1) & 0x07; + slot->emu_connection_typ = data & 0x01; + break; + case 0x07: + slot->output_level = data >> 5; + slot->rhy_noise = (data >> 3) & 0x03; + slot->waveform = data & 0x07; + break; + } +} + +#define KEY_ON_REGS_START (18 * 4 * 8) +#define TIMER1_REG (0x402) +#define TIMER2_REG (0x403) +#define TIMER_SETUP_REG (0x404) +#define CONFIG_REG (0x408) +#define BASSDRUM_REG (0x4bd) +#define TEST_REG (0x501) +#define FOUROP_CONN_REG (0x504) +#define NATIVE_MODE_REG (0x505) + +/* ------------------------------------------------------------------------- */ +static void +ESFM_write_reg_native (esfm_chip *chip, uint16_t address, uint8_t data) +{ + int i; + address = address & 0x7ff; + + if (address < KEY_ON_REGS_START) + { + // Slot register write + size_t channel_idx = address >> 5; + size_t slot_idx = (address >> 3) & 0x03; + size_t register_idx = address & 0x07; + esfm_slot *slot = &chip->channels[channel_idx].slots[slot_idx]; + + ESFM_slot_write(slot, register_idx, data); + } + else if (address < KEY_ON_REGS_START + 16) + { + // Key-on registers + size_t channel_idx = (address - KEY_ON_REGS_START); + esfm_channel *channel = &chip->channels[channel_idx]; + channel->key_on = data & 0x01; + channel->emu_mode_4op_enable = (data & 0x02) != 0; + } + else if (address < KEY_ON_REGS_START + 20) + { + // Key-on channels 17 and 18 (each half) + size_t channel_idx = 16 + ((address & 0x02) >> 1); + bool second_half = address & 0x01; + esfm_channel *channel = &chip->channels[channel_idx]; + if (second_half) + { + channel->key_on_2 = data & 0x01; + channel->emu_mode_4op_enable_2 = (data & 0x02) != 0; + } + else + { + channel->key_on = data & 0x01; + channel->emu_mode_4op_enable = (data & 0x02) != 0; + } + } + else + { + switch (address & 0x5ff) + { + case TIMER1_REG: + chip->timer_reload[0] = data; + break; + case TIMER2_REG: + chip->timer_reload[1] = data; + break; + case TIMER_SETUP_REG: + if (data & 0x80) + { + chip->timer_overflow[0] = 0; + chip->timer_overflow[1] = 0; + chip->irq_bit = 0; + } + chip->timer_enable[0] = (data & 0x01) != 0; + chip->timer_enable[1] = (data & 0x02) != 0; + chip->timer_mask[0] = (data & 0x20) != 0; + chip->timer_mask[1] = (data & 0x40) != 0; + break; + case CONFIG_REG: + chip->keyscale_mode = (data & 0x40) != 0; + break; + case BASSDRUM_REG: + chip->emu_rhy_mode_flags = data & 0x3f; + chip->emu_vibrato_deep = (data & 0x40) != 0; + chip->emu_tremolo_deep = (data & 0x80) != 0; + break; + case FOUROP_CONN_REG: + for (i = 0; i < 3; i++) + { + chip->channels[i].emu_mode_4op_enable = (data >> i) & 0x01; + chip->channels[i + 9].emu_mode_4op_enable = (data >> (i + 3)) & 0x01; + } + break; + case TEST_REG: + chip->test_bit_eg_halt = (data & 0x01) | ((data & 0x20) != 0); + chip->test_bit_distort = (data & 0x02) != 0; + chip->test_bit_attenuate = (data & 0x10) != 0; + chip->test_bit_phase_stop_reset = (data & 0x40) != 0; + break; + } + } +} + +/* ------------------------------------------------------------------------- */ +static uint8_t +ESFM_readback_reg_native (esfm_chip *chip, uint16_t address) +{ + int i; + uint8_t data = 0; + address = address & 0x7ff; + + if (address < KEY_ON_REGS_START) + { + // Slot register read + size_t channel_idx = address >> 5; + size_t slot_idx = (address >> 3) & 0x03; + size_t register_idx = address & 0x07; + esfm_slot *slot = &chip->channels[channel_idx].slots[slot_idx]; + + data = ESFM_slot_readback(slot, register_idx); + } + else if (address < KEY_ON_REGS_START + 16) + { + // Key-on registers + size_t channel_idx = (address - KEY_ON_REGS_START); + esfm_channel *channel = &chip->channels[channel_idx]; + + data |= channel->key_on != 0; + data |= (channel->emu_mode_4op_enable != 0) << 1; + } + else if (address < KEY_ON_REGS_START + 20) + { + // Key-on channels 17 and 18 (each half) + size_t channel_idx = 16 + ((address & 0x02) >> 1); + bool second_half = address & 0x01; + esfm_channel *channel = &chip->channels[channel_idx]; + if (second_half) + { + data |= channel->key_on_2 != 0; + data |= (channel->emu_mode_4op_enable_2 != 0) << 1; + } + else + { + data |= channel->key_on != 0; + data |= (channel->emu_mode_4op_enable != 0) << 1; + } + } + else + { + switch (address & 0x5ff) + { + case TIMER1_REG: + data = chip->timer_reload[0]; + break; + case TIMER2_REG: + data = chip->timer_reload[1]; + break; + case TIMER_SETUP_REG: + data |= chip->timer_enable[0] != 0; + data |= (chip->timer_enable[1] != 0) << 1; + data |= (chip->timer_mask[0] != 0) << 5; + data |= (chip->timer_mask[1] != 0) << 6; + break; + case CONFIG_REG: + data |= (chip->keyscale_mode != 0) << 6; + break; + case BASSDRUM_REG: + data |= chip->emu_rhy_mode_flags; + data |= chip->emu_vibrato_deep << 6; + data |= chip->emu_tremolo_deep << 7; + break; + case TEST_REG: + data |= chip->test_bit_eg_halt != 0; + data |= (chip->test_bit_distort != 0) << 1; + data |= (chip->test_bit_attenuate != 0) << 4; + data |= (chip->test_bit_eg_halt != 0) << 5; + data |= (chip->test_bit_phase_stop_reset != 0) << 6; + break; + case FOUROP_CONN_REG: + for (i = 0; i < 3; i++) + { + data |= (chip->channels[i].emu_mode_4op_enable != 0) << i; + data |= (chip->channels[i + 9].emu_mode_4op_enable != 0) << (i + 3); + } + break; + case NATIVE_MODE_REG: + data |= (chip->native_mode != 0) << 7; + break; + } + } + return data; +} + +/* ------------------------------------------------------------------------- */ +static void +ESFM_write_reg_emu (esfm_chip *chip, uint16_t address, uint8_t data) +{ + bool high = (address & 0x100) != 0; + uint8_t reg = address & 0xff; + int emu_slot_idx = ad_slot[address & 0x1f]; + int natv_chan_idx = -1; + int natv_slot_idx = -1; + int emu_chan_idx = (reg & 0x0f) > 8 ? -1 : ((reg & 0x0f) + high * 9); + + if (emu_slot_idx >= 0) + { + if (high) + { + emu_slot_idx += 18; + } + + natv_chan_idx = emu_slot_map[emu_slot_idx].channel_idx; + natv_slot_idx = emu_slot_map[emu_slot_idx].slot_idx; + } + + if (reg == 0xbd) + { + chip->emu_rhy_mode_flags = data & 0x3f; + chip->emu_vibrato_deep = (data & 0x40) != 0; + chip->emu_tremolo_deep = (data & 0x80) != 0; + if (chip->emu_rhy_mode_flags & 0x20) + { + // TODO: check if writes to 0xbd actually affect the readable key-on flags at + // 0x246, 0x247, 0x248; and if there's any visible effect from the SD and TC flags + chip->channels[6].key_on = (data & 0x10) != 0; + chip->channels[7].key_on = (data & 0x01) != 0; + chip->channels[8].key_on = (data & 0x04) != 0; + chip->channels[7].key_on_2 = (data & 0x08) != 0; + chip->channels[8].key_on_2 = (data & 0x02) != 0; + } + ESFM_emu_rearrange_connections(&chip->channels[7]); + ESFM_emu_rearrange_connections(&chip->channels[8]); + return; + } + + switch(reg & 0xf0) + { + case 0x00: + if (high) + { + int i; + switch(reg & 0x0f) + { + case 0x01: + chip->emu_wavesel_enable = (data & 0x20) != 0; + break; + case 0x02: + chip->timer_reload[0] = data; + break; + case 0x03: + chip->timer_reload[1] = data; + break; + case 0x04: + for (i = 0; i < 3; i++) + { + chip->channels[i].emu_mode_4op_enable = (data >> i) & 0x01; + chip->channels[i + 9].emu_mode_4op_enable = (data >> (i + 3)) & 0x01; + } + for (i = 0; i < 6; i++) + { + ESFM_emu_rearrange_connections(&chip->channels[i]); + ESFM_emu_rearrange_connections(&chip->channels[i + 9]); + } + break; + case 0x05: + chip->emu_newmode = data & 0x01; + if ((data & 0x80) != 0) + { + chip->native_mode = 1; + ESFM_emu_to_native_switch(chip); + } + break; + case 0x08: + chip->keyscale_mode = (data & 0x40) != 0; + break; + } + } + else + { + switch(reg & 0x0f) + { + case 0x01: + chip->emu_wavesel_enable = (data & 0x20) != 0; + break; + case 0x02: + chip->timer_reload[0] = data; + break; + case 0x03: + chip->timer_reload[1] = data; + break; + case 0x04: + chip->timer_enable[0] = data & 0x01; + chip->timer_enable[1] = (data & 0x02) != 0; + chip->timer_mask[0] = (data & 0x20) != 0; + chip->timer_mask[1] = (data & 0x40) != 0; + if (data & 0x80) + { + chip->irq_bit = 0; + } + break; + case 0x08: + chip->keyscale_mode = (data & 0x40) != 0; + break; + } + } + break; + case 0x20: case 0x30: + if (emu_slot_idx >= 0) + { + ESFM_slot_write(&chip->channels[natv_chan_idx].slots[natv_slot_idx], 0x0, data); + } + break; + case 0x40: case 0x50: + if (emu_slot_idx >= 0) + { + ESFM_slot_write(&chip->channels[natv_chan_idx].slots[natv_slot_idx], 0x1, data); + ESFM_emu_channel_update_keyscale(&chip->channels[natv_chan_idx]); + } + break; + case 0x60: case 0x70: + if (emu_slot_idx >= 0) + { + ESFM_slot_write(&chip->channels[natv_chan_idx].slots[natv_slot_idx], 0x2, data); + } + break; + case 0x80: case 0x90: + if (emu_slot_idx >= 0) + { + ESFM_slot_write(&chip->channels[natv_chan_idx].slots[natv_slot_idx], 0x3, data); + } + break; + case 0xa0: + if (emu_chan_idx >= 0) + { + ESFM_slot_write(&chip->channels[emu_chan_idx].slots[0], 0x4, data); + ESFM_emu_channel_update_keyscale(&chip->channels[emu_chan_idx]); + } + break; + case 0xb0: + if (emu_chan_idx >= 0) + { + esfm_channel *channel = &chip->channels[emu_chan_idx]; + // TODO: check if emulation mode actually writes to the native mode key on registers + // it might only use slot 0's emu key on field... + channel->key_on = (data & 0x20) != 0; + if (channel->channel_idx == 7 || channel->channel_idx == 8) + { + channel->key_on_2 = (data & 0x20) != 0; + } + ESFM_slot_write(&channel->slots[0], 0x5, data); + ESFM_emu_channel_update_keyscale(&chip->channels[emu_chan_idx]); + } + break; + case 0xc0: + if (emu_chan_idx >= 0) + { + ESFM_slot_write(&chip->channels[emu_chan_idx].slots[0], 0x6, data); + ESFM_emu_rearrange_connections(&chip->channels[emu_chan_idx]); + } + break; + case 0xe0: case 0xf0: + if (emu_slot_idx >= 0) + { + ESFM_slot_write(&chip->channels[natv_chan_idx].slots[natv_slot_idx], 0x7, data); + } + break; + } +} + + +/* ------------------------------------------------------------------------- */ +void +ESFM_write_reg (esfm_chip *chip, uint16_t address, uint8_t data) +{ + if (chip->native_mode) + { + ESFM_write_reg_native(chip, address, data); + return; + } + else + { + ESFM_write_reg_emu(chip, address, data); + return; + } +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_write_reg_buffered (esfm_chip *chip, uint16_t address, uint8_t data) +{ + uint64_t timestamp; + esfm_write_buf *new_entry, *last_entry; + + new_entry = &chip->write_buf[chip->write_buf_end]; + last_entry = &chip->write_buf[(chip->write_buf_end - 1) % ESFM_WRITEBUF_SIZE]; + + if (new_entry->valid) { + ESFM_write_reg(chip, new_entry->address, new_entry->data); + chip->write_buf_start = (chip->write_buf_end + 1) % ESFM_WRITEBUF_SIZE; + } + + new_entry->valid = 1; + new_entry->address = address; + new_entry->data = data; + timestamp = last_entry->timestamp + ESFM_WRITEBUF_DELAY; + if (timestamp < chip->write_buf_timestamp) + { + timestamp = chip->write_buf_timestamp; + } + + new_entry->timestamp = timestamp; + chip->write_buf_end = (chip->write_buf_end + 1) % ESFM_WRITEBUF_SIZE; +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_write_reg_buffered_fast (esfm_chip *chip, uint16_t address, uint8_t data) +{ + esfm_write_buf *new_entry; + + new_entry = &chip->write_buf[chip->write_buf_end]; + + if (new_entry->valid) { + ESFM_write_reg(chip, new_entry->address, new_entry->data); + chip->write_buf_start = (chip->write_buf_end + 1) % ESFM_WRITEBUF_SIZE; + } + + new_entry->valid = 1; + new_entry->address = address; + new_entry->data = data; + new_entry->timestamp = chip->write_buf_timestamp; + chip->write_buf_end = (chip->write_buf_end + 1) % ESFM_WRITEBUF_SIZE; +} + +/* ------------------------------------------------------------------------- */ +uint8_t +ESFM_readback_reg (esfm_chip *chip, uint16_t address) +{ + if (chip->native_mode) + { + return ESFM_readback_reg_native(chip, address); + } + else + { + return 0; + } +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_write_port (esfm_chip *chip, uint8_t offset, uint8_t data) +{ + if (chip->native_mode) + { + switch(offset) + { + case 0: + chip->native_mode = 0; + ESFM_native_to_emu_switch(chip); + chip->addr_latch = data; + break; + case 1: + ESFM_write_reg_native(chip, chip->addr_latch, data); + break; + case 2: + chip->addr_latch = (chip->addr_latch & 0xff00) | data; + break; + case 3: + chip->addr_latch = chip->addr_latch & 0xff; + chip->addr_latch |= (uint16)data << 8; + break; + } + } + else + { + switch(offset) + { + case 0: + chip->addr_latch = data; + break; + case 1: case 3: + ESFM_write_reg_emu(chip, chip->addr_latch, data); + break; + case 2: + chip->addr_latch = (uint16)data | 0x100; + break; + } + } +} + +/* ------------------------------------------------------------------------- */ +uint8_t +ESFM_read_port (esfm_chip *chip, uint8_t offset) +{ + uint8_t data = 0; + if (chip->native_mode) + { + switch(offset) + { + case 0: + // TODO: actually implement timer count, trigger and reset + data |= (chip->irq_bit != 0) << 7; + data |= (chip->timer_overflow[0] != 0) << 6; + data |= (chip->timer_overflow[1] != 0) << 5; + break; + case 1: + data = ESFM_readback_reg_native(chip, chip->addr_latch); + break; + // TODO: verify what the ESFM chip actually returns when reading + // from the other address ports + } + } + else + { + switch(offset) + { + case 0: + data |= (chip->irq_bit != 0) << 7; + data |= (chip->timer_overflow[0] != 0) << 6; + data |= (chip->timer_overflow[1] != 0) << 5; + break; + case 1: + data = 0; + break; + case 2: case 3: + // This matches OPL3 behavior. + // TODO: verify what the ESFM chip actually returns when reading + // from address ports in emulation mode + data = 0xff; + break; + } + } + return data; +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_set_mode (esfm_chip *chip, bool native_mode) +{ + native_mode = native_mode != 0; + + if (native_mode != (chip->native_mode != 0)) + { + chip->native_mode = native_mode; + if (native_mode) + { + ESFM_emu_to_native_switch(chip); + } + else + { + ESFM_native_to_emu_switch(chip); + } + } +} + +/* ------------------------------------------------------------------------- */ +void +ESFM_init (esfm_chip *chip) +{ + esfm_slot *slot; + esfm_channel *channel; + size_t channel_idx, slot_idx; + + memset(chip, 0, sizeof(esfm_chip)); + for (channel_idx = 0; channel_idx < 18; channel_idx++) + { + for (slot_idx = 0; slot_idx < 4; slot_idx++) + { + channel = &chip->channels[channel_idx]; + slot = &channel->slots[slot_idx]; + + channel->chip = chip; + channel->channel_idx = channel_idx; + slot->channel = channel; + slot->chip = chip; + slot->slot_idx = slot_idx; + slot->in.eg_position = slot->in.eg_output = 0x1ff; + slot->in.eg_state = EG_RELEASE; + slot->in.emu_mod_enable = ~((int13) 0); + if (slot_idx == 0) + { + slot->in.mod_input = &slot->in.feedback_buf; + } + else + { + esfm_slot *prev_slot = &channel->slots[slot_idx - 1]; + slot->in.mod_input = &prev_slot->in.output; + } + + if (slot_idx == 1) + { + slot->in.emu_output_enable = ~((int13) 0); + } + + if (channel_idx > 15 && slot_idx & 0x02) + { + slot->in.key_on = &channel->key_on_2; + } + else + { + slot->in.key_on = &channel->key_on; + } + + slot->out_enable[0] = slot->out_enable[1] = ~((int13) 0); + } + } + + chip->lfsr = 1; +} + diff --git a/instruments/ESFM/Synth Bass.fui b/instruments/ESFM/Synth Bass.fui new file mode 100644 index 000000000..0148b2f74 Binary files /dev/null and b/instruments/ESFM/Synth Bass.fui differ diff --git a/instruments/ESFM/djtBMX_1chostinato.fui b/instruments/ESFM/djtBMX_1chostinato.fui new file mode 100644 index 000000000..ee26b7b39 Binary files /dev/null and b/instruments/ESFM/djtBMX_1chostinato.fui differ diff --git a/instruments/ESFM/djtBMX_4opBassESFM.fui b/instruments/ESFM/djtBMX_4opBassESFM.fui new file mode 100644 index 000000000..f902ec50d Binary files /dev/null and b/instruments/ESFM/djtBMX_4opBassESFM.fui differ diff --git a/instruments/ESFM/djtBMX_4opESFMStrings.fui b/instruments/ESFM/djtBMX_4opESFMStrings.fui new file mode 100644 index 000000000..b942199c5 Binary files /dev/null and b/instruments/ESFM/djtBMX_4opESFMStrings.fui differ diff --git a/instruments/ESFM/djtBMX_4opESFMStrings2.fui b/instruments/ESFM/djtBMX_4opESFMStrings2.fui new file mode 100644 index 000000000..b975201a1 Binary files /dev/null and b/instruments/ESFM/djtBMX_4opESFMStrings2.fui differ diff --git a/instruments/ESFM/djtBMX_4opESFMStrings3.fui b/instruments/ESFM/djtBMX_4opESFMStrings3.fui new file mode 100644 index 000000000..b2e661504 Binary files /dev/null and b/instruments/ESFM/djtBMX_4opESFMStrings3.fui differ diff --git a/instruments/ESFM/djtBMX_4opESFMStrings4.fui b/instruments/ESFM/djtBMX_4opESFMStrings4.fui new file mode 100644 index 000000000..4f84563cd Binary files /dev/null and b/instruments/ESFM/djtBMX_4opESFMStrings4.fui differ diff --git a/instruments/ESFM/djtBMX_4opRubbaBassESFM.fui b/instruments/ESFM/djtBMX_4opRubbaBassESFM.fui new file mode 100644 index 000000000..4ff3a2a3a Binary files /dev/null and b/instruments/ESFM/djtBMX_4opRubbaBassESFM.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMBRAS.fui b/instruments/ESFM/djtBMX_ESFMBRAS.fui new file mode 100644 index 000000000..82ff64c41 Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMBRAS.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMBRASSSECT.fui b/instruments/ESFM/djtBMX_ESFMBRASSSECT.fui new file mode 100644 index 000000000..fbecba4ff Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMBRASSSECT.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMGIT.fui b/instruments/ESFM/djtBMX_ESFMGIT.fui new file mode 100644 index 000000000..2f1b75e13 Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMGIT.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMPWM.fui b/instruments/ESFM/djtBMX_ESFMPWM.fui new file mode 100644 index 000000000..f07c0d121 Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMPWM.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMSYN.fui b/instruments/ESFM/djtBMX_ESFMSYN.fui new file mode 100644 index 000000000..0d86beaee Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMSYN.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMresobell-short.fui b/instruments/ESFM/djtBMX_ESFMresobell-short.fui new file mode 100644 index 000000000..dc65c7d8c Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMresobell-short.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMresobell.fui b/instruments/ESFM/djtBMX_ESFMresobell.fui new file mode 100644 index 000000000..7422641a5 Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMresobell.fui differ diff --git a/instruments/ESFM/djtBMX_ESFMresopipe.fui b/instruments/ESFM/djtBMX_ESFMresopipe.fui new file mode 100644 index 000000000..08cc3bcea Binary files /dev/null and b/instruments/ESFM/djtBMX_ESFMresopipe.fui differ diff --git a/instruments/ESFM/djtBMX_PULSELESSBUZZER.fui b/instruments/ESFM/djtBMX_PULSELESSBUZZER.fui new file mode 100644 index 000000000..55040d931 Binary files /dev/null and b/instruments/ESFM/djtBMX_PULSELESSBUZZER.fui differ diff --git a/instruments/ESFM/djtBMX_analogoctbas.fui b/instruments/ESFM/djtBMX_analogoctbas.fui new file mode 100644 index 000000000..907b4cf86 Binary files /dev/null and b/instruments/ESFM/djtBMX_analogoctbas.fui differ diff --git a/instruments/ESFM/djtBMX_bells.fui b/instruments/ESFM/djtBMX_bells.fui new file mode 100644 index 000000000..03bae04d3 Binary files /dev/null and b/instruments/ESFM/djtBMX_bells.fui differ diff --git a/instruments/ESFM/djtBMX_brarsesin.fui b/instruments/ESFM/djtBMX_brarsesin.fui new file mode 100644 index 000000000..2d3c970f2 Binary files /dev/null and b/instruments/ESFM/djtBMX_brarsesin.fui differ diff --git a/instruments/ESFM/djtBMX_brassin.fui b/instruments/ESFM/djtBMX_brassin.fui new file mode 100644 index 000000000..9d58d0b91 Binary files /dev/null and b/instruments/ESFM/djtBMX_brassin.fui differ diff --git a/instruments/ESFM/djtBMX_bwaro.fui b/instruments/ESFM/djtBMX_bwaro.fui new file mode 100644 index 000000000..e84d877f1 Binary files /dev/null and b/instruments/ESFM/djtBMX_bwaro.fui differ diff --git a/instruments/ESFM/djtBMX_chorbel.fui b/instruments/ESFM/djtBMX_chorbel.fui new file mode 100644 index 000000000..47b0fe3a7 Binary files /dev/null and b/instruments/ESFM/djtBMX_chorbel.fui differ diff --git a/instruments/ESFM/djtBMX_chorpad.fui b/instruments/ESFM/djtBMX_chorpad.fui new file mode 100644 index 000000000..900743510 Binary files /dev/null and b/instruments/ESFM/djtBMX_chorpad.fui differ diff --git a/instruments/ESFM/djtBMX_clanger.fui b/instruments/ESFM/djtBMX_clanger.fui new file mode 100644 index 000000000..6d54e300b Binary files /dev/null and b/instruments/ESFM/djtBMX_clanger.fui differ diff --git a/instruments/ESFM/djtBMX_clanger2.fui b/instruments/ESFM/djtBMX_clanger2.fui new file mode 100644 index 000000000..84becd228 Binary files /dev/null and b/instruments/ESFM/djtBMX_clanger2.fui differ diff --git a/instruments/ESFM/djtBMX_clanger3.fui b/instruments/ESFM/djtBMX_clanger3.fui new file mode 100644 index 000000000..17ba2845f Binary files /dev/null and b/instruments/ESFM/djtBMX_clanger3.fui differ diff --git a/instruments/ESFM/djtBMX_clanger4.fui b/instruments/ESFM/djtBMX_clanger4.fui new file mode 100644 index 000000000..1810e1a94 Binary files /dev/null and b/instruments/ESFM/djtBMX_clanger4.fui differ diff --git a/instruments/ESFM/djtBMX_compile-basskick.fui b/instruments/ESFM/djtBMX_compile-basskick.fui new file mode 100644 index 000000000..7325a9834 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-basskick.fui differ diff --git a/instruments/ESFM/djtBMX_compile-closehh.fui b/instruments/ESFM/djtBMX_compile-closehh.fui new file mode 100644 index 000000000..ef6c0b604 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-closehh.fui differ diff --git a/instruments/ESFM/djtBMX_compile-marimba.fui b/instruments/ESFM/djtBMX_compile-marimba.fui new file mode 100644 index 000000000..46fd62732 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-marimba.fui differ diff --git a/instruments/ESFM/djtBMX_compile-openhh.fui b/instruments/ESFM/djtBMX_compile-openhh.fui new file mode 100644 index 000000000..55b8236b8 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-openhh.fui differ diff --git a/instruments/ESFM/djtBMX_compile-padbrass.fui b/instruments/ESFM/djtBMX_compile-padbrass.fui new file mode 100644 index 000000000..fe27ce49f Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-padbrass.fui differ diff --git a/instruments/ESFM/djtBMX_compile-sinetom.fui b/instruments/ESFM/djtBMX_compile-sinetom.fui new file mode 100644 index 000000000..8de198fa4 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-sinetom.fui differ diff --git a/instruments/ESFM/djtBMX_compile-snare.fui b/instruments/ESFM/djtBMX_compile-snare.fui new file mode 100644 index 000000000..a4b7f7e28 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-snare.fui differ diff --git a/instruments/ESFM/djtBMX_compile-springbass.fui b/instruments/ESFM/djtBMX_compile-springbass.fui new file mode 100644 index 000000000..9b5d90cd4 Binary files /dev/null and b/instruments/ESFM/djtBMX_compile-springbass.fui differ diff --git a/instruments/ESFM/djtBMX_compileagogo.fui b/instruments/ESFM/djtBMX_compileagogo.fui new file mode 100644 index 000000000..1882e71eb Binary files /dev/null and b/instruments/ESFM/djtBMX_compileagogo.fui differ diff --git a/instruments/ESFM/djtBMX_compilebrass.fui b/instruments/ESFM/djtBMX_compilebrass.fui new file mode 100644 index 000000000..fa34f2841 Binary files /dev/null and b/instruments/ESFM/djtBMX_compilebrass.fui differ diff --git a/instruments/ESFM/djtBMX_compilefartbass.fui b/instruments/ESFM/djtBMX_compilefartbass.fui new file mode 100644 index 000000000..4d36f99b5 Binary files /dev/null and b/instruments/ESFM/djtBMX_compilefartbass.fui differ diff --git a/instruments/ESFM/djtBMX_didgeritune.fui b/instruments/ESFM/djtBMX_didgeritune.fui new file mode 100644 index 000000000..69a910c46 Binary files /dev/null and b/instruments/ESFM/djtBMX_didgeritune.fui differ diff --git a/instruments/ESFM/djtBMX_drlead.fui b/instruments/ESFM/djtBMX_drlead.fui new file mode 100644 index 000000000..3cebf1a56 Binary files /dev/null and b/instruments/ESFM/djtBMX_drlead.fui differ diff --git a/instruments/ESFM/djtBMX_egless-kick.fui b/instruments/ESFM/djtBMX_egless-kick.fui new file mode 100644 index 000000000..237db9f2d Binary files /dev/null and b/instruments/ESFM/djtBMX_egless-kick.fui differ diff --git a/instruments/ESFM/djtBMX_explosion.fui b/instruments/ESFM/djtBMX_explosion.fui new file mode 100644 index 000000000..33b5d67db Binary files /dev/null and b/instruments/ESFM/djtBMX_explosion.fui differ diff --git a/instruments/ESFM/djtBMX_falcomkey.fui b/instruments/ESFM/djtBMX_falcomkey.fui new file mode 100644 index 000000000..b8fb4960b Binary files /dev/null and b/instruments/ESFM/djtBMX_falcomkey.fui differ diff --git a/instruments/ESFM/djtBMX_gitbsyn3.fui b/instruments/ESFM/djtBMX_gitbsyn3.fui new file mode 100644 index 000000000..4680aac41 Binary files /dev/null and b/instruments/ESFM/djtBMX_gitbsyn3.fui differ diff --git a/instruments/ESFM/djtBMX_gitbsyn4.fui b/instruments/ESFM/djtBMX_gitbsyn4.fui new file mode 100644 index 000000000..e7cb932b9 Binary files /dev/null and b/instruments/ESFM/djtBMX_gitbsyn4.fui differ diff --git a/instruments/ESFM/djtBMX_gitsyn2.fui b/instruments/ESFM/djtBMX_gitsyn2.fui new file mode 100644 index 000000000..28053a85b Binary files /dev/null and b/instruments/ESFM/djtBMX_gitsyn2.fui differ diff --git a/instruments/ESFM/djtBMX_gitty.fui b/instruments/ESFM/djtBMX_gitty.fui new file mode 100644 index 000000000..dbf633f16 Binary files /dev/null and b/instruments/ESFM/djtBMX_gitty.fui differ diff --git a/instruments/ESFM/djtBMX_hammeredkeypad.fui b/instruments/ESFM/djtBMX_hammeredkeypad.fui new file mode 100644 index 000000000..286c106f3 Binary files /dev/null and b/instruments/ESFM/djtBMX_hammeredkeypad.fui differ diff --git a/instruments/ESFM/djtBMX_kikbas.fui b/instruments/ESFM/djtBMX_kikbas.fui new file mode 100644 index 000000000..c92ffa5e3 Binary files /dev/null and b/instruments/ESFM/djtBMX_kikbas.fui differ diff --git a/instruments/ESFM/djtBMX_lfotest.fui b/instruments/ESFM/djtBMX_lfotest.fui new file mode 100644 index 000000000..f96a101fe Binary files /dev/null and b/instruments/ESFM/djtBMX_lfotest.fui differ diff --git a/instruments/ESFM/djtBMX_lofibrass.fui b/instruments/ESFM/djtBMX_lofibrass.fui new file mode 100644 index 000000000..48c9e2fa4 Binary files /dev/null and b/instruments/ESFM/djtBMX_lofibrass.fui differ diff --git a/instruments/ESFM/djtBMX_lylemays.fui b/instruments/ESFM/djtBMX_lylemays.fui new file mode 100644 index 000000000..469f7a61a Binary files /dev/null and b/instruments/ESFM/djtBMX_lylemays.fui differ diff --git a/instruments/ESFM/djtBMX_m1stylepaino.fui b/instruments/ESFM/djtBMX_m1stylepaino.fui new file mode 100644 index 000000000..b11fb2aa2 Binary files /dev/null and b/instruments/ESFM/djtBMX_m1stylepaino.fui differ diff --git a/instruments/ESFM/djtBMX_m1stylepaino2.fui b/instruments/ESFM/djtBMX_m1stylepaino2.fui new file mode 100644 index 000000000..44af11d14 Binary files /dev/null and b/instruments/ESFM/djtBMX_m1stylepaino2.fui differ diff --git a/instruments/ESFM/djtBMX_m1stylepaino3.fui b/instruments/ESFM/djtBMX_m1stylepaino3.fui new file mode 100644 index 000000000..68b3d6838 Binary files /dev/null and b/instruments/ESFM/djtBMX_m1stylepaino3.fui differ diff --git a/instruments/ESFM/djtBMX_m1stylepaino4.fui b/instruments/ESFM/djtBMX_m1stylepaino4.fui new file mode 100644 index 000000000..4e390c0a9 Binary files /dev/null and b/instruments/ESFM/djtBMX_m1stylepaino4.fui differ diff --git a/instruments/ESFM/djtBMX_m1stylepaino5.fui b/instruments/ESFM/djtBMX_m1stylepaino5.fui new file mode 100644 index 000000000..1ce005eda Binary files /dev/null and b/instruments/ESFM/djtBMX_m1stylepaino5.fui differ diff --git a/instruments/ESFM/djtBMX_nearest-drone.fui b/instruments/ESFM/djtBMX_nearest-drone.fui new file mode 100644 index 000000000..83c826b86 Binary files /dev/null and b/instruments/ESFM/djtBMX_nearest-drone.fui differ diff --git a/instruments/ESFM/djtBMX_neophytekick.fui b/instruments/ESFM/djtBMX_neophytekick.fui new file mode 100644 index 000000000..7134f0f37 Binary files /dev/null and b/instruments/ESFM/djtBMX_neophytekick.fui differ diff --git a/instruments/ESFM/djtBMX_neophytekick2.fui b/instruments/ESFM/djtBMX_neophytekick2.fui new file mode 100644 index 000000000..4d17e19cc Binary files /dev/null and b/instruments/ESFM/djtBMX_neophytekick2.fui differ diff --git a/instruments/ESFM/djtBMX_noisytom.fui b/instruments/ESFM/djtBMX_noisytom.fui new file mode 100644 index 000000000..b80ed42bd Binary files /dev/null and b/instruments/ESFM/djtBMX_noisytom.fui differ diff --git a/instruments/ESFM/djtBMX_panfluter.fui b/instruments/ESFM/djtBMX_panfluter.fui new file mode 100644 index 000000000..6e022e2bb Binary files /dev/null and b/instruments/ESFM/djtBMX_panfluter.fui differ diff --git a/instruments/ESFM/djtBMX_pianoyorgan.fui b/instruments/ESFM/djtBMX_pianoyorgan.fui new file mode 100644 index 000000000..5f5bc8d40 Binary files /dev/null and b/instruments/ESFM/djtBMX_pianoyorgan.fui differ diff --git a/instruments/ESFM/djtBMX_piezoclavi.fui b/instruments/ESFM/djtBMX_piezoclavi.fui new file mode 100644 index 000000000..30d571355 Binary files /dev/null and b/instruments/ESFM/djtBMX_piezoclavi.fui differ diff --git a/instruments/ESFM/djtBMX_pulselesspulse.fui b/instruments/ESFM/djtBMX_pulselesspulse.fui new file mode 100644 index 000000000..ef67474a4 Binary files /dev/null and b/instruments/ESFM/djtBMX_pulselesspulse.fui differ diff --git a/instruments/ESFM/djtBMX_pulselesspwm.fui b/instruments/ESFM/djtBMX_pulselesspwm.fui new file mode 100644 index 000000000..ea11256aa Binary files /dev/null and b/instruments/ESFM/djtBMX_pulselesspwm.fui differ diff --git a/instruments/ESFM/djtBMX_pwm2.fui b/instruments/ESFM/djtBMX_pwm2.fui new file mode 100644 index 000000000..266225e61 Binary files /dev/null and b/instruments/ESFM/djtBMX_pwm2.fui differ diff --git a/instruments/ESFM/djtBMX_pwm3.fui b/instruments/ESFM/djtBMX_pwm3.fui new file mode 100644 index 000000000..af7a0b5d3 Binary files /dev/null and b/instruments/ESFM/djtBMX_pwm3.fui differ diff --git a/instruments/ESFM/djtBMX_pwminv.fui b/instruments/ESFM/djtBMX_pwminv.fui new file mode 100644 index 000000000..20dbdef98 Binary files /dev/null and b/instruments/ESFM/djtBMX_pwminv.fui differ diff --git a/instruments/ESFM/djtBMX_quantizedcalilope.fui b/instruments/ESFM/djtBMX_quantizedcalilope.fui new file mode 100644 index 000000000..f4c5e9400 Binary files /dev/null and b/instruments/ESFM/djtBMX_quantizedcalilope.fui differ diff --git a/instruments/ESFM/djtBMX_quantizedcalilope2.fui b/instruments/ESFM/djtBMX_quantizedcalilope2.fui new file mode 100644 index 000000000..43b8a8144 Binary files /dev/null and b/instruments/ESFM/djtBMX_quantizedcalilope2.fui differ diff --git a/instruments/ESFM/djtBMX_quantizedcalilope3.fui b/instruments/ESFM/djtBMX_quantizedcalilope3.fui new file mode 100644 index 000000000..982737a37 Binary files /dev/null and b/instruments/ESFM/djtBMX_quantizedcalilope3.fui differ diff --git a/instruments/ESFM/djtBMX_quantizeddrone2.fui b/instruments/ESFM/djtBMX_quantizeddrone2.fui new file mode 100644 index 000000000..f00bac69a Binary files /dev/null and b/instruments/ESFM/djtBMX_quantizeddrone2.fui differ diff --git a/instruments/ESFM/djtBMX_quantizedhorn.fui b/instruments/ESFM/djtBMX_quantizedhorn.fui new file mode 100644 index 000000000..078c73f86 Binary files /dev/null and b/instruments/ESFM/djtBMX_quantizedhorn.fui differ diff --git a/instruments/ESFM/djtBMX_santur.fui b/instruments/ESFM/djtBMX_santur.fui new file mode 100644 index 000000000..b34356891 Binary files /dev/null and b/instruments/ESFM/djtBMX_santur.fui differ diff --git a/instruments/ESFM/djtBMX_santurys.fui b/instruments/ESFM/djtBMX_santurys.fui new file mode 100644 index 000000000..ed83b22a7 Binary files /dev/null and b/instruments/ESFM/djtBMX_santurys.fui differ diff --git a/instruments/ESFM/djtBMX_segapiano.fui b/instruments/ESFM/djtBMX_segapiano.fui new file mode 100644 index 000000000..43987085a Binary files /dev/null and b/instruments/ESFM/djtBMX_segapiano.fui differ diff --git a/instruments/ESFM/djtBMX_shttomsz.fui b/instruments/ESFM/djtBMX_shttomsz.fui new file mode 100644 index 000000000..b461b135a Binary files /dev/null and b/instruments/ESFM/djtBMX_shttomsz.fui differ diff --git a/instruments/ESFM/djtBMX_sinusoidgit.fui b/instruments/ESFM/djtBMX_sinusoidgit.fui new file mode 100644 index 000000000..161bd3537 Binary files /dev/null and b/instruments/ESFM/djtBMX_sinusoidgit.fui differ diff --git a/instruments/ESFM/djtBMX_sitardrone.fui b/instruments/ESFM/djtBMX_sitardrone.fui new file mode 100644 index 000000000..d953bdde0 Binary files /dev/null and b/instruments/ESFM/djtBMX_sitardrone.fui differ diff --git a/instruments/ESFM/djtBMX_slapbass.fui b/instruments/ESFM/djtBMX_slapbass.fui new file mode 100644 index 000000000..7dde1bd6e Binary files /dev/null and b/instruments/ESFM/djtBMX_slapbass.fui differ diff --git a/instruments/ESFM/djtBMX_softstar-string-enhanced.fui b/instruments/ESFM/djtBMX_softstar-string-enhanced.fui new file mode 100644 index 000000000..5b2aaa351 Binary files /dev/null and b/instruments/ESFM/djtBMX_softstar-string-enhanced.fui differ diff --git a/instruments/ESFM/djtBMX_springbass2.fui b/instruments/ESFM/djtBMX_springbass2.fui new file mode 100644 index 000000000..8e2a61bf9 Binary files /dev/null and b/instruments/ESFM/djtBMX_springbass2.fui differ diff --git a/instruments/ESFM/djtBMX_springbass3.fui b/instruments/ESFM/djtBMX_springbass3.fui new file mode 100644 index 000000000..9471b74f3 Binary files /dev/null and b/instruments/ESFM/djtBMX_springbass3.fui differ diff --git a/instruments/ESFM/djtBMX_springbass4.fui b/instruments/ESFM/djtBMX_springbass4.fui new file mode 100644 index 000000000..b53c46039 Binary files /dev/null and b/instruments/ESFM/djtBMX_springbass4.fui differ diff --git a/instruments/ESFM/djtBMX_squeiuz.fui b/instruments/ESFM/djtBMX_squeiuz.fui new file mode 100644 index 000000000..6597f8037 Binary files /dev/null and b/instruments/ESFM/djtBMX_squeiuz.fui differ diff --git a/instruments/ESFM/djtBMX_sunsoftbass.fui b/instruments/ESFM/djtBMX_sunsoftbass.fui new file mode 100644 index 000000000..b6f0ae2bb Binary files /dev/null and b/instruments/ESFM/djtBMX_sunsoftbass.fui differ diff --git a/instruments/ESFM/djtBMX_sunsoftbass2.fui b/instruments/ESFM/djtBMX_sunsoftbass2.fui new file mode 100644 index 000000000..b79c29ff3 Binary files /dev/null and b/instruments/ESFM/djtBMX_sunsoftbass2.fui differ diff --git a/instruments/ESFM/djtBMX_sunsoftbass3.fui b/instruments/ESFM/djtBMX_sunsoftbass3.fui new file mode 100644 index 000000000..4a66fef8a Binary files /dev/null and b/instruments/ESFM/djtBMX_sunsoftbass3.fui differ diff --git a/instruments/ESFM/djtBMX_sunsoftbass4.fui b/instruments/ESFM/djtBMX_sunsoftbass4.fui new file mode 100644 index 000000000..2777a8b28 Binary files /dev/null and b/instruments/ESFM/djtBMX_sunsoftbass4.fui differ diff --git a/instruments/ESFM/djtBMX_sunsoftbass5.fui b/instruments/ESFM/djtBMX_sunsoftbass5.fui new file mode 100644 index 000000000..9cfa41cbd Binary files /dev/null and b/instruments/ESFM/djtBMX_sunsoftbass5.fui differ diff --git a/instruments/ESFM/djtBMX_superpwm.fui b/instruments/ESFM/djtBMX_superpwm.fui new file mode 100644 index 000000000..1caf342de Binary files /dev/null and b/instruments/ESFM/djtBMX_superpwm.fui differ diff --git a/instruments/ESFM/djtBMX_sync-invtest.fui b/instruments/ESFM/djtBMX_sync-invtest.fui new file mode 100644 index 000000000..87f795152 Binary files /dev/null and b/instruments/ESFM/djtBMX_sync-invtest.fui differ diff --git a/instruments/ESFM/djtBMX_syncpwm-abuse.fui b/instruments/ESFM/djtBMX_syncpwm-abuse.fui new file mode 100644 index 000000000..cb457fd9e Binary files /dev/null and b/instruments/ESFM/djtBMX_syncpwm-abuse.fui differ diff --git a/instruments/ESFM/djtBMX_tabla.fui b/instruments/ESFM/djtBMX_tabla.fui new file mode 100644 index 000000000..6a971c0b2 Binary files /dev/null and b/instruments/ESFM/djtBMX_tabla.fui differ diff --git a/instruments/ESFM/djtBMX_tarnceseq.fui b/instruments/ESFM/djtBMX_tarnceseq.fui new file mode 100644 index 000000000..0a09cab3b Binary files /dev/null and b/instruments/ESFM/djtBMX_tarnceseq.fui differ diff --git a/instruments/ESFM/djtBMX_vic20square.fui b/instruments/ESFM/djtBMX_vic20square.fui new file mode 100644 index 000000000..2504d8ba4 Binary files /dev/null and b/instruments/ESFM/djtBMX_vic20square.fui differ diff --git a/instruments/ESFM/djtBMX_vic20squaretest.fui b/instruments/ESFM/djtBMX_vic20squaretest.fui new file mode 100644 index 000000000..3c27a510c Binary files /dev/null and b/instruments/ESFM/djtBMX_vic20squaretest.fui differ diff --git a/instruments/ESFM/djtBMX_wurly.fui b/instruments/ESFM/djtBMX_wurly.fui new file mode 100644 index 000000000..453349e84 Binary files /dev/null and b/instruments/ESFM/djtBMX_wurly.fui differ diff --git a/papers/format.md b/papers/format.md index 242e8bcc4..1a5a466a0 100644 --- a/papers/format.md +++ b/papers/format.md @@ -364,7 +364,8 @@ size | description 1 | disable new NES DPCM features (>=183) 1 | reset arp effect phase on new note (>=184) 1 | linear volume scaling rounds up (>=188) - 2 | reserved + 1 | legacy "always set volume" behavior (>=191) + 1 | reserved --- | **speed pattern of first song** (>=139) 1 | length of speed pattern (fail if this is lower than 0 or higher than 16) 16 | speed pattern (this overrides speed 1 and speed 2 settings) diff --git a/res/docpdf/make_paper.py b/res/docpdf/make_paper.py index fed4e9fee..72708a436 100644 --- a/res/docpdf/make_paper.py +++ b/res/docpdf/make_paper.py @@ -344,7 +344,7 @@ if __name__ == "__main__":
  • tildearrow
  • special thanks to ZoomTen for providing tools which assisted in the production of this document!

    -

    copyright © 2023 tildearrow and other authors.

    +

    copyright © 2024 tildearrow and other authors.

    this documentation is under the Creative Commons Attribution 3.0 Unported license.

    you may reproduce, modify and/or distribute this documentation provided this copyright notice (including license and attribution) is present and any necessary disclaimers whether modifications have been made.

    this documentation is provided as-is and without warranty of any kind.

    diff --git a/res/releaseReadme/stable-linux.txt b/res/releaseReadme/stable-linux.txt index 979720a83..be3b0078a 100644 --- a/res/releaseReadme/stable-linux.txt +++ b/res/releaseReadme/stable-linux.txt @@ -22,7 +22,7 @@ if you find issues (e.g. bugs or annoyances), report them. links below. # notes -copyright (C) 2021-2023 tildearrow and contributors. +copyright (C) 2021-2024 tildearrow and contributors. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. diff --git a/res/releaseReadme/stable-mac.txt b/res/releaseReadme/stable-mac.txt index d2a50cd89..63bad6b0d 100644 --- a/res/releaseReadme/stable-mac.txt +++ b/res/releaseReadme/stable-mac.txt @@ -32,7 +32,7 @@ if you find issues (e.g. bugs or annoyances), report them. links below. # notes -copyright (C) 2021-2023 tildearrow and contributors. +copyright (C) 2021-2024 tildearrow and contributors. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. diff --git a/res/releaseReadme/stable-win.txt b/res/releaseReadme/stable-win.txt index 562037c2c..c691defec 100644 --- a/res/releaseReadme/stable-win.txt +++ b/res/releaseReadme/stable-win.txt @@ -22,7 +22,7 @@ if you find issues (e.g. bugs or annoyances), report them. links below. # notes -copyright (C) 2021-2023 tildearrow and contributors. +copyright (C) 2021-2024 tildearrow and contributors. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. diff --git a/src/audio/abstract.cpp b/src/audio/abstract.cpp index e360d1cb1..f80116e1c 100644 --- a/src/audio/abstract.cpp +++ b/src/audio/abstract.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/jack.cpp b/src/audio/jack.cpp index 64c106c54..8e6ee56f0 100644 --- a/src/audio/jack.cpp +++ b/src/audio/jack.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/jack.h b/src/audio/jack.h index 41d76824b..2742ef877 100644 --- a/src/audio/jack.h +++ b/src/audio/jack.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/midi.cpp b/src/audio/midi.cpp index fa3faf1f4..bf40f2a9c 100644 --- a/src/audio/midi.cpp +++ b/src/audio/midi.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/pa.cpp b/src/audio/pa.cpp index 3ae960860..ec1c40a9b 100644 --- a/src/audio/pa.cpp +++ b/src/audio/pa.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/pa.h b/src/audio/pa.h index 846fc7087..30922c7d2 100644 --- a/src/audio/pa.h +++ b/src/audio/pa.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/rtmidi.cpp b/src/audio/rtmidi.cpp index ea1903c36..51d70a157 100644 --- a/src/audio/rtmidi.cpp +++ b/src/audio/rtmidi.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/rtmidi.h b/src/audio/rtmidi.h index 33a71af56..5ebbf1d9f 100644 --- a/src/audio/rtmidi.h +++ b/src/audio/rtmidi.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/sdlAudio.cpp b/src/audio/sdlAudio.cpp index e01f073c8..8f074a5aa 100644 --- a/src/audio/sdlAudio.cpp +++ b/src/audio/sdlAudio.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/sdlAudio.h b/src/audio/sdlAudio.h index a827b059d..b3b0a1843 100644 --- a/src/audio/sdlAudio.h +++ b/src/audio/sdlAudio.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/audio/taAudio.h b/src/audio/taAudio.h index 0b6f530c6..c57037605 100644 --- a/src/audio/taAudio.h +++ b/src/audio/taAudio.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/baseutils.cpp b/src/baseutils.cpp index 787496c7b..957d15b60 100644 --- a/src/baseutils.cpp +++ b/src/baseutils.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/baseutils.h b/src/baseutils.h index 7e3d8e8eb..292c57626 100644 --- a/src/baseutils.h +++ b/src/baseutils.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 546c5000f..a2e9a1ca9 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cli/cli.h b/src/cli/cli.h index b77df2e8a..fbb88567a 100644 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/bsr.h b/src/engine/bsr.h index ac3da44d9..437b02870 100644 --- a/src/engine/bsr.h +++ b/src/engine/bsr.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/chipUtils.h b/src/engine/chipUtils.h index 4ddc0738d..d7cef0e28 100644 --- a/src/engine/chipUtils.h +++ b/src/engine/chipUtils.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/cmdStream.cpp b/src/engine/cmdStream.cpp index 7b1a6033d..6036364c5 100644 --- a/src/engine/cmdStream.cpp +++ b/src/engine/cmdStream.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -233,6 +233,7 @@ bool DivCSPlayer::tick() { case DIV_CMD_AMIGA_PM: case DIV_CMD_MACRO_OFF: case DIV_CMD_MACRO_ON: + case DIV_CMD_MACRO_RESTART: arg0=(unsigned char)stream.readC(); break; case DIV_CMD_FM_TL: diff --git a/src/engine/cmdStream.h b/src/engine/cmdStream.h index 0c660b7af..cd0a786b7 100644 --- a/src/engine/cmdStream.h +++ b/src/engine/cmdStream.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/cmdStreamOps.cpp b/src/engine/cmdStreamOps.cpp index bff6bc66a..1d8b24fb8 100644 --- a/src/engine/cmdStreamOps.cpp +++ b/src/engine/cmdStreamOps.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -153,6 +153,7 @@ void writePackedCommandValues(SafeWriter* w, const DivCommand& c) { case DIV_CMD_AMIGA_PM: case DIV_CMD_MACRO_OFF: case DIV_CMD_MACRO_ON: + case DIV_CMD_MACRO_RESTART: case DIV_CMD_HINT_ARP_TIME: w->writeC(1); // length w->writeC(c.value); @@ -312,8 +313,6 @@ SafeWriter* DivEngine::saveCommand(bool binary) { for (DivCommand& i: cmdStream) { switch (i.cmd) { // strip away hinted/useless commands - case DIV_ALWAYS_SET_VOLUME: - break; case DIV_CMD_GET_VOLUME: break; case DIV_CMD_VOLUME: diff --git a/src/engine/config.cpp b/src/engine/config.cpp index ef8bf3a0e..71edc775b 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/config.h b/src/engine/config.h index b9f5e43e1..b8d91a4ef 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/configEngine.cpp b/src/engine/configEngine.cpp index 123a19a81..bc12fd417 100644 --- a/src/engine/configEngine.cpp +++ b/src/engine/configEngine.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -167,4 +167,8 @@ void DivEngine::setConf(String key, String value) { bool DivEngine::hasConf(String key) { return conf.has(key); -} \ No newline at end of file +} + +DivConfig& DivEngine::getConfObject() { + return conf; +} diff --git a/src/engine/dataErrors.h b/src/engine/dataErrors.h index e6d8fdc42..c5f0fffcc 100644 --- a/src/engine/dataErrors.h +++ b/src/engine/dataErrors.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/defines.h b/src/engine/defines.h index 9564f418d..8d9a501db 100644 --- a/src/engine/defines.h +++ b/src/engine/defines.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index 6dcb6171e..c459cc3b0 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -243,7 +243,12 @@ enum DivDispatchCmds { DIV_CMD_C64_AD, // (value) DIV_CMD_C64_SR, // (value) - DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol + DIV_CMD_ESFM_OP_PANNING, // (op, value) + DIV_CMD_ESFM_OUTLVL, // (op, value) + DIV_CMD_ESFM_MODIN, // (op, value) + DIV_CMD_ESFM_ENV_DELAY, // (op, value) + + DIV_CMD_MACRO_RESTART, // (which) DIV_CMD_MAX }; @@ -594,10 +599,10 @@ class DivDispatch { /** * map MIDI velocity (from 0 to 127) to chip volume. * @param ch the chip channel. -1 means N/A. - * @param vel input velocity. + * @param vel input velocity, from 0.0 to 1.0. * @return output volume. */ - virtual int mapVelocity(int ch, unsigned char vel); + virtual int mapVelocity(int ch, float vel); /** * get the lowest note in a portamento. @@ -606,6 +611,13 @@ class DivDispatch { */ virtual int getPortaFloor(int ch); + /** + * check whether to always set volume on volume change (even when same volume). + * only for compatibility purposes! + * @return truth. + */ + virtual bool getLegacyAlwaysSetVolume(); + /** * get the required amplification level of this dispatch's output. * @return the amplification level. diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index 878232ca0..ffcbe91eb 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,6 +82,7 @@ #include "platform/ted.h" #include "platform/c140.h" #include "platform/pcmdac.h" +#include "platform/esfm.h" #include "platform/dummy.h" #include "../ta-log.h" #include "song.h" @@ -644,6 +645,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do case DIV_SYSTEM_PCM_DAC: dispatch=new DivPlatformPCMDAC; break; + case DIV_SYSTEM_ESFM: + dispatch=new DivPlatformESFM; + break; case DIV_SYSTEM_DUMMY: dispatch=new DivPlatformDummy; break; diff --git a/src/engine/effect.h b/src/engine/effect.h index 5c735d31d..c1e399b39 100644 --- a/src/engine/effect.h +++ b/src/engine/effect.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/effect/abstract.cpp b/src/engine/effect/abstract.cpp index 9be95daa0..fd31353ef 100644 --- a/src/engine/effect/abstract.cpp +++ b/src/engine/effect/abstract.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/effect/dummy.cpp b/src/engine/effect/dummy.cpp index 13df4f3f5..4b6003ecd 100644 --- a/src/engine/effect/dummy.cpp +++ b/src/engine/effect/dummy.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/effect/dummy.h b/src/engine/effect/dummy.h index c8a42919d..77ab20d3f 100644 --- a/src/engine/effect/dummy.h +++ b/src/engine/effect/dummy.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/effectContainer.cpp b/src/engine/effectContainer.cpp index d51ddfe57..7c6908e1f 100644 --- a/src/engine/effectContainer.cpp +++ b/src/engine/effectContainer.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index fc999fcd9..971559719 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,7 +83,7 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNul case 0x82: return "82xx: Set panning (right channel)"; case 0x88: - return "88xx: Set panning (rear channels; x: left; y: right)"; + return "88xy: Set panning (rear channels; x: left; y: right)"; break; case 0x89: return "89xx: Set panning (rear left channel)"; @@ -129,6 +129,8 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNul return "F5xx: Disable macro (see manual)"; case 0xf6: return "F6xx: Enable macro (see manual)"; + case 0xf7: + return "F7xx: Restart macro (see manual)"; case 0xf8: return "F8xx: Single tick volume slide up"; case 0xf9: @@ -1371,6 +1373,9 @@ DivInstrument* DivEngine::getIns(int index, DivInstrumentType fallbackType) { case DIV_INS_OPL_DRUMS: return &song.nullInsOPLDrums; break; + case DIV_INS_ESFM: + return &song.nullInsESFM; + break; default: break; } @@ -2185,6 +2190,13 @@ int DivEngine::getMaxVolumeChan(int ch) { return chan[ch].volMax>>8; } +int DivEngine::mapVelocity(int ch, float vel) { + if (ch<0) return 0; + if (ch>=chans) return 0; + if (disCont[dispatchOfChan[ch]].dispatch==NULL) return 0; + return disCont[dispatchOfChan[ch]].dispatch->mapVelocity(dispatchChanOfChan[ch],vel); +} + unsigned char DivEngine::getOrder() { return prevOrder; } @@ -2402,6 +2414,9 @@ int DivEngine::addInstrument(int refChan, DivInstrumentType fallbackType) { case DIV_INS_OPL_DRUMS: *ins=song.nullInsOPLDrums; break; + case DIV_INS_ESFM: + *ins=song.nullInsESFM; + break; default: break; } @@ -3385,6 +3400,14 @@ void DivEngine::setMidiDirect(bool value) { midiIsDirect=value; } +void DivEngine::setMidiDirectProgram(bool value) { + midiIsDirectProgram=value; +} + +void DivEngine::setMidiVolExp(float value) { + midiVolExp=value; +} + void DivEngine::setMidiCallback(std::function what) { midiCallback=what; } @@ -3449,6 +3472,12 @@ void DivEngine::rescanAudioDevices() { audioDevs.clear(); if (output!=NULL) { audioDevs=output->listAudioDevices(); + } +} + +void DivEngine::rescanMidiDevices() { + if (output!=NULL) { + logV("re-scanning midi..."); if (output->midiIn!=NULL) { midiIns=output->midiIn->listDevices(); } diff --git a/src/engine/engine.h b/src/engine/engine.h index db8cb7b34..1e13e3ccb 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,8 +54,8 @@ class DivWorkPool; #define DIV_UNSTABLE -#define DIV_VERSION "dev189" -#define DIV_ENGINE_VERSION 189 +#define DIV_VERSION "dev191" +#define DIV_ENGINE_VERSION 191 // for imports #define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_FC 0xff02 @@ -176,16 +176,16 @@ struct DivNoteEvent { signed char channel; unsigned char ins; signed char note, volume; - bool on, nop, pad1, pad2; - DivNoteEvent(int c, int i, int n, int v, bool o): + bool on, nop, insChange, fromMIDI; + DivNoteEvent(int c, int i, int n, int v, bool o, bool ic=false, bool fm=false): channel(c), ins(i), note(n), volume(v), on(o), nop(false), - pad1(false), - pad2(false) {} + insChange(ic), + fromMIDI(fm) {} DivNoteEvent(): channel(-1), ins(0), @@ -193,8 +193,8 @@ struct DivNoteEvent { volume(-1), on(false), nop(true), - pad1(false), - pad2(false) {} + insChange(false), + fromMIDI(false) {} }; struct DivDispatchContainer { @@ -415,6 +415,7 @@ class DivEngine { bool firstTick; bool skipping; bool midiIsDirect; + bool midiIsDirectProgram; bool lowLatency; bool systemsRegistered; bool hasLoadedSomething; @@ -423,6 +424,7 @@ class DivEngine { bool midiOutProgramChange; int midiOutMode; int midiOutTimeRate; + float midiVolExp; int softLockCount; int subticks, ticks, curRow, curOrder, prevRow, prevOrder, remainingLoops, totalLoops, lastLoopPos, exportLoopCount, nextSpeed, elapsedBars, elapsedBeats, curSpeed; size_t curSubSongIndex; @@ -700,6 +702,9 @@ class DivEngine { double getConfDouble(String key, double fallback); String getConfString(String key, String fallback); + // get config object + DivConfig& getConfObject(); + // set a config value void setConf(String key, bool value); void setConf(String key, int value); @@ -850,6 +855,9 @@ class DivEngine { // get channel max volume int getMaxVolumeChan(int chan); + // map MIDI velocity to volume + int mapVelocity(int ch, float vel); + // get current order unsigned char getOrder(); @@ -946,7 +954,7 @@ class DivEngine { DivSample* sampleFromFile(const char* path); // get raw sample - DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles); + DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles, int rate); // delete sample void delSample(int index); @@ -1069,6 +1077,9 @@ class DivEngine { // rescan audio devices void rescanAudioDevices(); + /** rescan midi devices */ + void rescanMidiDevices(); + // set the console mode. void setConsoleMode(bool enable); @@ -1184,6 +1195,12 @@ class DivEngine { // set MIDI direct channel map void setMidiDirect(bool value); + // set MIDI direct program change + void setMidiDirectProgram(bool value); + + // set MIDI volume curve exponent + void setMidiVolExp(float value); + // set MIDI input callback // if the specified function returns -2, note feedback will be inhibited. void setMidiCallback(std::function what); @@ -1253,6 +1270,7 @@ class DivEngine { firstTick(false), skipping(false), midiIsDirect(false), + midiIsDirectProgram(false), lowLatency(false), systemsRegistered(false), hasLoadedSomething(false), @@ -1261,6 +1279,7 @@ class DivEngine { midiOutProgramChange(false), midiOutMode(DIV_MIDI_MODE_NOTE), midiOutTimeRate(0), + midiVolExp(2.0f), // General MIDI standard softLockCount(0), subticks(0), ticks(0), diff --git a/src/engine/export.cpp b/src/engine/export.cpp index 141736d9e..2ea35327f 100644 --- a/src/engine/export.cpp +++ b/src/engine/export.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/export.h b/src/engine/export.h index 3a51ee236..d8e1878f1 100644 --- a/src/engine/export.h +++ b/src/engine/export.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/export/abstract.cpp b/src/engine/export/abstract.cpp index ce07519c0..bd39e3aa0 100644 --- a/src/engine/export/abstract.cpp +++ b/src/engine/export/abstract.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/export/amigaValidation.cpp b/src/engine/export/amigaValidation.cpp index e1aa4dfdb..a613ee422 100644 --- a/src/engine/export/amigaValidation.cpp +++ b/src/engine/export/amigaValidation.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/export/amigaValidation.h b/src/engine/export/amigaValidation.h index 94d5eabbe..11a4ecd48 100644 --- a/src/engine/export/amigaValidation.h +++ b/src/engine/export/amigaValidation.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index cb6f4fa90..d4c02347a 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -187,6 +187,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ds.oldDPCM=true; ds.delayBehavior=0; ds.jumpTreatment=2; + ds.oldAlwaysSetVolume=true; // 1.1 compat flags if (ds.version>24) { @@ -1876,6 +1877,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { if (ds.version<188) { ds.ceilVolumeScaling=false; } + if (ds.version<191) { + ds.oldAlwaysSetVolume=true; + } ds.isDMF=false; reader.readS(); // reserved @@ -2424,7 +2428,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { } else { reader.readC(); } - for (int i=0; i<2; i++) { + if (ds.version>=191) { + ds.oldAlwaysSetVolume=reader.readC(); + } else { + reader.readC(); + } + for (int i=0; i<1; i++) { reader.readC(); } } @@ -5522,7 +5531,8 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) { w->writeC(song.oldDPCM); w->writeC(song.resetArpPhaseOnNewNote); w->writeC(song.ceilVolumeScaling); - for (int i=0; i<2; i++) { + w->writeC(song.oldAlwaysSetVolume); + for (int i=0; i<1; i++) { w->writeC(0); } @@ -6445,7 +6455,7 @@ SafeWriter* DivEngine::saveText(bool separatePatterns) { w->writeText(fmt::sprintf("- type: %d\n",(int)ins->type)); - if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPM) { + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPM || ins->type==DIV_INS_ESFM) { w->writeText("- FM parameters:\n"); w->writeText(fmt::sprintf(" - ALG: %d\n",ins->fm.alg)); w->writeText(fmt::sprintf(" - FB: %d\n",ins->fm.fb)); @@ -6489,10 +6499,29 @@ SafeWriter* DivEngine::saveText(bool separatePatterns) { } } + if (ins->type==DIV_INS_ESFM) { + w->writeText("- ESFM parameters:\n"); + w->writeText(fmt::sprintf(" - noise mode: %d\n",ins->esfm.noise)); + + for (int j=0; jfm.ops; j++) { + DivInstrumentESFM::Operator& opE=ins->esfm.op[j]; + + w->writeText(fmt::sprintf(" - operator %d:\n",j)); + w->writeText(fmt::sprintf(" - DL: %d\n",opE.delay)); + w->writeText(fmt::sprintf(" - OL: %d\n",opE.outLvl)); + w->writeText(fmt::sprintf(" - MI: %d\n",opE.modIn)); + w->writeText(fmt::sprintf(" - output left: %s\n",trueFalse[opE.left?1:0])); + w->writeText(fmt::sprintf(" - output right: %s\n",trueFalse[opE.right?1:0])); + w->writeText(fmt::sprintf(" - CT: %d\n",opE.ct)); + w->writeText(fmt::sprintf(" - DT: %d\n",opE.dt)); + w->writeText(fmt::sprintf(" - fixed frequency: %s\n",trueFalse[opE.fixed?1:0])); + } + } + if (ins->type==DIV_INS_GB) { w->writeText("- Game Boy parameters:\n"); w->writeText(fmt::sprintf(" - volume: %d\n",ins->gb.envVol)); - w->writeText(fmt::sprintf(" - direction: %d\n",gbEnvDir[ins->gb.envDir?1:0])); + w->writeText(fmt::sprintf(" - direction: %s\n",gbEnvDir[ins->gb.envDir?1:0])); w->writeText(fmt::sprintf(" - length: %d\n",ins->gb.envLen)); w->writeText(fmt::sprintf(" - sound length: %d\n",ins->gb.soundLen)); w->writeText(fmt::sprintf(" - use software envelope: %s\n",trueFalse[ins->gb.softEnv?1:0])); diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index 8236ebe0f..817c28463 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/fileOpsSample.cpp b/src/engine/fileOpsSample.cpp index 4a44d0192..3c5aa8087 100644 --- a/src/engine/fileOpsSample.cpp +++ b/src/engine/fileOpsSample.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -302,7 +302,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) { #endif } -DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles) { +DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles, int rate) { if (song.sample.size()>=256) { lastError="too many samples!"; return NULL; @@ -420,8 +420,8 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, return NULL; } - sample->rate=32000; - sample->centerRate=32000; + sample->rate=rate; + sample->centerRate=rate; sample->depth=depth; sample->init(samples); diff --git a/src/engine/filter.cpp b/src/engine/filter.cpp index ee325052b..3c81ce777 100644 --- a/src/engine/filter.cpp +++ b/src/engine/filter.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/filter.h b/src/engine/filter.h index 1406ee145..f45e9980f 100644 --- a/src/engine/filter.h +++ b/src/engine/filter.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 25c829ca8..71aaeb012 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -230,6 +230,29 @@ bool DivInstrumentSNES::operator==(const DivInstrumentSNES& other) { ); } +bool DivInstrumentESFM::operator==(const DivInstrumentESFM& other) { + return ( + _C(noise) && + _C(op[0]) && + _C(op[1]) && + _C(op[2]) && + _C(op[3]) + ); +} + +bool DivInstrumentESFM::Operator::operator==(const DivInstrumentESFM::Operator& other) { + return ( + _C(delay) && + _C(outLvl) && + _C(modIn) && + _C(left) && + _C(right) && + _C(fixed) && + _C(ct) && + _C(dt) + ); +} + #undef _C #define FEATURE_BEGIN(x) \ @@ -743,6 +766,22 @@ void DivInstrument::writeFeatureNE(SafeWriter* w) { FEATURE_END; } +void DivInstrument::writeFeatureEF(SafeWriter* w) { + FEATURE_BEGIN("EF"); + + w->writeC(esfm.noise&3); + for (int i=0; i<4; i++) { + DivInstrumentESFM::Operator& op=esfm.op[i]; + + w->writeC(((op.delay&7)<<5)|((op.outLvl&7)<<2)|((op.right&1)<<1)|(op.left&1)); + w->writeC((op.fixed&1)<<3|(op.modIn&7)); + w->writeC(op.ct); + w->writeC(op.dt); + } + + FEATURE_END; +} + void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bool insName) { size_t blockStartSeek=0; size_t blockEndSeek=0; @@ -786,6 +825,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo bool featureES=false; bool featureX1=false; bool featureNE=false; + bool featureEF=false; bool checkForWL=false; @@ -999,7 +1039,10 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo featureSM=true; featureSL=true; break; - + case DIV_INS_ESFM: + featureFM=true; + featureEF=true; + break; case DIV_INS_MAX: break; case DIV_INS_NULL: @@ -1047,6 +1090,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo if (x1_010!=defaultIns.x1_010) { featureX1=true; } + if (esfm!=defaultIns.esfm) { + featureEF=true; + } } // check ins name @@ -1189,6 +1235,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo if (featureNE) { writeFeatureNE(w); } + if (featureEF) { + writeFeatureEF(w); + } if (fui && (featureSL || featureWL)) { w->write("EN",2); @@ -2598,6 +2647,32 @@ void DivInstrument::readFeatureNE(SafeReader& reader, short version) { READ_FEAT_END; } +void DivInstrument::readFeatureEF(SafeReader& reader, short version) { + READ_FEAT_BEGIN; + + unsigned char next=reader.readC(); + esfm.noise=next&3; + + for (int i=0; i<4; i++) { + DivInstrumentESFM::Operator& op=esfm.op[i]; + + next=reader.readC(); + op.delay=(next>>5)&7; + op.outLvl=(next>>2)&7; + op.right=(next>>1)&1; + op.left=next&1; + + next=reader.readC(); + op.modIn=next&7; + op.fixed=(next>>3)&1; + + op.ct=reader.readC(); + op.dt=reader.readC(); + } + + READ_FEAT_END; +} + DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song) { unsigned char featCode[2]; bool volIsCutoff=false; @@ -2666,6 +2741,8 @@ DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, b readFeatureX1(reader,version); } else if (memcmp(featCode,"NE",2)==0) { // NES (DPCM) readFeatureNE(reader,version); + } else if (memcmp(featCode,"EF",2)==0) { // ESFM + readFeatureEF(reader,version); } else { if (song==NULL && (memcmp(featCode,"SL",2)==0 || (memcmp(featCode,"WL",2)==0))) { // nothing diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 31440d7aa..4304d5526 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,6 +85,7 @@ enum DivInstrumentType: unsigned short { DIV_INS_TED=52, DIV_INS_C140=53, DIV_INS_C219=54, + DIV_INS_ESFM=55, DIV_INS_MAX, DIV_INS_NULL }; @@ -771,6 +772,56 @@ struct DivInstrumentSNES { d2(0) {} }; +// ESFM operator structure: +// - DELAY, OUT, MOD, L, R, NOISE +// - Virtual: CT, DT, FIXED +// - In FM struct: AM, DAM, AR, DR, MULT, RR, SL, TL +// - In FM struct: KSL, VIB, DVB, WS, SUS, KSR +// - Not in struct: FNUML, FNUMH, BLOCK + +struct DivInstrumentESFM { + bool operator==(const DivInstrumentESFM& other); + bool operator!=(const DivInstrumentESFM& other) { + return !(*this==other); + } + + // Only works on OP4, so putting it outside the Operator struct instead + unsigned char noise; + struct Operator { + unsigned char delay, outLvl, modIn, left, right, fixed; + signed char ct, dt; + + bool operator==(const Operator& other); + bool operator!=(const Operator& other) { + return !(*this==other); + } + Operator(): + delay(0), + outLvl(0), + modIn(0), + left(1), + right(1), + fixed(0), + ct(0), + dt(0) {} + } op[4]; + DivInstrumentESFM(): + noise(0) + { + op[0].modIn=4; + op[0].outLvl=0; + + op[1].modIn=7; + op[1].outLvl=0; + + op[2].modIn=7; + op[2].outLvl=0; + + op[3].modIn=7; + op[3].outLvl=7; + } +}; + struct DivInstrument { String name; DivInstrumentType type; @@ -787,6 +838,7 @@ struct DivInstrument { DivInstrumentSoundUnit su; DivInstrumentES5506 es5506; DivInstrumentSNES snes; + DivInstrumentESFM esfm; /** * these are internal functions. @@ -811,6 +863,7 @@ struct DivInstrument { void writeFeatureES(SafeWriter* w); void writeFeatureX1(SafeWriter* w); void writeFeatureNE(SafeWriter* w); + void writeFeatureEF(SafeWriter* w); void readFeatureNA(SafeReader& reader, short version); void readFeatureFM(SafeReader& reader, short version); @@ -831,6 +884,7 @@ struct DivInstrument { void readFeatureES(SafeReader& reader, short version); void readFeatureX1(SafeReader& reader, short version); void readFeatureNE(SafeReader& reader, short version); + void readFeatureEF(SafeReader& reader, short version); DivDataErrors readInsDataOld(SafeReader& reader, short version); DivDataErrors readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song); diff --git a/src/engine/macroInt.cpp b/src/engine/macroInt.cpp index 557777cc8..621eab424 100644 --- a/src/engine/macroInt.cpp +++ b/src/engine/macroInt.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -245,6 +245,81 @@ void DivMacroInt::mask(unsigned char id, bool enabled) { #undef CONSIDER_OP #undef CONSIDER +#define CONSIDER(x,y,z) \ + case z: \ + macroState=&x; \ + macro=&ins->std.y; \ + break; + +#define CONSIDER_OP(oi,o) \ + CONSIDER(op[oi].am,opMacros[oi].amMacro,0+o) \ + CONSIDER(op[oi].ar,opMacros[oi].arMacro,1+o) \ + CONSIDER(op[oi].dr,opMacros[oi].drMacro,2+o) \ + CONSIDER(op[oi].mult,opMacros[oi].multMacro,3+o) \ + CONSIDER(op[oi].rr,opMacros[oi].rrMacro,4+o) \ + CONSIDER(op[oi].sl,opMacros[oi].slMacro,5+o) \ + CONSIDER(op[oi].tl,opMacros[oi].tlMacro,6+o) \ + CONSIDER(op[oi].dt2,opMacros[oi].dt2Macro,7+o) \ + CONSIDER(op[oi].rs,opMacros[oi].rsMacro,8+o) \ + CONSIDER(op[oi].dt,opMacros[oi].dtMacro,9+o) \ + CONSIDER(op[oi].d2r,opMacros[oi].d2rMacro,10+o) \ + CONSIDER(op[oi].ssg,opMacros[oi].ssgMacro,11+o) \ + CONSIDER(op[oi].dam,opMacros[oi].damMacro,12+o) \ + CONSIDER(op[oi].dvb,opMacros[oi].dvbMacro,13+o) \ + CONSIDER(op[oi].egt,opMacros[oi].egtMacro,14+o) \ + CONSIDER(op[oi].ksl,opMacros[oi].kslMacro,15+o) \ + CONSIDER(op[oi].sus,opMacros[oi].susMacro,16+o) \ + CONSIDER(op[oi].vib,opMacros[oi].vibMacro,17+o) \ + CONSIDER(op[oi].ws,opMacros[oi].wsMacro,18+o) \ + CONSIDER(op[oi].ksr,opMacros[oi].ksrMacro,19+o) + +void DivMacroInt::restart(unsigned char id) { + DivMacroStruct* macroState=NULL; + DivInstrumentMacro* macro=NULL; + + if (e==NULL) return; + if (ins==NULL) return; + + switch (id) { + CONSIDER(vol,volMacro,0) + CONSIDER(arp,arpMacro,1) + CONSIDER(duty,dutyMacro,2) + CONSIDER(wave,waveMacro,3) + CONSIDER(pitch,pitchMacro,4) + CONSIDER(ex1,ex1Macro,5) + CONSIDER(ex2,ex2Macro,6) + CONSIDER(ex3,ex3Macro,7) + CONSIDER(alg,algMacro,8) + CONSIDER(fb,fbMacro,9) + CONSIDER(fms,fmsMacro,10) + CONSIDER(ams,amsMacro,11) + CONSIDER(panL,panLMacro,12) + CONSIDER(panR,panRMacro,13) + CONSIDER(phaseReset,phaseResetMacro,14) + CONSIDER(ex4,ex4Macro,15) + CONSIDER(ex5,ex5Macro,16) + CONSIDER(ex6,ex6Macro,17) + CONSIDER(ex7,ex7Macro,18) + CONSIDER(ex8,ex8Macro,19) + + CONSIDER_OP(0,0x20) + CONSIDER_OP(2,0x40) + CONSIDER_OP(1,0x60) + CONSIDER_OP(3,0x80) + } + + if (macroState==NULL || macro==NULL) return; + + if (macro->len<=0) return; + if (macroState->masked) return; + + macroState->init(); + macroState->prepare(*macro,e); +} + +#undef CONSIDER_OP +#undef CONSIDER + void DivMacroInt::release() { released=true; } diff --git a/src/engine/macroInt.h b/src/engine/macroInt.h index 28e605029..611349966 100644 --- a/src/engine/macroInt.h +++ b/src/engine/macroInt.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -119,6 +119,11 @@ class DivMacroInt { */ void release(); + /** + * restart macro. + */ + void restart(unsigned char id); + /** * trigger next macro tick. */ diff --git a/src/engine/orders.h b/src/engine/orders.h index 170eb4ad4..771ec982d 100644 --- a/src/engine/orders.h +++ b/src/engine/orders.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/pattern.cpp b/src/engine/pattern.cpp index ea0cca7e0..aec429a51 100644 --- a/src/engine/pattern.cpp +++ b/src/engine/pattern.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/pattern.h b/src/engine/pattern.h index 8bb8fa21e..7b46e315f 100644 --- a/src/engine/pattern.h +++ b/src/engine/pattern.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/pitchTable.cpp b/src/engine/pitchTable.cpp index 818a97dce..97a91d1f6 100644 --- a/src/engine/pitchTable.cpp +++ b/src/engine/pitchTable.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/abstract.cpp b/src/engine/platform/abstract.cpp index aaa27a494..ae16c7d2f 100644 --- a/src/engine/platform/abstract.cpp +++ b/src/engine/platform/abstract.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,15 +102,19 @@ bool DivDispatch::isVolGlobal() { return false; } -int DivDispatch::mapVelocity(int ch, unsigned char vel) { +int DivDispatch::mapVelocity(int ch, float vel) { const int volMax=MAX(1,dispatch(DivCommand(DIV_CMD_GET_VOLMAX,MAX(ch,0)))); - return (vel*volMax)/127; + return round(vel*volMax); } int DivDispatch::getPortaFloor(int ch) { return 0x00; } +bool DivDispatch::getLegacyAlwaysSetVolume() { + return true; +} + float DivDispatch::getPostAmp() { return 1.0f; } diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index a884c21ce..95c9d49d5 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -721,8 +721,8 @@ int DivPlatformAmiga::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/amiga.h b/src/engine/platform/amiga.h index 903d7bd31..5a60d8658 100644 --- a/src/engine/platform/amiga.h +++ b/src/engine/platform/amiga.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index ab26b5b08..2b6663c32 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -783,8 +783,8 @@ int DivPlatformArcade::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 127; diff --git a/src/engine/platform/arcade.h b/src/engine/platform/arcade.h index 39ae3705e..1aadf513c 100644 --- a/src/engine/platform/arcade.h +++ b/src/engine/platform/arcade.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index 9928372cc..df75c4af8 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -651,8 +651,8 @@ int DivPlatformAY8910::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 15; @@ -719,6 +719,10 @@ DivDispatchOscBuffer* DivPlatformAY8910::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformAY8910::mapVelocity(int ch, float vel) { + return round(15.0*pow(vel,0.33)); +} + unsigned char* DivPlatformAY8910::getRegisterPool() { return regPool; } @@ -775,6 +779,10 @@ bool DivPlatformAY8910::keyOffAffectsArp(int ch) { return true; } +bool DivPlatformAY8910::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformAY8910::notifyInsDeletion(void* ins) { for (int i=0; i<3; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); diff --git a/src/engine/platform/ay.h b/src/engine/platform/ay.h index 354557fda..fe0a6758a 100644 --- a/src/engine/platform/ay.h +++ b/src/engine/platform/ay.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -131,6 +131,7 @@ class DivPlatformAY8910: public DivDispatch { int dispatch(DivCommand c); void* getChanState(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void flushWrites(); @@ -143,6 +144,7 @@ class DivPlatformAY8910: public DivDispatch { bool keyOffAffectsArp(int ch); DivMacroInt* getChanMacroInt(int ch); DivSamplePos getSamplePos(int ch); + bool getLegacyAlwaysSetVolume(); bool getDCOffRequired(); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index a337a2a31..1a6072717 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -653,8 +653,8 @@ int DivPlatformAY8930::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 31; @@ -718,6 +718,10 @@ DivDispatchOscBuffer* DivPlatformAY8930::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformAY8930::mapVelocity(int ch, float vel) { + return round(31.0*pow(vel,0.22)); +} + unsigned char* DivPlatformAY8930::getRegisterPool() { return regPool; } @@ -774,6 +778,10 @@ bool DivPlatformAY8930::keyOffAffectsArp(int ch) { return true; } +bool DivPlatformAY8930::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformAY8930::notifyInsDeletion(void* ins) { for (int i=0; i<3; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); diff --git a/src/engine/platform/ay8930.h b/src/engine/platform/ay8930.h index ba2f9abea..b43ec0fcd 100644 --- a/src/engine/platform/ay8930.h +++ b/src/engine/platform/ay8930.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,6 +132,7 @@ class DivPlatformAY8930: public DivDispatch { int dispatch(DivCommand c); void* getChanState(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); @@ -143,6 +144,7 @@ class DivPlatformAY8930: public DivDispatch { bool keyOffAffectsArp(int ch); DivMacroInt* getChanMacroInt(int ch); DivSamplePos getSamplePos(int ch); + bool getLegacyAlwaysSetVolume(); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); void poke(std::vector& wlist); diff --git a/src/engine/platform/bubsyswsg.cpp b/src/engine/platform/bubsyswsg.cpp index 94202de19..095876688 100644 --- a/src/engine/platform/bubsyswsg.cpp +++ b/src/engine/platform/bubsyswsg.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -246,8 +246,8 @@ int DivPlatformBubSysWSG::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/bubsyswsg.h b/src/engine/platform/bubsyswsg.h index c3891bf69..955b1d029 100644 --- a/src/engine/platform/bubsyswsg.h +++ b/src/engine/platform/bubsyswsg.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/c140.cpp b/src/engine/platform/c140.cpp index 09d08e304..14d203587 100644 --- a/src/engine/platform/c140.cpp +++ b/src/engine/platform/c140.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -441,8 +441,8 @@ int DivPlatformC140::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/c140.h b/src/engine/platform/c140.h index c84ab23ff..dbfc0b050 100644 --- a/src/engine/platform/c140.h +++ b/src/engine/platform/c140.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index cf0687d34..9130cdccf 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -536,8 +536,8 @@ int DivPlatformC64::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/c64.h b/src/engine/platform/c64.h index 5f7882c68..c24ee3159 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/dummy.cpp b/src/engine/platform/dummy.cpp index 18fa5ca93..d0723a08d 100644 --- a/src/engine/platform/dummy.cpp +++ b/src/engine/platform/dummy.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/dummy.h b/src/engine/platform/dummy.h index 51a399796..5b54acb85 100644 --- a/src/engine/platform/dummy.h +++ b/src/engine/platform/dummy.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index 64aca0be5..6c6e1732f 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1022,8 +1022,8 @@ int DivPlatformES5506::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index 6bac20c37..b51ee9f2c 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/esfm.cpp b/src/engine/platform/esfm.cpp new file mode 100644 index 000000000..090254a00 --- /dev/null +++ b/src/engine/platform/esfm.cpp @@ -0,0 +1,1077 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2024 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "esfm.h" +#include "../engine.h" +#include "../../ta-log.h" +#include +#include +#include + +#define CHIP_FREQBASE (32768*288) + +#define ADDR_AM_VIB_SUS_KSR_MULT 0x00 +#define ADDR_KSL_TL 0x01 +#define ADDR_AR_DR 0x02 +#define ADDR_SL_RR 0x03 +#define ADDR_FREQL 0x04 +#define ADDR_FREQH_BLOCK_DELAY 0x05 +#define ADDR_DAM_DVB_LEFT_RIGHT_MODIN 0x06 +#define ADDR_OUTLVL_NOISE_WS 0x07 + +#define KEY_ON_REGS_START (18*8*4) + +void DivPlatformESFM::acquire(short** buf, size_t len) { + thread_local short o[2]; + for (size_t h=0; hdata[oscBuf[c]->needle++]=ESFM_get_channel_output_native(&chip,c); + } + + buf[0][h]=o[0]; + buf[1][h]=o[1]; + } +} + +void DivPlatformESFM::tick(bool sysTick) { + for (int i=0; i<18; i++) { + chan[i].std.next(); + + if (chan[i].std.vol.had) { + chan[i].outVol=VOL_SCALE_LOG_BROKEN(chan[i].vol,MIN(63,chan[i].std.vol.val),63); + for (int o=0; o<4; o++) { + unsigned short baseAddr=i*32+o*8; + DivInstrumentFM::Operator& op=chan[i].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[i].state.esfm.op[o]; + unsigned char noise=chan[i].state.esfm.noise&3; + + if (isMuted[i]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + if (KVS_ES(i,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[i].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + } + } + + if (NEW_ARP_STRAT) { + chan[i].handleArp(); + } else if (chan[i].std.arp.had) { + if (!chan[i].inPorta) { + chan[i].baseFreq=NOTE_FREQUENCY(parent->calcArp(chan[i].note,chan[i].std.arp.val)); + } + chan[i].freqChanged=true; + } + + if (chan[i].std.panL.had) { + chan[i].globalPan=((chan[i].std.panL.val&1)<<1)|((chan[i].std.panL.val&2)>>1); + for (int o=0; o<4; o++) { + unsigned short baseAddr=i*32+o*8; + DivInstrumentFM::Operator& op=chan[i].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[i].state.esfm.op[o]; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[i].globalPan)&1)<<4)|(((opE.right&(chan[i].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + } + + if (chan[i].std.pitch.had) { + if (chan[i].std.pitch.mode) { + chan[i].pitch2+=chan[i].std.pitch.val; + CLAMP_VAR(chan[i].pitch2,-131071,131071); + } else { + chan[i].pitch2=chan[i].std.pitch.val; + } + chan[i].freqChanged=true; + } + + if (chan[i].std.phaseReset.had) { + if (chan[i].std.phaseReset.val==1 && chan[i].active) { + chan[i].keyOn=true; + } + } + + if (chan[i].std.duty.had) { + unsigned short baseAddr=i*32+3*8; + DivInstrumentESFM& ins=chan[i].state.esfm; + DivInstrumentFM::Operator& op=chan[i].state.fm.op[3]; + DivInstrumentESFM::Operator& opE=chan[i].state.esfm.op[3]; + ins.noise=chan[i].std.duty.val; + + if (isMuted[i]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((ins.noise&3)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((ins.noise&3)<<3)|((opE.outLvl&7)<<5)); + } + } + + for (int o=0; o<4; o++) { + unsigned short baseAddr=i*32+o*8; + DivInstrumentFM::Operator& op=chan[i].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[i].state.esfm.op[o]; + DivMacroInt::IntOp& m=chan[i].std.op[o]; + + if (m.am.had) { + op.am=m.am.val; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + if (m.vib.had) { + op.vib=m.vib.val; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + if (m.sus.had) { + op.sus=m.sus.val; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + if (m.ksr.had) { + op.ksr=m.ksr.val; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + if (m.mult.had) { + op.mult=m.mult.val; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + + if (m.ar.had) { + op.ar=m.ar.val; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + if (m.dr.had) { + op.dr=m.dr.val; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + if (m.sl.had) { + op.sl=m.sl.val; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + if (m.rr.had) { + op.rr=m.rr.val; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + + if (m.tl.had || m.ksl.had) { + if (m.tl.had) { + op.tl=m.tl.val&63; + } + if (m.ksl.had) { + op.ksl=m.ksl.val; + } + + if (KVS_ES(i,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[i].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + + if (m.dam.had) { + op.dam=m.dam.val; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[i].globalPan)&1)<<4)|(((opE.right&(chan[i].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + if (m.dvb.had) { + op.dvb=m.dvb.val; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[i].globalPan)&1)<<4)|(((opE.right&(chan[i].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + if (m.rs.had) { + // operator panning + opE.left=(m.rs.val&2)!=0; + opE.right=(m.rs.val&1)!=0; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[i].globalPan)&1)<<4)|(((opE.right&(chan[i].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + if (m.d2r.had) { + // modIn + opE.modIn=m.d2r.val; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[i].globalPan)&1)<<4)|(((opE.right&(chan[i].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + + if (m.egt.had | m.ws.had) { + unsigned char noise=chan[i].state.esfm.noise&3; + if (m.egt.had) { + // outLvl + opE.outLvl=m.egt.val; + } + if (m.ws.had) { + op.ws=m.ws.val; + } + + if (isMuted[i]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + } + } + + + + // detune/fixed pitch + if (opE.fixed) { + if (m.ssg.had) { + opE.ct=(opE.ct&(~(7<<2)))|((m.ssg.val&7)<<2); + chan[i].freqChanged=true; + } + if (m.dt.had) { + opE.dt=m.dt.val&0xff; + opE.ct=(opE.ct&(~3))|((m.dt.val>>8)&3); + chan[i].freqChanged=true; + } + } else { + chan[i].handleArpFmOp(0, o); + chan[i].handlePitchFmOp(o); + } + + if (m.dt2.had) { + opE.delay=m.dt2.val; + rWrite(baseAddr+ADDR_FREQH_BLOCK_DELAY,chan[i].freqH[o]|(opE.delay<<5)); + } + } + } + + + + for (int i=0; icalcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,octave(chan[i].baseFreq)*2,chan[i].pitch2,chipClock,CHIP_FREQBASE); + if (chan[i].freq<0) chan[i].freq=0; + if (chan[i].freq>131071) chan[i].freq=131071; + + for (int o=0; o<4; o++) { + unsigned short baseAddr=i*32+o*8; + DivInstrumentESFM::Operator& opE=chan[i].state.esfm.op[o]; + int ct=(int)opE.ct; + int dt=(int)opE.dt; + if (opE.fixed) { + chan[i].freqL[o]=opE.dt; + chan[i].freqH[o]=opE.ct&0x1f; + } else { + int arp=chan[i].fixedArp?chan[i].baseNoteOverride+ct:chan[i].arpOff+ct; + int pitch2=chan[i].pitch2+dt; + int fixedArp=chan[i].fixedArp; + if(chan[i].opsState[o].hasOpArp) { + arp=chan[i].opsState[o].fixedArp?chan[i].opsState[o].baseNoteOverride+ct:chan[i].opsState[o].arpOff+ct; + fixedArp=chan[i].opsState[o].fixedArp; + } + if(chan[i].opsState[o].hasOpPitch) { + pitch2=chan[i].opsState[o].pitch2+dt; + } + int opFreq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,arp,fixedArp,false,octave(chan[i].baseFreq)*2,pitch2,chipClock,CHIP_FREQBASE); + if (opFreq<0) opFreq=0; + if (opFreq>131071) opFreq=131071; + int freqt=toFreq(opFreq); + chan[i].freqL[o]=freqt&0xff; + chan[i].freqH[o]=freqt>>8; + } + immWrite(baseAddr+ADDR_FREQL,chan[i].freqL[o]); + immWrite(baseAddr+ADDR_FREQH_BLOCK_DELAY,chan[i].freqH[o]|(opE.delay<<5)); + hardResetElapsed+=2; + } + chan[i].freqChanged=false; + } + if (chan[i].keyOn && !chan[i].hardReset) { + // logI("chan[%d] soft key on", i); + if (i<16) { + immWrite(KEY_ON_REGS_START+i, 1); + } else { + // Handle writing to the split key-on registers of channels 16 and 17 + immWrite(KEY_ON_REGS_START+16+(i-16)*2, 1); + immWrite(KEY_ON_REGS_START+16+1+(i-16)*2, 1); + } + chan[i].keyOn=false; + } + } + + if (mustHardReset) { + for (unsigned int i=hardResetElapsed; i<128; i++) { + immWrite(0x25f, i&0xff); + } + for (int i=0; i<18; i++) { + if (chan[i].hardReset && chan[i].keyOn) { + // logI("chan[%d] hard reset key on, writing original slrr back", i); + for (int o=0; o<4; o++) { + unsigned short baseAddr=i*32+o*8; + DivInstrumentFM::Operator& op=chan[i].state.fm.op[o]; + immWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + if (i<16) { + immWrite(KEY_ON_REGS_START+i, 1); + } else { + // Handle writing to the split key-on registers of channels 16 and 17 + immWrite(KEY_ON_REGS_START+16+(i-16)*2, 1); + immWrite(KEY_ON_REGS_START+16+1+(i-16)*2, 1); + } + chan[i].keyOn=false; + } + } + } +} + +int DivPlatformESFM::octave(int freq) { + int result=1; + while (freq>0x3ff) { + freq>>=1; + result<<=1; + } + return result; +} + +int DivPlatformESFM::toFreq(int freq) { + int block=0; + while (freq>0x3ff) { + freq>>=1; + block++; + } + return ((block&7)<<10)|(freq&0x3ff); +} + +void DivPlatformESFM::muteChannel(int ch, bool mute) { + isMuted[ch]=mute; + + for (int o=0; o<4; o++) { + unsigned short baseAddr=ch*32+o*8; + DivInstrumentFM::Operator& op=chan[ch].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[ch].state.esfm.op[o]; + unsigned char noise=chan[ch].state.esfm.noise&3; + + if (isMuted[ch]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + if (KVS_ES(ch,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[ch].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + } +} + +void DivPlatformESFM::commitState(int ch, DivInstrument* ins) { + if (chan[ch].insChanged) { + chan[ch].state.fm=ins->fm; + chan[ch].state.esfm=ins->esfm; + for (int o=0; o<4; o++) { + unsigned short baseAddr=ch*32+o*8; + DivInstrumentFM::Operator& op=chan[ch].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[ch].state.esfm.op[o]; + unsigned char noise=chan[ch].state.esfm.noise&3; + + if (isMuted[ch]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + if (KVS_ES(ch,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[ch].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + rWrite(baseAddr+ADDR_FREQH_BLOCK_DELAY,chan[ch].freqH[o]|(opE.delay<<5)); + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[ch].globalPan)&1)<<4)|(((opE.right&(chan[ch].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + } +} + +int DivPlatformESFM::dispatch(DivCommand c) { + switch (c.cmd) { + case DIV_CMD_NOTE_ON: { + DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_ESFM); + + chan[c.chan].macroInit(ins); + memset(chan[c.chan].opsState, 0, sizeof(chan[c.chan].opsState)); + if (!chan[c.chan].std.vol.will) { + chan[c.chan].outVol=chan[c.chan].vol; + } + + commitState(c.chan,ins); + chan[c.chan].insChanged=false; + + if (c.value!=DIV_NOTE_NULL) { + chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value); + chan[c.chan].note=c.value; + chan[c.chan].freqChanged=true; + } + chan[c.chan].keyOn=true; + chan[c.chan].active=true; + break; + } + case DIV_CMD_NOTE_OFF: + chan[c.chan].keyOff=true; + chan[c.chan].keyOn=false; + break; + case DIV_CMD_NOTE_OFF_ENV: + chan[c.chan].keyOff=true; + chan[c.chan].keyOn=false; + chan[c.chan].std.release(); + break; + case DIV_CMD_ENV_RELEASE: + chan[c.chan].std.release(); + break; + case DIV_CMD_VOLUME: { + chan[c.chan].vol=c.value; + if (!chan[c.chan].std.vol.has) { + chan[c.chan].outVol=c.value; + } + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + if (KVS_ES(c.chan,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[c.chan].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + break; + } + case DIV_CMD_GET_VOLUME: + return chan[c.chan].vol; + break; + case DIV_CMD_INSTRUMENT: + if (chan[c.chan].ins!=c.value || c.value2==1) { + chan[c.chan].insChanged=true; + } + chan[c.chan].ins=c.value; + break; + case DIV_CMD_PANNING: { + chan[c.chan].globalPan=(c.value>0)|((c.value2>0)<<1); + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + break; + } + case DIV_CMD_PITCH: + chan[c.chan].pitch=c.value; + chan[c.chan].freqChanged=true; + break; + case DIV_CMD_NOTE_PORTA: { + int destFreq=NOTE_FREQUENCY(c.value2); + int newFreq; + bool return2=false; + if (destFreq>chan[c.chan].baseFreq) { + newFreq=chan[c.chan].baseFreq+c.value*((parent->song.linearPitch==2)?1:octave(chan[c.chan].baseFreq)); + if (newFreq>=destFreq) { + newFreq=destFreq; + return2=true; + } + } else { + newFreq=chan[c.chan].baseFreq-c.value*((parent->song.linearPitch==2)?1:octave(chan[c.chan].baseFreq)); + if (newFreq<=destFreq) { + newFreq=destFreq; + return2=true; + } + } + if (!chan[c.chan].portaPause && parent->song.linearPitch!=2) { + if (octave(chan[c.chan].baseFreq)!=octave(newFreq)) { + chan[c.chan].portaPause=true; + break; + } + } + chan[c.chan].baseFreq=newFreq; + chan[c.chan].portaPause=false; + chan[c.chan].freqChanged=true; + if (return2) { + chan[c.chan].inPorta=false; + return 2; + } + break; + } + case DIV_CMD_LEGATO: { + if (chan[c.chan].insChanged) { + DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_ESFM); + commitState(c.chan,ins); + chan[c.chan].insChanged=false; + } + chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value); + chan[c.chan].note=c.value; + chan[c.chan].freqChanged=true; + break; + } + case DIV_CMD_FM_MULT: { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.mult=c.value2&15; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + break; + } + case DIV_CMD_FM_TL: { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.tl=c.value2&63; + if (KVS_ES(c.chan,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[c.chan].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + break; + } + case DIV_CMD_FM_AR: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ar=c.value2&15; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ar=c.value2&15; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + break; + } + case DIV_CMD_FM_DR: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.dr=c.value2&15; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.dr=c.value2&15; + rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|(op.dr&0xf)); + } + break; + } + case DIV_CMD_FM_SL: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.sl=c.value2&15; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.sl=c.value2&15; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + break; + } + case DIV_CMD_FM_RR: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.rr=c.value2&15; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.rr=c.value2&15; + rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|(op.rr&0xf)); + } + break; + } + case DIV_CMD_FM_AM: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.am=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.am=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + break; + } + case DIV_CMD_FM_VIB: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.vib=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.vib=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + break; + } + case DIV_CMD_FM_SUS: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.sus=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.sus=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + break; + } + case DIV_CMD_FM_KSR: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ksr=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ksr=c.value2&1; + rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,((op.am&1)<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0xf)); + } + break; + } + case DIV_CMD_FM_WS: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + unsigned char noise=chan[c.chan].state.esfm.noise&3; + op.ws=c.value2&7; + if (isMuted[c.chan]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + } + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + unsigned char noise=chan[c.chan].state.esfm.noise&3; + op.ws=c.value2&7; + if (isMuted[c.chan]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + } + } + break; + } + // KSL + case DIV_CMD_FM_RS: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ksl=c.value2&3; + if (KVS_ES(c.chan,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[c.chan].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + op.ksl=c.value2&3; + if (KVS_ES(c.chan,o)) { + rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[c.chan].outVol&0x3f,63))|(op.ksl<<6)); + } else { + rWrite(baseAddr+ADDR_KSL_TL,(op.tl&0x3f)|(op.ksl<<6)); + } + } + break; + } + case DIV_CMD_FM_AM_DEPTH: { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + op.dam=c.value2&1; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + break; + } + case DIV_CMD_FM_PM_DEPTH: { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + op.dvb=c.value2&1; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + break; + } + case DIV_CMD_FM_FIXFREQ: { + unsigned int o=c.value&3; + bool isFNum=c.value&4; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + if (!opE.fixed) break; + if (isFNum) { + opE.dt=(c.value2)&0xff; + opE.ct=(opE.ct&(~3))|((c.value2>>8)&3); + chan[c.chan].freqChanged=true; + } else { + opE.ct=(opE.ct&(~(7<<2)))|((c.value2&7)<<2); + chan[c.chan].freqChanged=true; + } + break; + } + case DIV_CMD_ESFM_OP_PANNING: { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + opE.left=(c.value2&0xf0)!=0; + opE.right=(c.value2&0x0f)!=0; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + break; + } + case DIV_CMD_ESFM_OUTLVL: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + unsigned char noise=chan[c.chan].state.esfm.noise&3; + opE.outLvl=c.value2&7; + if (isMuted[c.chan]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + } + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + unsigned char noise=chan[c.chan].state.esfm.noise&3; + opE.outLvl=c.value2&7; + if (isMuted[c.chan]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|((o==3?noise:0)<<3)|((opE.outLvl&7)<<5)); + } + } + break; + } + case DIV_CMD_ESFM_MODIN: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + opE.modIn=c.value2&7; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[o]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + opE.modIn=c.value2&7; + rWrite(baseAddr+ADDR_DAM_DVB_LEFT_RIGHT_MODIN,((opE.modIn&7)<<1)|(((opE.left&chan[c.chan].globalPan)&1)<<4)|(((opE.right&(chan[c.chan].globalPan>>1))&1)<<5)|((op.dvb&1)<<6)|(op.dam<<7)); + } + break; + } + case DIV_CMD_ESFM_ENV_DELAY: { + if (c.value<0) { + for (int o=0; o<4; o++) { + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + opE.delay=c.value2&7; + rWrite(baseAddr+ADDR_FREQH_BLOCK_DELAY,chan[c.chan].freqH[o]|(opE.delay<<5)); + } + } else { + unsigned int o=c.value; + if (o >= 4) break; + unsigned short baseAddr=c.chan*32+o*8; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + opE.delay=c.value2&7; + rWrite(baseAddr+ADDR_FREQH_BLOCK_DELAY,chan[c.chan].freqH[o]|(opE.delay<<5)); + } + break; + } + case DIV_CMD_STD_NOISE_MODE: { + unsigned short baseAddr=c.chan*32+3*8; + DivInstrumentFM::Operator& op=chan[c.chan].state.fm.op[3]; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[3]; + DivInstrumentESFM insE=chan[c.chan].state.esfm; + insE.noise=c.value&3; + if (isMuted[c.chan]) { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|(insE.noise<<3)|0); + } else { + rWrite(baseAddr+ADDR_OUTLVL_NOISE_WS,(op.ws&7)|(insE.noise<<3)|((opE.outLvl&7)<<5)); + } + break; + } + case DIV_CMD_FM_DT: { + unsigned int o=c.value; + if (o >= 4) break; + DivInstrumentESFM::Operator& opE=chan[c.chan].state.esfm.op[o]; + if (opE.fixed) break; + opE.dt=c.value2-0x80; + chan[c.chan].freqChanged=true; + break; + } + case DIV_CMD_FM_HARD_RESET: + chan[c.chan].hardReset=c.value; + break; + case DIV_CMD_MACRO_OFF: + chan[c.chan].std.mask(c.value,true); + break; + case DIV_CMD_MACRO_ON: + chan[c.chan].std.mask(c.value,false); + break; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); + break; + case DIV_CMD_GET_VOLMAX: + return 63; + break; + case DIV_CMD_PRE_PORTA: + if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) { + chan[c.chan].baseFreq=NOTE_FREQUENCY(chan[c.chan].note); + } + chan[c.chan].inPorta=c.value; + break; + default: + break; + } + return 1; +} + +void DivPlatformESFM::forceIns() { + for (int i=0; i<18; i++) { + chan[i].insChanged=true; + chan[i].freqChanged=true; + } + for (int i=0; i>1); +} + +DivDispatchOscBuffer* DivPlatformESFM::getOscBuffer(int ch) { + return oscBuf[ch]; +} + +unsigned char* DivPlatformESFM::getRegisterPool() { + // // Uncomment this for debugging weird behavior + // for (int i=0; i& wlist) { + for (DivRegWrite& i: wlist) immWrite(i.addr,i.val); +} + +void DivPlatformESFM::setFlags(const DivConfig& flags) { + chipClock=COLOR_NTSC*4.0; + rate=chipClock/288.0; +} + +int DivPlatformESFM::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { + parent=p; + dumpWrites=false; + skipRegisterWrites=false; + for (int i=0; i<18; i++) { + isMuted[i]=false; + oscBuf[i]=new DivDispatchOscBuffer; + } + setFlags(flags); + reset(); + + return 18; +} + +void DivPlatformESFM::quit() { + for (int i=0; i<18; i++) { + delete oscBuf[i]; + } +} + +DivPlatformESFM::~DivPlatformESFM() { +} diff --git a/src/engine/platform/esfm.h b/src/engine/platform/esfm.h new file mode 100644 index 000000000..58fafbfab --- /dev/null +++ b/src/engine/platform/esfm.h @@ -0,0 +1,207 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2024 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "../dispatch.h" +#include "../../fixedQueue.h" +#include "../../../extern/ESFMu/esfm.h" + +// ESFM register address space technically spans 0x800 (2048) bytes, +// but we only need the first 0x254 (596) during normal use. +// Rounding it up to 0x400 bytes, the nearest power of 2. +#define ESFM_REG_POOL_SIZE 0x400 + +class DivPlatformESFM: public DivDispatch { + struct Channel: public SharedChannel { + struct { + DivInstrumentFM fm; + DivInstrumentESFM esfm; + } state; + unsigned char freqL[4], freqH[4]; + bool hardReset; + unsigned char globalPan; + int macroVolMul; + struct { + int baseNoteOverride; + bool fixedArp; + int arpOff; + int pitch2; + bool hasOpArp; + bool hasOpPitch; + } opsState[4]; + + void handleArpFmOp(int offset=0, int o=0) { + DivMacroInt::IntOp& m=this->std.op[o]; + if (m.ssg.had) { + opsState[o].hasOpArp=true; + + if (m.ssg.val<0) { + if (!(m.ssg.val&0x40000000)) { + opsState[o].baseNoteOverride=(m.ssg.val|0x40000000)+offset; + opsState[o].fixedArp=true; + } else { + opsState[o].arpOff=m.ssg.val; + opsState[o].fixedArp=false; + } + } else { + if (m.ssg.val&0x40000000) { + opsState[o].baseNoteOverride=(m.ssg.val&(~0x40000000))+offset; + opsState[o].fixedArp=true; + } else { + opsState[o].arpOff=m.ssg.val; + opsState[o].fixedArp=false; + } + } + freqChanged=true; + } + + else + { + opsState[o].hasOpArp=false; + } + } + + void handlePitchFmOp(int o) + { + DivMacroInt::IntOp& m=this->std.op[o]; + + if (m.dt.had) { + opsState[o].hasOpPitch=true; + + if (m.dt.mode) { + opsState[o].pitch2+=m.dt.val; + CLAMP_VAR(opsState[o].pitch2,-131071,131071); + } else { + opsState[o].pitch2=m.dt.val; + } + this->freqChanged=true; + } + + else + { + opsState[o].hasOpPitch=false; + } + } + + Channel(): + SharedChannel(0), + freqL{0, 0, 0, 0}, + freqH{0, 0, 0, 0}, + hardReset(false), + globalPan(3), + macroVolMul(64) { + memset(opsState, 0, sizeof(opsState)); + } + }; + Channel chan[18]; + DivDispatchOscBuffer* oscBuf[18]; + bool isMuted[18]; + struct QueuedWrite { + unsigned short addr; + unsigned char val; + bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} + }; + FixedQueue writes; + esfm_chip chip; + + unsigned char regPool[ESFM_REG_POOL_SIZE]; + short oldWrites[ESFM_REG_POOL_SIZE]; + short pendingWrites[ESFM_REG_POOL_SIZE]; + + int octave(int freq); + int toFreq(int freq); + void commitState(int ch, DivInstrument* ins); + + friend void putDispatchChip(void*,int); + friend void putDispatchChan(void*,int,int); + + inline void rWrite(unsigned short a, short v) { + if (!skipRegisterWrites && a 0 and o == 3 (last operator), + * or op[o].outLvl > 0 and (op[o].outLvl - op[o + 1].modIn) >= 2, + * or op[o].outLvl > 0 and op[o + 1].modIn == 0. + */ + inline bool KVS_ES(int c, int o) { + if (c<0 || c>=18 || o<0 || o>=4) return false; + + if (chan[c].state.fm.op[o].kvs==1) return true; + + if (chan[c].state.fm.op[o].kvs==2) { + if (chan[c].state.esfm.op[o].outLvl==7) return true; + else if (chan[c].state.esfm.op[o].outLvl>0) { + if (o==3) return true; + else if ((chan[c].state.esfm.op[o].outLvl-chan[c].state.esfm.op[o+1].modIn)>=2) { + return true; + } + else if (chan[c].state.esfm.op[o+1].modIn==0) { + return true; + } + } + } + return false; + } + + public: + void acquire(short** buf, size_t len); + int dispatch(DivCommand c); + void* getChanState(int chan); + DivMacroInt* getChanMacroInt(int ch); + unsigned short getPan(int ch); + DivDispatchOscBuffer* getOscBuffer(int chan); + unsigned char* getRegisterPool(); + int getRegisterPoolSize(); + int getOutputCount(); + void reset(); + void forceIns(); + void tick(bool sysTick=true); + void muteChannel(int ch, bool mute); + bool keyOffAffectsArp(int ch); + bool keyOffAffectsPorta(int ch); + bool getLegacyAlwaysSetVolume(); + void toggleRegisterDump(bool enable); + void notifyInsChange(int ins); + void notifyInsDeletion(void* ins); + int mapVelocity(int ch, float vel); + void poke(unsigned int addr, unsigned short val); + void poke(std::vector& wlist); + void setFlags(const DivConfig& flags); + int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); + void quit(); + ~DivPlatformESFM(); +}; diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index ea903cede..6d6a3c768 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -387,8 +387,8 @@ int DivPlatformFDS::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/fds.h b/src/engine/platform/fds.h index 5eda2c12f..49b52d063 100644 --- a/src/engine/platform/fds.h +++ b/src/engine/platform/fds.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/fmshared_OPM.h b/src/engine/platform/fmshared_OPM.h index 2002db333..41be72567 100644 --- a/src/engine/platform/fmshared_OPM.h +++ b/src/engine/platform/fmshared_OPM.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/fmshared_OPN.h b/src/engine/platform/fmshared_OPN.h index 32ea4c002..5671e136e 100644 --- a/src/engine/platform/fmshared_OPN.h +++ b/src/engine/platform/fmshared_OPN.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -186,6 +186,17 @@ class DivPlatformOPN: public DivPlatformFMBase { void setCombo(bool combo) { useCombo=combo; } + virtual int mapVelocity(int ch, float vel) { + if (ch==csmChan) return vel*127.0; + if (ch==adpcmBChanOffs) return vel*255.0; + if (ch>=adpcmAChanOffs) { + if (vel==0) return 0; + if (vel>=1.0) return 31; + return CLAMP(round(32.0-(56.0-log2(vel*127.0)*8.0)),0,31); + } + if (ch>=psgChanOffs) return round(15.0*pow(vel,0.33)); + return DivPlatformFMBase::mapVelocity(ch,vel); + } }; #endif diff --git a/src/engine/platform/fmsharedbase.h b/src/engine/platform/fmsharedbase.h index e458904eb..3f5db9229 100644 --- a/src/engine/platform/fmsharedbase.h +++ b/src/engine/platform/fmsharedbase.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,6 +121,24 @@ class DivPlatformFMBase: public DivDispatch { } } } + + virtual int mapVelocity(int ch, float vel) { + // -0.75dB per step + // -6: 64: 8 + // -12: 32: 16 + // -18: 16: 24 + // -24: 8: 32 + // -30: 4: 40 + // -36: 2: 48 + // -42: 1: 56 + if (vel==0) return 0; + if (vel>=1.0) return 127; + return CLAMP(round(128.0-(56.0-log2(vel*127.0)*8.0)),0,127); + } + + bool getLegacyAlwaysSetVolume() { + return true; + } friend void putDispatchChan(void*,int,int); diff --git a/src/engine/platform/ga20.cpp b/src/engine/platform/ga20.cpp index cc796bd61..df8677584 100644 --- a/src/engine/platform/ga20.cpp +++ b/src/engine/platform/ga20.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -311,8 +311,8 @@ int DivPlatformGA20::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/ga20.h b/src/engine/platform/ga20.h index 3831d32c2..995a7cc15 100644 --- a/src/engine/platform/ga20.h +++ b/src/engine/platform/ga20.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index 741fe2c3c..3ae02dcf9 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -553,8 +553,8 @@ int DivPlatformGB::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/gb.h b/src/engine/platform/gb.h index 0e7fb52d3..6fe094020 100644 --- a/src/engine/platform/gb.h +++ b/src/engine/platform/gb.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 633bf2886..57bb640e6 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -348,7 +348,7 @@ void DivPlatformGenesis::tick(bool sysTick) { } } - if (i>=5 && chan[i].furnaceDac) { + if (i>=5 && chan[i].furnaceDac && chan[i].dacMode) { if (NEW_ARP_STRAT) { chan[i].handleArp(); } else if (chan[i].std.arp.had) { @@ -1183,8 +1183,8 @@ int DivPlatformGenesis::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 127; @@ -1300,6 +1300,12 @@ DivDispatchOscBuffer* DivPlatformGenesis::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformGenesis::mapVelocity(int ch, float vel) { + if (ch==csmChan) return DivPlatformOPN::mapVelocity(ch,vel); + if (ch>5) return DivPlatformOPN::mapVelocity(5,vel); + return DivPlatformOPN::mapVelocity(ch,vel); +} + unsigned char* DivPlatformGenesis::getRegisterPool() { return regPool; } diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index 82d4301b9..a24cabb52 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,6 +112,7 @@ class DivPlatformGenesis: public DivPlatformOPN { virtual unsigned short getPan(int chan); DivSamplePos getSamplePos(int ch); DivDispatchOscBuffer* getOscBuffer(int chan); + virtual int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index aab02e1e1..a3860f09d 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -418,9 +418,6 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: opChan[ch].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; case DIV_CMD_PRE_PORTA: break; default: @@ -818,6 +815,12 @@ DivDispatchOscBuffer* DivPlatformGenesisExt::getOscBuffer(int ch) { return NULL; } +int DivPlatformGenesisExt::mapVelocity(int ch, float vel) { + if (ch>=extChanOffs+4) return DivPlatformGenesis::mapVelocity(ch-3,vel); + if (ch>=extChanOffs) return DivPlatformGenesis::mapVelocity(extChanOffs,vel); + return DivPlatformGenesis::mapVelocity(ch,vel); +} + void DivPlatformGenesisExt::reset() { DivPlatformGenesis::reset(); diff --git a/src/engine/platform/genesisext.h b/src/engine/platform/genesisext.h index 63112c069..caf752e02 100644 --- a/src/engine/platform/genesisext.h +++ b/src/engine/platform/genesisext.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); void reset(); void forceIns(); void tick(bool sysTick=true); diff --git a/src/engine/platform/k007232.cpp b/src/engine/platform/k007232.cpp index b2d92e2fc..eb2157e05 100644 --- a/src/engine/platform/k007232.cpp +++ b/src/engine/platform/k007232.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -395,8 +395,8 @@ int DivPlatformK007232::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/k007232.h b/src/engine/platform/k007232.h index 5eb379985..379d41106 100644 --- a/src/engine/platform/k007232.h +++ b/src/engine/platform/k007232.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/k053260.cpp b/src/engine/platform/k053260.cpp index e05b13a70..b084f3a23 100644 --- a/src/engine/platform/k053260.cpp +++ b/src/engine/platform/k053260.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -345,8 +345,8 @@ int DivPlatformK053260::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/k053260.h b/src/engine/platform/k053260.h index 27b2a7910..4f1afea2d 100644 --- a/src/engine/platform/k053260.h +++ b/src/engine/platform/k053260.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/lynx.cpp b/src/engine/platform/lynx.cpp index f06de0415..68f3ac762 100644 --- a/src/engine/platform/lynx.cpp +++ b/src/engine/platform/lynx.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -353,8 +353,8 @@ int DivPlatformLynx::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; @@ -438,6 +438,10 @@ bool DivPlatformLynx::keyOffAffectsPorta(int ch) { return true; } +bool DivPlatformLynx::getLegacyAlwaysSetVolume() { + return false; +} + //int DivPlatformLynx::getPortaFloor(int ch) { // return 12; //} diff --git a/src/engine/platform/lynx.h b/src/engine/platform/lynx.h index e081f7ff7..7d705261d 100644 --- a/src/engine/platform/lynx.h +++ b/src/engine/platform/lynx.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,6 +84,7 @@ class DivPlatformLynx: public DivDispatch { int getOutputCount(); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); + bool getLegacyAlwaysSetVolume(); //int getPortaFloor(int ch); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); diff --git a/src/engine/platform/mmc5.cpp b/src/engine/platform/mmc5.cpp index e9ac6be9c..899bf7d8a 100644 --- a/src/engine/platform/mmc5.cpp +++ b/src/engine/platform/mmc5.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -327,8 +327,8 @@ int DivPlatformMMC5::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/mmc5.h b/src/engine/platform/mmc5.h index 291a1baf4..1f95d6161 100644 --- a/src/engine/platform/mmc5.h +++ b/src/engine/platform/mmc5.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/msm5232.cpp b/src/engine/platform/msm5232.cpp index 997ab607e..875b5a8ef 100644 --- a/src/engine/platform/msm5232.cpp +++ b/src/engine/platform/msm5232.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -297,8 +297,8 @@ int DivPlatformMSM5232::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/msm5232.h b/src/engine/platform/msm5232.h index efa5c919c..ec7739a30 100644 --- a/src/engine/platform/msm5232.h +++ b/src/engine/platform/msm5232.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/msm6258.cpp b/src/engine/platform/msm6258.cpp index c5d5c2c0e..b2dd96a4c 100644 --- a/src/engine/platform/msm6258.cpp +++ b/src/engine/platform/msm6258.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -268,8 +268,8 @@ int DivPlatformMSM6258::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 8; @@ -371,6 +371,10 @@ bool DivPlatformMSM6258::keyOffAffectsArp(int ch) { return false; } +bool DivPlatformMSM6258::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformMSM6258::notifyInsChange(int ins) { for (int i=0; i<1; i++) { if (chan[i].ins==ins) { diff --git a/src/engine/platform/msm6258.h b/src/engine/platform/msm6258.h index 2a4c3512b..9b84c2236 100644 --- a/src/engine/platform/msm6258.h +++ b/src/engine/platform/msm6258.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,6 +75,7 @@ class DivPlatformMSM6258: public DivDispatch { void muteChannel(int ch, bool mute); int getOutputCount(); bool keyOffAffectsArp(int ch); + bool getLegacyAlwaysSetVolume(); void notifyInsChange(int ins); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); diff --git a/src/engine/platform/msm6295.cpp b/src/engine/platform/msm6295.cpp index 06510d69f..886d447fd 100644 --- a/src/engine/platform/msm6295.cpp +++ b/src/engine/platform/msm6295.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -241,8 +241,8 @@ int DivPlatformMSM6295::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 8; @@ -330,6 +330,10 @@ bool DivPlatformMSM6295::keyOffAffectsArp(int ch) { return false; } +bool DivPlatformMSM6295::getLegacyAlwaysSetVolume() { + return false; +} + float DivPlatformMSM6295::getPostAmp() { return 3.0f; } diff --git a/src/engine/platform/msm6295.h b/src/engine/platform/msm6295.h index f7c8c58e0..51e052a81 100644 --- a/src/engine/platform/msm6295.h +++ b/src/engine/platform/msm6295.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -87,6 +87,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf { virtual void tick(bool sysTick=true) override; virtual void muteChannel(int ch, bool mute) override; virtual bool keyOffAffectsArp(int ch) override; + virtual bool getLegacyAlwaysSetVolume() override; virtual float getPostAmp() override; virtual void notifyInsChange(int ins) override; virtual void notifyInsDeletion(void* ins) override; diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index 1d6596f12..5e2ccd9c0 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -452,8 +452,8 @@ int DivPlatformN163::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/n163.h b/src/engine/platform/n163.h index e4d5b24d2..648a7af24 100644 --- a/src/engine/platform/n163.h +++ b/src/engine/platform/n163.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/namcowsg.cpp b/src/engine/platform/namcowsg.cpp index 0aa4bbd94..f6d358a57 100644 --- a/src/engine/platform/namcowsg.cpp +++ b/src/engine/platform/namcowsg.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -199,7 +199,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) { for (int i=0; i>4; + chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol,chan[i].std.vol.val,15); } if (chan[i].std.duty.had) { chan[i].noise=chan[i].std.duty.val; @@ -445,8 +445,8 @@ int DivPlatformNamcoWSG::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/namcowsg.h b/src/engine/platform/namcowsg.h index ab4451705..f023e8ba7 100644 --- a/src/engine/platform/namcowsg.h +++ b/src/engine/platform/namcowsg.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 32319fcbb..6abdf1dc9 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -659,8 +659,8 @@ int DivPlatformNES::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/nes.h b/src/engine/platform/nes.h index 48ed6a1b8..43377fee2 100644 --- a/src/engine/platform/nes.h +++ b/src/engine/platform/nes.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 8eb95fc28..fbad13218 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1343,7 +1343,7 @@ void DivPlatformOPL::commitState(int ch, DivInstrument* ins) { int DivPlatformOPL::dispatch(DivCommand c) { if (c.chan>=totalChans && c.chan!=adpcmChan) return 0; // ineffective in 4-op mode - if (oplType==3 && c.chan!=adpcmChan && c.chan<14 && (c.chan&1) && c.cmd!=DIV_CMD_GET_VOLMAX && c.cmd!=DIV_ALWAYS_SET_VOLUME) { + if (oplType==3 && c.chan!=adpcmChan && c.chan<14 && (c.chan&1) && c.cmd!=DIV_CMD_GET_VOLMAX) { if (chan[c.chan-1].fourOp) return 0; } switch (c.cmd) { @@ -1970,8 +1970,8 @@ int DivPlatformOPL::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: if (c.chan==adpcmChan) return 255; @@ -2104,6 +2104,21 @@ DivDispatchOscBuffer* DivPlatformOPL::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformOPL::mapVelocity(int ch, float vel) { + if (ch==adpcmChan) return vel*255.0; + // -0.75dB per step + // -6: 64: 8 + // -12: 32: 16 + // -18: 16: 24 + // -24: 8: 32 + // -30: 4: 40 + // -36: 2: 48 + // -42: 1: 56 + if (vel==0) return 0; + if (vel>=1.0) return 63; + return CLAMP(round(64.0-(56.0-log2(vel*127.0)*8.0)),0,63); +} + unsigned char* DivPlatformOPL::getRegisterPool() { return regPool; } @@ -2264,6 +2279,10 @@ bool DivPlatformOPL::keyOffAffectsPorta(int ch) { return false; } +bool DivPlatformOPL::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformOPL::notifyInsChange(int ins) { for (int i=0; i=1.0) return 15; + return CLAMP(round(16.0-(14.0-log2(vel*127.0)*2.0)),0,15); +} + unsigned char* DivPlatformOPLL::getRegisterPool() { return regPool; } @@ -1036,6 +1043,10 @@ bool DivPlatformOPLL::keyOffAffectsPorta(int ch) { return false; } +bool DivPlatformOPLL::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformOPLL::notifyInsChange(int ins) { for (int i=0; i<11; i++) { if (chan[i].ins==ins) { diff --git a/src/engine/platform/opll.h b/src/engine/platform/opll.h index e8bd627a4..53e5a2aa0 100644 --- a/src/engine/platform/opll.h +++ b/src/engine/platform/opll.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +95,7 @@ class DivPlatformOPLL: public DivDispatch { void* getChanState(int chan); DivMacroInt* getChanMacroInt(int ch); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); @@ -104,6 +105,7 @@ class DivPlatformOPLL: public DivDispatch { void setYMFM(bool use); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); + bool getLegacyAlwaysSetVolume(); float getPostAmp(); void toggleRegisterDump(bool enable); void setVRC7(bool vrc); diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 037a1cd69..d8be4dd21 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -474,8 +474,8 @@ int DivPlatformPCE::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; @@ -539,6 +539,10 @@ DivDispatchOscBuffer* DivPlatformPCE::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformPCE::mapVelocity(int ch, float vel) { + return round(31.0*pow(vel,0.22)); +} + unsigned char* DivPlatformPCE::getRegisterPool() { return regPool; } diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index c2649eb05..ceba204be 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,6 +86,7 @@ class DivPlatformPCE: public DivDispatch { DivChannelModeHints getModeHints(int chan); DivSamplePos getSamplePos(int ch); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); diff --git a/src/engine/platform/pcmdac.cpp b/src/engine/platform/pcmdac.cpp index adc8770ee..eebcd3860 100644 --- a/src/engine/platform/pcmdac.cpp +++ b/src/engine/platform/pcmdac.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -452,8 +452,8 @@ int DivPlatformPCMDAC::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pcmdac.h b/src/engine/platform/pcmdac.h index 17513690a..91befa623 100644 --- a/src/engine/platform/pcmdac.h +++ b/src/engine/platform/pcmdac.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index 593c41b8a..d1500dd55 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -373,6 +373,9 @@ void DivPlatformPCSpeaker::tick(bool sysTick) { if (chan[i].keyOff) { on=false; } + if (freq!=chan[i].freq && resetPhase) { + pos=0; + } freq=chan[i].freq; if (chan[i].keyOn) chan[i].keyOn=false; if (chan[i].keyOff) chan[i].keyOff=false; @@ -473,8 +476,8 @@ int DivPlatformPCSpeaker::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; @@ -610,6 +613,7 @@ void DivPlatformPCSpeaker::setFlags(const DivConfig& flags) { CHECK_CUSTOM_CLOCK; rate=chipClock/PCSPKR_DIVIDER; speakerType=flags.getInt("speakerType",0)&3; + resetPhase=flags.getBool("resetPhase",false); oscBuf->rate=rate; switch (speakerType) { diff --git a/src/engine/platform/pcspkr.h b/src/engine/platform/pcspkr.h index b1a394444..3a5a8067f 100644 --- a/src/engine/platform/pcspkr.h +++ b/src/engine/platform/pcspkr.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ class DivPlatformPCSpeaker: public DivDispatch { FixedQueue realQueue; std::mutex realQueueLock; bool isMuted[1]; - bool on, flip, lastOn, realOutEnabled; + bool on, flip, lastOn, realOutEnabled, resetPhase; int pos, speakerType, beepFD, realOutMethod; float low, band; float low2, high2, band2; diff --git a/src/engine/platform/pet.cpp b/src/engine/platform/pet.cpp index e7f135759..aa730fbbf 100644 --- a/src/engine/platform/pet.cpp +++ b/src/engine/platform/pet.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -239,8 +239,8 @@ int DivPlatformPET::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pet.h b/src/engine/platform/pet.h index 771d5cbb5..72bdfea0d 100644 --- a/src/engine/platform/pet.h +++ b/src/engine/platform/pet.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/pokemini.cpp b/src/engine/platform/pokemini.cpp index aa8adc0d7..d2e6d4e49 100644 --- a/src/engine/platform/pokemini.cpp +++ b/src/engine/platform/pokemini.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -253,8 +253,8 @@ int DivPlatformPokeMini::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pokemini.h b/src/engine/platform/pokemini.h index 4e14bf572..b0f8c8c52 100644 --- a/src/engine/platform/pokemini.h +++ b/src/engine/platform/pokemini.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/pokey.cpp b/src/engine/platform/pokey.cpp index da2ec7030..de39cd77a 100644 --- a/src/engine/platform/pokey.cpp +++ b/src/engine/platform/pokey.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -374,8 +374,8 @@ int DivPlatformPOKEY::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pokey.h b/src/engine/platform/pokey.h index 35bc595f3..6407c0778 100644 --- a/src/engine/platform/pokey.h +++ b/src/engine/platform/pokey.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/pong.cpp b/src/engine/platform/pong.cpp index 7d478b83b..9f8781f45 100644 --- a/src/engine/platform/pong.cpp +++ b/src/engine/platform/pong.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -180,8 +180,8 @@ int DivPlatformPong::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pong.h b/src/engine/platform/pong.h index 4fb13477c..2bde92d9b 100644 --- a/src/engine/platform/pong.h +++ b/src/engine/platform/pong.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/pv1000.cpp b/src/engine/platform/pv1000.cpp index 0d7d728d0..17ad84e72 100644 --- a/src/engine/platform/pv1000.cpp +++ b/src/engine/platform/pv1000.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -188,8 +188,8 @@ int DivPlatformPV1000::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/pv1000.h b/src/engine/platform/pv1000.h index 740f16c4b..e4ce1da42 100644 --- a/src/engine/platform/pv1000.h +++ b/src/engine/platform/pv1000.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/qsound.cpp b/src/engine/platform/qsound.cpp index 95a455e3f..4709fb668 100644 --- a/src/engine/platform/qsound.cpp +++ b/src/engine/platform/qsound.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -587,8 +587,8 @@ int DivPlatformQSound::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/qsound.h b/src/engine/platform/qsound.h index 6daccc120..929411402 100644 --- a/src/engine/platform/qsound.h +++ b/src/engine/platform/qsound.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/rf5c68.cpp b/src/engine/platform/rf5c68.cpp index c183cd505..06f9ab53e 100644 --- a/src/engine/platform/rf5c68.cpp +++ b/src/engine/platform/rf5c68.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -291,8 +291,8 @@ int DivPlatformRF5C68::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/rf5c68.h b/src/engine/platform/rf5c68.h index 9c706ccd5..3ae081017 100644 --- a/src/engine/platform/rf5c68.h +++ b/src/engine/platform/rf5c68.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index b1ba48826..e58cbe578 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -316,8 +316,8 @@ int DivPlatformSAA1099::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 15; @@ -435,6 +435,10 @@ bool DivPlatformSAA1099::keyOffAffectsArp(int ch) { return true; } +bool DivPlatformSAA1099::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformSAA1099::notifyInsDeletion(void* ins) { for (int i=0; i<6; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); diff --git a/src/engine/platform/saa.h b/src/engine/platform/saa.h index 339799d2e..9f15bc838 100644 --- a/src/engine/platform/saa.h +++ b/src/engine/platform/saa.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,6 +91,7 @@ class DivPlatformSAA1099: public DivDispatch { int getOutputCount(); int getPortaFloor(int ch); bool keyOffAffectsArp(int ch); + bool getLegacyAlwaysSetVolume(); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); void poke(std::vector& wlist); diff --git a/src/engine/platform/scc.cpp b/src/engine/platform/scc.cpp index cd97ff309..eca067ae4 100644 --- a/src/engine/platform/scc.cpp +++ b/src/engine/platform/scc.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -261,8 +261,8 @@ int DivPlatformSCC::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/scc.h b/src/engine/platform/scc.h index f075753aa..f7aad5fb1 100644 --- a/src/engine/platform/scc.h +++ b/src/engine/platform/scc.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index f81dbc487..5c5170186 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -339,8 +339,8 @@ int DivPlatformSegaPCM::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 127; @@ -372,6 +372,10 @@ void DivPlatformSegaPCM::forceIns() { } } +bool DivPlatformSegaPCM::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformSegaPCM::notifyInsChange(int ins) { for (int i=0; i<16; i++) { if (chan[i].ins==ins) { diff --git a/src/engine/platform/segapcm.h b/src/engine/platform/segapcm.h index b03459f5d..f99da7317 100644 --- a/src/engine/platform/segapcm.h +++ b/src/engine/platform/segapcm.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,6 +103,7 @@ class DivPlatformSegaPCM: public DivDispatch { void renderSamples(int chipID); void setFlags(const DivConfig& flags); int getOutputCount(); + bool getLegacyAlwaysSetVolume(); void poke(unsigned int addr, unsigned short val); void poke(std::vector& wlist); const void* getSampleMem(int index=0); diff --git a/src/engine/platform/sm8521.cpp b/src/engine/platform/sm8521.cpp index 52c3442ce..ada99de24 100644 --- a/src/engine/platform/sm8521.cpp +++ b/src/engine/platform/sm8521.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -277,8 +277,8 @@ int DivPlatformSM8521::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/sm8521.h b/src/engine/platform/sm8521.h index f9faeebda..40baf36df 100644 --- a/src/engine/platform/sm8521.h +++ b/src/engine/platform/sm8521.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index 7aa0455ca..27693e7cb 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -420,8 +420,8 @@ int DivPlatformSMS::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; @@ -462,6 +462,10 @@ DivDispatchOscBuffer* DivPlatformSMS::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformSMS::mapVelocity(int ch, float vel) { + return round(15.0*pow(vel,0.33)); +} + unsigned char* DivPlatformSMS::getRegisterPool() { return regPool; } @@ -505,6 +509,10 @@ bool DivPlatformSMS::keyOffAffectsPorta(int ch) { return true; } +bool DivPlatformSMS::getLegacyAlwaysSetVolume() { + return false; +} + int DivPlatformSMS::getPortaFloor(int ch) { return 12; } diff --git a/src/engine/platform/sms.h b/src/engine/platform/sms.h index 5eaf204ba..d2d0c901f 100644 --- a/src/engine/platform/sms.h +++ b/src/engine/platform/sms.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -79,6 +79,7 @@ class DivPlatformSMS: public DivDispatch { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); @@ -88,6 +89,7 @@ class DivPlatformSMS: public DivDispatch { int getOutputCount(); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); + bool getLegacyAlwaysSetVolume(); float getPostAmp(); int getPortaFloor(int ch); void setFlags(const DivConfig& flags); diff --git a/src/engine/platform/snes.cpp b/src/engine/platform/snes.cpp index 0b6bdbbc9..8cc205a16 100644 --- a/src/engine/platform/snes.cpp +++ b/src/engine/platform/snes.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -587,6 +587,9 @@ int DivPlatformSNES::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); + break; default: break; } diff --git a/src/engine/platform/snes.h b/src/engine/platform/snes.h index 8c48c6c72..315f5a89b 100644 --- a/src/engine/platform/snes.h +++ b/src/engine/platform/snes.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/su.cpp b/src/engine/platform/su.cpp index 5a88618f3..5ac95d3cd 100644 --- a/src/engine/platform/su.cpp +++ b/src/engine/platform/su.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -502,8 +502,8 @@ int DivPlatformSoundUnit::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/su.h b/src/engine/platform/su.h index 7062cbc8b..f39a59cc7 100644 --- a/src/engine/platform/su.h +++ b/src/engine/platform/su.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index 25260a44c..484151595 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -446,8 +446,8 @@ int DivPlatformSwan::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/swan.h b/src/engine/platform/swan.h index 4dab6eb7c..aa5f9dd95 100644 --- a/src/engine/platform/swan.h +++ b/src/engine/platform/swan.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/t6w28.cpp b/src/engine/platform/t6w28.cpp index f2dfe7120..b93780ba2 100644 --- a/src/engine/platform/t6w28.cpp +++ b/src/engine/platform/t6w28.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -271,8 +271,8 @@ int DivPlatformT6W28::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; @@ -308,6 +308,10 @@ DivDispatchOscBuffer* DivPlatformT6W28::getOscBuffer(int ch) { return oscBuf[ch]; } +int DivPlatformT6W28::mapVelocity(int ch, float vel) { + return round(15.0*pow(vel,0.33)); +} + unsigned char* DivPlatformT6W28::getRegisterPool() { return regPool; } diff --git a/src/engine/platform/t6w28.h b/src/engine/platform/t6w28.h index 5e69c6268..e6ddeb13c 100644 --- a/src/engine/platform/t6w28.h +++ b/src/engine/platform/t6w28.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,6 +65,7 @@ class DivPlatformT6W28: public DivDispatch { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); unsigned char* getRegisterPool(); int getRegisterPoolSize(); void reset(); diff --git a/src/engine/platform/ted.cpp b/src/engine/platform/ted.cpp index a1e431bb4..a30c0fd79 100644 --- a/src/engine/platform/ted.cpp +++ b/src/engine/platform/ted.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -236,8 +236,8 @@ int DivPlatformTED::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/ted.h b/src/engine/platform/ted.h index a2bd1d636..e6b27b2e7 100644 --- a/src/engine/platform/ted.h +++ b/src/engine/platform/ted.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/tia.cpp b/src/engine/platform/tia.cpp index 86038216a..ea0b7e6e1 100644 --- a/src/engine/platform/tia.cpp +++ b/src/engine/platform/tia.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -258,8 +258,8 @@ int DivPlatformTIA::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 15; @@ -340,6 +340,10 @@ bool DivPlatformTIA::keyOffAffectsArp(int ch) { return true; } +bool DivPlatformTIA::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformTIA::notifyInsDeletion(void* ins) { for (int i=0; i<2; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); diff --git a/src/engine/platform/tia.h b/src/engine/platform/tia.h index 4e7420b79..a66de9cbd 100644 --- a/src/engine/platform/tia.h +++ b/src/engine/platform/tia.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ class DivPlatformTIA: public DivDispatch { float getPostAmp(); int getOutputCount(); bool keyOffAffectsArp(int ch); + bool getLegacyAlwaysSetVolume(); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); void poke(std::vector& wlist); diff --git a/src/engine/platform/tx81z.cpp b/src/engine/platform/tx81z.cpp index f677429ff..3fee5e04e 100644 --- a/src/engine/platform/tx81z.cpp +++ b/src/engine/platform/tx81z.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -880,8 +880,8 @@ int DivPlatformTX81Z::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: return 127; diff --git a/src/engine/platform/tx81z.h b/src/engine/platform/tx81z.h index 93da1cd7a..8c97ed22e 100644 --- a/src/engine/platform/tx81z.h +++ b/src/engine/platform/tx81z.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/vb.cpp b/src/engine/platform/vb.cpp index c94867fa7..2ee8f8af5 100644 --- a/src/engine/platform/vb.cpp +++ b/src/engine/platform/vb.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -395,8 +395,8 @@ int DivPlatformVB::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/vb.h b/src/engine/platform/vb.h index 940491f60..a270c1c23 100644 --- a/src/engine/platform/vb.h +++ b/src/engine/platform/vb.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/vera.cpp b/src/engine/platform/vera.cpp index 38b166bd1..7c48dc108 100644 --- a/src/engine/platform/vera.cpp +++ b/src/engine/platform/vera.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -434,12 +434,12 @@ int DivPlatformVERA::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); + break; case DIV_CMD_EXTERNAL: rWriteZSMSync(c.value); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; default: break; } @@ -470,6 +470,10 @@ int DivPlatformVERA::getRegisterPoolSize() { return 67; } +bool DivPlatformVERA::getLegacyAlwaysSetVolume() { + return false; +} + void DivPlatformVERA::muteChannel(int ch, bool mute) { isMuted[ch]=mute; if (ch<16) { diff --git a/src/engine/platform/vera.h b/src/engine/platform/vera.h index 992bb0798..db2005bd7 100644 --- a/src/engine/platform/vera.h +++ b/src/engine/platform/vera.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,6 +73,7 @@ class DivPlatformVERA: public DivDispatch { void tick(bool sysTick=true); void muteChannel(int ch, bool mute); void setFlags(const DivConfig& flags); + bool getLegacyAlwaysSetVolume(); void notifyInsDeletion(void* ins); float getPostAmp(); int getOutputCount(); diff --git a/src/engine/platform/vic20.cpp b/src/engine/platform/vic20.cpp index 05705f7c7..fae616370 100644 --- a/src/engine/platform/vic20.cpp +++ b/src/engine/platform/vic20.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -252,8 +252,8 @@ int DivPlatformVIC20::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/vic20.h b/src/engine/platform/vic20.h index b1c1533ab..962c1ef7e 100644 --- a/src/engine/platform/vic20.h +++ b/src/engine/platform/vic20.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index 96088d937..f5f7371d6 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -412,8 +412,8 @@ int DivPlatformVRC6::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/vrc6.h b/src/engine/platform/vrc6.h index f20e0d39c..5a02a350a 100644 --- a/src/engine/platform/vrc6.h +++ b/src/engine/platform/vrc6.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index 7015fa517..9600cc09b 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -832,8 +832,8 @@ int DivPlatformX1_010::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/x1_010.h b/src/engine/platform/x1_010.h index 632d95424..f4a815455 100644 --- a/src/engine/platform/x1_010.h +++ b/src/engine/platform/x1_010.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2203.cpp b/src/engine/platform/ym2203.cpp index 913f84045..974a2ad2b 100644 --- a/src/engine/platform/ym2203.cpp +++ b/src/engine/platform/ym2203.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -861,8 +861,8 @@ int DivPlatformYM2203::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: if (c.chan>2) return 15; diff --git a/src/engine/platform/ym2203.h b/src/engine/platform/ym2203.h index fb96a2b60..334d8f650 100644 --- a/src/engine/platform/ym2203.h +++ b/src/engine/platform/ym2203.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2203ext.cpp b/src/engine/platform/ym2203ext.cpp index adb312ad8..bd2e6c4a5 100644 --- a/src/engine/platform/ym2203ext.cpp +++ b/src/engine/platform/ym2203ext.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -375,9 +375,6 @@ int DivPlatformYM2203Ext::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: opChan[ch].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; case DIV_CMD_PRE_PORTA: break; default: @@ -692,6 +689,12 @@ DivDispatchOscBuffer* DivPlatformYM2203Ext::getOscBuffer(int ch) { return NULL; } +int DivPlatformYM2203Ext::mapVelocity(int ch, float vel) { + if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel); + if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel); + return DivPlatformOPN::mapVelocity(ch,vel); +} + void DivPlatformYM2203Ext::reset() { DivPlatformYM2203::reset(); diff --git a/src/engine/platform/ym2203ext.h b/src/engine/platform/ym2203ext.h index 731e2a202..c735e196b 100644 --- a/src/engine/platform/ym2203ext.h +++ b/src/engine/platform/ym2203ext.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ class DivPlatformYM2203Ext: public DivPlatformYM2203 { void* getChanState(int chan); DivMacroInt* getChanMacroInt(int ch); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); void reset(); void forceIns(); void tick(bool sysTick=true); diff --git a/src/engine/platform/ym2608.cpp b/src/engine/platform/ym2608.cpp index 9ec5518b0..4d3986b2d 100644 --- a/src/engine/platform/ym2608.cpp +++ b/src/engine/platform/ym2608.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1352,8 +1352,8 @@ int DivPlatformYM2608::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: if (c.chan>14) return 255; diff --git a/src/engine/platform/ym2608.h b/src/engine/platform/ym2608.h index e7a8bc6e5..2b51da1d6 100644 --- a/src/engine/platform/ym2608.h +++ b/src/engine/platform/ym2608.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2608Interface.cpp b/src/engine/platform/ym2608Interface.cpp index d357caa23..1422f2d26 100644 --- a/src/engine/platform/ym2608Interface.cpp +++ b/src/engine/platform/ym2608Interface.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2608ext.cpp b/src/engine/platform/ym2608ext.cpp index 50424d4eb..d27703c58 100644 --- a/src/engine/platform/ym2608ext.cpp +++ b/src/engine/platform/ym2608ext.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -399,9 +399,6 @@ int DivPlatformYM2608Ext::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: opChan[ch].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; case DIV_CMD_PRE_PORTA: break; default: @@ -767,6 +764,12 @@ DivDispatchOscBuffer* DivPlatformYM2608Ext::getOscBuffer(int ch) { return NULL; } +int DivPlatformYM2608Ext::mapVelocity(int ch, float vel) { + if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel); + if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel); + return DivPlatformOPN::mapVelocity(ch,vel); +} + void DivPlatformYM2608Ext::reset() { DivPlatformYM2608::reset(); diff --git a/src/engine/platform/ym2608ext.h b/src/engine/platform/ym2608ext.h index 0c9c1a418..52a3619ad 100644 --- a/src/engine/platform/ym2608ext.h +++ b/src/engine/platform/ym2608ext.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ class DivPlatformYM2608Ext: public DivPlatformYM2608 { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); void reset(); void forceIns(); void tick(bool sysTick=true); diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 01d5a3bb6..f30ce9082 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1324,8 +1324,8 @@ int DivPlatformYM2610::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: if (c.chan>=adpcmBChanOffs) return 255; diff --git a/src/engine/platform/ym2610.h b/src/engine/platform/ym2610.h index 99b1e73b7..0df5573be 100644 --- a/src/engine/platform/ym2610.h +++ b/src/engine/platform/ym2610.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2610Interface.cpp b/src/engine/platform/ym2610Interface.cpp index 916cab0ad..da8239744 100644 --- a/src/engine/platform/ym2610Interface.cpp +++ b/src/engine/platform/ym2610Interface.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index 1937abd62..e588bea94 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1391,8 +1391,8 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; case DIV_CMD_GET_VOLMAX: if (c.chan>=adpcmBChanOffs) return 255; diff --git a/src/engine/platform/ym2610b.h b/src/engine/platform/ym2610b.h index 80c040e77..6d46dedb1 100644 --- a/src/engine/platform/ym2610b.h +++ b/src/engine/platform/ym2610b.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ym2610bext.cpp b/src/engine/platform/ym2610bext.cpp index 545a80e98..519c7004e 100644 --- a/src/engine/platform/ym2610bext.cpp +++ b/src/engine/platform/ym2610bext.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -395,9 +395,6 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: opChan[ch].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; case DIV_CMD_PRE_PORTA: break; default: @@ -757,6 +754,12 @@ DivDispatchOscBuffer* DivPlatformYM2610BExt::getOscBuffer(int ch) { return NULL; } +int DivPlatformYM2610BExt::mapVelocity(int ch, float vel) { + if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel); + if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel); + return DivPlatformOPN::mapVelocity(ch,vel); +} + void DivPlatformYM2610BExt::reset() { DivPlatformYM2610B::reset(); diff --git a/src/engine/platform/ym2610bext.h b/src/engine/platform/ym2610bext.h index 024119cff..a215507e9 100644 --- a/src/engine/platform/ym2610bext.h +++ b/src/engine/platform/ym2610bext.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); void reset(); void forceIns(); void tick(bool sysTick=true); diff --git a/src/engine/platform/ym2610ext.cpp b/src/engine/platform/ym2610ext.cpp index 39e341675..d9a111114 100644 --- a/src/engine/platform/ym2610ext.cpp +++ b/src/engine/platform/ym2610ext.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -395,9 +395,6 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: opChan[ch].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 0; - break; case DIV_CMD_PRE_PORTA: break; default: @@ -757,6 +754,12 @@ DivDispatchOscBuffer* DivPlatformYM2610Ext::getOscBuffer(int ch) { return NULL; } +int DivPlatformYM2610Ext::mapVelocity(int ch, float vel) { + if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel); + if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel); + return DivPlatformOPN::mapVelocity(ch,vel); +} + void DivPlatformYM2610Ext::reset() { DivPlatformYM2610::reset(); diff --git a/src/engine/platform/ym2610ext.h b/src/engine/platform/ym2610ext.h index f860a36cd..256235111 100644 --- a/src/engine/platform/ym2610ext.h +++ b/src/engine/platform/ym2610ext.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); + int mapVelocity(int ch, float vel); void reset(); void forceIns(); void tick(bool sysTick=true); diff --git a/src/engine/platform/ym2610shared.h b/src/engine/platform/ym2610shared.h index 36db018f2..0c96e5447 100644 --- a/src/engine/platform/ym2610shared.h +++ b/src/engine/platform/ym2610shared.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/ymz280b.cpp b/src/engine/platform/ymz280b.cpp index 9a8b45e9d..395d1524e 100644 --- a/src/engine/platform/ymz280b.cpp +++ b/src/engine/platform/ymz280b.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -321,8 +321,8 @@ int DivPlatformYMZ280B::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/ymz280b.h b/src/engine/platform/ymz280b.h index 913b8ec6e..703cef6c8 100644 --- a/src/engine/platform/ymz280b.h +++ b/src/engine/platform/ymz280b.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/zxbeeper.cpp b/src/engine/platform/zxbeeper.cpp index 3592c049b..ffa974e9f 100644 --- a/src/engine/platform/zxbeeper.cpp +++ b/src/engine/platform/zxbeeper.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -218,8 +218,8 @@ int DivPlatformZXBeeper::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/zxbeeper.h b/src/engine/platform/zxbeeper.h index 9bd3678a8..8fe97f8ca 100644 --- a/src/engine/platform/zxbeeper.h +++ b/src/engine/platform/zxbeeper.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/platform/zxbeeperquadtone.cpp b/src/engine/platform/zxbeeperquadtone.cpp index 3be196ad0..bc3fc884d 100644 --- a/src/engine/platform/zxbeeperquadtone.cpp +++ b/src/engine/platform/zxbeeperquadtone.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -288,8 +288,8 @@ int DivPlatformZXBeeperQuadTone::dispatch(DivCommand c) { case DIV_CMD_MACRO_ON: chan[c.chan].std.mask(c.value,false); break; - case DIV_ALWAYS_SET_VOLUME: - return 1; + case DIV_CMD_MACRO_RESTART: + chan[c.chan].std.restart(c.value); break; default: break; diff --git a/src/engine/platform/zxbeeperquadtone.h b/src/engine/platform/zxbeeperquadtone.h index 8291f8646..4efd66c07 100644 --- a/src/engine/platform/zxbeeperquadtone.h +++ b/src/engine/platform/zxbeeperquadtone.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index d2a0db179..3ff0560bc 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -242,7 +242,12 @@ const char* cmdName[]={ "C64_AD", "C64_SR", - "ALWAYS_SET_VOLUME" + "ESFM_OP_PANNING", + "ESFM_OUTLVL", + "ESFM_MODIN", + "ESFM_ENV_DELAY", + + "MACRO_RESTART", }; static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!"); @@ -267,8 +272,6 @@ int DivEngine::dispatchCmd(DivCommand c) { if (!skipping) { switch (c.cmd) { // strip away hinted/useless commands - case DIV_ALWAYS_SET_VOLUME: - break; case DIV_CMD_GET_VOLUME: break; case DIV_CMD_VOLUME: @@ -615,7 +618,7 @@ void DivEngine::processRow(int i, bool afterDelay) { // volume if (pat->data[whatRow][3]!=-1) { - if (dispatchCmd(DivCommand(DIV_ALWAYS_SET_VOLUME,i)) || (MIN(chan[i].volMax,chan[i].volume)>>8)!=pat->data[whatRow][3]) { + if (!song.oldAlwaysSetVolume || disCont[dispatchOfChan[i]].dispatch->getLegacyAlwaysSetVolume() || (MIN(chan[i].volMax,chan[i].volume)>>8)!=pat->data[whatRow][3]) { if (pat->data[whatRow][0]==0 && pat->data[whatRow][1]==0) { chan[i].midiAftertouch=true; } @@ -1005,6 +1008,9 @@ void DivEngine::processRow(int i, bool afterDelay) { case 0xf6: // enable macro dispatchCmd(DivCommand(DIV_CMD_MACRO_ON,i,effectVal&0xff)); break; + case 0xf7: // restart macro + dispatchCmd(DivCommand(DIV_CMD_MACRO_RESTART,i,effectVal&0xff)); + break; case 0xf8: // single volume ramp up chan[i].volume=MIN(chan[i].volume+effectVal*256,chan[i].volMax); dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8)); @@ -1370,11 +1376,18 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) { pendingNotes.pop_front(); continue; } + if (note.insChange) { + dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,note.channel,note.ins,0)); + pendingNotes.pop_front(); + continue; + } if (note.on) { - dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,note.channel,note.ins,1)); - if (note.volume>=0) { - int mappedVol=disCont[dispatchOfChan[note.channel]].dispatch->mapVelocity(note.channel,note.volume); - logV("dispatching volume (%d -> %d)",note.volume,mappedVol); + if (!(midiIsDirect && midiIsDirectProgram && note.fromMIDI)) { + dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,note.channel,note.ins,1)); + } + if (note.volume>=0 && !disCont[dispatchOfChan[note.channel]].dispatch->isVolGlobal()) { + float curvedVol=pow((float)note.volume/127.0f,midiVolExp); + int mappedVol=disCont[dispatchOfChan[note.channel]].dispatch->mapVelocity(dispatchChanOfChan[note.channel],curvedVol); dispatchCmd(DivCommand(DIV_CMD_VOLUME,note.channel,mappedVol)); } dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,note.channel,note.note)); @@ -1832,7 +1845,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi case TA_MIDI_NOTE_OFF: { if (chan<0 || chan>=chans) break; if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); + pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false,false,true)); } else { autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); } @@ -1847,13 +1860,13 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi if (chan<0 || chan>=chans) break; if (msg.data[1]==0) { if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); + pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false,false,true)); } else { autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); } } else { if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,ins,msg.data[0]-12,msg.data[1],true)); + pendingNotes.push_back(DivNoteEvent(chan,ins,msg.data[0]-12,msg.data[1],true,false,true)); } else { autoNoteOn(msg.type&15,ins,msg.data[0]-12,msg.data[1]); } @@ -1861,7 +1874,9 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi break; } case TA_MIDI_PROGRAM: { - // TODO: change instrument event thingy + if (midiIsDirect && midiIsDirectProgram) { + pendingNotes.push_back(DivNoteEvent(chan,msg.data[0],0,0,false,true,true)); + } break; } } diff --git a/src/engine/safeReader.cpp b/src/engine/safeReader.cpp index 5ac416e27..09c012a5f 100644 --- a/src/engine/safeReader.cpp +++ b/src/engine/safeReader.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/safeReader.h b/src/engine/safeReader.h index 8fd4d105e..7ab5e6b81 100644 --- a/src/engine/safeReader.h +++ b/src/engine/safeReader.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/safeWriter.cpp b/src/engine/safeWriter.cpp index acdf9ad6b..3f62569ac 100644 --- a/src/engine/safeWriter.cpp +++ b/src/engine/safeWriter.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/safeWriter.h b/src/engine/safeWriter.h index 28a3d9b91..640e78c47 100644 --- a/src/engine/safeWriter.h +++ b/src/engine/safeWriter.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 4332503cd..bb8a21d3f 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/sample.h b/src/engine/sample.h index 253fe347c..63d219259 100644 --- a/src/engine/sample.h +++ b/src/engine/sample.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/sfWrapper.cpp b/src/engine/sfWrapper.cpp index 62ddf949f..814f9c00f 100644 --- a/src/engine/sfWrapper.cpp +++ b/src/engine/sfWrapper.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/sfWrapper.h b/src/engine/sfWrapper.h index e4746b530..c32c8ba19 100644 --- a/src/engine/sfWrapper.h +++ b/src/engine/sfWrapper.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/song.cpp b/src/engine/song.cpp index 828f0a1bc..70d625597 100644 --- a/src/engine/song.cpp +++ b/src/engine/song.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/song.h b/src/engine/song.h index 5ecccaaaa..7f29ddb69 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -131,7 +131,8 @@ enum DivSystem { DIV_SYSTEM_K053260, DIV_SYSTEM_TED, DIV_SYSTEM_C140, - DIV_SYSTEM_C219 + DIV_SYSTEM_C219, + DIV_SYSTEM_ESFM }; enum DivEffectType: unsigned short { @@ -382,6 +383,7 @@ struct DivSong { bool oldDPCM; bool resetArpPhaseOnNewNote; bool ceilVolumeScaling; + bool oldAlwaysSetVolume; std::vector ins; std::vector wave; @@ -397,7 +399,7 @@ struct DivSong { std::vector effects; - DivInstrument nullIns, nullInsOPLL, nullInsOPL, nullInsOPLDrums, nullInsQSound; + DivInstrument nullIns, nullInsOPLL, nullInsOPL, nullInsOPLDrums, nullInsQSound, nullInsESFM; DivWavetable nullWave; DivSample nullSample; @@ -504,7 +506,8 @@ struct DivSong { preNoteNoEffect(false), oldDPCM(false), resetArpPhaseOnNewNote(false), - ceilVolumeScaling(false) { + ceilVolumeScaling(false), + oldAlwaysSetVolume(false) { for (int i=0; i, effectValAnd<1>}}, + {0x12, {DIV_CMD_FM_TL, "12xx: Set level of operator 1 (0 highest, 3F lowest)", constVal<0>, effectVal}}, + {0x13, {DIV_CMD_FM_TL, "13xx: Set level of operator 2 (0 highest, 3F lowest)", constVal<1>, effectVal}}, + {0x14, {DIV_CMD_FM_TL, "14xx: Set level of operator 3 (0 highest, 3F lowest)", constVal<2>, effectVal}}, + {0x15, {DIV_CMD_FM_TL, "15xx: Set level of operator 4 (0 highest, 3F lowest)", constVal<3>, effectVal}}, + {0x16, {DIV_CMD_FM_MULT, "16xy: Set operator multiplier (x: operator from 1 to 4; y: multiplier)", effectOpValNoZero<4>, effectValAnd<15>}}, + {0x17, {DIV_CMD_FM_PM_DEPTH, "17xy: Set vibrato depth (x: operator from 1 to 4 (0 for all ops); y: depth (0: normal, 1: double))", effectOpVal<4>, effectValAnd<1>}}, + {0x19, {DIV_CMD_FM_AR, "19xx: Set attack of all operators (0 to F)", constVal<-1>, effectValAnd<15>}}, + {0x1a, {DIV_CMD_FM_AR, "1Axx: Set attack of operator 1 (0 to F)", constVal<0>, effectValAnd<15>}}, + {0x1b, {DIV_CMD_FM_AR, "1Bxx: Set attack of operator 2 (0 to F)", constVal<1>, effectValAnd<15>}}, + {0x1c, {DIV_CMD_FM_AR, "1Cxx: Set attack of operator 3 (0 to F)", constVal<2>, effectValAnd<15>}}, + {0x1d, {DIV_CMD_FM_AR, "1Dxx: Set attack of operator 4 (0 to F)", constVal<3>, effectValAnd<15>}}, + {0x20, {DIV_CMD_ESFM_OP_PANNING, "20xy: Set panning of operator 1 (x: left; y: right)", constVal<0>, effectVal}}, + {0x21, {DIV_CMD_ESFM_OP_PANNING, "21xy: Set panning of operator 2 (x: left; y: right)", constVal<1>, effectVal}}, + {0x22, {DIV_CMD_ESFM_OP_PANNING, "22xy: Set panning of operator 3 (x: left; y: right)", constVal<2>, effectVal}}, + {0x23, {DIV_CMD_ESFM_OP_PANNING, "23xy: Set panning of operator 4 (x: left; y: right)", constVal<3>, effectVal}}, + {0x24, {DIV_CMD_ESFM_OUTLVL, "24xy: Set output level register (x: operator from 1 to 4 (0 for all ops); y: level from 0 to 7)", effectOpVal<4>, effectValAnd<7>}}, + {0x25, {DIV_CMD_ESFM_MODIN, "25xy: Set modulation input level (x: operator from 1 to 4 (0 for all ops); y: level from 0 to 7)", effectOpVal<4>, effectValAnd<7>}}, + {0x26, {DIV_CMD_ESFM_ENV_DELAY, "26xy: Set envelope delay (x: operator from 1 to 4 (0 for all ops); y: delay from 0 to 7)", effectOpVal<4>, effectValAnd<7>}}, + {0x27, {DIV_CMD_STD_NOISE_MODE, "27xx: Set noise mode for operator 4 (x: mode from 0 to 3)", effectValAnd<3>}}, + {0x2a, {DIV_CMD_FM_WS, "2Axy: Set waveform (x: operator from 1 to 4 (0 for all ops); y: waveform from 0 to 7)", effectOpVal<4>, effectValAnd<7>}}, + {0x2f, {DIV_CMD_FM_FIXFREQ, "2Fxy: Set fixed frequency block (x: operator from 1 to 4; y: octave from 0 to 7)", effectOpValNoZero<4>, effectValAnd<7>}}, + {0x40, {DIV_CMD_FM_DT, "40xx: Set detune of operator 1 (80: center)", constVal<0>, effectVal}}, + {0x41, {DIV_CMD_FM_DT, "41xx: Set detune of operator 2 (80: center)", constVal<1>, effectVal}}, + {0x42, {DIV_CMD_FM_DT, "42xx: Set detune of operator 3 (80: center)", constVal<2>, effectVal}}, + {0x43, {DIV_CMD_FM_DT, "43xx: Set detune of operator 4 (80: center)", constVal<3>, effectVal}}, + {0x50, {DIV_CMD_FM_AM, "50xy: Set AM (x: operator from 1 to 4 (0 for all ops); y: AM)", effectOpVal<4>, effectValAnd<1>}}, + {0x51, {DIV_CMD_FM_SL, "51xy: Set sustain level (x: operator from 1 to 4 (0 for all ops); y: sustain)", effectOpVal<4>, effectValAnd<15>}}, + {0x52, {DIV_CMD_FM_RR, "52xy: Set release (x: operator from 1 to 4 (0 for all ops); y: release)", effectOpVal<4>, effectValAnd<15>}}, + {0x53, {DIV_CMD_FM_VIB, "53xy: Set vibrato (x: operator from 1 to 4 (0 for all ops); y: enabled)", effectOpVal<4>, effectValAnd<1>}}, + {0x54, {DIV_CMD_FM_RS, "54xy: Set envelope scale (x: operator from 1 to 4 (0 for all ops); y: scale from 0 to 3)", effectOpVal<4>, effectValAnd<3>}}, + {0x55, {DIV_CMD_FM_SUS, "55xy: Set envelope sustain (x: operator from 1 to 4 (0 for all ops); y: enabled)", effectOpVal<4>, effectValAnd<1>}}, + {0x56, {DIV_CMD_FM_DR, "56xx: Set decay of all operators (0 to F)", constVal<-1>, effectValAnd<15>}}, + {0x57, {DIV_CMD_FM_DR, "57xx: Set decay of operator 1 (0 to F)", constVal<0>, effectValAnd<15>}}, + {0x58, {DIV_CMD_FM_DR, "58xx: Set decay of operator 2 (0 to F)", constVal<1>, effectValAnd<15>}}, + {0x59, {DIV_CMD_FM_DR, "59xx: Set decay of operator 3 (0 to F)", constVal<2>, effectValAnd<15>}}, + {0x5a, {DIV_CMD_FM_DR, "5Axx: Set decay of operator 4 (0 to F)", constVal<3>, effectValAnd<15>}}, + {0x5b, {DIV_CMD_FM_KSR, "5Bxy: Set whether key will scale envelope (x: operator from 1 to 4 (0 for all ops); y: enabled)", effectOpVal<4>, effectValAnd<1>}} + }; + const EffectHandler fmESFMFixFreqFNumHandler[4]={ + {DIV_CMD_FM_FIXFREQ, "3xyy: Set fixed frequency F-num of operator 1 (x: high 2 bits from 0 to 3; y: low 8 bits of F-num)", constVal<4>, effectValLong<10>}, + {DIV_CMD_FM_FIXFREQ, "3xyy: Set fixed frequency F-num of operator 2 (x: high 2 bits from 4 to 7; y: low 8 bits of F-num)", constVal<5>, effectValLong<10>}, + {DIV_CMD_FM_FIXFREQ, "3xyy: Set fixed frequency F-num of operator 3 (x: high 2 bits from 8 to B; y: low 8 bits of F-num)", constVal<6>, effectValLong<10>}, + {DIV_CMD_FM_FIXFREQ, "3xyy: Set fixed frequency F-num of operator 4 (x: high 2 bits from C to F; y: low 8 bits of F-num)", constVal<7>, effectValLong<10>}, + }; + for (int i=0; i<16; i++) { + fmESFMPostEffectHandlerMap.emplace(0x30+i,fmESFMFixFreqFNumHandler[i/4]); + } + // SysDefs // this chip uses YMZ ADPCM, but the emulator uses ADPCM-B because I got it wrong back then. @@ -1921,6 +1971,20 @@ void DivEngine::registerSystems() { } ); + sysDefs[DIV_SYSTEM_ESFM]=new DivSysDef( + "ESS ES1xxx series (ESFM)", NULL, 0xd1, 0, 18, true, false, 0, false, 0, 0, 0, + "a unique FM synth featured in PC sound cards.\nbased on the OPL3 design, but with lots of its features extended.", + {"FM 1", "FM 2", "FM 3", "FM 4", "FM 5", "FM 6", "FM 7", "FM 8", "FM 9", "FM 10", "FM 11", "FM 12", "FM 13", "FM 14", "FM 15", "FM 16", "FM 17", "FM 18"}, + {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"}, + {DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_FM}, + {DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM, DIV_INS_ESFM}, + {}, + { + {0x2e, {DIV_CMD_FM_HARD_RESET, "2Exx: Toggle hard envelope reset on new notes"}}, + }, + fmESFMPostEffectHandlerMap + ); + sysDefs[DIV_SYSTEM_DUMMY]=new DivSysDef( "Dummy System", NULL, 0xfd, 0, 8, false, true, 0, false, 0, 0, 0, "this is a system designed for testing purposes.", diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index c8c6cef79..5e3ad32a1 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/wavOps.cpp b/src/engine/wavOps.cpp index 7c89dd710..edf4a8885 100644 --- a/src/engine/wavOps.cpp +++ b/src/engine/wavOps.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/waveSynth.cpp b/src/engine/waveSynth.cpp index 6fe34f261..5ef9899b3 100644 --- a/src/engine/waveSynth.cpp +++ b/src/engine/waveSynth.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/waveSynth.h b/src/engine/waveSynth.h index 21b6055ff..65046eb60 100644 --- a/src/engine/waveSynth.h +++ b/src/engine/waveSynth.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/wavetable.cpp b/src/engine/wavetable.cpp index a14c28bbe..00e2d1d2d 100644 --- a/src/engine/wavetable.cpp +++ b/src/engine/wavetable.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/wavetable.h b/src/engine/wavetable.h index 52405082e..a7085527d 100644 --- a/src/engine/wavetable.h +++ b/src/engine/wavetable.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/winStuff.cpp b/src/engine/winStuff.cpp index 4452a5143..83eec6c08 100644 --- a/src/engine/winStuff.cpp +++ b/src/engine/winStuff.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/winStuff.h b/src/engine/winStuff.h index a569f6a09..105f93f69 100644 --- a/src/engine/winStuff.h +++ b/src/engine/winStuff.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/workPool.cpp b/src/engine/workPool.cpp index 60d580acf..b7372f082 100644 --- a/src/engine/workPool.cpp +++ b/src/engine/workPool.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/workPool.h b/src/engine/workPool.h index ec12843aa..48d1b96e0 100644 --- a/src/engine/workPool.h +++ b/src/engine/workPool.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/zsm.cpp b/src/engine/zsm.cpp index 03d294638..87dbde8d2 100644 --- a/src/engine/zsm.cpp +++ b/src/engine/zsm.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/zsm.h b/src/engine/zsm.h index 79b8b116c..d1fd8ec04 100644 --- a/src/engine/zsm.h +++ b/src/engine/zsm.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/engine/zsmOps.cpp b/src/engine/zsmOps.cpp index 3c72da663..a2f9385ba 100644 --- a/src/engine/zsmOps.cpp +++ b/src/engine/zsmOps.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/fileutils.cpp b/src/fileutils.cpp index ede4054c8..eca6bf3b7 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/fileutils.h b/src/fileutils.h index 38b5732be..e35c9cfbf 100644 --- a/src/fileutils.h +++ b/src/fileutils.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/fixedQueue.h b/src/fixedQueue.h index 4e3379622..68f883edc 100644 --- a/src/fixedQueue.h +++ b/src/fixedQueue.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/about.cpp b/src/gui/about.cpp index 31b6ed00a..8c014121f 100644 --- a/src/gui/about.cpp +++ b/src/gui/about.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,6 +39,7 @@ const char* aboutLine[]={ "cam900", "djtuBIG-MaliceX", "Eknous", + "Kagamiin~", "laoo", "LTVA1", "MooingLemur", @@ -109,6 +110,7 @@ const char* aboutLine[]={ "Korbo", "jaezu", "Laggy", + "leejh20", "LovelyA72", "LTVA1", "LunaMoth", @@ -193,6 +195,7 @@ const char* aboutLine[]={ "adpcm by superctr", "Nuked-OPL3/OPLL/OPM/OPN2/PSG by nukeykt", "YM3812-LLE, YMF262-LLE and YMF276-LLE by nukeykt", + "ESFMu by Kagamiin~", "ymfm by Aaron Giles", "MAME SN76496 by Nicola Salmoria", "MAME AY-3-8910 by Couriersud", @@ -234,7 +237,7 @@ const char* aboutLine[]={ "Xenium Demoparty", "all members of Deflers of Noice!", "", - "copyright © 2021-2023 tildearrow", + "copyright © 2021-2024 tildearrow", "(and contributors).", "licensed under GPLv2+! see", "LICENSE for more information.", diff --git a/src/gui/actionUtil.h b/src/gui/actionUtil.h index 51fffa002..2987b6262 100644 --- a/src/gui/actionUtil.h +++ b/src/gui/actionUtil.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/chanOsc.cpp b/src/gui/chanOsc.cpp index f702fdb96..dca83ddec 100644 --- a/src/gui/chanOsc.cpp +++ b/src/gui/chanOsc.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -348,6 +348,7 @@ void FurnaceGUI::drawChanOsc() { "- %v: volume (decimal)\n" "- %V: volume (percentage)\n" "- %b: volume (hex)\n" + "- %l: new line\n" "- %%: percent sign" ); ImGui::EndTooltip(); @@ -751,6 +752,10 @@ void FurnaceGUI::drawChanOsc() { text+=fmt::sprintf("%s",noteName(noteMod,oct)); break; } + case 'l': { + text+='\n'; + break; + } case '%': text+='%'; break; diff --git a/src/gui/channels.cpp b/src/gui/channels.cpp index 608604ea8..69ed7385c 100644 --- a/src/gui/channels.cpp +++ b/src/gui/channels.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/clock.cpp b/src/gui/clock.cpp index a44ae13d5..2f4a541c6 100644 --- a/src/gui/clock.cpp +++ b/src/gui/clock.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/compatFlags.cpp b/src/gui/compatFlags.cpp index a11200544..eccc63244 100644 --- a/src/gui/compatFlags.cpp +++ b/src/gui/compatFlags.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -192,6 +192,10 @@ void FurnaceGUI::drawCompatFlags() { if (ImGui::IsItemHovered()) { ImGui::SetTooltip("behavior changed in 0.6.1"); } + ImGui::Checkbox("Legacy technical ALWAYS_SET_VOLUME behavior",&e->song.oldAlwaysSetVolume); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("behavior changed in 0.6.1\nthis flag will be removed if I find out that none of the songs break after disabling it."); + } ImGui::EndTabItem(); } if (ImGui::BeginTabItem(".mod import")) { diff --git a/src/gui/cursor.cpp b/src/gui/cursor.cpp index ca5f51b64..80dcd17f8 100644 --- a/src/gui/cursor.cpp +++ b/src/gui/cursor.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 527848a63..6ae3fb8b7 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +76,7 @@ void FurnaceGUI::insListItem(int i, int dir, int asset) { const char* insType="Bug!"; if (i>=0 && isong.insLen) { DivInstrument* ins=e->song.ins[i]; - insType=(ins->type>DIV_INS_MAX)?"Unknown":insTypes[ins->type][0]; + insType=(ins->type>=DIV_INS_MAX)?"Unknown":insTypes[ins->type][0]; const char** insIcon=NULL; if (ins->type>=DIV_INS_MAX) { diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 87a295f71..807b32ed1 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/debug.h b/src/gui/debug.h index 4ec4cd87c..76c81fb57 100644 --- a/src/gui/debug.h +++ b/src/gui/debug.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/debugWindow.cpp b/src/gui/debugWindow.cpp index 1efde1e09..ce56f470b 100644 --- a/src/gui/debugWindow.cpp +++ b/src/gui/debugWindow.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index 3acc4bc59..0d43a2eea 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,6 +65,10 @@ void FurnaceGUI::doAction(int what) { case GUI_ACTION_SAVE_AS: openFileDialog(GUI_FILE_SAVE); break; + case GUI_ACTION_EXPORT: + curExportType=GUI_EXPORT_NONE; + displayExport=true; + break; case GUI_ACTION_UNDO: if (curWindow==GUI_WINDOW_SAMPLE_EDIT) { doUndoSample(); @@ -639,6 +643,11 @@ void FurnaceGUI::doAction(int what) { e->song.ins[curIns]->fm.op[i].rr=15; e->song.ins[curIns]->fm.op[i].tl=127; e->song.ins[curIns]->fm.op[i].dt=3; + + e->song.ins[curIns]->esfm.op[i].ct=0; + e->song.ins[curIns]->esfm.op[i].dt=0; + e->song.ins[curIns]->esfm.op[i].modIn=0; + e->song.ins[curIns]->esfm.op[i].outLvl=0; } } wantScrollList=true; diff --git a/src/gui/editControls.cpp b/src/gui/editControls.cpp index b9b8a7409..1a611b264 100644 --- a/src/gui/editControls.cpp +++ b/src/gui/editControls.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -519,24 +519,8 @@ void FurnaceGUI::drawMobileControls() { openFileDialog(GUI_FILE_SAVE_DMF_LEGACY); } ImGui::SameLine(); - if (ImGui::Button("Export Audio")) { - openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); - } - ImGui::SameLine(); - if (ImGui::Button("Export VGM")) { - openFileDialog(GUI_FILE_EXPORT_VGM); - } - - if (ImGui::Button("CmdStream")) { - openFileDialog(GUI_FILE_EXPORT_CMDSTREAM_BINARY); - } - ImGui::SameLine(); - if (ImGui::Button("CmdStream Text")) { - openFileDialog(GUI_FILE_EXPORT_CMDSTREAM); - } - ImGui::SameLine(); - if (ImGui::Button("Text")) { - openFileDialog(GUI_FILE_EXPORT_TEXT); + if (ImGui::Button("Export")) { + doAction(GUI_ACTION_EXPORT); } if (ImGui::Button("Restore Backup")) { diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index d27c55a13..fd2715bc8 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -771,10 +771,10 @@ unsigned int convertEffectMPT_S3M(unsigned char symbol, unsigned int val) { return (0x80<<8)|((val&0xf)<<4); break; case 0xC: - return (0xFC<<8)|(val&0xf); + return (0xEC<<8)|(val&0xf); break; case 0xD: - return (0xFD<<8)|(val&0xf); + return (0xED<<8)|(val&0xf); break; default: break; @@ -1117,7 +1117,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String if (invalidData) { - logW("invalid OpenMPT clipboard data! failed at line %d char %d",i,charPos); + logW("invalid clipboard data! failed at line %d char %d",i,charPos); logW("%s",line.c_str()); break; } diff --git a/src/gui/exportOptions.cpp b/src/gui/exportOptions.cpp new file mode 100644 index 000000000..16dd7eeda --- /dev/null +++ b/src/gui/exportOptions.cpp @@ -0,0 +1,357 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2024 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "gui.h" +#include "guiConst.h" +#include "../fileutils.h" +#include "misc/cpp/imgui_stdlib.h" +#include + +void FurnaceGUI::drawExportAudio(bool onWindow) { + exitDisabledTimer=1; + + ImGui::RadioButton("one file",&audioExportType,0); + ImGui::RadioButton("multiple files (one per chip)",&audioExportType,1); + ImGui::RadioButton("multiple files (one per channel)",&audioExportType,2); + if (ImGui::InputInt("Loops",&exportLoops,1,2)) { + if (exportLoops<0) exportLoops=0; + } + if (ImGui::InputDouble("Fade out (seconds)",&exportFadeOut,1.0,2.0,"%.1f")) { + if (exportFadeOut<0.0) exportFadeOut=0.0; + } + + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + + if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { + switch (audioExportType) { + case 0: + openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); + break; + case 1: + openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_SYS); + break; + case 2: + openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_CHANNEL); + break; + } + ImGui::CloseCurrentPopup(); + } +} + +void FurnaceGUI::drawExportVGM(bool onWindow) { + exitDisabledTimer=1; + + ImGui::Text("settings:"); + if (ImGui::BeginCombo("format version",fmt::sprintf("%d.%.2x",vgmExportVersion>>8,vgmExportVersion&0xff).c_str())) { + for (int i=0; i<7; i++) { + if (ImGui::Selectable(fmt::sprintf("%d.%.2x",vgmVersions[i]>>8,vgmVersions[i]&0xff).c_str(),vgmExportVersion==vgmVersions[i])) { + vgmExportVersion=vgmVersions[i]; + } + } + ImGui::EndCombo(); + } + ImGui::Checkbox("loop",&vgmExportLoop); + if (vgmExportLoop && e->song.loopModality==2) { + ImGui::Text("loop trail:"); + ImGui::Indent(); + if (ImGui::RadioButton("auto-detect",vgmExportTrailingTicks==-1)) { + vgmExportTrailingTicks=-1; + } + if (ImGui::RadioButton("add one loop",vgmExportTrailingTicks==-2)) { + vgmExportTrailingTicks=-2; + } + if (ImGui::RadioButton("custom",vgmExportTrailingTicks>=0)) { + vgmExportTrailingTicks=0; + } + if (vgmExportTrailingTicks>=0) { + ImGui::SameLine(); + if (ImGui::InputInt("##TrailTicks",&vgmExportTrailingTicks,1,100)) { + if (vgmExportTrailingTicks<0) vgmExportTrailingTicks=0; + } + } + ImGui::Unindent(); + } + ImGui::Checkbox("add pattern change hints",&vgmExportPatternHints); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip( + "inserts data blocks on pattern changes.\n" + "useful if you are writing a playback routine.\n\n" + + "the format of a pattern change data block is:\n" + "67 66 FE ll ll ll ll 01 oo rr pp pp pp ...\n" + "- ll: length, a 32-bit little-endian number\n" + "- oo: order\n" + "- rr: initial row (a 0Dxx effect is able to select a different row)\n" + "- pp: pattern index (one per channel)\n\n" + + "pattern indexes are ordered as they appear in the song." + ); + } + ImGui::Checkbox("direct stream mode",&vgmExportDirectStream); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip( + "required for DualPCM and MSM6258 export.\n\n" + "allows for volume/direction changes when playing samples,\n" + "at the cost of a massive increase in file size." + ); + } + ImGui::Text("chips to export:"); + bool hasOneAtLeast=false; + for (int i=0; isong.systemLen; i++) { + int minVersion=e->minVGMVersion(e->song.system[i]); + ImGui::BeginDisabled(minVersion>vgmExportVersion || minVersion==0); + ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),&willExport[i]); + ImGui::EndDisabled(); + if (minVersion>vgmExportVersion) { + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { + ImGui::SetTooltip("this chip is only available in VGM %d.%.2x and higher!",minVersion>>8,minVersion&0xff); + } + } else if (minVersion==0) { + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { + ImGui::SetTooltip("this chip is not supported by the VGM format!"); + } + } else { + if (willExport[i]) hasOneAtLeast=true; + } + } + ImGui::Text("select the chip you wish to export, but only up to %d of each type.",(vgmExportVersion>=0x151)?2:1); + if (hasOneAtLeast) { + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_VGM); + ImGui::CloseCurrentPopup(); + } + } else { + ImGui::Text("nothing to export"); + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(400.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + } + } +} + +void FurnaceGUI::drawExportZSM(bool onWindow) { + exitDisabledTimer=1; + + ImGui::Text("Commander X16 Zsound Music File"); + if (ImGui::InputInt("Tick Rate (Hz)",&zsmExportTickRate,1,2)) { + if (zsmExportTickRate<1) zsmExportTickRate=1; + if (zsmExportTickRate>44100) zsmExportTickRate=44100; + } + ImGui::Checkbox("loop",&zsmExportLoop); + ImGui::SameLine(); + ImGui::Checkbox("optimize size",&zsmExportOptimize); + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_ZSM); + ImGui::CloseCurrentPopup(); + } +} + +void FurnaceGUI::drawExportAmigaVal(bool onWindow) { + exitDisabledTimer=1; + + ImGui::Text( + "this is NOT ROM export! only use for making sure the\n" + "Furnace Amiga emulator is working properly by\n" + "comparing it with real Amiga output." + ); + ImGui::AlignTextToFramePadding(); + ImGui::Text("Directory"); + ImGui::SameLine(); + ImGui::InputText("##AVDPath",&workingDirROMExport); + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button("Bake Data",ImVec2(200.0f*dpiScale,0))) { + std::vector out=e->buildROM(DIV_ROM_AMIGA_VALIDATION); + if (workingDirROMExport.size()>0) { + if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR; + } + for (DivROMExportOutput& i: out) { + String path=workingDirROMExport+i.name; + FILE* outFile=ps_fopen(path.c_str(),"wb"); + if (outFile!=NULL) { + fwrite(i.data->getFinalBuf(),1,i.data->size(),outFile); + fclose(outFile); + } + i.data->finish(); + delete i.data; + } + showError(fmt::sprintf("Done! Baked %d files.",(int)out.size())); + ImGui::CloseCurrentPopup(); + } +} + +void FurnaceGUI::drawExportText(bool onWindow) { + exitDisabledTimer=1; + + ImGui::Text( + "this option exports the song to a text file.\n" + ); + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_TEXT); + ImGui::CloseCurrentPopup(); + } +} + +void FurnaceGUI::drawExportCommand(bool onWindow) { + exitDisabledTimer=1; + + ImGui::Text( + "this option exports a text or binary file which\n" + "contains a dump of the internal command stream\n" + "produced when playing the song.\n\n" + + "technical/development use only!" + ); + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button("Cancel",ImVec2(133.3f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button("Export (binary)",ImVec2(133.3f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_CMDSTREAM_BINARY); + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Export (text)",ImVec2(133.3f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_CMDSTREAM); + ImGui::CloseCurrentPopup(); + } +} + +void FurnaceGUI::drawExport() { + if (settings.exportOptionsLayout==1 || curExportType==GUI_EXPORT_NONE) { + if (ImGui::BeginTabBar("ExportTypes")) { + if (ImGui::BeginTabItem("Audio")) { + drawExportAudio(true); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("VGM")) { + drawExportVGM(true); + ImGui::EndTabItem(); + } + int numZSMCompat=0; + for (int i=0; isong.systemLen; i++) { + if ((e->song.system[i]==DIV_SYSTEM_VERA) || (e->song.system[i]==DIV_SYSTEM_YM2151)) numZSMCompat++; + } + if (numZSMCompat>0) { + if (ImGui::BeginTabItem("ZSM")) { + drawExportZSM(true); + ImGui::EndTabItem(); + } + } + int numAmiga=0; + for (int i=0; isong.systemLen; i++) { + if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++; + } + if (numAmiga && settings.iCannotWait) { + if (ImGui::BeginTabItem("Amiga Validation")) { + drawExportAmigaVal(true); + ImGui::EndTabItem(); + } + } + if (ImGui::BeginTabItem("Text")) { + drawExportText(true); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Command Stream")) { + drawExportCommand(true); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + } else switch (curExportType) { + case GUI_EXPORT_AUDIO: + drawExportAudio(true); + break; + case GUI_EXPORT_VGM: + drawExportVGM(true); + break; + case GUI_EXPORT_ZSM: + drawExportZSM(true); + break; + case GUI_EXPORT_AMIGA_VAL: + drawExportAmigaVal(true); + break; + case GUI_EXPORT_TEXT: + drawExportText(true); + break; + case GUI_EXPORT_CMD_STREAM: + drawExportCommand(true); + break; + default: + ImGui::Text("congratulations! you've unlocked a secret panel."); + if (ImGui::Button("Toggle hidden systems")) { + settings.hiddenSystems=!settings.hiddenSystems; + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Toggle all instrument types")) { + settings.displayAllInsTypes=!settings.displayAllInsTypes; + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Set pitch linearity to Partial")) { + e->song.linearPitch=1; + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Enable multi-threading settings")) { + settings.showPool=1; + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Set fat to max")) { + ImGuiStyle& sty=ImGui::GetStyle(); + sty.FramePadding=ImVec2(20.0f*dpiScale,20.0f*dpiScale); + sty.ItemSpacing=ImVec2(10.0f*dpiScale,10.0f*dpiScale); + sty.ItemInnerSpacing=ImVec2(10.0f*dpiScale,10.0f*dpiScale); + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Set muscle and fat to zero")) { + ImGuiStyle& sty=ImGui::GetStyle(); + sty.FramePadding=ImVec2(0,0); + sty.ItemSpacing=ImVec2(0,0); + sty.ItemInnerSpacing=ImVec2(0,0); + ImGui::CloseCurrentPopup(); + } + if (ImGui::Button("Tell tildearrow this must be a mistake")) { + showError("yeah, it's a bug. write a bug report in the GitHub page and tell me how did you get here."); + ImGui::CloseCurrentPopup(); + } + break; + } +} diff --git a/src/gui/findReplace.cpp b/src/gui/findReplace.cpp index 5e2825231..dd87d5313 100644 --- a/src/gui/findReplace.cpp +++ b/src/gui/findReplace.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/fmPreview.cpp b/src/gui/fmPreview.cpp index 5586d1c20..525d30339 100644 --- a/src/gui/fmPreview.cpp +++ b/src/gui/fmPreview.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "../../extern/opn/ym3438.h" #include "../../extern/opm/opm.h" #include "../../extern/opl/opl3.h" +#include "../../extern/ESFMu/esfm.h" extern "C" { #include "../../extern/Nuked-OPLL/opll.h" } @@ -337,6 +338,76 @@ void FurnaceGUI::renderFMPreviewOPZ(const DivInstrumentFM& params, int pos) { } } +#define ESFM_WRITE(addr,val) \ + ESFM_write_reg_buffered_fast((esfm_chip*)fmPreviewESFM,(addr),(val)) + +void FurnaceGUI::renderFMPreviewESFM(const DivInstrumentFM& params, const DivInstrumentESFM& esfmParams, int pos) { + if (fmPreviewESFM==NULL) { + fmPreviewESFM=new esfm_chip; + pos=0; + } + short out[4]; + bool mult0=false; + + if (pos==0) { + ESFM_init((esfm_chip*)fmPreviewESFM); + // set native mode + ESFM_WRITE(0x105, 0x80); + + // set params + for (int i=0; i<4; i++) { + if ((params.op[i].mult&15)==0) { + mult0=true; + break; + } + } + + for (int i=0; i<4; i++) { + const DivInstrumentFM::Operator& op=params.op[i]; + const DivInstrumentESFM::Operator& opE=esfmParams.op[i]; + unsigned short baseAddr=i*8; + unsigned char freqL, freqH; + if (opE.fixed) { + freqL=opE.dt; + freqH=opE.ct&0x1f; + } else { + // perform detune calculation + int offset=(opE.ct<<7)+opE.dt; + double fbase=(mult0?2048.0:1024.0)*pow(2.0,(float)offset/(128.0*12.0)); + int bf=round(fbase); + int block=0; + while (bf>0x3ff) { + bf>>=1; + block++; + } + freqL=bf&0xff; + freqH=((block&7)<<2)|((bf>>8)&3); + } + + ESFM_WRITE(baseAddr+0,(op.am<<7)|((op.vib&1)<<6)|((op.sus&1)<<5)|((op.ksr&1)<<4)|(op.mult&0x0f)); + ESFM_WRITE(baseAddr+1,(op.ksl<<6)|(op.tl&0x3f)); + ESFM_WRITE(baseAddr+2,(op.ar<<4)|(op.dr&0x0f)); + ESFM_WRITE(baseAddr+3,(op.sl<<4)|(op.rr&0x0f)); + + ESFM_WRITE(baseAddr+4,freqL); + ESFM_WRITE(baseAddr+5,(opE.delay<<5)|freqH); + + ESFM_WRITE(baseAddr+6,(op.dam<<7)|((op.dvb&1)<<6)|((opE.right&1)<<5)|((opE.left&1)<<4)|((opE.modIn&7)<<1)); + ESFM_WRITE(baseAddr+7,(opE.outLvl<<5)|((i==3?esfmParams.noise:0)<<3)|(op.ws&7)); + } + } + + // note on + ESFM_WRITE(0x240, 1); + + // render + for (int i=0; itype) { case DIV_INS_FM: @@ -354,6 +425,8 @@ void FurnaceGUI::renderFMPreview(const DivInstrument* ins, int pos) { case DIV_INS_OPZ: renderFMPreviewOPZ(ins->fm,pos); break; + case DIV_INS_ESFM: + renderFMPreviewESFM(ins->fm,ins->esfm,pos); default: break; } diff --git a/src/gui/fonts.cpp b/src/gui/fonts.cpp index 4ab0f6a4c..e7d9c5df9 100644 --- a/src/gui/fonts.cpp +++ b/src/gui/fonts.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/fonts.h b/src/gui/fonts.h index 25e186c07..cbebb8253 100644 --- a/src/gui/fonts.h +++ b/src/gui/fonts.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/gradient.cpp b/src/gui/gradient.cpp index a36768ead..b9ef9e48f 100644 --- a/src/gui/gradient.cpp +++ b/src/gui/gradient.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/grooves.cpp b/src/gui/grooves.cpp index eee8db56e..431cae610 100644 --- a/src/gui/grooves.cpp +++ b/src/gui/grooves.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a9efea15b..02cb0beef 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2,7 +2,7 @@ // OK, sorry for inserting the define here but I'm so tired of this extension /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1216,7 +1216,7 @@ void FurnaceGUI::noteInput(int num, int key, int vol) { if (latchVol!=-1) { pat->data[cursor.y][3]=MIN(maxVol,latchVol); } else if (vol!=-1) { - pat->data[cursor.y][3]=(vol*maxVol)/127; + pat->data[cursor.y][3]=e->mapVelocity(cursor.xCoarse,pow((float)vol/127.0f,midiMap.volExp)); } if (latchEffect!=-1) pat->data[cursor.y][4]=latchEffect; if (latchEffectVal!=-1) pat->data[cursor.y][5]=latchEffectVal; @@ -1319,6 +1319,32 @@ void FurnaceGUI::valueInput(int num, bool direct, int target) { } } +void FurnaceGUI::orderInput(int num) { + if (orderCursor>=0 && orderCursorgetTotalChannelCount()) { + prepareUndo(GUI_UNDO_CHANGE_ORDER); + e->lockSave([this,num]() { + if (!curNibble && !settings.pushNibble) e->curOrders->ord[orderCursor][curOrder]=0; + e->curOrders->ord[orderCursor][curOrder]=((e->curOrders->ord[orderCursor][curOrder]<<4)|num); + }); + MARK_MODIFIED; + curNibble=!curNibble; + if (orderEditMode==2 || orderEditMode==3) { + if (!curNibble) { + if (orderEditMode==2) { + orderCursor++; + if (orderCursor>=e->getTotalChannelCount()) orderCursor=0; + } else if (orderEditMode==3) { + if (curOrdercurSubSong->ordersLen-1) { + setOrder(curOrder+1); + } + } + } + } + e->walkSong(loopOrder,loopRow,loopEnd); + makeUndo(GUI_UNDO_CHANGE_ORDER); + } +} + #define changeLatch(x) \ if (x<0) x=0; \ if (!latchNibble && !settings.pushNibble) x=0; \ @@ -1529,29 +1555,7 @@ void FurnaceGUI::keyDown(SDL_Event& ev) { auto it=valueKeys.find(ev.key.keysym.sym); if (it!=valueKeys.cend()) { int num=it->second; - if (orderCursor>=0 && orderCursorgetTotalChannelCount()) { - prepareUndo(GUI_UNDO_CHANGE_ORDER); - e->lockSave([this,num]() { - if (!curNibble && !settings.pushNibble) e->curOrders->ord[orderCursor][curOrder]=0; - e->curOrders->ord[orderCursor][curOrder]=((e->curOrders->ord[orderCursor][curOrder]<<4)|num); - }); - MARK_MODIFIED; - curNibble=!curNibble; - if (orderEditMode==2 || orderEditMode==3) { - if (!curNibble) { - if (orderEditMode==2) { - orderCursor++; - if (orderCursor>=e->getTotalChannelCount()) orderCursor=0; - } else if (orderEditMode==3) { - if (curOrdercurSubSong->ordersLen-1) { - setOrder(curOrder+1); - } - } - } - } - e->walkSong(loopOrder,loopRow,loopEnd); - makeUndo(GUI_UNDO_CHANGE_ORDER); - } + orderInput(num); } } break; @@ -2246,6 +2250,8 @@ int FurnaceGUI::load(String path) { showWarning(e->getWarnings(),GUI_WARN_GENERIC); } pushRecentFile(path); + // walk song + e->walkSong(loopOrder,loopRow,loopEnd); // do not auto-play a backup if (path.find(backupPath)!=0) { if (settings.playOnLoad==2 || (settings.playOnLoad==1 && wasPlaying)) { @@ -3776,7 +3782,7 @@ bool FurnaceGUI::loop() { noteInput( msg.data[0]-12, 0, - midiMap.volInput?((int)(pow((double)msg.data[1]/127.0,midiMap.volExp)*127.0)):-1 + midiMap.volInput?msg.data[1]:-1 ); } } else { @@ -3803,7 +3809,7 @@ bool FurnaceGUI::loop() { } break; case TA_MIDI_PROGRAM: - if (midiMap.programChange) { + if (midiMap.programChange && !(midiMap.directChannel && midiMap.directProgram)) { curIns=msg.data[0]; if (curIns>=(int)e->song.ins.size()) curIns=e->song.ins.size()-1; wavePreviewInit=true; @@ -4099,197 +4105,84 @@ bool FurnaceGUI::loop() { openFileDialog(GUI_FILE_SAVE_DMF_LEGACY); } ImGui::Separator(); - if (ImGui::BeginMenu("export audio...")) { - exitDisabledTimer=1; - if (ImGui::MenuItem("one file")) { - openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); + if (settings.exportOptionsLayout==0) { + if (ImGui::BeginMenu("export audio...")) { + drawExportAudio(); + ImGui::EndMenu(); } - if (ImGui::MenuItem("multiple files (one per chip)")) { - openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_SYS); + if (ImGui::BeginMenu("export VGM...")) { + drawExportVGM(); + ImGui::EndMenu(); } - if (ImGui::MenuItem("multiple files (one per channel)")) { - openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_CHANNEL); - } - if (ImGui::InputInt("Loops",&exportLoops,1,2)) { - if (exportLoops<0) exportLoops=0; - } - if (ImGui::InputDouble("Fade out (seconds)",&exportFadeOut,1.0,2.0,"%.1f")) { - if (exportFadeOut<0.0) exportFadeOut=0.0; - } - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("export VGM...")) { - exitDisabledTimer=1; - ImGui::Text("settings:"); - if (ImGui::BeginCombo("format version",fmt::sprintf("%d.%.2x",vgmExportVersion>>8,vgmExportVersion&0xff).c_str())) { - for (int i=0; i<7; i++) { - if (ImGui::Selectable(fmt::sprintf("%d.%.2x",vgmVersions[i]>>8,vgmVersions[i]&0xff).c_str(),vgmExportVersion==vgmVersions[i])) { - vgmExportVersion=vgmVersions[i]; - } - } - ImGui::EndCombo(); - } - ImGui::Checkbox("loop",&vgmExportLoop); - if (vgmExportLoop && e->song.loopModality==2) { - ImGui::Text("loop trail:"); - ImGui::Indent(); - if (ImGui::RadioButton("auto-detect",vgmExportTrailingTicks==-1)) { - vgmExportTrailingTicks=-1; - } - if (ImGui::RadioButton("add one loop",vgmExportTrailingTicks==-2)) { - vgmExportTrailingTicks=-2; - } - if (ImGui::RadioButton("custom",vgmExportTrailingTicks>=0)) { - vgmExportTrailingTicks=0; - } - if (vgmExportTrailingTicks>=0) { - ImGui::SameLine(); - if (ImGui::InputInt("##TrailTicks",&vgmExportTrailingTicks,1,100)) { - if (vgmExportTrailingTicks<0) vgmExportTrailingTicks=0; - } - } - ImGui::Unindent(); - } - ImGui::Checkbox("add pattern change hints",&vgmExportPatternHints); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip( - "inserts data blocks on pattern changes.\n" - "useful if you are writing a playback routine.\n\n" - - "the format of a pattern change data block is:\n" - "67 66 FE ll ll ll ll 01 oo rr pp pp pp ...\n" - "- ll: length, a 32-bit little-endian number\n" - "- oo: order\n" - "- rr: initial row (a 0Dxx effect is able to select a different row)\n" - "- pp: pattern index (one per channel)\n\n" - - "pattern indexes are ordered as they appear in the song." - ); - } - ImGui::Checkbox("direct stream mode",&vgmExportDirectStream); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip( - "required for DualPCM and MSM6258 export.\n\n" - "allows for volume/direction changes when playing samples,\n" - "at the cost of a massive increase in file size." - ); - } - ImGui::Text("chips to export:"); - bool hasOneAtLeast=false; + int numZSMCompat=0; for (int i=0; isong.systemLen; i++) { - int minVersion=e->minVGMVersion(e->song.system[i]); - ImGui::BeginDisabled(minVersion>vgmExportVersion || minVersion==0); - ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),&willExport[i]); - ImGui::EndDisabled(); - if (minVersion>vgmExportVersion) { - if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { - ImGui::SetTooltip("this chip is only available in VGM %d.%.2x and higher!",minVersion>>8,minVersion&0xff); - } - } else if (minVersion==0) { - if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { - ImGui::SetTooltip("this chip is not supported by the VGM format!"); - } - } else { - if (willExport[i]) hasOneAtLeast=true; + if ((e->song.system[i]==DIV_SYSTEM_VERA) || (e->song.system[i]==DIV_SYSTEM_YM2151)) numZSMCompat++; + } + if (numZSMCompat>0) { + if (ImGui::BeginMenu("export ZSM...")) { + drawExportZSM(); + ImGui::EndMenu(); } } - ImGui::Text("select the chip you wish to export,"); - ImGui::Text("but only up to %d of each type.",(vgmExportVersion>=0x151)?2:1); - if (hasOneAtLeast) { - if (ImGui::MenuItem("click to export")) { - openFileDialog(GUI_FILE_EXPORT_VGM); - } - } else { - ImGui::Text("nothing to export"); + int numAmiga=0; + for (int i=0; isong.systemLen; i++) { + if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++; } - ImGui::EndMenu(); - } - int numZSMCompat=0; - for (int i=0; isong.systemLen; i++) { - if ((e->song.system[i] == DIV_SYSTEM_VERA) || (e->song.system[i] == DIV_SYSTEM_YM2151)) numZSMCompat++; - } - if (numZSMCompat > 0) { - if (ImGui::BeginMenu("export ZSM...")) { - exitDisabledTimer=1; - ImGui::Text("Commander X16 Zsound Music File"); - if (ImGui::InputInt("Tick Rate (Hz)",&zsmExportTickRate,1,10)) { - if (zsmExportTickRate<1) zsmExportTickRate=1; - if (zsmExportTickRate>44100) zsmExportTickRate=44100; - } - ImGui::Checkbox("loop",&zsmExportLoop); - ImGui::SameLine(); - ImGui::Checkbox("optimize size",&zsmExportOptimize); - ImGui::SameLine(); - if (ImGui::Button("Begin Export")) { - openFileDialog(GUI_FILE_EXPORT_ZSM); - ImGui::CloseCurrentPopup(); + if (numAmiga && settings.iCannotWait) { + if (ImGui::BeginMenu("export Amiga validation data...")) { + drawExportAmigaVal(); + ImGui::EndMenu(); } + } + if (ImGui::BeginMenu("export text...")) { + drawExportText(); ImGui::EndMenu(); } - } - int numAmiga=0; - for (int i=0; isong.systemLen; i++) { - if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++; - } - if (numAmiga && settings.iCannotWait) { - if (ImGui::BeginMenu("export Amiga validation data...")) { - exitDisabledTimer=1; - ImGui::Text( - "this is NOT ROM export! only use for making sure the\n" - "Furnace Amiga emulator is working properly by\n" - "comparing it with real Amiga output." - ); - ImGui::AlignTextToFramePadding(); - ImGui::Text("Directory"); - ImGui::SameLine(); - ImGui::InputText("##AVDPath",&workingDirROMExport); - if (ImGui::Button("Bake Data")) { - std::vector out=e->buildROM(DIV_ROM_AMIGA_VALIDATION); - if (workingDirROMExport.size()>0) { - if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR; - } - for (DivROMExportOutput& i: out) { - String path=workingDirROMExport+i.name; - FILE* outFile=ps_fopen(path.c_str(),"wb"); - if (outFile!=NULL) { - fwrite(i.data->getFinalBuf(),1,i.data->size(),outFile); - fclose(outFile); - } - i.data->finish(); - delete i.data; - } - showError(fmt::sprintf("Done! Baked %d files.",(int)out.size())); - ImGui::CloseCurrentPopup(); - } + if (ImGui::BeginMenu("export command stream...")) { + drawExportCommand(); ImGui::EndMenu(); } - } - if (ImGui::BeginMenu("export text...")) { - exitDisabledTimer=1; - ImGui::Text( - "this option exports the song to a text file.\n" - ); - if (ImGui::Button("export")) { - openFileDialog(GUI_FILE_EXPORT_TEXT); + } else if (settings.exportOptionsLayout==2) { + if (ImGui::MenuItem("export audio...")) { + curExportType=GUI_EXPORT_AUDIO; + displayExport=true; } - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("export command stream...")) { - exitDisabledTimer=1; - ImGui::Text( - "this option exports a text or binary file which\n" - "contains a dump of the internal command stream\n" - "produced when playing the song.\n\n" - - "technical/development use only!" - ); - if (ImGui::Button("export (binary)")) { - openFileDialog(GUI_FILE_EXPORT_CMDSTREAM_BINARY); + if (ImGui::MenuItem("export VGM...")) { + curExportType=GUI_EXPORT_VGM; + displayExport=true; } - if (ImGui::Button("export (text)")) { - openFileDialog(GUI_FILE_EXPORT_CMDSTREAM); + int numZSMCompat=0; + for (int i=0; isong.systemLen; i++) { + if ((e->song.system[i]==DIV_SYSTEM_VERA) || (e->song.system[i]==DIV_SYSTEM_YM2151)) numZSMCompat++; + } + if (numZSMCompat>0) { + if (ImGui::MenuItem("export ZSM...")) { + curExportType=GUI_EXPORT_ZSM; + displayExport=true; + } + } + int numAmiga=0; + for (int i=0; isong.systemLen; i++) { + if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++; + } + if (numAmiga && settings.iCannotWait) { + if (ImGui::MenuItem("export Amiga validation data...")) { + curExportType=GUI_EXPORT_AMIGA_VAL; + displayExport=true; + } + } + if (ImGui::MenuItem("export text...")) { + curExportType=GUI_EXPORT_TEXT; + displayExport=true; + } + if (ImGui::MenuItem("export command stream...")) { + curExportType=GUI_EXPORT_CMD_STREAM; + displayExport=true; + } + } else { + if (ImGui::MenuItem("export...",BIND_FOR(GUI_ACTION_EXPORT))) { + displayExport=true; } - ImGui::EndMenu(); } ImGui::Separator(); if (!settings.classicChipOptions) { @@ -4629,6 +4522,7 @@ bool FurnaceGUI::loop() { ordersOpen=true; curWindow=GUI_WINDOW_ORDERS; MEASURE(orders,drawOrders()); + MEASURE(piano,drawPiano()); break; case GUI_SCENE_INSTRUMENT: insEditOpen=true; @@ -5485,6 +5379,11 @@ bool FurnaceGUI::loop() { } } + if (displayExport) { + displayExport=false; + ImGui::OpenPopup("Export"); + } + if (displayEditString) { ImGui::OpenPopup("EditString"); } @@ -5526,6 +5425,12 @@ bool FurnaceGUI::loop() { ImGui::EndPopup(); } + if (ImGui::BeginPopupModal("Export",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5)); + drawExport(); + ImGui::EndPopup(); + } + centerNextWindow("Error",canvasW,canvasH); if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Text("%s",errorString.c_str()); @@ -6083,6 +5988,15 @@ bool FurnaceGUI::loop() { pendingRawSampleBigEndian=false; } + ImGui::AlignTextToFramePadding(); + ImGui::Text("Sample rate"); + ImGui::SameLine(); + ImGui::SetNextItemWidth(120.0f*dpiScale); + if (ImGui::InputInt("##RSRate",&pendingRawSampleRate,100,1000)) { + if (pendingRawSampleRate<100) pendingRawSampleRate=100; + if (pendingRawSampleRate>384000) pendingRawSampleRate=384000; + } + if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_8BIT || pendingRawSampleDepth==DIV_SAMPLE_DEPTH_16BIT) { ImGui::AlignTextToFramePadding(); ImGui::Text("Channels"); @@ -6128,7 +6042,7 @@ bool FurnaceGUI::loop() { } if (ImGui::Button("OK")) { - DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian,pendingRawSampleUnsigned,pendingRawSampleSwapNibbles); + DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian,pendingRawSampleUnsigned,pendingRawSampleSwapNibbles,pendingRawSampleRate); if (s==NULL) { showError(e->getLastError()); } else { @@ -7018,6 +6932,7 @@ bool FurnaceGUI::init() { return -2; } + if (midiMap.directChannel && midiMap.directProgram) return -1; return curIns; }); @@ -7319,6 +7234,7 @@ FurnaceGUI::FurnaceGUI(): editString(NULL), pendingRawSampleDepth(8), pendingRawSampleChannels(1), + pendingRawSampleRate(32000), pendingRawSampleUnsigned(false), pendingRawSampleBigEndian(false), pendingRawSampleSwapNibbles(false), @@ -7726,7 +7642,9 @@ FurnaceGUI::FurnaceGUI(): introSkipDo(false), introStopped(false), curTutorial(-1), - curTutorialStep(0) { + curTutorialStep(0), + audioExportType(0), + curExportType(GUI_EXPORT_NONE) { // value keys valueKeys[SDLK_0]=0; valueKeys[SDLK_1]=1; diff --git a/src/gui/gui.h b/src/gui/gui.h index b379ee743..3227efede 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -101,6 +101,7 @@ enum FurnaceGUIColors { GUI_COLOR_MODAL_BACKDROP, GUI_COLOR_HEADER, GUI_COLOR_TEXT, + GUI_COLOR_TEXT_DISABLED, GUI_COLOR_ACCENT_PRIMARY, GUI_COLOR_ACCENT_SECONDARY, GUI_COLOR_TITLE_INACTIVE, @@ -124,6 +125,36 @@ enum FurnaceGUIColors { GUI_COLOR_NAV_HIGHLIGHT, GUI_COLOR_NAV_WIN_HIGHLIGHT, GUI_COLOR_NAV_WIN_BACKDROP, + GUI_COLOR_PLOT_LINES, + GUI_COLOR_PLOT_LINES_HOVER, + GUI_COLOR_PLOT_HISTOGRAM, + GUI_COLOR_PLOT_HISTOGRAM_HOVER, + + GUI_COLOR_BUTTON, + GUI_COLOR_BUTTON_HOVER, + GUI_COLOR_BUTTON_ACTIVE, + GUI_COLOR_TAB, + GUI_COLOR_TAB_HOVER, + GUI_COLOR_TAB_ACTIVE, + GUI_COLOR_TAB_UNFOCUSED, + GUI_COLOR_TAB_UNFOCUSED_ACTIVE, + GUI_COLOR_IMGUI_HEADER, + GUI_COLOR_IMGUI_HEADER_HOVER, + GUI_COLOR_IMGUI_HEADER_ACTIVE, + GUI_COLOR_RESIZE_GRIP, + GUI_COLOR_RESIZE_GRIP_HOVER, + GUI_COLOR_RESIZE_GRIP_ACTIVE, + GUI_COLOR_WIDGET_BACKGROUND, + GUI_COLOR_WIDGET_BACKGROUND_HOVER, + GUI_COLOR_WIDGET_BACKGROUND_ACTIVE, + GUI_COLOR_SLIDER_GRAB, + GUI_COLOR_SLIDER_GRAB_ACTIVE, + GUI_COLOR_TITLE_BACKGROUND_ACTIVE, + GUI_COLOR_CHECK_MARK, + GUI_COLOR_TEXT_SELECTION, + GUI_COLOR_TABLE_ROW_EVEN, + GUI_COLOR_TABLE_ROW_ODD, + GUI_COLOR_TOGGLE_OFF, GUI_COLOR_TOGGLE_ON, GUI_COLOR_EDITING, @@ -259,6 +290,7 @@ enum FurnaceGUIColors { GUI_COLOR_INSTR_TED, GUI_COLOR_INSTR_C140, GUI_COLOR_INSTR_C219, + GUI_COLOR_INSTR_ESFM, GUI_COLOR_INSTR_UNKNOWN, GUI_COLOR_CHANNEL_BG, @@ -437,6 +469,21 @@ enum FurnaceGUIMobileScenes { GUI_SCENE_OTHER, }; +enum FurnaceGUISettingGroups: unsigned int { + GUI_SETTINGS_GENERAL=1, + GUI_SETTINGS_AUDIO=2, + GUI_SETTINGS_MIDI=4, + GUI_SETTINGS_KEYBOARD=8, + GUI_SETTINGS_BEHAVIOR=16, + GUI_SETTINGS_FONT=32, + GUI_SETTINGS_APPEARANCE=64, + GUI_SETTINGS_LAYOUTS=128, + GUI_SETTINGS_COLOR=256, + GUI_SETTINGS_EMULATION=512, + + GUI_SETTINGS_ALL=0xffffffff +}; + enum FurnaceGUIFileDialogs { GUI_FILE_OPEN, GUI_FILE_OPEN_BACKUP, @@ -504,6 +551,17 @@ enum FurnaceGUIWarnings { GUI_WARN_GENERIC }; +enum FurnaceGUIExportTypes { + GUI_EXPORT_NONE=-1, + + GUI_EXPORT_AUDIO=0, + GUI_EXPORT_VGM, + GUI_EXPORT_ZSM, + GUI_EXPORT_CMD_STREAM, + GUI_EXPORT_AMIGA_VAL, + GUI_EXPORT_TEXT +}; + enum FurnaceGUIFMAlgs { FM_ALGS_4OP, FM_ALGS_2OP_OPL, @@ -517,6 +575,7 @@ enum FurnaceGUIActions { GUI_ACTION_OPEN_BACKUP, GUI_ACTION_SAVE, GUI_ACTION_SAVE_AS, + GUI_ACTION_EXPORT, GUI_ACTION_UNDO, GUI_ACTION_REDO, GUI_ACTION_PLAY_TOGGLE, @@ -827,6 +886,14 @@ struct SelectionPoint { xCoarse(0), xFine(0), y(0) {} }; +struct UndoRegion { + struct UndoRegionPoint { + int ord, x, y; + UndoRegionPoint(): + ord(0), x(0), y(0) {} + } begin, end; +}; + enum ActionType { GUI_UNDO_CHANGE_ORDER, GUI_UNDO_PATTERN_EDIT, @@ -936,7 +1003,7 @@ struct MIDIMap { int**** map; std::vector binds; - bool noteInput, volInput, rawVolume, polyInput, directChannel, programChange, midiClock, midiTimeCode, yamahaFMResponse; + bool noteInput, volInput, rawVolume, polyInput, directChannel, programChange, midiClock, midiTimeCode, yamahaFMResponse, directProgram; // 0: disabled // // 1: C- C# D- D# E- F- F# G- G# A- A# B- @@ -999,11 +1066,12 @@ struct MIDIMap { midiClock(false), midiTimeCode(false), yamahaFMResponse(false), + directProgram(false), valueInputStyle(1), valueInputControlMSB(0), valueInputControlLSB(0), valueInputControlSingle(0), - volExp(1.0f), + volExp(2.0f), valueInputCurMSB(0), valueInputCurLSB(0), valueInputCurSingle(0) { @@ -1177,8 +1245,10 @@ struct FurnaceGUIMacroDesc { bool isBitfield, blockMode, bit30; String (*hoverFunc)(int,float,void*); void* hoverFuncUser; + bool isArp; + bool isPitch; - FurnaceGUIMacroDesc(const char* name, DivInstrumentMacro* m, int macroMin, int macroMax, float macroHeight, ImVec4 col=ImVec4(1.0f,1.0f,1.0f,1.0f), bool block=false, const char* mName=NULL, String (*hf)(int,float,void*)=NULL, bool bitfield=false, const char** bfVal=NULL, unsigned int bitOff=0, bool bit30Special=false, void* hfu=NULL): + FurnaceGUIMacroDesc(const char* name, DivInstrumentMacro* m, int macroMin, int macroMax, float macroHeight, ImVec4 col=ImVec4(1.0f,1.0f,1.0f,1.0f), bool block=false, const char* mName=NULL, String (*hf)(int,float,void*)=NULL, bool bitfield=false, const char** bfVal=NULL, unsigned int bitOff=0, bool bit30Special=false, void* hfu=NULL, bool isArp=false, bool isPitch=false): macro(m), height(macroHeight), displayName(name), @@ -1190,7 +1260,9 @@ struct FurnaceGUIMacroDesc { blockMode(block), bit30(bit30Special), hoverFunc(hf), - hoverFuncUser(hfu) { + hoverFuncUser(hfu), + isArp(isArp), + isPitch(isPitch) { // MSVC -> hell this->min=macroMin; this->max=macroMax; @@ -1387,7 +1459,7 @@ class FurnaceGUI { bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList; bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed; bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu; - bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly, notifyWaveChange; + bool displayNew, displayExport, fullScreen, preserveChanPos, wantScrollList, noteInputPoly, notifyWaveChange; bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString; bool mobileEdit; bool killGraphics; @@ -1420,11 +1492,12 @@ class FurnaceGUI { void* fmPreviewOPLL; void* fmPreviewOPZ; void* fmPreviewOPZInterface; + void* fmPreviewESFM; String* editString; SDL_Event userEvent; String pendingRawSample; - int pendingRawSampleDepth, pendingRawSampleChannels; + int pendingRawSampleDepth, pendingRawSampleChannels, pendingRawSampleRate; bool pendingRawSampleUnsigned, pendingRawSampleBigEndian, pendingRawSampleSwapNibbles, pendingRawSampleReplace; ImGuiWindowFlags globalWinFlags; @@ -1546,6 +1619,8 @@ class FurnaceGUI { int roundedWindows; int roundedButtons; int roundedMenus; + int roundedTabs; + int roundedScrollbars; int loadJapanese; int loadChinese; int loadChineseTraditional; @@ -1642,6 +1717,7 @@ class FurnaceGUI { int centerPopup; int insIconsStyle; int classicChipOptions; + int exportOptionsLayout; int wasapiEx; int chanOscThreads; int renderPoolThreads; @@ -1654,6 +1730,7 @@ class FurnaceGUI { int fontAutoHint; int fontAntiAlias; int selectAssetOnLoad; + int basicColors; unsigned int maxUndoSteps; String mainFontPath; String headFontPath; @@ -1742,6 +1819,8 @@ class FurnaceGUI { roundedWindows(1), roundedButtons(1), roundedMenus(0), + roundedTabs(1), + roundedScrollbars(1), loadJapanese(0), loadChinese(0), loadChineseTraditional(0), @@ -1837,11 +1916,12 @@ class FurnaceGUI { centerPopup(1), insIconsStyle(1), classicChipOptions(0), + exportOptionsLayout(1), wasapiEx(0), chanOscThreads(0), renderPoolThreads(0), showPool(0), - writeInsNames(1), + writeInsNames(0), readInsNames(1), fontBackend(1), fontHinting(0), @@ -1849,6 +1929,7 @@ class FurnaceGUI { fontAutoHint(1), fontAntiAlias(1), selectAssetOnLoad(1), + basicColors(1), maxUndoSteps(100), mainFontPath(""), headFontPath(""), @@ -2243,7 +2324,7 @@ class FurnaceGUI { int pianoOffset, pianoOffsetEdit; int pianoView, pianoInputPadMode; - //effect sorting + // effect sorting bool effectsShow[10]; // TX81Z @@ -2283,9 +2364,21 @@ class FurnaceGUI { // tutorial int curTutorial, curTutorialStep; + // export options + int audioExportType; + FurnaceGUIExportTypes curExportType; + + void drawExportAudio(bool onWindow=false); + void drawExportVGM(bool onWindow=false); + void drawExportZSM(bool onWindow=false); + void drawExportAmigaVal(bool onWindow=false); + void drawExportText(bool onWindow=false); + void drawExportCommand(bool onWindow=false); + void drawSSGEnv(unsigned char type, const ImVec2& size); void drawWaveform(unsigned char type, bool opz, const ImVec2& size); void drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, const ImVec2& size); + void drawESFMAlgorithm(DivInstrumentESFM& esfm, const ImVec2& size); void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, unsigned char egt, unsigned char algOrGlobalSus, float maxTl, float maxArDr, float maxRr, const ImVec2& size, unsigned short instType); void drawGBEnv(unsigned char vol, unsigned char len, unsigned char sLen, bool dir, const ImVec2& size); bool drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& flags, bool modifyOnChange, bool fromMenu=false); @@ -2297,6 +2390,7 @@ class FurnaceGUI { void renderFMPreviewOPLL(const DivInstrumentFM& params, int pos=0); void renderFMPreviewOPL(const DivInstrumentFM& params, int pos=0); void renderFMPreviewOPZ(const DivInstrumentFM& params, int pos=0); + void renderFMPreviewESFM(const DivInstrumentFM& params, const DivInstrumentESFM& esfmParams, int pos=0); // these ones offer ctrl-wheel fine value changes. bool CWSliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format=NULL, ImGuiSliderFlags flags=0); @@ -2394,6 +2488,7 @@ class FurnaceGUI { void drawSettings(); void drawDebug(); void drawNewSong(); + void drawExport(); void drawLog(); void drawEffectList(); void drawSubSongs(bool asChild=false); @@ -2419,6 +2514,9 @@ class FurnaceGUI { void resetColors(); void resetKeybinds(); + void readConfig(DivConfig& conf, FurnaceGUISettingGroups groups=GUI_SETTINGS_ALL); + void writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups=GUI_SETTINGS_ALL); + void syncSettings(); void commitSettings(); void syncTutorial(); @@ -2469,6 +2567,7 @@ class FurnaceGUI { DivSystem systemPicker(); void noteInput(int num, int key, int vol=-1); void valueInput(int num, bool direct=false, int target=-1); + void orderInput(int num); void doGenerateWave(); diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 9761af578..f48b8b906 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -175,6 +175,7 @@ const char* insTypes[DIV_INS_MAX+1][3]={ {"TED",ICON_FA_BAR_CHART,ICON_FUR_INS_TED}, {"C140",ICON_FA_VOLUME_UP,ICON_FUR_INS_C140}, {"C219",ICON_FA_VOLUME_UP,ICON_FUR_INS_C219}, + {"FM (ESFM)",ICON_FA_AREA_CHART,ICON_FUR_INS_ESFM}, {NULL,ICON_FA_QUESTION,ICON_FA_QUESTION} }; @@ -515,7 +516,7 @@ const FurnaceGUIColors fxColors[256]={ GUI_COLOR_PATTERN_EFFECT_VOLUME, // F4 GUI_COLOR_PATTERN_EFFECT_MISC, // F5 GUI_COLOR_PATTERN_EFFECT_MISC, // F6 - GUI_COLOR_PATTERN_EFFECT_INVALID, // F7 + GUI_COLOR_PATTERN_EFFECT_MISC, // F7 GUI_COLOR_PATTERN_EFFECT_VOLUME, // F8 GUI_COLOR_PATTERN_EFFECT_VOLUME, // F9 GUI_COLOR_PATTERN_EFFECT_VOLUME, // FA @@ -537,6 +538,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("OPEN_BACKUP", "Restore backup", 0), D("SAVE", "Save file", FURKMOD_CMD|SDLK_s), D("SAVE_AS", "Save as", FURKMOD_CMD|FURKMOD_SHIFT|SDLK_s), + D("EXPORT", "Export", 0), D("UNDO", "Undo", FURKMOD_CMD|SDLK_z), #ifdef __APPLE__ D("REDO", "Redo", FURKMOD_CMD|FURKMOD_SHIFT|SDLK_z), @@ -794,6 +796,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_MODAL_BACKDROP,"",ImVec4(0.0f,0.0f,0.0f,0.55f)), D(GUI_COLOR_HEADER,"",ImVec4(0.2f,0.2f,0.2f,1.0f)), D(GUI_COLOR_TEXT,"",ImVec4(1.0f,1.0f,1.0f,1.0f)), + D(GUI_COLOR_TEXT_DISABLED,"",ImVec4(0.5f,0.5f,0.5f,1.0f)), D(GUI_COLOR_ACCENT_PRIMARY,"",ImVec4(0.06f,0.53f,0.98f,1.0f)), D(GUI_COLOR_ACCENT_SECONDARY,"",ImVec4(0.26f,0.59f,0.98f,1.0f)), D(GUI_COLOR_TITLE_INACTIVE,"",ImVec4(0.04f,0.04f,0.04f,1.0f)), @@ -817,6 +820,36 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_NAV_HIGHLIGHT,"",ImVec4(0.26f,0.59f,0.98f,1.0f)), D(GUI_COLOR_NAV_WIN_HIGHLIGHT,"",ImVec4(1.0f,1.0f,1.0f,0.7f)), D(GUI_COLOR_NAV_WIN_BACKDROP,"",ImVec4(0.8f,0.8f,0.8f,0.2f)), + D(GUI_COLOR_PLOT_LINES,"",ImVec4(0.61f,0.61f,0.61f,1.0f)), + D(GUI_COLOR_PLOT_LINES_HOVER,"",ImVec4(1.00f,0.43f,0.35f,1.00f)), + D(GUI_COLOR_PLOT_HISTOGRAM,"",ImVec4(0.0f,0.9f,1.0f,1.0f)), + D(GUI_COLOR_PLOT_HISTOGRAM_HOVER,"",ImVec4(0.0f,0.9f,1.0f,1.0f)), + + D(GUI_COLOR_BUTTON,"",ImVec4(0.085f,0.216f,0.343f,1.0f)), + D(GUI_COLOR_BUTTON_HOVER,"",ImVec4(0.075f,0.287f,0.49f,1.0f)), + D(GUI_COLOR_BUTTON_ACTIVE,"",ImVec4(0.06f,0.53f,0.98f,1.0f)), + D(GUI_COLOR_TAB,"",ImVec4(0.085f,0.216f,0.343f,1.0f)), + D(GUI_COLOR_TAB_HOVER,"",ImVec4(0.165f,0.313f,0.49f,1.0f)), + D(GUI_COLOR_TAB_ACTIVE,"",ImVec4(0.25f,0.47f,0.735f,1.0f)), + D(GUI_COLOR_TAB_UNFOCUSED,"",ImVec4(0.085f,0.216f,0.343f,1.0f)), + D(GUI_COLOR_TAB_UNFOCUSED_ACTIVE,"",ImVec4(0.075f,0.287f,0.49f,1.0f)), + D(GUI_COLOR_IMGUI_HEADER,"",ImVec4(0.083f,0.156f,0.245f,1.0f)), + D(GUI_COLOR_IMGUI_HEADER_HOVER,"",ImVec4(0.165f,0.313f,0.49f,1.0f)), + D(GUI_COLOR_IMGUI_HEADER_ACTIVE,"",ImVec4(0.26f,0.59f,0.98f,1.0f)), + D(GUI_COLOR_RESIZE_GRIP,"",ImVec4(0.083f,0.156f,0.245f,1.0f)), + D(GUI_COLOR_RESIZE_GRIP_HOVER,"",ImVec4(0.165f,0.313f,0.49f,1.0f)), + D(GUI_COLOR_RESIZE_GRIP_ACTIVE,"",ImVec4(0.26f,0.59f,0.98f,1.0f)), + D(GUI_COLOR_WIDGET_BACKGROUND,"",ImVec4(0.083f,0.156f,0.245f,1.0f)), + D(GUI_COLOR_WIDGET_BACKGROUND_HOVER,"",ImVec4(0.165f,0.313f,0.49f,1.0f)), + D(GUI_COLOR_WIDGET_BACKGROUND_ACTIVE,"",ImVec4(0.26f,0.59f,0.98f,1.0f)), + D(GUI_COLOR_SLIDER_GRAB,"",ImVec4(0.06f,0.53f,0.98f,1.0f)), + D(GUI_COLOR_SLIDER_GRAB_ACTIVE,"",ImVec4(0.06f,0.53f,0.98f,1.0f)), + D(GUI_COLOR_TITLE_BACKGROUND_ACTIVE,"",ImVec4(0.085f,0.216f,0.343f,1.0f)), + D(GUI_COLOR_CHECK_MARK,"",ImVec4(0.06f,0.53f,0.98f,1.0f)), + D(GUI_COLOR_TEXT_SELECTION,"",ImVec4(0.165f,0.313f,0.49f,1.0f)), + D(GUI_COLOR_TABLE_ROW_EVEN,"",ImVec4(0.0f,0.0f,0.0f,0.0f)), + D(GUI_COLOR_TABLE_ROW_ODD,"",ImVec4(1.0f,1.0f,1.0f,0.06f)), + D(GUI_COLOR_TOGGLE_OFF,"",ImVec4(0.2f,0.2f,0.2f,1.0f)), D(GUI_COLOR_TOGGLE_ON,"",ImVec4(0.2f,0.6f,0.2f,1.0f)), D(GUI_COLOR_EDITING,"",ImVec4(0.2f,0.1f,0.1f,1.0f)), @@ -952,6 +985,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_INSTR_TED,"",ImVec4(0.7f,0.6f,1.0f,1.0f)), D(GUI_COLOR_INSTR_C140,"",ImVec4(1.0f,1.0f,0.0f,1.0f)), D(GUI_COLOR_INSTR_C219,"",ImVec4(1.0f,0.8f,0.0f,1.0f)), + D(GUI_COLOR_INSTR_ESFM,"",ImVec4(0.1f,0.9f,1.0f,1.0f)), D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)), D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)), @@ -1167,6 +1201,7 @@ const int availableSystems[]={ DIV_SYSTEM_C140, DIV_SYSTEM_C219, DIV_SYSTEM_PCM_DAC, + DIV_SYSTEM_ESFM, DIV_SYSTEM_PONG, 0 // don't remove this last one! }; @@ -1202,6 +1237,7 @@ const int chipsFM[]={ DIV_SYSTEM_OPL3, DIV_SYSTEM_OPL3_DRUMS, DIV_SYSTEM_OPZ, + DIV_SYSTEM_ESFM, 0 // don't remove this last one! }; diff --git a/src/gui/guiConst.h b/src/gui/guiConst.h index 0695a6013..4456ebd3c 100644 --- a/src/gui/guiConst.h +++ b/src/gui/guiConst.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/image.cpp b/src/gui/image.cpp index a5c7baec3..a31c1dd9f 100644 --- a/src/gui/image.cpp +++ b/src/gui/image.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/image.h b/src/gui/image.h index d4c0bf6a5..39fcf6cf4 100644 --- a/src/gui/image.h +++ b/src/gui/image.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 3e2eb578d..e96d1b64e 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,18 @@ const char* fmParamNames[3][32]={ {"ALG", "FB", "FMS/PMS", "AMS", "AR", "DR", "D2R", "RR", "SL", "TL", "RS", "MULT", "DT", "DT2", "SSG-EG", "AM", "DAM", "DVB", "EGT", "EGS", "KSL", "SUS", "VIB", "WS", "KSR", "DC", "DM", "EGS", "REV", "Fine", "FMS/PMS2", "AMS2"} }; +const char* esfmParamLongNames[9]={ + "OP4 Noise Mode", "Envelope Delay", "Output Level", "Modulation Input Level", "Left Output", "Right Output", "Coarse Tune (semitones)", "Detune", "Fixed Frequency Mode" +}; + +const char* esfmParamNames[9]={ + "OP4 Noise Mode", "Env. Delay", "Output Level", "ModInput", "Left", "Right", "Tune", "Detune", "Fixed" +}; + +const char* esfmParamShortNames[9]={ + "NOI", "DL", "OL", "MI", "L", "R", "CT", "DT", "FIX" +}; + const char* fmParamShortNames[3][32]={ {"ALG", "FB", "FMS", "AMS", "A", "D", "D2", "R", "S", "TL", "RS", "ML", "DT", "DT2", "SSG", "AM", "DAM", "DVB", "SUS", "SUS", "KSL", "SUS", "VIB", "WS", "KSR", "DC", "DM", "EGS", "REV", "Fine", "FMS2", "AMS2"}, {"ALG", "FB", "FMS", "AMS", "A", "D", "SR", "R", "S", "TL", "KS", "ML", "DT", "DT2", "SSG", "AM", "AMD", "FMD", "EGT", "EGT", "KSL", "SUS", "VIB", "WS", "KSR", "DC", "DM", "EGS", "REV", "Fine", "FMS2", "AMS2"}, @@ -154,6 +166,14 @@ const char* oplDrumNames[4]={ "Snare", "Tom", "Top", "HiHat" }; +const char* esfmNoiseModeNames[4]={ + "Normal", "Snare", "HiHat", "Top" +}; + +const char* esfmNoiseModeDescriptions[4]={ + "Noise disabled", "Square + noise", "Ringmod from OP3 + noise", "Ringmod from OP3 + double pitch ModInput\nWARNING - has emulation issues, subject to change" +}; + const bool opIsOutput[8][4]={ {false,false,false,true}, {false,false,false,true}, @@ -207,8 +227,23 @@ enum FMParams { FM_AMS2=31 }; +enum ESFMParams { + ESFM_NOISE=0, + ESFM_DELAY=1, + ESFM_OUTLVL=2, + ESFM_MODIN=3, + ESFM_LEFT=4, + ESFM_RIGHT=5, + ESFM_CT=6, + ESFM_DT=7, + ESFM_FIXED=8 +}; + #define FM_NAME(x) fmParamNames[settings.fmNames][x] #define FM_SHORT_NAME(x) fmParamShortNames[settings.fmNames][x] +#define ESFM_LONG_NAME(x) (esfmParamLongNames[x]) +#define ESFM_NAME(x) (esfmParamNames[x]) +#define ESFM_SHORT_NAME(x) (esfmParamShortNames[x]) const char* macroTypeLabels[4]={ ICON_FA_BAR_CHART "##IMacroType", @@ -1144,6 +1179,110 @@ void FurnaceGUI::drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, cons } } +void FurnaceGUI::drawESFMAlgorithm(DivInstrumentESFM& esfm, const ImVec2& size) { + ImDrawList* dl=ImGui::GetWindowDrawList(); + ImGuiWindow* window=ImGui::GetCurrentWindow(); + + ImVec2 minArea=window->DC.CursorPos; + ImVec2 maxArea=ImVec2( + minArea.x+size.x, + minArea.y+size.y + ); + ImRect rect=ImRect(minArea,maxArea); + ImGuiStyle& style=ImGui::GetStyle(); + ImU32 colorM=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_MOD]); + ImU32 colorC=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_CAR]); + ImU32 colorsL[8]; + for (int i=0; i<8; i++){ + float alpha=(float)i/7.0f; + ImVec4 color=uiColors[GUI_COLOR_FM_ALG_LINE]; + color.w *= alpha; + colorsL[i]=ImGui::GetColorU32(color); + } + ImGui::ItemSize(size,style.FramePadding.y); + if (ImGui::ItemAdd(rect,ImGui::GetID("alg"))) { + ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ALG_BG]),true,style.FrameRounding); + const float circleRadius=6.0f*dpiScale+1.0f; + //int modFb = esfm.op[0].modIn&7; + int mod12 = esfm.op[1].modIn&7; + int mod23 = esfm.op[2].modIn&7; + int mod34 = esfm.op[3].modIn&7; + int out1 = esfm.op[0].outLvl&7; + int out2 = esfm.op[1].outLvl&7; + int out3 = esfm.op[2].outLvl&7; + int out4 = esfm.op[3].outLvl&7; + bool isMod[4]; + for (int i=0; i<4; i++) { + DivInstrumentESFM::Operator& opE=esfm.op[i]; + isMod[i]=true; + if (opE.outLvl==7) isMod[i]=false; + else if (opE.outLvl>0) { + if (i==3) isMod[i]=false; + else { + DivInstrumentESFM::Operator& opENext=esfm.op[i+1]; + if (opENext.modIn==0) isMod[i]=false; + else if ((opE.outLvl-opENext.modIn)>=2) isMod[i]=false; + } + } + } + + ImVec2 posOp1=ImLerp(rect.Min,rect.Max,ImVec2(0.2f,0.25f)); + ImVec2 posOp2=ImLerp(rect.Min,rect.Max,ImVec2(0.4f,0.25f)); + ImVec2 posOp3=ImLerp(rect.Min,rect.Max,ImVec2(0.6f,0.25f)); + ImVec2 posOp4=ImLerp(rect.Min,rect.Max,ImVec2(0.8f,0.25f)); + ImVec2 posBusbarOp1=ImLerp(rect.Min,rect.Max,ImVec2(0.2f,0.75f)); + ImVec2 posBusbarOp2=ImLerp(rect.Min,rect.Max,ImVec2(0.4f,0.75f)); + ImVec2 posBusbarOp3=ImLerp(rect.Min,rect.Max,ImVec2(0.6f,0.75f)); + ImVec2 posBusbarOp4=ImLerp(rect.Min,rect.Max,ImVec2(0.8f,0.75f)); + + ImVec2 posBusbarStart=ImLerp(rect.Min,rect.Max,ImVec2(0.15f,0.75f)); + ImVec2 posBusbarEnd=ImLerp(rect.Min,rect.Max,ImVec2(0.85f,0.75f)); + bool busbarStartSeen=false; + for (int i=0; i<4; i++) { + DivInstrumentESFM::Operator& opE=esfm.op[i]; + if (opE.outLvl>0) { + if (!busbarStartSeen) { + busbarStartSeen=true; + posBusbarStart=ImLerp(rect.Min,rect.Max,ImVec2(0.15f+0.2f*i,0.75f)); + } + posBusbarEnd=ImLerp(rect.Min,rect.Max,ImVec2(0.25f+0.2f*i,0.75f)); + } + } + + if (mod12) addAALine(dl,posOp1,posOp2,colorsL[mod12]); + if (mod23) addAALine(dl,posOp2,posOp3,colorsL[mod23]); + if (mod34) addAALine(dl,posOp3,posOp4,colorsL[mod34]); + if (out1) addAALine(dl,posOp1,posBusbarOp1,colorsL[out1]); + if (out2) addAALine(dl,posOp2,posBusbarOp2,colorsL[out2]); + if (out3) addAALine(dl,posOp3,posBusbarOp3,colorsL[out3]); + if (out4) addAALine(dl,posOp4,posBusbarOp4,colorsL[out4]); + + addAALine(dl,posBusbarStart,posBusbarEnd,colorsL[2]); + // addAALine(dl,posBusbarEnd,posBusbarEnd+ImVec2(-8.0f*dpiScale,-4.0f*dpiScale),colorsL[2]); + // addAALine(dl,posBusbarEnd,posBusbarEnd+ImVec2(-8.0f*dpiScale,4.0f*dpiScale),colorsL[2]); + // addAALine(dl,posBusbarStart+ImVec2(4.0f*dpiScale,-4.0f*dpiScale),posBusbarStart+ImVec2(4.0f*dpiScale,4.0f*dpiScale),colorsL[2]); + + dl->AddCircle(posOp1,6.0f*dpiScale+1.0f,isMod[0]?colorM:colorC); + dl->AddCircleFilled(posOp1,4.0f*dpiScale+1.0f,isMod[0]?colorM:colorC); + dl->AddCircleFilled(posOp2,4.0f*dpiScale+1.0f,isMod[1]?colorM:colorC); + dl->AddCircleFilled(posOp3,4.0f*dpiScale+1.0f,isMod[2]?colorM:colorC); + dl->AddCircleFilled(posOp4,4.0f*dpiScale+1.0f,isMod[3]?colorM:colorC); + + posOp1.x-=ImGui::CalcTextSize("1").x+circleRadius+3.0f*dpiScale; + posOp2.x-=ImGui::CalcTextSize("2").x+circleRadius+3.0f*dpiScale; + posOp3.x-=ImGui::CalcTextSize("3").x+circleRadius+3.0f*dpiScale; + posOp4.x-=ImGui::CalcTextSize("4").x+circleRadius+3.0f*dpiScale; + posOp1.y-=ImGui::CalcTextSize("1").y*0.5f; + posOp2.y-=ImGui::CalcTextSize("2").y*0.5f; + posOp3.y-=ImGui::CalcTextSize("3").y*0.5f; + posOp4.y-=ImGui::CalcTextSize("4").y*0.5f; + dl->AddText(posOp1,isMod[0]?colorM:colorC,"1"); + dl->AddText(posOp2,isMod[1]?colorM:colorC,"2"); + dl->AddText(posOp3,isMod[2]?colorM:colorC,"3"); + dl->AddText(posOp4,isMod[3]?colorM:colorC,"4"); + } +} + void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, unsigned char egt, unsigned char algOrGlobalSus, float maxTl, float maxArDr, float maxRr, const ImVec2& size, unsigned short instType) { ImDrawList* dl=ImGui::GetWindowDrawList(); ImGuiWindow* window=ImGui::GetCurrentWindow(); @@ -1199,7 +1338,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, //addAALine(dl,pos3,posSLineVEnd,colorS); //draw vert. line through sustain level addAALine(dl,pos1,pos2,color); //A addAALine(dl,pos2,posDecayRate0Pt,color); //Line from A to end of graph - } else if (d2r==0.0 || ((instType==DIV_INS_OPL || instType==DIV_INS_SNES) && sus==1.0) || (instType==DIV_INS_OPLL && egt!=0.0)) { //envelope stays at the sustain level forever + } else if (d2r==0.0 || ((instType==DIV_INS_OPL || instType==DIV_INS_SNES || instType==DIV_INS_ESFM) && sus==1.0) || (instType==DIV_INS_OPLL && egt!=0.0)) { //envelope stays at the sustain level forever dl->AddTriangleFilled(posRStart,posREnd,pos1,colorS); //draw release as shaded triangle behind everything addAALine(dl,pos3,posSLineHEnd,colorR); //draw horiz line through sustain level addAALine(dl,pos3,posSLineVEnd,colorR); //draw vert. line through sustain level @@ -1398,10 +1537,10 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); if (i.macro->vZoom<1) { - if (i.macro->macroType==DIV_MACRO_ARP) { + if (i.macro->macroType==DIV_MACRO_ARP || i.isArp) { i.macro->vZoom=24; i.macro->vScroll=120-12; - } else if (i.macro->macroType==DIV_MACRO_PITCH) { + } else if (i.macro->macroType==DIV_MACRO_PITCH || i.isPitch) { i.macro->vZoom=128; i.macro->vScroll=2048-64; } else { @@ -2298,17 +2437,21 @@ void FurnaceGUI::alterSampleMap(int column, int val) { if (dragItem!=NULL) { \ if (dragItem->IsDataType("FUR_OP")) { \ if (opToMove!=i && opToMove>=0) { \ - int destOp=(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS)?opOrder[i]:i; \ - int sourceOp=(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS)?opOrder[opToMove]:opToMove; \ + int destOp=(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_ESFM)?opOrder[i]:i; \ + int sourceOp=(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_ESFM)?opOrder[opToMove]:opToMove; \ if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \ e->lockEngine([ins,destOp,sourceOp]() { \ ins->fm.op[destOp]=ins->fm.op[sourceOp]; \ + ins->esfm.op[destOp]=ins->esfm.op[sourceOp]; \ }); \ } else { \ e->lockEngine([ins,destOp,sourceOp]() { \ DivInstrumentFM::Operator origOp=ins->fm.op[sourceOp]; \ + DivInstrumentESFM::Operator origOpE=ins->esfm.op[sourceOp]; \ ins->fm.op[sourceOp]=ins->fm.op[destOp]; \ + ins->esfm.op[sourceOp]=ins->esfm.op[destOp]; \ ins->fm.op[destOp]=origOp; \ + ins->esfm.op[destOp]=origOpE; \ }); \ } \ PARAMETER; \ @@ -2824,7 +2967,11 @@ void FurnaceGUI::drawInsEdit() { updateFMPreview=false; } if (settings.insEditColorize) { - pushAccentColors(uiColors[GUI_COLOR_INSTR_STD+ins->type],uiColors[GUI_COLOR_INSTR_STD+ins->type],uiColors[GUI_COLOR_INSTR_STD+ins->type],ImVec4(0.0f,0.0f,0.0f,0.0f)); + if (ins->type>=DIV_INS_MAX) { + pushAccentColors(uiColors[GUI_COLOR_INSTR_UNKNOWN],uiColors[GUI_COLOR_INSTR_UNKNOWN],uiColors[GUI_COLOR_INSTR_UNKNOWN],ImVec4(0.0f,0.0f,0.0f,0.0f)); + } else { + pushAccentColors(uiColors[GUI_COLOR_INSTR_STD+ins->type],uiColors[GUI_COLOR_INSTR_STD+ins->type],uiColors[GUI_COLOR_INSTR_STD+ins->type],ImVec4(0.0f,0.0f,0.0f,0.0f)); + } } if (ImGui::BeginTable("InsProp",3)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); @@ -2885,14 +3032,8 @@ void FurnaceGUI::drawInsEdit() { ImGui::Text("Type"); ImGui::TableNextColumn(); - if (ins->type>=DIV_INS_MAX) ins->type=DIV_INS_FM; int insType=ins->type; ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - /* - if (ImGui::Combo("##Type",&insType,insTypes,DIV_INS_MAX,DIV_INS_MAX)) { - ins->type=(DivInstrumentType)insType; - } - */ bool warnType=true; for (DivInstrumentType i: e->getPossibleInsTypes()) { if (i==insType) { @@ -2901,7 +3042,7 @@ void FurnaceGUI::drawInsEdit() { } pushWarningColor(warnType,warnType && failedNoteOn); - if (ImGui::BeginCombo("##Type",insTypes[insType][0])) { + if (ImGui::BeginCombo("##Type",(insType>=DIV_INS_MAX)?"Unknown":insTypes[insType][0])) { std::vector insTypeList; if (settings.displayAllInsTypes) { for (int i=0; insTypes[i][0]; i++) { @@ -2971,7 +3112,7 @@ void FurnaceGUI::drawInsEdit() { if (ImGui::BeginTabBar("insEditTab")) { std::vector macroList; - if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPM) { + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPM || ins->type==DIV_INS_ESFM) { char label[32]; int opCount=4; if (ins->type==DIV_INS_OPLL) opCount=2; @@ -3005,10 +3146,10 @@ void FurnaceGUI::drawInsEdit() { } } - if (ImGui::BeginTable("fmDetails",3,ImGuiTableFlags_SizingStretchSame)) { - ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); - ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0); - ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.0); + if (ImGui::BeginTable("fmDetails",3,(ins->type==DIV_INS_ESFM)?ImGuiTableFlags_SizingStretchProp:ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,((ins->type==DIV_INS_ESFM)?0.50f:0.0f)); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,((ins->type==DIV_INS_ESFM)?0.15f:0.0f)); + ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,((ins->type==DIV_INS_ESFM)?0.35f:0.0f)); ImGui::TableNextRow(); switch (ins->type) { @@ -3166,6 +3307,23 @@ void FurnaceGUI::drawInsEdit() { } break; } + case DIV_INS_ESFM: { + ImGui::TableNextColumn(); + P(CWSliderScalar(ESFM_LONG_NAME(ESFM_NOISE),ImGuiDataType_U8,&ins->esfm.noise,&_ZERO,&_THREE,esfmNoiseModeNames[ins->esfm.noise&3])); rightClickable + ImGui::TextUnformatted(esfmNoiseModeDescriptions[ins->esfm.noise&3]); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); + if (fmPreviewOn) { + drawFMPreview(ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale)); + if (!fmPreviewPaused) { + renderFMPreview(ins,1); + WAKE_UP; + } + } else { + drawESFMAlgorithm(ins->esfm, ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale)); + } + kvsConfig(ins); + } default: break; } @@ -3256,9 +3414,15 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_OPL ||ins->type==DIV_INS_OPL_DRUMS) numCols=13; if (ins->type==DIV_INS_OPLL) numCols=12; if (ins->type==DIV_INS_OPZ) numCols=19; + if (ins->type==DIV_INS_ESFM) numCols=19; if (ImGui::BeginTable("FMOperators",numCols,ImGuiTableFlags_SizingStretchProp|ImGuiTableFlags_BordersH|ImGuiTableFlags_BordersOuterV)) { // configure columns ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); // op name + if (ins->type==DIV_INS_ESFM) { + ImGui::TableSetupColumn("c0e0",ImGuiTableColumnFlags_WidthStretch,0.05f); // outLvl + ImGui::TableSetupColumn("c0e1",ImGuiTableColumnFlags_WidthFixed); // -separator- + ImGui::TableSetupColumn("c0e2",ImGuiTableColumnFlags_WidthStretch,0.05f); // delay + } ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.05f); // ar ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.05f); // dr ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.05f); // sl @@ -3273,13 +3437,20 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableSetupColumn("c8z0",ImGuiTableColumnFlags_WidthStretch,0.05f); // egs ImGui::TableSetupColumn("c8z1",ImGuiTableColumnFlags_WidthStretch,0.05f); // rev } + if (ins->type==DIV_INS_ESFM) { + ImGui::TableSetupColumn("c8e0",ImGuiTableColumnFlags_WidthStretch,0.05f); // outLvl + } ImGui::TableSetupColumn("c9",ImGuiTableColumnFlags_WidthStretch,0.05f); // mult if (ins->type==DIV_INS_OPZ) { ImGui::TableSetupColumn("c9z",ImGuiTableColumnFlags_WidthStretch,0.05f); // fine } - if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { + if (ins->type==DIV_INS_ESFM) { + ImGui::TableSetupColumn("c9e",ImGuiTableColumnFlags_WidthStretch,0.05f); // ct + } + + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM || ins->type==DIV_INS_ESFM) { ImGui::TableSetupColumn("c10",ImGuiTableColumnFlags_WidthStretch,0.05f); // dt } if (ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { @@ -3296,7 +3467,17 @@ void FurnaceGUI::drawInsEdit() { // header ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); - + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_TEXT(ESFM_SHORT_NAME(ESFM_MODIN)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_MODIN)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_MODIN)); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); + CENTER_TEXT(ESFM_SHORT_NAME(ESFM_DELAY)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_DELAY)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_DELAY)); + } ImGui::TableNextColumn(); CENTER_TEXT(FM_SHORT_NAME(FM_AR)); ImGui::TextUnformatted(FM_SHORT_NAME(FM_AR)); @@ -3352,6 +3533,12 @@ void FurnaceGUI::drawInsEdit() { ImGui::TextUnformatted(FM_SHORT_NAME(FM_REV)); TOOLTIP_TEXT(FM_NAME(FM_REV)); } + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_TEXT(ESFM_SHORT_NAME(ESFM_OUTLVL)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_OUTLVL)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_OUTLVL)); + } ImGui::TableNextColumn(); CENTER_TEXT(FM_SHORT_NAME(FM_MULT)); ImGui::TextUnformatted(FM_SHORT_NAME(FM_MULT)); @@ -3362,6 +3549,12 @@ void FurnaceGUI::drawInsEdit() { ImGui::TextUnformatted(FM_SHORT_NAME(FM_FINE)); TOOLTIP_TEXT(FM_NAME(FM_FINE)); } + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_TEXT(ESFM_SHORT_NAME(ESFM_CT)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_CT)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_CT)); + } ImGui::TableNextColumn(); if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { CENTER_TEXT(FM_SHORT_NAME(FM_DT)); @@ -3369,6 +3562,12 @@ void FurnaceGUI::drawInsEdit() { TOOLTIP_TEXT(FM_NAME(FM_DT)); ImGui::TableNextColumn(); } + if (ins->type==DIV_INS_ESFM) { + CENTER_TEXT(ESFM_SHORT_NAME(ESFM_DT)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_DT)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_DT)); + ImGui::TableNextColumn(); + } if (ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { CENTER_TEXT(FM_SHORT_NAME(FM_DT2)); ImGui::TextUnformatted(FM_SHORT_NAME(FM_DT2)); @@ -3384,7 +3583,7 @@ void FurnaceGUI::drawInsEdit() { ImGui::TextUnformatted("Other"); } ImGui::TableNextColumn(); - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_ESFM) { ImGui::TableNextColumn(); CENTER_TEXT(FM_NAME(FM_WS)); ImGui::TextUnformatted(FM_NAME(FM_WS)); @@ -3400,7 +3599,9 @@ void FurnaceGUI::drawInsEdit() { float sliderHeight=32.0f*dpiScale; for (int i=0; itype!=DIV_INS_OPL_DRUMS)?opOrder[i]:i]; + DivInstrumentFM::Operator& op=fmOrigin.op[(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_ESFM)?opOrder[i]:i]; + DivInstrumentESFM::Operator& opE=ins->esfm.op[i]; + ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -3409,6 +3610,22 @@ void FurnaceGUI::drawInsEdit() { bool mod=true; if (ins->type==DIV_INS_OPL_DRUMS) { mod=false; + } else if (ins->type==DIV_INS_ESFM) { + // this is the same as the KVS heuristic in platform/esfm.h + if (opE.outLvl==7) { + mod=false; + } else if (opE.outLvl>0) { + if (i==3) { + mod=false; + } else { + DivInstrumentESFM::Operator& opENext=ins->esfm.op[i+1]; + if (opENext.modIn==0) { + mod=false; + } else if ((opE.outLvl-opENext.modIn)>=2) { + mod=false; + } + } + } } else if (opCount==4) { if (ins->type==DIV_INS_OPL) { if (opIsOutputOPL[fmOrigin.alg&3][i]) mod=false; @@ -3435,7 +3652,17 @@ void FurnaceGUI::drawInsEdit() { } } - if (i==0) sliderHeight=(ImGui::GetContentRegionAvail().y/opCount)-ImGui::GetStyle().ItemSpacing.y; + if (i==0) { + sliderHeight=(ImGui::GetContentRegionAvail().y/opCount)-ImGui::GetStyle().ItemSpacing.y; + float sliderMinHeightOPL=ImGui::GetFrameHeight()*4.0+ImGui::GetStyle().ItemSpacing.y*3.0; + float sliderMinHeightESFM=ImGui::GetFrameHeight()*5.0+ImGui::GetStyle().ItemSpacing.y*4.0; + if ((ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL) && sliderHeighttype==DIV_INS_ESFM && sliderHeighttype==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { maxTl=63; } int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM)?31:15; @@ -3480,8 +3707,21 @@ void FurnaceGUI::drawInsEdit() { bool ksrOn=op.ksr; bool vibOn=op.vib; bool susOn=op.sus; + bool fixedOn=opE.fixed; unsigned char ssgEnv=op.ssgEnv&7; + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_VSLIDER; + P(CWVSliderScalar("##MODIN",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&opE.modIn,&_ZERO,&_SEVEN)); rightClickable + ImGui::TableNextColumn(); + ImGui::Dummy(ImVec2(4.0f*dpiScale,2.0f*dpiScale)); + ImGui::TableNextColumn(); + opE.delay&=7; + CENTER_VSLIDER; + P(CWVSliderScalar("##DELAY",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&opE.delay,&_ZERO,&_SEVEN)); rightClickable + } + ImGui::TableNextColumn(); op.ar&=maxArDr; CENTER_VSLIDER; @@ -3548,6 +3788,12 @@ void FurnaceGUI::drawInsEdit() { P(CWVSliderScalar("##REV",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&op.dam,&_ZERO,&_SEVEN)); rightClickable } + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_VSLIDER; + P(CWVSliderScalar("##OUTLVL",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&opE.outLvl,&_ZERO,&_SEVEN)); rightClickable + } + ImGui::TableNextColumn(); CENTER_VSLIDER; P(CWVSliderScalar("##MULT",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&op.mult,&_ZERO,&_FIFTEEN)); rightClickable @@ -3558,6 +3804,12 @@ void FurnaceGUI::drawInsEdit() { P(CWVSliderScalar("##FINE",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&op.dvb,&_ZERO,&_FIFTEEN)); rightClickable } + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_VSLIDER; + P(CWVSliderScalar("##CT",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_S8,&opE.ct,&_MINUS_TWENTY_FOUR,&_TWENTY_FOUR)); rightClickable + } + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { int detune=detuneMap[settings.unsignedDetune?1:0][op.dt&7]; ImGui::TableNextColumn(); @@ -3628,6 +3880,119 @@ void FurnaceGUI::drawInsEdit() { op.ssgEnv=(op.ssgEnv&8)|(ssgEnv&7); } } + } else if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextColumn(); + CENTER_VSLIDER; + P(CWVSliderScalar("##DT",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_S8,&opE.dt,&_MINUS_ONE_HUNDRED_TWENTY_EIGHT,&_ONE_HUNDRED_TWENTY_SEVEN)); rightClickable + + ImGui::TableNextColumn(); + bool amOn=op.am; + bool leftOn=opE.left; + bool rightOn=opE.right; + + ImGui::SetCursorPosY(ImGui::GetCursorPosY()+0.5*(sliderHeight-ImGui::GetFrameHeight()*5.0-ImGui::GetStyle().ItemSpacing.y*4.0)); + ImVec2 curPosBeforeDummy = ImGui::GetCursorPos(); + ImGui::Dummy(ImVec2(ImGui::GetFrameHeightWithSpacing()*2.0f+ImGui::CalcTextSize(FM_SHORT_NAME(FM_DAM)).x*2.0f,1.0f)); + ImGui::SetCursorPos(curPosBeforeDummy); + + if (ImGui::BeginTable("panCheckboxes",(fixedOn)?3:2,ImGuiTableFlags_SizingStretchProp)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,1.0); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,1.0); + if (fixedOn) { + ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,1.2); + } + + float yCoordBeforeTablePadding=ImGui::GetCursorPosY(); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yCoordBeforeTablePadding); + if (ImGui::Checkbox(ESFM_SHORT_NAME(ESFM_LEFT),&leftOn)) { PARAMETER + opE.left=leftOn; + } + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yCoordBeforeTablePadding); + if (ImGui::Checkbox(ESFM_SHORT_NAME(ESFM_RIGHT),&rightOn)) { PARAMETER + opE.right=rightOn; + } + if (fixedOn) { + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yCoordBeforeTablePadding); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_AM),&amOn)) { PARAMETER + op.am=amOn; + } + } + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_KSR),&ksrOn)) { PARAMETER + op.ksr=ksrOn; + } + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_SUS),&susOn)) { PARAMETER + op.sus=susOn; + } + if (fixedOn) { + bool damOn=op.dam; + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DAM),&damOn)) { PARAMETER + op.dam=damOn; + } + } + ImGui::EndTable(); + } + ImGui::SetCursorPosY(ImGui::GetCursorPosY()-0.5*ImGui::GetStyle().ItemSpacing.y); + if (ImGui::Checkbox(ESFM_NAME(ESFM_FIXED),&fixedOn)) { PARAMETER + opE.fixed=fixedOn; + // HACK: reset zoom and scroll in fixed pitch macros so that they draw correctly + ins->std.opMacros[i].ssgMacro.vZoom=-1; + ins->std.opMacros[i].dtMacro.vZoom=-1; + } + if (ins->type==DIV_INS_ESFM) { + if (fixedOn) { + int block=(opE.ct>>2)&7; + int freqNum=((opE.ct&3)<<8)|((unsigned char)opE.dt); + if (ImGui::InputInt("Block",&block,1,1)) { + if (block<0) block=0; + if (block>7) block=7; + opE.ct=(opE.ct&(~(7<<2)))|(block<<2); + } + if (ImGui::InputInt("FreqNum",&freqNum,1,16)) { + if (freqNum<0) freqNum=0; + if (freqNum>1023) freqNum=1023; + opE.dt=freqNum&0xff; + opE.ct=(opE.ct&(~3))|(freqNum>>8); + } + } else { + if (ImGui::BeginTable("amVibCheckboxes",2,ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0); + + float yCoordBeforeTablePadding=ImGui::GetCursorPosY(); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yCoordBeforeTablePadding); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_AM),&amOn)) { PARAMETER + op.am=amOn; + } + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yCoordBeforeTablePadding); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_VIB),&vibOn)) { PARAMETER + op.vib=vibOn; + } + bool damOn=op.dam; + bool dvbOn=op.dvb; + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DAM),&damOn)) { PARAMETER + op.dam=damOn; + } + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DVB),&dvbOn)) { PARAMETER + op.dvb=dvbOn; + } + ImGui::EndTable(); + } + } + } } else if (ins->type!=DIV_INS_OPM) { ImGui::TableNextColumn(); bool amOn=op.am; @@ -3652,24 +4017,33 @@ void FurnaceGUI::drawInsEdit() { } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_ESFM) { ImGui::TableNextColumn(); ImGui::Dummy(ImVec2(4.0f*dpiScale,2.0f*dpiScale)); ImGui::TableNextColumn(); - drawWaveform(op.ws&7,ins->type==DIV_INS_OPZ,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight-ImGui::GetFrameHeightWithSpacing())); + drawWaveform(op.ws&7,ins->type==DIV_INS_OPZ,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight-ImGui::GetFrameHeightWithSpacing()*((ins->type==DIV_INS_ESFM && fixedOn)?3.0f:1.0f))); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); P(CWSliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,(ins->type==DIV_INS_OPZ)?opzWaveforms[op.ws&7]:(settings.oplStandardWaveNames?oplWaveformsStandard[op.ws&7]:oplWaveforms[op.ws&7]))); rightClickable if ((ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) && ImGui::IsItemHovered()) { ImGui::SetTooltip("OPL2/3 only (last 4 waveforms are OPL3 only)"); } + if (ins->type==DIV_INS_ESFM && fixedOn) { + if (ImGui::Checkbox(FM_SHORT_NAME(FM_VIB),&vibOn)) { PARAMETER + op.vib=vibOn; + } + bool dvbOn=op.dvb; + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DVB),&dvbOn)) { PARAMETER + op.dvb=dvbOn; + } + } } else if (ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPM) { ImGui::TableNextColumn(); ImGui::Dummy(ImVec2(4.0f*dpiScale,2.0f*dpiScale)); } ImGui::TableNextColumn(); - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight),ins->type); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_ESFM)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight),ins->type); if (settings.separateFMColors) { popAccentColors(); @@ -3698,7 +4072,8 @@ void FurnaceGUI::drawInsEdit() { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding,ImVec2(8.0f*dpiScale,4.0f*dpiScale)); if (ImGui::BeginTable("AltFMOperators",columns,ImGuiTableFlags_SizingStretchSame|ImGuiTableFlags_BordersInner)) { for (int i=0; itype!=DIV_INS_OPL_DRUMS)?opOrder[i]:i]; + DivInstrumentFM::Operator& op=fmOrigin.op[(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_ESFM)?opOrder[i]:i]; + DivInstrumentESFM::Operator& opE=ins->esfm.op[i]; if ((settings.fmLayout!=6 && ((i+1)&1)) || i==0 || settings.fmLayout==5) ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::PushID(fmt::sprintf("op%d",i).c_str()); @@ -3708,6 +4083,17 @@ void FurnaceGUI::drawInsEdit() { bool mod=true; if (ins->type==DIV_INS_OPL_DRUMS) { mod=false; + } else if (ins->type==DIV_INS_ESFM) { + // this is the same as the KVS heuristic in platform/esfm.h + if (opE.outLvl==7) mod=false; + else if (opE.outLvl>0) { + if (i==3) mod=false; + else { + DivInstrumentESFM::Operator& opENext=ins->esfm.op[i+1]; + if (opENext.modIn==0) mod=false; + else if ((opE.outLvl-opENext.modIn)>=2) mod=false; + } + } } else if (opCount==4) { if (ins->type==DIV_INS_OPL) { if (opIsOutputOPL[fmOrigin.alg&3][i]) mod=false; @@ -3762,8 +4148,8 @@ void FurnaceGUI::drawInsEdit() { } float sliderHeight=200.0f*dpiScale; - float waveWidth=140.0*dpiScale; - float waveHeight=sliderHeight-ImGui::GetFrameHeightWithSpacing()*((ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL)?5.0f:4.5f); + float waveWidth=140.0*dpiScale*((ins->type==DIV_INS_ESFM)?0.85f:1.0f); + float waveHeight=sliderHeight-ImGui::GetFrameHeightWithSpacing()*((ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPL || ins->type==DIV_INS_ESFM)?5.0f:4.5f); int maxTl=127; if (ins->type==DIV_INS_OPLL) { @@ -3773,7 +4159,7 @@ void FurnaceGUI::drawInsEdit() { maxTl=63; } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { maxTl=63; } int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM)?31:15; @@ -3795,9 +4181,15 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextRow(); ImGui::TableNextColumn(); float textY=ImGui::GetCursorPosY(); - CENTER_TEXT_20(FM_SHORT_NAME(FM_AR)); - ImGui::TextUnformatted(FM_SHORT_NAME(FM_AR)); - TOOLTIP_TEXT(FM_NAME(FM_AR)); + if (ins->type==DIV_INS_ESFM) { + CENTER_TEXT_20(ESFM_SHORT_NAME(ESFM_DELAY)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_DELAY)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_DELAY)); + } else { + CENTER_TEXT_20(FM_SHORT_NAME(FM_AR)); + ImGui::TextUnformatted(FM_SHORT_NAME(FM_AR)); + TOOLTIP_TEXT(FM_NAME(FM_AR)); + } ImGui::TableNextColumn(); if (ins->type==DIV_INS_FM) { ImGui::Text("SSG-EG"); @@ -3807,14 +4199,18 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextColumn(); ImGui::Text("Envelope"); ImGui::TableNextColumn(); - CENTER_TEXT(FM_SHORT_NAME(FM_TL)); - ImGui::TextUnformatted(FM_SHORT_NAME(FM_TL)); - TOOLTIP_TEXT(FM_NAME(FM_TL)); // A/D/S/R ImGui::TableNextColumn(); + if (ins->type==DIV_INS_ESFM) { + opE.delay&=7; + P(CWVSliderScalar("##DELAY",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&opE.delay,&_ZERO,&_SEVEN)); rightClickable + ImGui::SameLine(); + } + op.ar&=maxArDr; + float textX_AR=ImGui::GetCursorPosX(); P(CWVSliderScalar("##AR",ImVec2(20.0f*dpiScale,sliderHeight),ImGuiDataType_U8,&op.ar,&maxArDr,&_ZERO)); rightClickable ImGui::SameLine(); @@ -3851,8 +4247,15 @@ void FurnaceGUI::drawInsEdit() { } ImVec2 prevCurPos=ImGui::GetCursorPos(); - + // labels + if (ins->type==DIV_INS_ESFM) { + ImGui::SetCursorPos(ImVec2(textX_AR,textY)); + CENTER_TEXT_20(FM_SHORT_NAME(FM_AR)); + ImGui::TextUnformatted(FM_SHORT_NAME(FM_AR)); + TOOLTIP_TEXT(FM_NAME(FM_AR)); + } + ImGui::SetCursorPos(ImVec2(textX_DR,textY)); CENTER_TEXT_20(FM_SHORT_NAME(FM_DR)); ImGui::TextUnformatted(FM_SHORT_NAME(FM_DR)); @@ -4094,6 +4497,78 @@ void FurnaceGUI::drawInsEdit() { P(CWSliderScalar("##RS",ImGuiDataType_U8,&op.rs,&_ZERO,&_THREE,tempID)); rightClickable break; } + case DIV_INS_ESFM: + // waveform + drawWaveform(op.ws&7,ins->type==DIV_INS_OPZ,ImVec2(waveWidth,waveHeight)); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(CWSliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,(ins->type==DIV_INS_OPZ)?opzWaveforms[op.ws&7]:(settings.oplStandardWaveNames?oplWaveformsStandard[op.ws&7]:oplWaveforms[op.ws&7]))); rightClickable + + // params + ImGui::Separator(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + snprintf(tempID,1024,"%s: %%d",FM_NAME(FM_MULT)); + P(CWSliderScalar("##MULT",ImGuiDataType_U8,&op.mult,&_ZERO,&_FIFTEEN,tempID)); rightClickable + + if (opE.fixed) { + int block=(opE.ct>>2)&7; + int freqNum=((opE.ct&3)<<8)|((unsigned char)opE.dt); + ImGui::Text("Blk"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Block"); + } + ImGui::SameLine(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + //ImVec2 cursorAlign=ImGui::GetCursorPos(); + if (ImGui::InputInt("##Block",&block,1,1)) { + if (block<0) block=0; + if (block>7) block=7; + opE.ct=(opE.ct&(~(7<<2)))|(block<<2); + } + + ImGui::Text("F"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Frequency (F-Num)"); + } + ImGui::SameLine(); + //ImGui::SetCursorPos(ImVec2(cursorAlign.x,ImGui::GetCursorPosY())); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt("##FreqNum",&freqNum,1,16)) { + if (freqNum<0) freqNum=0; + if (freqNum>1023) freqNum=1023; + opE.dt=freqNum&0xff; + opE.ct=(opE.ct&(~3))|(freqNum>>8); + } + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + snprintf(tempID,1024,"%s: %%d",ESFM_NAME(ESFM_CT)); + P(CWSliderScalar("##CT",ImGuiDataType_S8,&opE.ct,&_MINUS_TWENTY_FOUR,&_TWENTY_FOUR,tempID)); rightClickable + + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + snprintf(tempID,1024,"%s: %%d",ESFM_NAME(ESFM_DT)); + P(CWSliderScalar("##DT",ImGuiDataType_S8,&opE.dt,&_MINUS_ONE_HUNDRED_TWENTY_EIGHT,&_ONE_HUNDRED_TWENTY_SEVEN,tempID)); rightClickable + } + + if (ImGui::BeginTable("panCheckboxes",2,ImGuiTableFlags_SizingStretchSame)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0f); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0f); + + float yPosOutsideTablePadding=ImGui::GetCursorPosY(); + bool leftOn=opE.left; + bool rightOn=opE.right; + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yPosOutsideTablePadding); + if (ImGui::Checkbox(ESFM_SHORT_NAME(ESFM_LEFT),&leftOn)) { PARAMETER + opE.left=leftOn; + } + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yPosOutsideTablePadding); + if (ImGui::Checkbox(ESFM_SHORT_NAME(ESFM_RIGHT),&rightOn)) { PARAMETER + opE.right=rightOn; + } + ImGui::EndTable(); + } + break; default: break; } @@ -4103,7 +4578,10 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_OPZ) { envHeight-=ImGui::GetFrameHeightWithSpacing()*2.0f; } - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,envHeight),ins->type); + if (ins->type==DIV_INS_ESFM) { + envHeight-=ImGui::GetFrameHeightWithSpacing()*3.0f; + } + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_ESFM)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,envHeight),ins->type); if (ins->type==DIV_INS_OPZ) { ImGui::Separator(); @@ -4144,9 +4622,81 @@ void FurnaceGUI::drawInsEdit() { } } + if (ins->type==DIV_INS_ESFM) { + ImGui::Separator(); + if (ImGui::BeginTable("FMParamsInnerESFM",2)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.64f); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.36f); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + snprintf(tempID,1024,"%s: %%d",FM_NAME(FM_KSL)); + int ksl=kslMap[op.ksl&3]; + if (CWSliderInt("##KSL",&ksl,0,3,tempID)) { + op.ksl=kslMap[ksl&3]; + PARAMETER; + } rightClickable + + bool amOn=op.am; + bool fixedOn=opE.fixed; + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_KSR),&ksrOn)) { PARAMETER + op.ksr=ksrOn; + } + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::BeginTable("vibAmCheckboxes",2)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0f); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0f); + + float yPosOutsideTablePadding=ImGui::GetCursorPosY(); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yPosOutsideTablePadding); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_VIB),&vibOn)) { PARAMETER + op.vib=vibOn; + } + ImGui::TableNextColumn(); + ImGui::SetCursorPosY(yPosOutsideTablePadding); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_AM),&amOn)) { PARAMETER + op.am=amOn; + } + + bool damOn=op.dam; + bool dvbOn=op.dvb; + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DVB),&dvbOn)) { PARAMETER + op.dvb=dvbOn; + } + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_DAM),&damOn)) { PARAMETER + op.dam=damOn; + } + ImGui::EndTable(); + } + ImGui::TableNextColumn(); + if (ImGui::Checkbox(FM_SHORT_NAME(FM_SUS),&susOn)) { PARAMETER + op.sus=susOn; + } + if (ImGui::Checkbox(ESFM_NAME(ESFM_FIXED),&fixedOn)) { PARAMETER + opE.fixed=fixedOn; + // HACK: reset zoom and scroll in fixed pitch macros so that they draw correctly + ins->std.opMacros[i].ssgMacro.vZoom=-1; + ins->std.opMacros[i].dtMacro.vZoom=-1; + } + + ImGui::EndTable(); + } + } + ImGui::TableNextColumn(); op.tl&=maxTl; - P(CWVSliderScalar("##TL",ImVec2(ImGui::GetFrameHeight(),sliderHeight-((ins->type==DIV_INS_FM || ins->type==DIV_INS_OPM)?(ImGui::GetFrameHeightWithSpacing()+ImGui::CalcTextSize(FM_SHORT_NAME(FM_AM)).y+ImGui::GetStyle().ItemSpacing.y):0.0f)),ImGuiDataType_U8,&op.tl,&maxTl,&_ZERO)); rightClickable + float tlSliderWidth=(ins->type==DIV_INS_ESFM)?20.0f*dpiScale:ImGui::GetFrameHeight(); + float tlSliderHeight=sliderHeight-((ins->type==DIV_INS_FM || ins->type==DIV_INS_OPM)?(ImGui::GetFrameHeightWithSpacing()+ImGui::CalcTextSize(FM_SHORT_NAME(FM_AM)).y+ImGui::GetStyle().ItemSpacing.y):0.0f); + float textX_tl=ImGui::GetCursorPosX(); + P(CWVSliderScalar("##TL",ImVec2(tlSliderWidth,tlSliderHeight),ImGuiDataType_U8,&op.tl,&maxTl,&_ZERO)); rightClickable if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPM) { CENTER_TEXT(FM_SHORT_NAME(FM_AM)); @@ -4158,6 +4708,42 @@ void FurnaceGUI::drawInsEdit() { } } + if (ins->type==DIV_INS_ESFM) { + ImGui::SameLine(); + float textX_outLvl=ImGui::GetCursorPosX(); + P(CWVSliderScalar("##OUTLVL",ImVec2(tlSliderWidth,tlSliderHeight),ImGuiDataType_U8,&opE.outLvl,&_ZERO,&_SEVEN)); rightClickable + + ImGui::SameLine(); + float textX_modIn=ImGui::GetCursorPosX(); + P(CWVSliderScalar("##MODIN",ImVec2(tlSliderWidth,tlSliderHeight),ImGuiDataType_U8,&opE.modIn,&_ZERO,&_SEVEN)); rightClickable + + prevCurPos=ImGui::GetCursorPos(); + ImGui::SetCursorPos(ImVec2(textX_tl,textY)); + CENTER_TEXT_20(FM_SHORT_NAME(FM_TL)); + ImGui::TextUnformatted(FM_SHORT_NAME(FM_TL)); + TOOLTIP_TEXT(FM_NAME(FM_TL)); + + ImGui::SetCursorPos(ImVec2(textX_outLvl,textY)); + CENTER_TEXT_20(ESFM_SHORT_NAME(ESFM_OUTLVL)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_OUTLVL)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_OUTLVL)); + + ImGui::SetCursorPos(ImVec2(textX_modIn,textY)); + CENTER_TEXT_20(ESFM_SHORT_NAME(ESFM_MODIN)); + ImGui::TextUnformatted(ESFM_SHORT_NAME(ESFM_MODIN)); + TOOLTIP_TEXT(ESFM_LONG_NAME(ESFM_MODIN)); + + ImGui::SetCursorPos(prevCurPos); + } else { + prevCurPos=ImGui::GetCursorPos(); + ImGui::SetCursorPos(ImVec2(textX_tl,textY)); + CENTER_TEXT(FM_SHORT_NAME(FM_TL)); + ImGui::TextUnformatted(FM_SHORT_NAME(FM_TL)); + TOOLTIP_TEXT(FM_NAME(FM_TL)); + + ImGui::SetCursorPos(prevCurPos); + } + ImGui::EndTable(); } ImGui::PopStyleVar(); @@ -4186,7 +4772,8 @@ void FurnaceGUI::drawInsEdit() { } if (ImGui::BeginTable("FMOperators",columns,ImGuiTableFlags_SizingStretchSame)) { for (int i=0; itype!=DIV_INS_OPL_DRUMS)?opOrder[i]:i]; + DivInstrumentFM::Operator& op=fmOrigin.op[(opCount==4 && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_ESFM)?opOrder[i]:i]; + DivInstrumentESFM::Operator& opE=ins->esfm.op[i]; if ((settings.fmLayout!=3 && ((i+1)&1)) || i==0 || settings.fmLayout==2) ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Separator(); @@ -4197,6 +4784,22 @@ void FurnaceGUI::drawInsEdit() { bool mod=true; if (ins->type==DIV_INS_OPL_DRUMS) { mod=false; + } else if (ins->type==DIV_INS_ESFM) { + // this is the same as the KVS heuristic in platform/esfm.h + if (opE.outLvl==7) { + mod=false; + } else if (opE.outLvl>0) { + if (i==3) { + mod=false; + } else { + DivInstrumentESFM::Operator& opENext=ins->esfm.op[i+1]; + if (opENext.modIn==0) { + mod=false; + } else if ((opE.outLvl-opENext.modIn)>=2) { + mod=false; + } + } + } } else if (opCount==4) { if (ins->type==DIV_INS_OPL) { if (opIsOutputOPL[fmOrigin.alg&3][i]) mod=false; @@ -4264,7 +4867,7 @@ void FurnaceGUI::drawInsEdit() { maxTl=63; } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { maxTl=63; } int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM)?31:15; @@ -4274,14 +4877,14 @@ void FurnaceGUI::drawInsEdit() { bool vibOn=op.vib; bool susOn=op.sus; // don't you make fun of this one unsigned char ssgEnv=op.ssgEnv&7; - if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_OPZ && ins->type!=DIV_INS_OPM) { + if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPL_DRUMS && ins->type!=DIV_INS_OPZ && ins->type!=DIV_INS_OPM && ins->type!=DIV_INS_ESFM) { ImGui::SameLine(); if (ImGui::Checkbox((ins->type==DIV_INS_OPLL)?FM_NAME(FM_EGS):"SSG On",&ssgOn)) { PARAMETER op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3); } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { ImGui::SameLine(); if (ImGui::Checkbox(FM_NAME(FM_SUS),&susOn)) { PARAMETER op.sus=susOn; @@ -4297,12 +4900,22 @@ void FurnaceGUI::drawInsEdit() { } //52.0 controls vert scaling; default 96 - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale),ins->type); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_ESFM)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,fmOrigin.alg,maxTl,maxArDr,15,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale),ins->type); //P(CWSliderScalar(FM_NAME(FM_AR),ImGuiDataType_U8,&op.ar,&_ZERO,&_THIRTY_ONE)); rightClickable if (ImGui::BeginTable("opParams",2,ImGuiTableFlags_SizingStretchProp)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); \ ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,0.0); \ + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + opE.delay&=7; + P(CWSliderScalar("##DELAY",ImGuiDataType_U8,&opE.delay,&_ZERO,&_SEVEN)); rightClickable + ImGui::TableNextColumn(); + ImGui::Text("%s",ESFM_NAME(ESFM_DELAY)); + } + ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); @@ -4487,7 +5100,51 @@ void FurnaceGUI::drawInsEdit() { } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ) { + if (ins->type==DIV_INS_ESFM) { + bool fixedOn=opE.fixed; + if (fixedOn) { + int block=(opE.ct>>2)&7; + int freqNum=((opE.ct&3)<<8)|((unsigned char)opE.dt); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt("##Block",&block,1,1)) { + if (block<0) block=0; + if (block>7) block=7; + opE.ct=(opE.ct&(~(7<<2)))|(block<<2); + } + ImGui::TableNextColumn(); + ImGui::Text("Block"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputInt("##FreqNum",&freqNum,1,16)) { + if (freqNum<0) freqNum=0; + if (freqNum>1023) freqNum=1023; + opE.dt=freqNum&0xff; + opE.ct=(opE.ct&(~3))|(freqNum>>8); + } + ImGui::TableNextColumn(); + ImGui::Text("FreqNum"); + } else { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(CWSliderScalar("##CT",ImGuiDataType_S8,&opE.ct,&_MINUS_TWENTY_FOUR,&_TWENTY_FOUR)); rightClickable + ImGui::TableNextColumn(); + ImGui::Text("%s",ESFM_NAME(ESFM_CT)); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(CWSliderScalar("##DT",ImGuiDataType_S8,&opE.dt,&_MINUS_ONE_HUNDRED_TWENTY_EIGHT,&_ONE_HUNDRED_TWENTY_SEVEN)); rightClickable + ImGui::TableNextColumn(); + ImGui::Text("%s",ESFM_NAME(ESFM_DT)); + } + + } + + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_ESFM) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); @@ -4498,11 +5155,33 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextColumn(); ImGui::Text("%s",FM_NAME(FM_WS)); } - + + if (ins->type==DIV_INS_ESFM) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Separator(); + ImGui::TableNextColumn(); + ImGui::Separator(); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(CWSliderScalar("##OUTLVL",ImGuiDataType_U8,&opE.outLvl,&_ZERO,&_SEVEN)); rightClickable + ImGui::TableNextColumn(); + ImGui::Text("%s",ESFM_NAME(ESFM_OUTLVL)); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(CWSliderScalar("##MODIN",ImGuiDataType_U8,&opE.modIn,&_ZERO,&_SEVEN)); rightClickable + ImGui::TableNextColumn(); + ImGui::Text("%s",ESFM_NAME(ESFM_MODIN)); + } + ImGui::EndTable(); } - if (ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { if (ImGui::Checkbox(FM_NAME(FM_VIB),&vibOn)) { PARAMETER op.vib=vibOn; } @@ -4512,6 +5191,35 @@ void FurnaceGUI::drawInsEdit() { } } + if (ins->type==DIV_INS_ESFM) { + bool dvbOn=op.dvb; + bool damOn=op.dam; + bool leftOn=opE.left; + bool rightOn=opE.right; + bool fixedOn=opE.fixed; + if (ImGui::Checkbox(FM_NAME(FM_DVB),&dvbOn)) { PARAMETER + op.dvb=dvbOn; + } + ImGui::SameLine(); + if (ImGui::Checkbox(FM_NAME(FM_DAM),&damOn)) { PARAMETER + op.dam=damOn; + } + if (ImGui::Checkbox(ESFM_NAME(ESFM_LEFT),&leftOn)) { PARAMETER + opE.left=leftOn; + } + ImGui::SameLine(); + if (ImGui::Checkbox(ESFM_NAME(ESFM_RIGHT),&rightOn)) { PARAMETER + opE.right=rightOn; + } + ImGui::SameLine(); + if (ImGui::Checkbox(ESFM_NAME(ESFM_FIXED),&fixedOn)) { PARAMETER + opE.fixed=fixedOn; + // HACK: reset zoom and scroll in fixed pitch macros so that they draw correctly + ins->std.opMacros[i].ssgMacro.vZoom=-1; + ins->std.opMacros[i].dtMacro.vZoom=-1; + } + } + if (settings.separateFMColors) { popAccentColors(); } @@ -4524,46 +5232,48 @@ void FurnaceGUI::drawInsEdit() { ImGui::EndDisabled(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("FM Macros")) { - if (ins->type==DIV_INS_OPLL) { - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_SUS),&ins->std.algMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FB),&ins->std.fbMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DC),&ins->std.fmsMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DM),&ins->std.amsMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); - } else { - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_ALG),&ins->std.algMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FB),&ins->std.fbMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); - if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPL_DRUMS) { - if (ins->type==DIV_INS_OPZ) { - // TODO: FMS2/AMS2 macros - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FMS),&ins->std.fmsMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AMS),&ins->std.amsMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER])); - } else { - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FMS),&ins->std.fmsMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AMS),&ins->std.amsMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER])); + if (ins->type!=DIV_INS_ESFM) { + if (ImGui::BeginTabItem("FM Macros")) { + if (ins->type==DIV_INS_OPLL) { + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_SUS),&ins->std.algMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FB),&ins->std.fbMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DC),&ins->std.fmsMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DM),&ins->std.amsMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + } else { + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_ALG),&ins->std.algMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FB),&ins->std.fbMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); + if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPZ) { + // TODO: FMS2/AMS2 macros + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FMS),&ins->std.fmsMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AMS),&ins->std.amsMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER])); + } else { + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_FMS),&ins->std.fmsMacro,0,7,96,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AMS),&ins->std.amsMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER])); + } } } + + if (ins->type==DIV_INS_FM) { + macroList.push_back(FurnaceGUIMacroDesc("LFO Speed",&ins->std.ex3Macro,0,8,96,uiColors[GUI_COLOR_MACRO_OTHER])); + } + if (ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { + macroList.push_back(FurnaceGUIMacroDesc("AM Depth",&ins->std.ex1Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("PM Depth",&ins->std.ex2Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("LFO Speed",&ins->std.ex3Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("LFO Shape",&ins->std.waveMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroLFOWaves)); + } + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPM) { + macroList.push_back(FurnaceGUIMacroDesc("OpMask",&ins->std.ex4Macro,0,4,128,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,fmOperatorBits)); + } else if (ins->type==DIV_INS_OPZ) { + macroList.push_back(FurnaceGUIMacroDesc("AM Depth 2",&ins->std.ex5Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("PM Depth 2",&ins->std.ex6Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("LFO2 Speed",&ins->std.ex7Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("LFO2 Shape",&ins->std.ex8Macro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroLFOWaves)); + } + drawMacros(macroList,macroEditStateFM); + ImGui::EndTabItem(); } - - if (ins->type==DIV_INS_FM) { - macroList.push_back(FurnaceGUIMacroDesc("LFO Speed",&ins->std.ex3Macro,0,8,96,uiColors[GUI_COLOR_MACRO_OTHER])); - } - if (ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) { - macroList.push_back(FurnaceGUIMacroDesc("AM Depth",&ins->std.ex1Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("PM Depth",&ins->std.ex2Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("LFO Speed",&ins->std.ex3Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("LFO Shape",&ins->std.waveMacro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroLFOWaves)); - } - if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPM) { - macroList.push_back(FurnaceGUIMacroDesc("OpMask",&ins->std.ex4Macro,0,4,128,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,fmOperatorBits)); - } else if (ins->type==DIV_INS_OPZ) { - macroList.push_back(FurnaceGUIMacroDesc("AM Depth 2",&ins->std.ex5Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("PM Depth 2",&ins->std.ex6Macro,0,127,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("LFO2 Speed",&ins->std.ex7Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("LFO2 Shape",&ins->std.ex8Macro,0,3,48,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroLFOWaves)); - } - drawMacros(macroList,macroEditStateFM); - ImGui::EndTabItem(); } for (int i=0; itype==DIV_INS_OPL_DRUMS) { @@ -4574,7 +5284,7 @@ void FurnaceGUI::drawInsEdit() { } if (ImGui::BeginTabItem(label)) { ImGui::PushID(i); - int ordi=(opCount==4)?orderedOps[i]:i; + int ordi=(opCount==4 && ins->type!=DIV_INS_ESFM)?orderedOps[i]:i; int maxTl=127; if (ins->type==DIV_INS_OPLL) { if (i==1) { @@ -4583,7 +5293,7 @@ void FurnaceGUI::drawInsEdit() { maxTl=63; } } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_ESFM) { maxTl=63; } int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM)?31:15; @@ -4615,6 +5325,33 @@ void FurnaceGUI::drawInsEdit() { macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_VIB),&ins->std.opMacros[ordi].vibMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_KSR),&ins->std.opMacros[ordi].ksrMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_EGS),&ins->std.opMacros[ordi].egtMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + } else if (ins->type==DIV_INS_ESFM) { + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_TL),&ins->std.opMacros[ordi].tlMacro,0,maxTl,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(ESFM_NAME(ESFM_DELAY),&ins->std.opMacros[ordi].dt2Macro,0,7,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AR),&ins->std.opMacros[ordi].arMacro,0,maxArDr,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DR),&ins->std.opMacros[ordi].drMacro,0,maxArDr,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_SL),&ins->std.opMacros[ordi].slMacro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_RR),&ins->std.opMacros[ordi].rrMacro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_KSL),&ins->std.opMacros[ordi].kslMacro,0,3,32,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_MULT),&ins->std.opMacros[ordi].multMacro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_WS),&ins->std.opMacros[ordi].wsMacro,0,7,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(ESFM_NAME(ESFM_OUTLVL),&ins->std.opMacros[ordi].egtMacro,0,7,64,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc(ESFM_NAME(ESFM_MODIN),&ins->std.opMacros[ordi].d2rMacro,0,7,64,uiColors[GUI_COLOR_MACRO_OTHER])); + if (ins->esfm.op[ordi].fixed) { + macroList.push_back(FurnaceGUIMacroDesc("Block",&ins->std.opMacros[ordi].ssgMacro,0,7,64,uiColors[GUI_COLOR_MACRO_OTHER],true)); + macroList.push_back(FurnaceGUIMacroDesc("FreqNum",&ins->std.opMacros[ordi].dtMacro,0,1023,160,uiColors[GUI_COLOR_MACRO_OTHER])); + } else { + macroList.push_back(FurnaceGUIMacroDesc("Op. Arpeggio",&ins->std.opMacros[ordi].ssgMacro,-120,120,160,uiColors[GUI_COLOR_MACRO_PITCH],true,NULL,macroHoverNote,false,NULL,0,true,ins->std.opMacros[ordi].ssgMacro.val,true)); + macroList.push_back(FurnaceGUIMacroDesc("Op. Pitch",&ins->std.opMacros[ordi].dtMacro,-2048,2047,160,uiColors[GUI_COLOR_MACRO_PITCH],true,macroRelativeMode,NULL,false,NULL,0,false,NULL,false,true)); + } + + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AM),&ins->std.opMacros[ordi].amMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_VIB),&ins->std.opMacros[ordi].vibMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DAM),&ins->std.opMacros[ordi].damMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_DVB),&ins->std.opMacros[ordi].dvbMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_KSR),&ins->std.opMacros[ordi].ksrMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_SUS),&ins->std.opMacros[ordi].susMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + macroList.push_back(FurnaceGUIMacroDesc("Op. Panning",&ins->std.opMacros[ordi].rsMacro,0,2,40,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,panBits)); } else { macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_TL),&ins->std.opMacros[ordi].tlMacro,0,maxTl,128,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc(FM_NAME(FM_AR),&ins->std.opMacros[ordi].arMacro,0,maxArDr,64,uiColors[GUI_COLOR_MACRO_OTHER])); @@ -5969,7 +6706,7 @@ void FurnaceGUI::drawInsEdit() { ImGui::EndTabItem(); } } - if (ImGui::BeginTabItem("Macros")) { + if (ins->typetype==DIV_INS_PCE || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_SM8521) { volMax=31; } - if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_VERA || ins->type==DIV_INS_VRC6_SAW) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_VERA || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_ESFM) { volMax=63; } if (ins->type==DIV_INS_AMIGA) { @@ -6157,6 +6894,10 @@ void FurnaceGUI::drawInsEdit() { dutyLabel="Echo Level"; dutyMax=32767; } + if (ins->type==DIV_INS_ESFM) { + dutyLabel="OP4 Noise Mode"; + dutyMax=3; + } const char* waveLabel="Waveform"; int waveMax=(ins->type==DIV_INS_VERA)?3:(MAX(1,e->song.waveLen-1)); @@ -6170,7 +6911,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_VIC || ins->type==DIV_INS_OPLL) waveMax=15; if (ins->type==DIV_INS_C64) waveMax=4; if (ins->type==DIV_INS_SAA1099) waveMax=2; - if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM) waveMax=0; + if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPL_DRUMS || ins->type==DIV_INS_OPZ || ins->type==DIV_INS_OPM || ins->type==DIV_INS_ESFM) waveMax=0; if (ins->type==DIV_INS_MIKEY) waveMax=0; if (ins->type==DIV_INS_MULTIPCM) waveMax=0; if (ins->type==DIV_INS_ADPCMA) waveMax=0; @@ -6271,7 +7012,8 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_MSM6258 || ins->type==DIV_INS_VERA || ins->type==DIV_INS_ADPCMA || - ins->type==DIV_INS_ADPCMB) { + ins->type==DIV_INS_ADPCMB || + ins->type==DIV_INS_ESFM) { panMax=2; panSingle=true; } @@ -6414,7 +7156,8 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_K053260 || ins->type==DIV_INS_C140 || ins->type==DIV_INS_C219 || - ins->type==DIV_INS_TED) { + ins->type==DIV_INS_TED || + ins->type==DIV_INS_ESFM) { macroList.push_back(FurnaceGUIMacroDesc("Phase Reset",&ins->std.phaseResetMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); } if (ex1Max>0) { @@ -6521,6 +7264,12 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_VRC6) { insTabSample(ins); } + if (ins->type>=DIV_INS_MAX) { + if (ImGui::BeginTabItem("Error")) { + ImGui::Text("invalid instrument type! change it first."); + ImGui::EndTabItem(); + } + } ImGui::EndTabBar(); } if (settings.insEditColorize) { diff --git a/src/gui/intConst.cpp b/src/gui/intConst.cpp index 09a988e84..dde39ea34 100644 --- a/src/gui/intConst.cpp +++ b/src/gui/intConst.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ const int _EIGHT=8; const int _TEN=10; const int _FIFTEEN=15; const int _SIXTEEN=16; +const int _TWENTY_FOUR=24; const int _THIRTY_ONE=31; const int _SIXTY_FOUR=64; const int _ONE_HUNDRED=100; @@ -37,5 +38,6 @@ const int _FIVE_HUNDRED_ELEVEN=511; const int _TWO_THOUSAND_FORTY_SEVEN=2047; const int _FOUR_THOUSAND_NINETY_FIVE=4095; const int _SIXTY_FIVE_THOUSAND_FIVE_HUNDRED_THIRTY_FIVE=65535; +const int _MINUS_TWENTY_FOUR=-24; const int _MINUS_ONE_HUNDRED_TWENTY_SEVEN=-127; const int _MINUS_ONE_HUNDRED_TWENTY_EIGHT=-128; diff --git a/src/gui/intConst.h b/src/gui/intConst.h index 153fc868c..26f3b9e8b 100644 --- a/src/gui/intConst.h +++ b/src/gui/intConst.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ extern const int _EIGHT; extern const int _TEN; extern const int _FIFTEEN; extern const int _SIXTEEN; +extern const int _TWENTY_FOUR; extern const int _THIRTY_ONE; extern const int _SIXTY_FOUR; extern const int _ONE_HUNDRED; @@ -39,5 +40,6 @@ extern const int _FIVE_HUNDRED_ELEVEN; extern const int _TWO_THOUSAND_FORTY_SEVEN; extern const int _FOUR_THOUSAND_NINETY_FIVE; extern const int _SIXTY_FIVE_THOUSAND_FIVE_HUNDRED_THIRTY_FIVE; +extern const int _MINUS_TWENTY_FOUR; extern const int _MINUS_ONE_HUNDRED_TWENTY_SEVEN; extern const int _MINUS_ONE_HUNDRED_TWENTY_EIGHT; diff --git a/src/gui/intro.cpp b/src/gui/intro.cpp index 0fc1c9600..e87482d9d 100644 --- a/src/gui/intro.cpp +++ b/src/gui/intro.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/introTune.h b/src/gui/introTune.h index 43f44e7a3..eda8c72ee 100644 --- a/src/gui/introTune.h +++ b/src/gui/introTune.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/log.cpp b/src/gui/log.cpp index 0dc56e5de..552259e91 100644 --- a/src/gui/log.cpp +++ b/src/gui/log.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/macstuff.h b/src/gui/macstuff.h index 242abd17f..6fd8247c8 100644 --- a/src/gui/macstuff.h +++ b/src/gui/macstuff.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/midiMap.cpp b/src/gui/midiMap.cpp index 602347107..fac0399b8 100644 --- a/src/gui/midiMap.cpp +++ b/src/gui/midiMap.cpp @@ -139,6 +139,7 @@ bool MIDIMap::read(String path) { UNDERSTAND_OPTION(midiClock) else UNDERSTAND_OPTION(midiTimeCode) else UNDERSTAND_OPTION(yamahaFMResponse) else + UNDERSTAND_OPTION(directProgram) else UNDERSTAND_OPTION(valueInputStyle) else UNDERSTAND_OPTION(valueInputControlMSB) else UNDERSTAND_OPTION(valueInputControlLSB) else @@ -205,6 +206,7 @@ bool MIDIMap::write(String path) { WRITE_OPTION(midiClock); WRITE_OPTION(midiTimeCode); WRITE_OPTION(yamahaFMResponse); + WRITE_OPTION(directProgram); WRITE_OPTION(valueInputStyle); WRITE_OPTION(valueInputControlMSB); WRITE_OPTION(valueInputControlLSB); diff --git a/src/gui/mixer.cpp b/src/gui/mixer.cpp index c023445ab..d4ddbfa85 100644 --- a/src/gui/mixer.cpp +++ b/src/gui/mixer.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/newSong.cpp b/src/gui/newSong.cpp index 98c44357c..3fed2da3b 100644 --- a/src/gui/newSong.cpp +++ b/src/gui/newSong.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/orders.cpp b/src/gui/orders.cpp index 43dba3d79..f01168e1d 100644 --- a/src/gui/orders.cpp +++ b/src/gui/orders.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -181,6 +181,10 @@ void FurnaceGUI::drawOrderButtons() { } NEXT_BUTTON; + if (orderEditMode==0 && mobileUI) { + orderEditMode=1; + } + const char* orderEditModeLabel="?##OrderEditMode"; if (orderEditMode==3) { orderEditModeLabel=ICON_FA_ARROWS_V "##OrderEditMode"; @@ -193,7 +197,7 @@ void FurnaceGUI::drawOrderButtons() { } if (ImGui::Button(orderEditModeLabel)) { handleUnimportant orderEditMode++; - if (orderEditMode>3) orderEditMode=0; + if (orderEditMode>3) orderEditMode=mobileUI?1:0; curNibble=false; } if (ImGui::IsItemHovered()) { @@ -219,7 +223,7 @@ void FurnaceGUI::drawOrders() { if (!ordersOpen) return; if (mobileUI) { patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*canvasH)):ImVec2((0.16*canvasH)+0.5*canvasW*mobileMenuPos,0.0f)); - patWindowSize=(portrait?ImVec2(canvasW,canvasH-(0.16*canvasW)):ImVec2(canvasW-(0.16*canvasH),canvasH)); + patWindowSize=(portrait?ImVec2(canvasW,canvasH-(0.16*canvasW)-(pianoOpen?(0.4*canvasW):0.0f)):ImVec2(canvasW-(0.16*canvasH),canvasH-(pianoOpen?(0.3*canvasH):0.0f))); ImGui::SetNextWindowPos(patWindowPos); ImGui::SetNextWindowSize(patWindowSize); } else { diff --git a/src/gui/osc.cpp b/src/gui/osc.cpp index 8f8e8add4..d6537373c 100644 --- a/src/gui/osc.cpp +++ b/src/gui/osc.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/patManager.cpp b/src/gui/patManager.cpp index 17dfb91e7..8721ef200 100644 --- a/src/gui/patManager.cpp +++ b/src/gui/patManager.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 9e5c6e538..762d8ceca 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1463,7 +1463,6 @@ void FurnaceGUI::drawPattern() { if (i.cmd==DIV_CMD_PRE_NOTE) continue; if (i.cmd==DIV_CMD_SAMPLE_BANK) continue; if (i.cmd==DIV_CMD_GET_VOLUME) continue; - if (i.cmd==DIV_ALWAYS_SET_VOLUME) continue; if (i.cmd==DIV_CMD_HINT_VOLUME || i.cmd==DIV_CMD_HINT_PORTA || i.cmd==DIV_CMD_HINT_LEGATO || diff --git a/src/gui/piano.cpp b/src/gui/piano.cpp index a167b1b89..d71740cdb 100644 --- a/src/gui/piano.cpp +++ b/src/gui/piano.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,11 @@ const bool isTopKey[12]={ #define VALUE_DIGIT(x,label) \ if (ImGui::Button(label,buttonSize)) { \ - valueInput(x,false); \ + if (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0) { \ + orderInput(x); \ + } else { \ + valueInput(x,false); \ + } \ } void FurnaceGUI::drawPiano() { @@ -166,7 +170,7 @@ void FurnaceGUI::drawPiano() { } ImGui::TableNextColumn(); - if (pianoInputPadMode==PIANO_INPUT_PAD_REPLACE && cursor.xFine>0 && curWindow==GUI_WINDOW_PATTERN) { + if (pianoInputPadMode==PIANO_INPUT_PAD_REPLACE && ((cursor.xFine>0 && curWindow==GUI_WINDOW_PATTERN) || (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0))) { ImVec2 buttonSize=ImGui::GetContentRegionAvail(); if (ImGui::BeginTable("InputPadP",8,ImGuiTableFlags_SizingFixedSame)) { ImGui::TableNextRow(); @@ -443,9 +447,9 @@ void FurnaceGUI::drawPiano() { ImGui::End(); // draw input pad if necessary - if ((curWindow==GUI_WINDOW_PATTERN || !mobileUI) && ((pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_AUTO && cursor.xFine>0) || pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_VISIBLE)) { + if ((curWindow==GUI_WINDOW_ORDERS || curWindow==GUI_WINDOW_PATTERN || !mobileUI) && ((pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_AUTO && (cursor.xFine>0 || (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0))) || pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_VISIBLE)) { if (ImGui::Begin("Input Pad",NULL,ImGuiWindowFlags_NoTitleBar)) { - ImGui::BeginDisabled(cursor.xFine==0); + ImGui::BeginDisabled(cursor.xFine==0 && !(curWindow==GUI_WINDOW_ORDERS && orderEditMode>0)); if (ImGui::BeginTable("InputPad",3,ImGuiTableFlags_Borders)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/src/gui/plot_nolerp.cpp b/src/gui/plot_nolerp.cpp index f4d03717d..69361b4d3 100644 --- a/src/gui/plot_nolerp.cpp +++ b/src/gui/plot_nolerp.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/plot_nolerp.h b/src/gui/plot_nolerp.h index fbc66c1eb..cdd5a1df5 100644 --- a/src/gui/plot_nolerp.h +++ b/src/gui/plot_nolerp.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index e64452721..d1a21cc26 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1070,6 +1070,17 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "") } ); + ENTRY( + "PC + ESS AudioDrive ES1488 (native ESFM mode)", { + CH(DIV_SYSTEM_ESFM, 1.0f, 0, ""), + CH(DIV_SYSTEM_PCM_DAC, 1.0f, 0, + "rate=44100\n" + "outDepth=15\n" + "stereo=true\n" + ), + CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "") + } + ); ENTRY( "PC + PC-FXGA", { CH(DIV_SYSTEM_PCE, 1.0f, 0, ""), // HuC6230 (WSG from HuC6280 but with built in 2 OKI ADPCM playback engines) @@ -2364,6 +2375,11 @@ void FurnaceGUI::initSystemPresets() { ) } ); + ENTRY( + "ESS ES1xxx series (ESFM)", { + CH(DIV_SYSTEM_ESFM, 1.0f, 0, "") + } + ); if (settings.hiddenSystems) { ENTRY( "Yamaha YMU759 (MA-2)", { diff --git a/src/gui/regView.cpp b/src/gui/regView.cpp index 729f17c6e..6ad6c0814 100644 --- a/src/gui/regView.cpp +++ b/src/gui/regView.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render.cpp b/src/gui/render.cpp index 94600246a..f7d004ce9 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/abstract.cpp b/src/gui/render/abstract.cpp index cf76ebbb0..a970705de 100644 --- a/src/gui/render/abstract.cpp +++ b/src/gui/render/abstract.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderDX11.cpp b/src/gui/render/renderDX11.cpp index 26bfd0937..80b877034 100644 --- a/src/gui/render/renderDX11.cpp +++ b/src/gui/render/renderDX11.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderDX11.h b/src/gui/render/renderDX11.h index 39cc32df8..8348d068f 100644 --- a/src/gui/render/renderDX11.h +++ b/src/gui/render/renderDX11.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderGL.cpp b/src/gui/render/renderGL.cpp index 38fa4966b..840f3088e 100644 --- a/src/gui/render/renderGL.cpp +++ b/src/gui/render/renderGL.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderGL.h b/src/gui/render/renderGL.h index 55d399730..da7fa844d 100644 --- a/src/gui/render/renderGL.h +++ b/src/gui/render/renderGL.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderSDL.cpp b/src/gui/render/renderSDL.cpp index de1e28d3c..2aae041cb 100644 --- a/src/gui/render/renderSDL.cpp +++ b/src/gui/render/renderSDL.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/render/renderSDL.h b/src/gui/render/renderSDL.h index f19135841..ba68f5366 100644 --- a/src/gui/render/renderSDL.h +++ b/src/gui/render/renderSDL.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 3ab8fe7a3..d00852c8b 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/sampleUtil.h b/src/gui/sampleUtil.h index bdef166f4..bb1a254ae 100644 --- a/src/gui/sampleUtil.h +++ b/src/gui/sampleUtil.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/scaling.cpp b/src/gui/scaling.cpp index 6df1db087..f680e91dd 100644 --- a/src/gui/scaling.cpp +++ b/src/gui/scaling.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/scaling.h b/src/gui/scaling.h index be2c9f035..72c4b4cfb 100644 --- a/src/gui/scaling.h +++ b/src/gui/scaling.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 381c2eb9e..2ec4a0fd2 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1129,6 +1129,13 @@ void FurnaceGUI::drawSettings() { ImGui::EndCombo(); } + ImGui::SameLine(); + if (ImGui::Button("Re-scan MIDI devices")) { + e->rescanMidiDevices(); + audioEngineChanged=true; + settingsChanged=false; + } + if (hasToReloadMidi) { midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg"); midiMap.compile(); @@ -1139,9 +1146,21 @@ void FurnaceGUI::drawSettings() { // TODO //ImGui::Checkbox("Use raw velocity value (don't map from linear to log)",&midiMap.rawVolume); //ImGui::Checkbox("Polyphonic/chord input",&midiMap.polyInput); - if (ImGui::Checkbox("Map MIDI channels to direct channels",&midiMap.directChannel)) settingsChanged=true; + if (ImGui::Checkbox("Map MIDI channels to direct channels",&midiMap.directChannel)) { + e->setMidiDirect(midiMap.directChannel); + e->setMidiDirectProgram(midiMap.directChannel && midiMap.directProgram); + settingsChanged=true; + } + if (midiMap.directChannel) { + if (ImGui::Checkbox("Program change pass-through",&midiMap.directProgram)) { + e->setMidiDirectProgram(midiMap.directChannel && midiMap.directProgram); + settingsChanged=true; + } + } if (ImGui::Checkbox("Map Yamaha FM voice data to instruments",&midiMap.yamahaFMResponse)) settingsChanged=true; - if (ImGui::Checkbox("Program change is instrument selection",&midiMap.programChange)) settingsChanged=true; + if (!(midiMap.directChannel && midiMap.directProgram)) { + if (ImGui::Checkbox("Program change is instrument selection",&midiMap.programChange)) settingsChanged=true; + } //ImGui::Checkbox("Listen to MIDI clock",&midiMap.midiClock); //ImGui::Checkbox("Listen to MIDI time code",&midiMap.midiTimeCode); if (ImGui::Combo("Value input style",&midiMap.valueInputStyle,valueInputStyles,7)) settingsChanged=true; @@ -1198,6 +1217,7 @@ void FurnaceGUI::drawSettings() { if (ImGui::SliderFloat("Volume curve",&midiMap.volExp,0.01,8.0,"%.2f")) { if (midiMap.volExp<0.01) midiMap.volExp=0.01; if (midiMap.volExp>8.0) midiMap.volExp=8.0; + e->setMidiVolExp(midiMap.volExp); settingsChanged=true; } rightClickable float curve[128]; @@ -1659,6 +1679,7 @@ void FurnaceGUI::drawSettings() { UI_KEYBIND_CONFIG(GUI_ACTION_OPEN_BACKUP); UI_KEYBIND_CONFIG(GUI_ACTION_SAVE); UI_KEYBIND_CONFIG(GUI_ACTION_SAVE_AS); + UI_KEYBIND_CONFIG(GUI_ACTION_EXPORT); UI_KEYBIND_CONFIG(GUI_ACTION_UNDO); UI_KEYBIND_CONFIG(GUI_ACTION_REDO); UI_KEYBIND_CONFIG(GUI_ACTION_PLAY_TOGGLE); @@ -2646,6 +2667,22 @@ void FurnaceGUI::drawSettings() { } ImGui::Unindent(); + ImGui::Text("Export options layout:"); + ImGui::Indent(); + if (ImGui::RadioButton("Sub-menus in File menu##eol0",settings.exportOptionsLayout==0)) { + settings.exportOptionsLayout=0; + settingsChanged=true; + } + if (ImGui::RadioButton("Modal window with tabs##eol1",settings.exportOptionsLayout==1)) { + settings.exportOptionsLayout=1; + settingsChanged=true; + } + if (ImGui::RadioButton("Modal windows with options in File menu##eol2",settings.exportOptionsLayout==2)) { + settings.exportOptionsLayout=2; + settingsChanged=true; + } + ImGui::Unindent(); + bool capitalMenuBarB=settings.capitalMenuBar; if (ImGui::Checkbox("Capitalize menu bar",&capitalMenuBarB)) { settings.capitalMenuBar=capitalMenuBarB; @@ -2717,11 +2754,31 @@ void FurnaceGUI::drawSettings() { ImGui::Unindent(); ImGui::Text("Pattern view labels:"); - if (ImGui::InputTextWithHint("Note off (3-char)","OFF",&settings.noteOffLabel)) settingsChanged=true; - if (ImGui::InputTextWithHint("Note release (3-char)","===",&settings.noteRelLabel)) settingsChanged=true; - if (ImGui::InputTextWithHint("Macro release (3-char)","REL",&settings.macroRelLabel)) settingsChanged=true; - if (ImGui::InputTextWithHint("Empty field (3-char)","...",&settings.emptyLabel)) settingsChanged=true; - if (ImGui::InputTextWithHint("Empty field (2-char)","..",&settings.emptyLabel2)) settingsChanged=true; + ImGui::PushFont(patFont); + if (ImGui::InputTextWithHint("##PVLOff","OFF",&settings.noteOffLabel)) settingsChanged=true; + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Text("Note off (3-char)"); + ImGui::PushFont(patFont); + if (ImGui::InputTextWithHint("##PVLRel","===",&settings.noteRelLabel)) settingsChanged=true; + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Text("Note release (3-char)"); + ImGui::PushFont(patFont); + if (ImGui::InputTextWithHint("##PVLMacroRel","REL",&settings.macroRelLabel)) settingsChanged=true; + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Text("Macro release (3-char)"); + ImGui::PushFont(patFont); + if (ImGui::InputTextWithHint("##PVLE3","...",&settings.emptyLabel)) settingsChanged=true; + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Text("Empty field (3-char)"); + ImGui::PushFont(patFont); + if (ImGui::InputTextWithHint("##PVLE2","..",&settings.emptyLabel2)) settingsChanged=true; + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Text("Empty field (2-char)"); ImGui::Text("Pattern view spacing after:"); @@ -3135,6 +3192,18 @@ void FurnaceGUI::drawSettings() { settingsChanged=true; } + bool roundedTabsB=settings.roundedTabs; + if (ImGui::Checkbox("Rounded tabs",&roundedTabsB)) { + settings.roundedTabs=roundedTabsB; + settingsChanged=true; + } + + bool roundedScrollbarsB=settings.roundedScrollbars; + if (ImGui::Checkbox("Rounded scrollbars",&roundedScrollbarsB)) { + settings.roundedScrollbars=roundedScrollbarsB; + settingsChanged=true; + } + bool frameBordersB=settings.frameBorders; if (ImGui::Checkbox("Borders around widgets",&frameBordersB)) { settings.frameBorders=frameBordersB; @@ -3157,26 +3226,84 @@ void FurnaceGUI::drawSettings() { if (ImGui::Button("Reset defaults")) { showWarning("Are you sure you want to reset the color scheme?",GUI_WARN_RESET_COLORS); } - if (ImGui::TreeNode("General")) { - ImGui::Text("Color scheme type:"); - ImGui::Indent(); - if (ImGui::RadioButton("Dark##gcb0",settings.guiColorsBase==0)) { - settings.guiColorsBase=0; - applyUISettings(false); - settingsChanged=true; + bool basicColorsB=!settings.basicColors; + if (ImGui::Checkbox("Guru mode",&basicColorsB)) { + settings.basicColors=!basicColorsB; + applyUISettings(false); + settingsChanged=true; + } + if (settings.basicColors) { + if (ImGui::TreeNode("Interface")) { + if (ImGui::SliderInt("Frame shading",&settings.guiColorsShading,0,100,"%d%%")) { + if (settings.guiColorsShading<0) settings.guiColorsShading=0; + if (settings.guiColorsShading>100) settings.guiColorsShading=100; + applyUISettings(false); + settingsChanged=true; + } + ImGui::Text("Color scheme type:"); + ImGui::Indent(); + if (ImGui::RadioButton("Dark##gcb0",settings.guiColorsBase==0)) { + settings.guiColorsBase=0; + applyUISettings(false); + settingsChanged=true; + } + if (ImGui::RadioButton("Light##gcb1",settings.guiColorsBase==1)) { + settings.guiColorsBase=1; + applyUISettings(false); + settingsChanged=true; + } + ImGui::Unindent(); + + ImGui::Text("Accent colors:"); + ImGui::Indent(); + UI_COLOR_CONFIG(GUI_COLOR_ACCENT_PRIMARY,"Primary"); + UI_COLOR_CONFIG(GUI_COLOR_ACCENT_SECONDARY,"Secondary"); + ImGui::Unindent(); + + ImGui::TreePop(); } - if (ImGui::RadioButton("Light##gcb1",settings.guiColorsBase==1)) { - settings.guiColorsBase=1; - applyUISettings(false); - settingsChanged=true; - } - ImGui::Unindent(); - if (ImGui::SliderInt("Frame shading",&settings.guiColorsShading,0,100,"%d%%")) { - if (settings.guiColorsShading<0) settings.guiColorsShading=0; - if (settings.guiColorsShading>100) settings.guiColorsShading=100; - applyUISettings(false); - settingsChanged=true; + } else { + if (ImGui::TreeNode("Interface")) { + if (ImGui::SliderInt("Frame shading",&settings.guiColorsShading,0,100,"%d%%")) { + if (settings.guiColorsShading<0) settings.guiColorsShading=0; + if (settings.guiColorsShading>100) settings.guiColorsShading=100; + applyUISettings(false); + settingsChanged=true; + } + + UI_COLOR_CONFIG(GUI_COLOR_BUTTON,"Button"); + UI_COLOR_CONFIG(GUI_COLOR_BUTTON_HOVER,"Button (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_BUTTON_ACTIVE,"Button (active)"); + UI_COLOR_CONFIG(GUI_COLOR_TAB,"Tab"); + UI_COLOR_CONFIG(GUI_COLOR_TAB_HOVER,"Tab (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_TAB_ACTIVE,"Tab (active)"); + UI_COLOR_CONFIG(GUI_COLOR_TAB_UNFOCUSED,"Tab (unfocused)"); + UI_COLOR_CONFIG(GUI_COLOR_TAB_UNFOCUSED_ACTIVE,"Tab (unfocused and active)"); + UI_COLOR_CONFIG(GUI_COLOR_IMGUI_HEADER,"ImGui header"); + UI_COLOR_CONFIG(GUI_COLOR_IMGUI_HEADER_HOVER,"ImGui header (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_IMGUI_HEADER_ACTIVE,"ImGui header (active)"); + UI_COLOR_CONFIG(GUI_COLOR_RESIZE_GRIP,"Resize grip"); + UI_COLOR_CONFIG(GUI_COLOR_RESIZE_GRIP_HOVER,"Resize grip (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_RESIZE_GRIP_ACTIVE,"Resize grip (active)"); + UI_COLOR_CONFIG(GUI_COLOR_WIDGET_BACKGROUND,"Widget background"); + UI_COLOR_CONFIG(GUI_COLOR_WIDGET_BACKGROUND_HOVER,"Widget background (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_WIDGET_BACKGROUND_ACTIVE,"Widget background (active)"); + UI_COLOR_CONFIG(GUI_COLOR_SLIDER_GRAB,"Slider grab"); + UI_COLOR_CONFIG(GUI_COLOR_SLIDER_GRAB_ACTIVE,"Slider grab (active)"); + UI_COLOR_CONFIG(GUI_COLOR_TITLE_BACKGROUND_ACTIVE,"Title background (active)"); + UI_COLOR_CONFIG(GUI_COLOR_CHECK_MARK,"Checkbox/radio button mark"); + UI_COLOR_CONFIG(GUI_COLOR_TEXT_SELECTION,"Text selection"); + UI_COLOR_CONFIG(GUI_COLOR_PLOT_LINES,"Line plot"); + UI_COLOR_CONFIG(GUI_COLOR_PLOT_LINES_HOVER,"Line plot (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_PLOT_HISTOGRAM,"Histogram plot"); + UI_COLOR_CONFIG(GUI_COLOR_PLOT_HISTOGRAM_HOVER,"Histogram plot (hovered)"); + UI_COLOR_CONFIG(GUI_COLOR_TABLE_ROW_EVEN,"Table row (even)"); + UI_COLOR_CONFIG(GUI_COLOR_TABLE_ROW_ODD,"Table row (odd)"); + + ImGui::TreePop(); } + } + if (ImGui::TreeNode("Interface (other)")) { UI_COLOR_CONFIG(GUI_COLOR_BACKGROUND,"Background"); UI_COLOR_CONFIG(GUI_COLOR_FRAME_BACKGROUND,"Window background"); UI_COLOR_CONFIG(GUI_COLOR_FRAME_BACKGROUND_CHILD,"Sub-window background"); @@ -3184,8 +3311,7 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_MODAL_BACKDROP,"Modal backdrop"); UI_COLOR_CONFIG(GUI_COLOR_HEADER,"Header"); UI_COLOR_CONFIG(GUI_COLOR_TEXT,"Text"); - UI_COLOR_CONFIG(GUI_COLOR_ACCENT_PRIMARY,"Primary"); - UI_COLOR_CONFIG(GUI_COLOR_ACCENT_SECONDARY,"Secondary"); + UI_COLOR_CONFIG(GUI_COLOR_TEXT_DISABLED,"Text (disabled)"); UI_COLOR_CONFIG(GUI_COLOR_TITLE_INACTIVE,"Title bar (inactive)"); UI_COLOR_CONFIG(GUI_COLOR_TITLE_COLLAPSED,"Title bar (collapsed)"); UI_COLOR_CONFIG(GUI_COLOR_MENU_BAR,"Menu bar"); @@ -3206,11 +3332,11 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_DRAG_DROP_TARGET,"Drag and drop target"); UI_COLOR_CONFIG(GUI_COLOR_NAV_WIN_HIGHLIGHT,"Window switcher (highlight)"); UI_COLOR_CONFIG(GUI_COLOR_NAV_WIN_BACKDROP,"Window switcher backdrop"); + ImGui::TreePop(); + } + if (ImGui::TreeNode("Miscellaneous")) { UI_COLOR_CONFIG(GUI_COLOR_TOGGLE_ON,"Toggle on"); UI_COLOR_CONFIG(GUI_COLOR_TOGGLE_OFF,"Toggle off"); - UI_COLOR_CONFIG(GUI_COLOR_EDITING,"Editing"); - UI_COLOR_CONFIG(GUI_COLOR_EDITING_CLONE,"Editing (will clone)"); - UI_COLOR_CONFIG(GUI_COLOR_SONG_LOOP,"Song loop"); UI_COLOR_CONFIG(GUI_COLOR_PLAYBACK_STAT,"Playback status"); UI_COLOR_CONFIG(GUI_COLOR_DESTRUCTIVE,"Destructive hint"); UI_COLOR_CONFIG(GUI_COLOR_WARNING,"Warning hint"); @@ -3271,6 +3397,7 @@ void FurnaceGUI::drawSettings() { if (ImGui::TreeNode("Orders")) { UI_COLOR_CONFIG(GUI_COLOR_ORDER_ROW_INDEX,"Order number"); UI_COLOR_CONFIG(GUI_COLOR_ORDER_ACTIVE,"Playing order background"); + UI_COLOR_CONFIG(GUI_COLOR_SONG_LOOP,"Song loop"); UI_COLOR_CONFIG(GUI_COLOR_ORDER_SELECTED,"Selected order"); UI_COLOR_CONFIG(GUI_COLOR_ORDER_SIMILAR,"Similar patterns"); UI_COLOR_CONFIG(GUI_COLOR_ORDER_INACTIVE,"Inactive patterns"); @@ -3383,6 +3510,8 @@ void FurnaceGUI::drawSettings() { } if (ImGui::TreeNode("Pattern")) { UI_COLOR_CONFIG(GUI_COLOR_PATTERN_PLAY_HEAD,"Playhead"); + UI_COLOR_CONFIG(GUI_COLOR_EDITING,"Editing"); + UI_COLOR_CONFIG(GUI_COLOR_EDITING_CLONE,"Editing (will clone)"); UI_COLOR_CONFIG(GUI_COLOR_PATTERN_CURSOR,"Cursor"); UI_COLOR_CONFIG(GUI_COLOR_PATTERN_CURSOR_HOVER,"Cursor (hovered)"); UI_COLOR_CONFIG(GUI_COLOR_PATTERN_CURSOR_ACTIVE,"Cursor (clicked)"); @@ -3605,207 +3734,329 @@ void FurnaceGUI::drawSettings() { x=maxV; \ } -void FurnaceGUI::syncSettings() { - settings.mainFontSize=e->getConfInt("mainFontSize",18); - settings.headFontSize=e->getConfInt("headFontSize",27); - settings.patFontSize=e->getConfInt("patFontSize",18); - settings.iconSize=e->getConfInt("iconSize",16); - settings.audioEngine=(e->getConfString("audioEngine","SDL")=="SDL")?1:0; - if (e->getConfString("audioEngine","SDL")=="JACK") { - settings.audioEngine=DIV_AUDIO_JACK; - } else if (e->getConfString("audioEngine","SDL")=="PortAudio") { - settings.audioEngine=DIV_AUDIO_PORTAUDIO; - } else { - settings.audioEngine=DIV_AUDIO_SDL; +void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { + if (groups&GUI_SETTINGS_GENERAL) { + settings.renderDriver=conf.getString("renderDriver",""); + settings.noDMFCompat=conf.getInt("noDMFCompat",0); + + settings.dpiScale=conf.getFloat("dpiScale",0.0f); + + settings.initialSysName=conf.getString("initialSysName",""); + + // initial system + String initialSys2=conf.getString("initialSys2",""); + bool oldVol=conf.getInt("configVersion",DIV_ENGINE_VERSION)<135; + if (initialSys2.empty()) { + initialSys2=e->decodeSysDesc(conf.getString("initialSys","")); + oldVol=false; + } + settings.initialSys.clear(); + settings.initialSys.loadFromBase64(initialSys2.c_str()); + if (settings.initialSys.getInt("id0",0)==0) { + settings.initialSys.clear(); + settings.initialSys.set("id0",e->systemToFileFur(DIV_SYSTEM_YM2612)); + settings.initialSys.set("vol0",1.0f); + settings.initialSys.set("pan0",0.0f); + settings.initialSys.set("fr0",0.0f); + settings.initialSys.set("flags0",""); + settings.initialSys.set("id1",e->systemToFileFur(DIV_SYSTEM_SMS)); + settings.initialSys.set("vol1",0.5f); + settings.initialSys.set("pan1",0); + settings.initialSys.set("fr1",0); + settings.initialSys.set("flags1",""); + } else { + if (oldVol) { + for (int i=0; settings.initialSys.getInt(fmt::sprintf("id%d",i),0); i++) { + float newVol=settings.initialSys.getInt(fmt::sprintf("vol%d",i),64); + float newPan=settings.initialSys.getInt(fmt::sprintf("pan%d",i),0); + newVol/=64.0f; + newPan/=127.0f; + settings.initialSys.set(fmt::sprintf("vol%d",i),newVol); + settings.initialSys.set(fmt::sprintf("pan%d",i),newPan); + } + conf.set("initialSys2",settings.initialSys.toBase64()); + conf.set("configVersion",DIV_ENGINE_VERSION); + } + } + + settings.noThreadedInput=conf.getInt("noThreadedInput",0); + settings.powerSave=conf.getInt("powerSave",POWER_SAVE_DEFAULT); + settings.eventDelay=conf.getInt("eventDelay",0); + + settings.renderBackend=conf.getString("renderBackend",GUI_BACKEND_DEFAULT_NAME); + settings.renderClearPos=conf.getInt("renderClearPos",0); + + settings.chanOscThreads=conf.getInt("chanOscThreads",0); + settings.renderPoolThreads=conf.getInt("renderPoolThreads",0); + settings.showPool=conf.getInt("showPool",0); + settings.writeInsNames=conf.getInt("writeInsNames",0); + settings.readInsNames=conf.getInt("readInsNames",1); + settings.defaultAuthorName=conf.getString("defaultAuthorName",""); + + settings.hiddenSystems=conf.getInt("hiddenSystems",0); + settings.allowEditDocking=conf.getInt("allowEditDocking",1); + settings.sysFileDialog=conf.getInt("sysFileDialog",SYS_FILE_DIALOG_DEFAULT); + settings.displayAllInsTypes=conf.getInt("displayAllInsTypes",0); + settings.displayPartial=conf.getInt("displayPartial",0); + + settings.blankIns=conf.getInt("blankIns",0); + + settings.saveWindowPos=conf.getInt("saveWindowPos",1); + + settings.saveUnusedPatterns=conf.getInt("saveUnusedPatterns",0); + settings.maxRecentFile=conf.getInt("maxRecentFile",10); + + settings.persistFadeOut=conf.getInt("persistFadeOut",1); + settings.exportLoops=conf.getInt("exportLoops",0); + settings.exportFadeOut=conf.getDouble("exportFadeOut",0.0); + + settings.doubleClickTime=conf.getFloat("doubleClickTime",0.3f); + settings.disableFadeIn=conf.getInt("disableFadeIn",0); + settings.alwaysPlayIntro=conf.getInt("alwaysPlayIntro",0); + settings.iCannotWait=conf.getInt("iCannotWait",0); + + settings.compress=conf.getInt("compress",1); + settings.newPatternFormat=conf.getInt("newPatternFormat",1); + settings.newSongBehavior=conf.getInt("newSongBehavior",0); + settings.playOnLoad=conf.getInt("playOnLoad",0); + settings.centerPopup=conf.getInt("centerPopup",1); + } + + if (groups&GUI_SETTINGS_AUDIO) { + settings.audioEngine=(conf.getString("audioEngine","SDL")=="SDL")?1:0; + if (conf.getString("audioEngine","SDL")=="JACK") { + settings.audioEngine=DIV_AUDIO_JACK; + } else if (conf.getString("audioEngine","SDL")=="PortAudio") { + settings.audioEngine=DIV_AUDIO_PORTAUDIO; + } else { + settings.audioEngine=DIV_AUDIO_SDL; + } + settings.audioDevice=conf.getString("audioDevice",""); + settings.sdlAudioDriver=conf.getString("sdlAudioDriver",""); + settings.audioQuality=conf.getInt("audioQuality",0); + settings.audioHiPass=conf.getInt("audioHiPass",1); + settings.audioBufSize=conf.getInt("audioBufSize",1024); + settings.audioRate=conf.getInt("audioRate",44100); + settings.audioChans=conf.getInt("audioChans",2); + + settings.lowLatency=conf.getInt("lowLatency",0); + + settings.metroVol=conf.getInt("metroVol",100); + settings.sampleVol=conf.getInt("sampleVol",50); + + settings.wasapiEx=conf.getInt("wasapiEx",0); + + settings.clampSamples=conf.getInt("clampSamples",0); + settings.forceMono=conf.getInt("forceMono",0); + } + + if (groups&GUI_SETTINGS_MIDI) { + settings.midiInDevice=conf.getString("midiInDevice",""); + settings.midiOutDevice=conf.getString("midiOutDevice",""); + settings.midiOutClock=conf.getInt("midiOutClock",0); + settings.midiOutTime=conf.getInt("midiOutTime",0); + settings.midiOutProgramChange=conf.getInt("midiOutProgramChange",0); + settings.midiOutMode=conf.getInt("midiOutMode",1); + settings.midiOutTimeRate=conf.getInt("midiOutTimeRate",0); + } + + if (groups&GUI_SETTINGS_KEYBOARD) { + // keybinds + for (int i=0; igetConfString("audioDevice",""); - settings.audioChans=e->getConfInt("audioChans",2); - settings.midiInDevice=e->getConfString("midiInDevice",""); - settings.midiOutDevice=e->getConfString("midiOutDevice",""); - settings.renderDriver=e->getConfString("renderDriver",""); - settings.sdlAudioDriver=e->getConfString("sdlAudioDriver",""); - settings.audioQuality=e->getConfInt("audioQuality",0); - settings.audioHiPass=e->getConfInt("audioHiPass",1); - settings.audioBufSize=e->getConfInt("audioBufSize",1024); - settings.audioRate=e->getConfInt("audioRate",44100); - settings.arcadeCore=e->getConfInt("arcadeCore",0); - settings.ym2612Core=e->getConfInt("ym2612Core",0); - settings.snCore=e->getConfInt("snCore",0); - settings.nesCore=e->getConfInt("nesCore",0); - settings.fdsCore=e->getConfInt("fdsCore",0); - settings.c64Core=e->getConfInt("c64Core",0); - settings.pokeyCore=e->getConfInt("pokeyCore",1); - settings.opnCore=e->getConfInt("opnCore",1); - settings.opl2Core=e->getConfInt("opl2Core",0); - settings.opl3Core=e->getConfInt("opl3Core",0); - settings.arcadeCoreRender=e->getConfInt("arcadeCoreRender",1); - settings.ym2612CoreRender=e->getConfInt("ym2612CoreRender",0); - settings.snCoreRender=e->getConfInt("snCoreRender",0); - settings.nesCoreRender=e->getConfInt("nesCoreRender",0); - settings.fdsCoreRender=e->getConfInt("fdsCoreRender",1); - settings.c64CoreRender=e->getConfInt("c64CoreRender",1); - settings.pokeyCoreRender=e->getConfInt("pokeyCoreRender",1); - settings.opnCoreRender=e->getConfInt("opnCoreRender",1); - settings.opl2CoreRender=e->getConfInt("opl2CoreRender",0); - settings.opl3CoreRender=e->getConfInt("opl3CoreRender",0); - settings.pcSpeakerOutMethod=e->getConfInt("pcSpeakerOutMethod",0); - settings.yrw801Path=e->getConfString("yrw801Path",""); - settings.tg100Path=e->getConfString("tg100Path",""); - settings.mu5Path=e->getConfString("mu5Path",""); - settings.mainFont=e->getConfInt("mainFont",0); - settings.headFont=e->getConfInt("headFont",0); - settings.patFont=e->getConfInt("patFont",0); - settings.mainFontPath=e->getConfString("mainFontPath",""); - settings.headFontPath=e->getConfString("headFontPath",""); - settings.patFontPath=e->getConfString("patFontPath",""); - settings.patRowsBase=e->getConfInt("patRowsBase",0); - settings.orderRowsBase=e->getConfInt("orderRowsBase",1); - settings.soloAction=e->getConfInt("soloAction",0); - settings.pullDeleteBehavior=e->getConfInt("pullDeleteBehavior",1); - settings.wrapHorizontal=e->getConfInt("wrapHorizontal",0); - settings.wrapVertical=e->getConfInt("wrapVertical",0); - settings.macroView=e->getConfInt("macroView",0); - settings.fmNames=e->getConfInt("fmNames",0); - settings.allowEditDocking=e->getConfInt("allowEditDocking",1); - settings.chipNames=e->getConfInt("chipNames",0); - settings.overflowHighlight=e->getConfInt("overflowHighlight",0); - settings.partyTime=e->getConfInt("partyTime",0); - settings.flatNotes=e->getConfInt("flatNotes",0); - settings.germanNotation=e->getConfInt("germanNotation",0); - settings.stepOnDelete=e->getConfInt("stepOnDelete",0); - settings.scrollStep=e->getConfInt("scrollStep",0); - settings.sysSeparators=e->getConfInt("sysSeparators",1); - settings.forceMono=e->getConfInt("forceMono",0); - settings.controlLayout=e->getConfInt("controlLayout",3); - settings.statusDisplay=e->getConfInt("statusDisplay",0); - settings.dpiScale=e->getConfFloat("dpiScale",0.0f); - settings.viewPrevPattern=e->getConfInt("viewPrevPattern",1); - settings.guiColorsBase=e->getConfInt("guiColorsBase",0); - settings.guiColorsShading=e->getConfInt("guiColorsShading",0); - settings.avoidRaisingPattern=e->getConfInt("avoidRaisingPattern",0); - settings.insFocusesPattern=e->getConfInt("insFocusesPattern",1); - settings.stepOnInsert=e->getConfInt("stepOnInsert",0); - settings.unifiedDataView=e->getConfInt("unifiedDataView",0); - settings.sysFileDialog=e->getConfInt("sysFileDialog",SYS_FILE_DIALOG_DEFAULT); - settings.roundedWindows=e->getConfInt("roundedWindows",1); - settings.roundedButtons=e->getConfInt("roundedButtons",1); - settings.roundedMenus=e->getConfInt("roundedMenus",0); - settings.loadJapanese=e->getConfInt("loadJapanese",0); - settings.loadChinese=e->getConfInt("loadChinese",0); - settings.loadChineseTraditional=e->getConfInt("loadChineseTraditional",0); - settings.loadKorean=e->getConfInt("loadKorean",0); - settings.fmLayout=e->getConfInt("fmLayout",4); - settings.sampleLayout=e->getConfInt("sampleLayout",0); - settings.waveLayout=e->getConfInt("waveLayout",0); - settings.susPosition=e->getConfInt("susPosition",0); - settings.effectCursorDir=e->getConfInt("effectCursorDir",1); - settings.cursorPastePos=e->getConfInt("cursorPastePos",1); - settings.titleBarInfo=e->getConfInt("titleBarInfo",1); - settings.titleBarSys=e->getConfInt("titleBarSys",1); - settings.frameBorders=e->getConfInt("frameBorders",0); - settings.effectDeletionAltersValue=e->getConfInt("effectDeletionAltersValue",1); - settings.oscRoundedCorners=e->getConfInt("oscRoundedCorners",1); - settings.oscTakesEntireWindow=e->getConfInt("oscTakesEntireWindow",0); - settings.oscBorder=e->getConfInt("oscBorder",1); - settings.oscEscapesBoundary=e->getConfInt("oscEscapesBoundary",0); - settings.oscMono=e->getConfInt("oscMono",1); - settings.oscAntiAlias=e->getConfInt("oscAntiAlias",1); - settings.separateFMColors=e->getConfInt("separateFMColors",0); - settings.insEditColorize=e->getConfInt("insEditColorize",0); - settings.metroVol=e->getConfInt("metroVol",100); - settings.sampleVol=e->getConfInt("sampleVol",50); - settings.pushNibble=e->getConfInt("pushNibble",0); - settings.scrollChangesOrder=e->getConfInt("scrollChangesOrder",0); - settings.oplStandardWaveNames=e->getConfInt("oplStandardWaveNames",0); - settings.cursorMoveNoScroll=e->getConfInt("cursorMoveNoScroll",0); - settings.lowLatency=e->getConfInt("lowLatency",0); - settings.notePreviewBehavior=e->getConfInt("notePreviewBehavior",1); - settings.powerSave=e->getConfInt("powerSave",POWER_SAVE_DEFAULT); - settings.absorbInsInput=e->getConfInt("absorbInsInput",0); - settings.eventDelay=e->getConfInt("eventDelay",0); - settings.moveWindowTitle=e->getConfInt("moveWindowTitle",1); - settings.hiddenSystems=e->getConfInt("hiddenSystems",0); - settings.horizontalDataView=e->getConfInt("horizontalDataView",0); - settings.noMultiSystem=e->getConfInt("noMultiSystem",0); - settings.oldMacroVSlider=e->getConfInt("oldMacroVSlider",0); - settings.displayAllInsTypes=e->getConfInt("displayAllInsTypes",0); - settings.displayPartial=e->getConfInt("displayPartial",0); - settings.noteCellSpacing=e->getConfInt("noteCellSpacing",0); - settings.insCellSpacing=e->getConfInt("insCellSpacing",0); - settings.volCellSpacing=e->getConfInt("volCellSpacing",0); - settings.effectCellSpacing=e->getConfInt("effectCellSpacing",0); - settings.effectValCellSpacing=e->getConfInt("effectValCellSpacing",0); - settings.doubleClickColumn=e->getConfInt("doubleClickColumn",1); - settings.blankIns=e->getConfInt("blankIns",0); - settings.dragMovesSelection=e->getConfInt("dragMovesSelection",2); - settings.unsignedDetune=e->getConfInt("unsignedDetune",0); - settings.noThreadedInput=e->getConfInt("noThreadedInput",0); - settings.saveWindowPos=e->getConfInt("saveWindowPos",1); - settings.initialSysName=e->getConfString("initialSysName",""); - settings.clampSamples=e->getConfInt("clampSamples",0); - settings.noteOffLabel=e->getConfString("noteOffLabel","OFF"); - settings.noteRelLabel=e->getConfString("noteRelLabel","==="); - settings.macroRelLabel=e->getConfString("macroRelLabel","REL"); - settings.emptyLabel=e->getConfString("emptyLabel","..."); - settings.emptyLabel2=e->getConfString("emptyLabel2",".."); - settings.saveUnusedPatterns=e->getConfInt("saveUnusedPatterns",0); - settings.channelColors=e->getConfInt("channelColors",1); - settings.channelTextColors=e->getConfInt("channelTextColors",0); - settings.channelStyle=e->getConfInt("channelStyle",1); - settings.channelVolStyle=e->getConfInt("channelVolStyle",0); - settings.channelFeedbackStyle=e->getConfInt("channelFeedbackStyle",1); - settings.channelFont=e->getConfInt("channelFont",1); - settings.channelTextCenter=e->getConfInt("channelTextCenter",1); - settings.maxRecentFile=e->getConfInt("maxRecentFile",10); - settings.midiOutClock=e->getConfInt("midiOutClock",0); - settings.midiOutTime=e->getConfInt("midiOutTime",0); - settings.midiOutProgramChange=e->getConfInt("midiOutProgramChange",0); - settings.midiOutMode=e->getConfInt("midiOutMode",1); - settings.midiOutTimeRate=e->getConfInt("midiOutTimeRate",0); - settings.centerPattern=e->getConfInt("centerPattern",0); - settings.ordersCursor=e->getConfInt("ordersCursor",1); - settings.persistFadeOut=e->getConfInt("persistFadeOut",1); - settings.exportLoops=e->getConfInt("exportLoops",0); - settings.exportFadeOut=e->getConfDouble("exportFadeOut",0.0); - settings.macroLayout=e->getConfInt("macroLayout",0); - settings.doubleClickTime=e->getConfFloat("doubleClickTime",0.3f); - settings.oneDigitEffects=e->getConfInt("oneDigitEffects",0); - settings.disableFadeIn=e->getConfInt("disableFadeIn",0); - settings.alwaysPlayIntro=e->getConfInt("alwaysPlayIntro",0); - settings.cursorFollowsOrder=e->getConfInt("cursorFollowsOrder",1); - settings.iCannotWait=e->getConfInt("iCannotWait",0); - settings.orderButtonPos=e->getConfInt("orderButtonPos",2); - settings.compress=e->getConfInt("compress",1); - settings.newPatternFormat=e->getConfInt("newPatternFormat",1); - settings.renderBackend=e->getConfString("renderBackend",GUI_BACKEND_DEFAULT_NAME); - settings.renderClearPos=e->getConfInt("renderClearPos",0); - settings.insertBehavior=e->getConfInt("insertBehavior",1); - settings.pullDeleteRow=e->getConfInt("pullDeleteRow",1); - settings.newSongBehavior=e->getConfInt("newSongBehavior",0); - settings.memUsageUnit=e->getConfInt("memUsageUnit",1); - settings.cursorFollowsWheel=e->getConfInt("cursorFollowsWheel",0); - settings.noDMFCompat=e->getConfInt("noDMFCompat",0); - settings.removeInsOff=e->getConfInt("removeInsOff",0); - settings.removeVolOff=e->getConfInt("removeVolOff",0); - settings.playOnLoad=e->getConfInt("playOnLoad",0); - settings.insTypeMenu=e->getConfInt("insTypeMenu",1); - settings.capitalMenuBar=e->getConfInt("capitalMenuBar",0); - settings.centerPopup=e->getConfInt("centerPopup",1); - settings.insIconsStyle=e->getConfInt("insIconsStyle",1); - settings.classicChipOptions=e->getConfInt("classicChipOptions",0); - settings.wasapiEx=e->getConfInt("wasapiEx",0); - settings.chanOscThreads=e->getConfInt("chanOscThreads",0); - settings.renderPoolThreads=e->getConfInt("renderPoolThreads",0); - settings.showPool=e->getConfInt("showPool",0); - settings.writeInsNames=e->getConfInt("writeInsNames",1); - settings.readInsNames=e->getConfInt("readInsNames",1); - settings.defaultAuthorName=e->getConfString("defaultAuthorName",""); - settings.fontBackend=e->getConfInt("fontBackend",FONT_BACKEND_DEFAULT); - settings.fontHinting=e->getConfInt("fontHinting",0); - settings.fontBitmap=e->getConfInt("fontBitmap",0); - settings.fontAutoHint=e->getConfInt("fontAutoHint",1); - settings.fontAntiAlias=e->getConfInt("fontAntiAlias",1); - settings.selectAssetOnLoad=e->getConfInt("selectAssetOnLoad",1); clampSetting(settings.mainFontSize,2,96); clampSetting(settings.headFontSize,2,96); @@ -3846,7 +4097,6 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.pullDeleteBehavior,0,1); clampSetting(settings.wrapHorizontal,0,2); clampSetting(settings.wrapVertical,0,3); - clampSetting(settings.macroView,0,1); clampSetting(settings.fmNames,0,2); clampSetting(settings.allowEditDocking,0,1); clampSetting(settings.chipNames,0,1); @@ -3872,6 +4122,8 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.roundedWindows,0,1); clampSetting(settings.roundedButtons,0,1); clampSetting(settings.roundedMenus,0,1); + clampSetting(settings.roundedTabs,0,1); + clampSetting(settings.roundedScrollbars,0,1); clampSetting(settings.loadJapanese,0,1); clampSetting(settings.loadChinese,0,1); clampSetting(settings.loadChineseTraditional,0,1); @@ -3960,6 +4212,7 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.centerPopup,0,1); clampSetting(settings.insIconsStyle,0,2); clampSetting(settings.classicChipOptions,0,1); + clampSetting(settings.exportOptionsLayout,0,2); clampSetting(settings.wasapiEx,0,1); clampSetting(settings.chanOscThreads,0,256); clampSetting(settings.renderPoolThreads,0,DIV_MAX_CHIPS); @@ -3972,52 +4225,307 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.fontAutoHint,0,2); clampSetting(settings.fontAntiAlias,0,1); clampSetting(settings.selectAssetOnLoad,0,1); + clampSetting(settings.basicColors,0,1); if (settings.exportLoops<0.0) settings.exportLoops=0.0; - if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0; + if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0; +} - String initialSys2=e->getConfString("initialSys2",""); - bool oldVol=e->getConfInt("configVersion",DIV_ENGINE_VERSION)<135; - if (initialSys2.empty()) { - initialSys2=e->decodeSysDesc(e->getConfString("initialSys","")); - oldVol=false; +void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) { + // general + if (groups&GUI_SETTINGS_GENERAL) { + conf.set("renderDriver",settings.renderDriver); + conf.set("noDMFCompat",settings.noDMFCompat); + + conf.set("dpiScale",settings.dpiScale); + + conf.set("initialSys2",settings.initialSys.toBase64()); + conf.set("initialSysName",settings.initialSysName); + + conf.set("noThreadedInput",settings.noThreadedInput); + conf.set("powerSave",settings.powerSave); + conf.set("eventDelay",settings.eventDelay); + + conf.set("renderBackend",settings.renderBackend); + conf.set("renderClearPos",settings.renderClearPos); + + conf.set("chanOscThreads",settings.chanOscThreads); + conf.set("renderPoolThreads",settings.renderPoolThreads); + conf.set("showPool",settings.showPool); + conf.set("writeInsNames",settings.writeInsNames); + conf.set("readInsNames",settings.readInsNames); + conf.set("defaultAuthorName",settings.defaultAuthorName); + + conf.set("hiddenSystems",settings.hiddenSystems); + conf.set("allowEditDocking",settings.allowEditDocking); + conf.set("sysFileDialog",settings.sysFileDialog); + conf.set("displayAllInsTypes",settings.displayAllInsTypes); + conf.set("displayPartial",settings.displayPartial); + + conf.set("blankIns",settings.blankIns); + + conf.set("saveWindowPos",settings.saveWindowPos); + + conf.set("saveUnusedPatterns",settings.saveUnusedPatterns); + conf.set("maxRecentFile",settings.maxRecentFile); + + conf.set("persistFadeOut",settings.persistFadeOut); + conf.set("exportLoops",settings.exportLoops); + conf.set("exportFadeOut",settings.exportFadeOut); + + conf.set("doubleClickTime",settings.doubleClickTime); + conf.set("disableFadeIn",settings.disableFadeIn); + conf.set("alwaysPlayIntro",settings.alwaysPlayIntro); + conf.set("iCannotWait",settings.iCannotWait); + + conf.set("compress",settings.compress); + conf.set("newPatternFormat",settings.newPatternFormat); + conf.set("newSongBehavior",settings.newSongBehavior); + conf.set("playOnLoad",settings.playOnLoad); + conf.set("centerPopup",settings.centerPopup); } - settings.initialSys.clear(); - settings.initialSys.loadFromBase64(initialSys2.c_str()); - if (settings.initialSys.getInt("id0",0)==0) { - settings.initialSys.clear(); - settings.initialSys.set("id0",e->systemToFileFur(DIV_SYSTEM_YM2612)); - settings.initialSys.set("vol0",1.0f); - settings.initialSys.set("pan0",0.0f); - settings.initialSys.set("fr0",0.0f); - settings.initialSys.set("flags0",""); - settings.initialSys.set("id1",e->systemToFileFur(DIV_SYSTEM_SMS)); - settings.initialSys.set("vol1",0.5f); - settings.initialSys.set("pan1",0); - settings.initialSys.set("fr1",0); - settings.initialSys.set("flags1",""); - } else { - if (oldVol) { - for (int i=0; settings.initialSys.getInt(fmt::sprintf("id%d",i),0); i++) { - float newVol=settings.initialSys.getInt(fmt::sprintf("vol%d",i),64); - float newPan=settings.initialSys.getInt(fmt::sprintf("pan%d",i),0); - newVol/=64.0f; - newPan/=127.0f; - settings.initialSys.set(fmt::sprintf("vol%d",i),newVol); - settings.initialSys.set(fmt::sprintf("pan%d",i),newPan); - } - e->setConf("initialSys2",settings.initialSys.toBase64()); - e->setConf("configVersion",DIV_ENGINE_VERSION); + + // audio + if (groups&GUI_SETTINGS_AUDIO) { + conf.set("audioEngine",String(audioBackends[settings.audioEngine])); + conf.set("audioDevice",settings.audioDevice); + conf.set("sdlAudioDriver",settings.sdlAudioDriver); + conf.set("audioQuality",settings.audioQuality); + conf.set("audioHiPass",settings.audioHiPass); + conf.set("audioBufSize",settings.audioBufSize); + conf.set("audioRate",settings.audioRate); + conf.set("audioChans",settings.audioChans); + + conf.set("lowLatency",settings.lowLatency); + + conf.set("metroVol",settings.metroVol); + conf.set("sampleVol",settings.sampleVol); + + conf.set("wasapiEx",settings.wasapiEx); + + conf.set("clampSamples",settings.clampSamples); + conf.set("forceMono",settings.forceMono); + } + + // MIDI + if (groups&GUI_SETTINGS_MIDI) { + conf.set("midiInDevice",settings.midiInDevice); + conf.set("midiOutDevice",settings.midiOutDevice); + conf.set("midiOutClock",settings.midiOutClock); + conf.set("midiOutTime",settings.midiOutTime); + conf.set("midiOutProgramChange",settings.midiOutProgramChange); + conf.set("midiOutMode",settings.midiOutMode); + conf.set("midiOutTimeRate",settings.midiOutTimeRate); + } + + // keyboard + if (groups&GUI_SETTINGS_KEYBOARD) { + // keybinds + for (int i=0; igetConfInt(String("keybind_GUI_ACTION_")+String(guiActions[i].name),guiActions[i].defaultBind); - } + // emulation + if (groups&GUI_SETTINGS_EMULATION) { + conf.set("arcadeCore",settings.arcadeCore); + conf.set("ym2612Core",settings.ym2612Core); + conf.set("snCore",settings.snCore); + conf.set("nesCore",settings.nesCore); + conf.set("fdsCore",settings.fdsCore); + conf.set("c64Core",settings.c64Core); + conf.set("pokeyCore",settings.pokeyCore); + conf.set("opnCore",settings.opnCore); + conf.set("opl2Core",settings.opl2Core); + conf.set("opl3Core",settings.opl3Core); + conf.set("arcadeCoreRender",settings.arcadeCoreRender); + conf.set("ym2612CoreRender",settings.ym2612CoreRender); + conf.set("snCoreRender",settings.snCoreRender); + conf.set("nesCoreRender",settings.nesCoreRender); + conf.set("fdsCoreRender",settings.fdsCoreRender); + conf.set("c64CoreRender",settings.c64CoreRender); + conf.set("pokeyCoreRender",settings.pokeyCoreRender); + conf.set("opnCoreRender",settings.opnCoreRender); + conf.set("opl2CoreRender",settings.opl2CoreRender); + conf.set("opl3CoreRender",settings.opl3CoreRender); - decodeKeyMap(noteKeys,e->getConfString("noteKeys",DEFAULT_NOTE_KEYS)); + conf.set("pcSpeakerOutMethod",settings.pcSpeakerOutMethod); + + conf.set("yrw801Path",settings.yrw801Path); + conf.set("tg100Path",settings.tg100Path); + conf.set("mu5Path",settings.mu5Path); + } +} + +void FurnaceGUI::syncSettings() { + readConfig(e->getConfObject()); parseKeybinds(); @@ -4025,6 +4533,8 @@ void FurnaceGUI::syncSettings() { midiMap.compile(); e->setMidiDirect(midiMap.directChannel); + e->setMidiDirectProgram(midiMap.directChannel && midiMap.directProgram); + e->setMidiVolExp(midiMap.volExp); e->setMetronomeVol(((float)settings.metroVol)/100.0f); e->setSamplePreviewVol(((float)settings.sampleVol)/100.0f); } @@ -4059,216 +4569,10 @@ void FurnaceGUI::commitSettings() { settings.audioHiPass!=e->getConfInt("audioHiPass",1) ); - e->setConf("mainFontSize",settings.mainFontSize); - e->setConf("headFontSize",settings.headFontSize); - e->setConf("patFontSize",settings.patFontSize); - e->setConf("iconSize",settings.iconSize); - e->setConf("audioEngine",String(audioBackends[settings.audioEngine])); - e->setConf("audioDevice",settings.audioDevice); - e->setConf("midiInDevice",settings.midiInDevice); - e->setConf("midiOutDevice",settings.midiOutDevice); - e->setConf("renderDriver",settings.renderDriver); - e->setConf("sdlAudioDriver",settings.sdlAudioDriver); - e->setConf("audioQuality",settings.audioQuality); - e->setConf("audioHiPass",settings.audioHiPass); - e->setConf("audioBufSize",settings.audioBufSize); - e->setConf("audioRate",settings.audioRate); - e->setConf("audioChans",settings.audioChans); - e->setConf("arcadeCore",settings.arcadeCore); - e->setConf("ym2612Core",settings.ym2612Core); - e->setConf("snCore",settings.snCore); - e->setConf("nesCore",settings.nesCore); - e->setConf("fdsCore",settings.fdsCore); - e->setConf("c64Core",settings.c64Core); - e->setConf("pokeyCore",settings.pokeyCore); - e->setConf("opnCore",settings.opnCore); - e->setConf("opl2Core",settings.opl2Core); - e->setConf("opl3Core",settings.opl3Core); - e->setConf("arcadeCoreRender",settings.arcadeCoreRender); - e->setConf("ym2612CoreRender",settings.ym2612CoreRender); - e->setConf("snCoreRender",settings.snCoreRender); - e->setConf("nesCoreRender",settings.nesCoreRender); - e->setConf("fdsCoreRender",settings.fdsCoreRender); - e->setConf("c64CoreRender",settings.c64CoreRender); - e->setConf("pokeyCoreRender",settings.pokeyCoreRender); - e->setConf("opnCoreRender",settings.opnCoreRender); - e->setConf("opl2CoreRender",settings.opl2CoreRender); - e->setConf("opl3CoreRender",settings.opl3CoreRender); - e->setConf("pcSpeakerOutMethod",settings.pcSpeakerOutMethod); - e->setConf("yrw801Path",settings.yrw801Path); - e->setConf("tg100Path",settings.tg100Path); - e->setConf("mu5Path",settings.mu5Path); - e->setConf("mainFont",settings.mainFont); - e->setConf("headFont",settings.headFont); - e->setConf("patFont",settings.patFont); - e->setConf("mainFontPath",settings.mainFontPath); - e->setConf("headFontPath",settings.headFontPath); - e->setConf("patFontPath",settings.patFontPath); - e->setConf("patRowsBase",settings.patRowsBase); - e->setConf("orderRowsBase",settings.orderRowsBase); - e->setConf("soloAction",settings.soloAction); - e->setConf("pullDeleteBehavior",settings.pullDeleteBehavior); - e->setConf("wrapHorizontal",settings.wrapHorizontal); - e->setConf("wrapVertical",settings.wrapVertical); - e->setConf("macroView",settings.macroView); - e->setConf("fmNames",settings.fmNames); - e->setConf("allowEditDocking",settings.allowEditDocking); - e->setConf("chipNames",settings.chipNames); - e->setConf("overflowHighlight",settings.overflowHighlight); - e->setConf("partyTime",settings.partyTime); - e->setConf("flatNotes",settings.flatNotes); - e->setConf("germanNotation",settings.germanNotation); - e->setConf("stepOnDelete",settings.stepOnDelete); - e->setConf("scrollStep",settings.scrollStep); - e->setConf("sysSeparators",settings.sysSeparators); - e->setConf("forceMono",settings.forceMono); - e->setConf("controlLayout",settings.controlLayout); - e->setConf("statusDisplay",settings.statusDisplay); - e->setConf("dpiScale",settings.dpiScale); - e->setConf("viewPrevPattern",settings.viewPrevPattern); - e->setConf("guiColorsBase",settings.guiColorsBase); - e->setConf("guiColorsShading",settings.guiColorsShading); - e->setConf("avoidRaisingPattern",settings.avoidRaisingPattern); - e->setConf("insFocusesPattern",settings.insFocusesPattern); - e->setConf("stepOnInsert",settings.stepOnInsert); - e->setConf("unifiedDataView",settings.unifiedDataView); - e->setConf("sysFileDialog",settings.sysFileDialog); - e->setConf("roundedWindows",settings.roundedWindows); - e->setConf("roundedButtons",settings.roundedButtons); - e->setConf("roundedMenus",settings.roundedMenus); - e->setConf("loadJapanese",settings.loadJapanese); - e->setConf("loadChinese",settings.loadChinese); - e->setConf("loadChineseTraditional",settings.loadChineseTraditional); - e->setConf("loadKorean",settings.loadKorean); - e->setConf("fmLayout",settings.fmLayout); - e->setConf("sampleLayout",settings.sampleLayout); - e->setConf("waveLayout",settings.waveLayout); - e->setConf("susPosition",settings.susPosition); - e->setConf("effectCursorDir",settings.effectCursorDir); - e->setConf("cursorPastePos",settings.cursorPastePos); - e->setConf("titleBarInfo",settings.titleBarInfo); - e->setConf("titleBarSys",settings.titleBarSys); - e->setConf("frameBorders",settings.frameBorders); - e->setConf("effectDeletionAltersValue",settings.effectDeletionAltersValue); - e->setConf("oscRoundedCorners",settings.oscRoundedCorners); - e->setConf("oscTakesEntireWindow",settings.oscTakesEntireWindow); - e->setConf("oscBorder",settings.oscBorder); - e->setConf("oscEscapesBoundary",settings.oscEscapesBoundary); - e->setConf("oscMono",settings.oscMono); - e->setConf("oscAntiAlias",settings.oscAntiAlias); - e->setConf("separateFMColors",settings.separateFMColors); - e->setConf("insEditColorize",settings.insEditColorize); - e->setConf("metroVol",settings.metroVol); - e->setConf("sampleVol",settings.sampleVol); - e->setConf("pushNibble",settings.pushNibble); - e->setConf("scrollChangesOrder",settings.scrollChangesOrder); - e->setConf("oplStandardWaveNames",settings.oplStandardWaveNames); - e->setConf("cursorMoveNoScroll",settings.cursorMoveNoScroll); - e->setConf("lowLatency",settings.lowLatency); - e->setConf("notePreviewBehavior",settings.notePreviewBehavior); - e->setConf("powerSave",settings.powerSave); - e->setConf("absorbInsInput",settings.absorbInsInput); - e->setConf("eventDelay",settings.eventDelay); - e->setConf("moveWindowTitle",settings.moveWindowTitle); - e->setConf("hiddenSystems",settings.hiddenSystems); - e->setConf("initialSys2",settings.initialSys.toBase64()); - e->setConf("initialSysName",settings.initialSysName); - e->setConf("horizontalDataView",settings.horizontalDataView); - e->setConf("noMultiSystem",settings.noMultiSystem); - e->setConf("oldMacroVSlider",settings.oldMacroVSlider); - e->setConf("displayAllInsTypes",settings.displayAllInsTypes); - e->setConf("displayPartial",settings.displayPartial); - e->setConf("noteCellSpacing",settings.noteCellSpacing); - e->setConf("insCellSpacing",settings.insCellSpacing); - e->setConf("volCellSpacing",settings.volCellSpacing); - e->setConf("effectCellSpacing",settings.effectCellSpacing); - e->setConf("effectValCellSpacing",settings.effectValCellSpacing); - e->setConf("doubleClickColumn",settings.doubleClickColumn); - e->setConf("blankIns",settings.blankIns); - e->setConf("dragMovesSelection",settings.dragMovesSelection); - e->setConf("unsignedDetune",settings.unsignedDetune); - e->setConf("noThreadedInput",settings.noThreadedInput); - e->setConf("saveWindowPos",settings.saveWindowPos); - e->setConf("clampSamples",settings.clampSamples); - e->setConf("noteOffLabel",settings.noteOffLabel); - e->setConf("noteRelLabel",settings.noteRelLabel); - e->setConf("macroRelLabel",settings.macroRelLabel); - e->setConf("emptyLabel",settings.emptyLabel); - e->setConf("emptyLabel2",settings.emptyLabel2); - e->setConf("saveUnusedPatterns",settings.saveUnusedPatterns); - e->setConf("channelColors",settings.channelColors); - e->setConf("channelTextColors",settings.channelTextColors); - e->setConf("channelStyle",settings.channelStyle); - e->setConf("channelVolStyle",settings.channelVolStyle); - e->setConf("channelFeedbackStyle",settings.channelFeedbackStyle); - e->setConf("channelFont",settings.channelFont); - e->setConf("channelTextCenter",settings.channelTextCenter); - e->setConf("maxRecentFile",settings.maxRecentFile); - e->setConf("midiOutClock",settings.midiOutClock); - e->setConf("midiOutTime",settings.midiOutTime); - e->setConf("midiOutProgramChange",settings.midiOutProgramChange); - e->setConf("midiOutMode",settings.midiOutMode); - e->setConf("midiOutTimeRate",settings.midiOutTimeRate); - e->setConf("centerPattern",settings.centerPattern); - e->setConf("ordersCursor",settings.ordersCursor); - e->setConf("persistFadeOut",settings.persistFadeOut); - e->setConf("exportLoops",settings.exportLoops); - e->setConf("exportFadeOut",settings.exportFadeOut); - e->setConf("macroLayout",settings.macroLayout); - e->setConf("doubleClickTime",settings.doubleClickTime); - e->setConf("oneDigitEffects",settings.oneDigitEffects); - e->setConf("disableFadeIn",settings.disableFadeIn); - e->setConf("alwaysPlayIntro",settings.alwaysPlayIntro); - e->setConf("cursorFollowsOrder",settings.cursorFollowsOrder); - e->setConf("iCannotWait",settings.iCannotWait); - e->setConf("orderButtonPos",settings.orderButtonPos); - e->setConf("compress",settings.compress); - e->setConf("newPatternFormat",settings.newPatternFormat); - e->setConf("renderBackend",settings.renderBackend); - e->setConf("renderClearPos",settings.renderClearPos); - e->setConf("insertBehavior",settings.insertBehavior); - e->setConf("pullDeleteRow",settings.pullDeleteRow); - e->setConf("newSongBehavior",settings.newSongBehavior); - e->setConf("memUsageUnit",settings.memUsageUnit); - e->setConf("cursorFollowsWheel",settings.cursorFollowsWheel); - e->setConf("noDMFCompat",settings.noDMFCompat); - e->setConf("removeInsOff",settings.removeInsOff); - e->setConf("removeVolOff",settings.removeVolOff); - e->setConf("playOnLoad",settings.playOnLoad); - e->setConf("insTypeMenu",settings.insTypeMenu); - e->setConf("capitalMenuBar",settings.capitalMenuBar); - e->setConf("centerPopup",settings.centerPopup); - e->setConf("insIconsStyle",settings.insIconsStyle); - e->setConf("classicChipOptions",settings.classicChipOptions); - e->setConf("wasapiEx",settings.wasapiEx); - e->setConf("chanOscThreads",settings.chanOscThreads); - e->setConf("renderPoolThreads",settings.renderPoolThreads); - e->setConf("showPool",settings.showPool); - e->setConf("writeInsNames",settings.writeInsNames); - e->setConf("readInsNames",settings.readInsNames); - e->setConf("defaultAuthorName",settings.defaultAuthorName); - e->setConf("fontBackend",settings.fontBackend); - e->setConf("fontHinting",settings.fontHinting); - e->setConf("fontBitmap",settings.fontBitmap); - e->setConf("fontAutoHint",settings.fontAutoHint); - e->setConf("fontAntiAlias",settings.fontAntiAlias); - e->setConf("selectAssetOnLoad",settings.selectAssetOnLoad); - - // colors - for (int i=0; isetConf(guiColors[i].name,(int)ImGui::ColorConvertFloat4ToU32(uiColors[i])); - } - - // keybinds - for (int i=0; isetConf(String("keybind_GUI_ACTION_")+String(guiActions[i].name),actionKeys[i]); - } + writeConfig(e->getConfObject()); parseKeybinds(); - e->setConf("noteKeys",encodeKeyMap(noteKeys)); - midiMap.compile(); midiMap.write(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg"); @@ -4315,69 +4619,36 @@ void FurnaceGUI::commitSettings() { } bool FurnaceGUI::importColors(String path) { - FILE* f=ps_fopen(path.c_str(),"rb"); - if (f==NULL) { + DivConfig c; + if (!c.loadFromFile(path.c_str(),false,false)) { logW("error while opening color file for import: %s",strerror(errno)); return false; } - resetColors(); - char line[4096]; - while (!feof(f)) { - String key=""; - String value=""; - bool keyOrValue=false; - if (fgets(line,4095,f)==NULL) { - break; - } - for (char* i=line; *i; i++) { - if (*i=='\n') continue; - if (keyOrValue) { - value+=*i; - } else { - if (*i=='=') { - keyOrValue=true; - } else { - key+=*i; - } - } - } - if (keyOrValue) { - // unoptimal - const char* cs=key.c_str(); - bool found=false; - for (int i=0; igetConfInt(guiColors[i].name,guiColors[i].defaultColor)); - } - } - for (int i=0; i<64; i++) { ImVec4 col1=uiColors[GUI_COLOR_PATTERN_VOLUME_MIN]; ImVec4 col2=uiColors[GUI_COLOR_PATTERN_VOLUME_HALF]; @@ -4833,6 +5097,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) { secondaryHoverActual=secondaryHover; + // TODO: improve if (mobileUI) { // disable all hovered colors primaryHover=primary; secondaryHover=secondary; @@ -4862,31 +5127,63 @@ void FurnaceGUI::applyUISettings(bool updateFonts) { sty.Colors[ImGuiCol_NavWindowingHighlight]=uiColors[GUI_COLOR_NAV_WIN_HIGHLIGHT]; sty.Colors[ImGuiCol_NavWindowingDimBg]=uiColors[GUI_COLOR_NAV_WIN_BACKDROP]; sty.Colors[ImGuiCol_Text]=uiColors[GUI_COLOR_TEXT]; + sty.Colors[ImGuiCol_TextDisabled]=uiColors[GUI_COLOR_TEXT_DISABLED]; - sty.Colors[ImGuiCol_Button]=primary; - sty.Colors[ImGuiCol_ButtonHovered]=primaryHover; - sty.Colors[ImGuiCol_ButtonActive]=primaryActive; - sty.Colors[ImGuiCol_Tab]=primary; - sty.Colors[ImGuiCol_TabHovered]=secondaryHover; - sty.Colors[ImGuiCol_TabActive]=secondarySemiActive; - sty.Colors[ImGuiCol_TabUnfocused]=primary; - sty.Colors[ImGuiCol_TabUnfocusedActive]=primaryHover; - sty.Colors[ImGuiCol_Header]=secondary; - sty.Colors[ImGuiCol_HeaderHovered]=secondaryHover; - sty.Colors[ImGuiCol_HeaderActive]=secondaryActive; - sty.Colors[ImGuiCol_ResizeGrip]=secondary; - sty.Colors[ImGuiCol_ResizeGripHovered]=secondaryHover; - sty.Colors[ImGuiCol_ResizeGripActive]=secondaryActive; - sty.Colors[ImGuiCol_FrameBg]=secondary; - sty.Colors[ImGuiCol_FrameBgHovered]=secondaryHover; - sty.Colors[ImGuiCol_FrameBgActive]=secondaryActive; - sty.Colors[ImGuiCol_SliderGrab]=primaryActive; - sty.Colors[ImGuiCol_SliderGrabActive]=primaryActive; - sty.Colors[ImGuiCol_TitleBgActive]=primary; - sty.Colors[ImGuiCol_CheckMark]=primaryActive; - sty.Colors[ImGuiCol_TextSelectedBg]=secondaryHoverActual; - sty.Colors[ImGuiCol_PlotHistogram]=uiColors[GUI_COLOR_MACRO_OTHER]; - sty.Colors[ImGuiCol_PlotHistogramHovered]=uiColors[GUI_COLOR_MACRO_OTHER]; + if (settings.basicColors) { + sty.Colors[ImGuiCol_Button]=primary; + sty.Colors[ImGuiCol_ButtonHovered]=primaryHover; + sty.Colors[ImGuiCol_ButtonActive]=primaryActive; + sty.Colors[ImGuiCol_Tab]=primary; + sty.Colors[ImGuiCol_TabHovered]=secondaryHover; + sty.Colors[ImGuiCol_TabActive]=secondarySemiActive; + sty.Colors[ImGuiCol_TabUnfocused]=primary; + sty.Colors[ImGuiCol_TabUnfocusedActive]=primaryHover; + sty.Colors[ImGuiCol_Header]=secondary; + sty.Colors[ImGuiCol_HeaderHovered]=secondaryHover; + sty.Colors[ImGuiCol_HeaderActive]=secondaryActive; + sty.Colors[ImGuiCol_ResizeGrip]=secondary; + sty.Colors[ImGuiCol_ResizeGripHovered]=secondaryHover; + sty.Colors[ImGuiCol_ResizeGripActive]=secondaryActive; + sty.Colors[ImGuiCol_FrameBg]=secondary; + sty.Colors[ImGuiCol_FrameBgHovered]=secondaryHover; + sty.Colors[ImGuiCol_FrameBgActive]=secondaryActive; + sty.Colors[ImGuiCol_SliderGrab]=primaryActive; + sty.Colors[ImGuiCol_SliderGrabActive]=primaryActive; + sty.Colors[ImGuiCol_TitleBgActive]=primary; + sty.Colors[ImGuiCol_CheckMark]=primaryActive; + sty.Colors[ImGuiCol_TextSelectedBg]=secondaryHoverActual; + sty.Colors[ImGuiCol_PlotHistogram]=uiColors[GUI_COLOR_MACRO_OTHER]; + sty.Colors[ImGuiCol_PlotHistogramHovered]=uiColors[GUI_COLOR_MACRO_OTHER]; + } else { + sty.Colors[ImGuiCol_Button]=uiColors[GUI_COLOR_BUTTON]; + sty.Colors[ImGuiCol_ButtonHovered]=uiColors[GUI_COLOR_BUTTON_HOVER]; + sty.Colors[ImGuiCol_ButtonActive]=uiColors[GUI_COLOR_BUTTON_ACTIVE]; + sty.Colors[ImGuiCol_Tab]=uiColors[GUI_COLOR_TAB]; + sty.Colors[ImGuiCol_TabHovered]=uiColors[GUI_COLOR_TAB_HOVER]; + sty.Colors[ImGuiCol_TabActive]=uiColors[GUI_COLOR_TAB_ACTIVE]; + sty.Colors[ImGuiCol_TabUnfocused]=uiColors[GUI_COLOR_TAB_UNFOCUSED]; + sty.Colors[ImGuiCol_TabUnfocusedActive]=uiColors[GUI_COLOR_TAB_UNFOCUSED_ACTIVE]; + sty.Colors[ImGuiCol_Header]=uiColors[GUI_COLOR_IMGUI_HEADER]; + sty.Colors[ImGuiCol_HeaderHovered]=uiColors[GUI_COLOR_IMGUI_HEADER_HOVER]; + sty.Colors[ImGuiCol_HeaderActive]=uiColors[GUI_COLOR_IMGUI_HEADER_ACTIVE]; + sty.Colors[ImGuiCol_ResizeGrip]=uiColors[GUI_COLOR_RESIZE_GRIP]; + sty.Colors[ImGuiCol_ResizeGripHovered]=uiColors[GUI_COLOR_RESIZE_GRIP_HOVER]; + sty.Colors[ImGuiCol_ResizeGripActive]=uiColors[GUI_COLOR_RESIZE_GRIP_ACTIVE]; + sty.Colors[ImGuiCol_FrameBg]=uiColors[GUI_COLOR_WIDGET_BACKGROUND]; + sty.Colors[ImGuiCol_FrameBgHovered]=uiColors[GUI_COLOR_WIDGET_BACKGROUND_HOVER]; + sty.Colors[ImGuiCol_FrameBgActive]=uiColors[GUI_COLOR_WIDGET_BACKGROUND_ACTIVE]; + sty.Colors[ImGuiCol_SliderGrab]=uiColors[GUI_COLOR_SLIDER_GRAB]; + sty.Colors[ImGuiCol_SliderGrabActive]=uiColors[GUI_COLOR_SLIDER_GRAB_ACTIVE]; + sty.Colors[ImGuiCol_TitleBgActive]=uiColors[GUI_COLOR_TITLE_BACKGROUND_ACTIVE]; + sty.Colors[ImGuiCol_CheckMark]=uiColors[GUI_COLOR_CHECK_MARK]; + sty.Colors[ImGuiCol_TextSelectedBg]=uiColors[GUI_COLOR_TEXT_SELECTION]; + sty.Colors[ImGuiCol_PlotLines]=uiColors[GUI_COLOR_PLOT_LINES]; + sty.Colors[ImGuiCol_PlotLinesHovered]=uiColors[GUI_COLOR_PLOT_LINES_HOVER]; + sty.Colors[ImGuiCol_PlotHistogram]=uiColors[GUI_COLOR_PLOT_HISTOGRAM]; + sty.Colors[ImGuiCol_PlotHistogramHovered]=uiColors[GUI_COLOR_PLOT_HISTOGRAM_HOVER]; + sty.Colors[ImGuiCol_TableRowBg]=uiColors[GUI_COLOR_TABLE_ROW_EVEN]; + sty.Colors[ImGuiCol_TableRowBgAlt]=uiColors[GUI_COLOR_TABLE_ROW_ODD]; + } sty.Colors[ImGuiCol_Border]=uiColors[GUI_COLOR_BORDER]; sty.Colors[ImGuiCol_BorderShadow]=uiColors[GUI_COLOR_BORDER_SHADOW]; @@ -4896,6 +5193,16 @@ void FurnaceGUI::applyUISettings(bool updateFonts) { sty.GrabRounding=6.0f; } if (settings.roundedMenus) sty.PopupRounding=8.0f; + if (settings.roundedTabs) { + sty.TabRounding=4.0f; + } else { + sty.TabRounding=0.0f; + } + if (settings.roundedScrollbars) { + sty.ScrollbarRounding=9.0f; + } else { + sty.ScrollbarRounding=0.0f; + } if (settings.frameBorders) { sty.FrameBorderSize=1.0f; diff --git a/src/gui/songInfo.cpp b/src/gui/songInfo.cpp index 7c9b6063b..b67970d73 100644 --- a/src/gui/songInfo.cpp +++ b/src/gui/songInfo.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/songNotes.cpp b/src/gui/songNotes.cpp index d0218f7bf..e45ddf331 100644 --- a/src/gui/songNotes.cpp +++ b/src/gui/songNotes.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/speed.cpp b/src/gui/speed.cpp index b9b4988bc..3acb81518 100644 --- a/src/gui/speed.cpp +++ b/src/gui/speed.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/spoiler.cpp b/src/gui/spoiler.cpp index 05e6d0ead..74026a6df 100644 --- a/src/gui/spoiler.cpp +++ b/src/gui/spoiler.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp index 5bc2ee102..49c1f6cf6 100644 --- a/src/gui/stats.cpp +++ b/src/gui/stats.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 813ba80bb..d3070e2e3 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -997,6 +997,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl case DIV_SYSTEM_PCSPKR: { int clockSel=flags.getInt("clockSel",0); int speakerType=flags.getInt("speakerType",0); + bool resetPhase=flags.getBool("resetPhase",false); ImGui::Text("Clock rate:"); ImGui::Indent(); @@ -1034,10 +1035,15 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl } ImGui::Unindent(); + if (ImGui::Checkbox("Reset phase on frequency change",&resetPhase)) { + altered=true; + } + if (altered) { e->lockSave([&]() { flags.set("clockSel",clockSel); flags.set("speakerType",speakerType); + flags.set("resetPhase",resetPhase); }); } break; @@ -2279,6 +2285,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl case DIV_SYSTEM_C219: break; case DIV_SYSTEM_YMU759: + case DIV_SYSTEM_ESFM: supportsCustomRate=false; ImGui::Text("nothing to configure"); break; diff --git a/src/gui/sysManager.cpp b/src/gui/sysManager.cpp index 07741e44c..efe2c29a1 100644 --- a/src/gui/sysManager.cpp +++ b/src/gui/sysManager.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/sysPartNumber.cpp b/src/gui/sysPartNumber.cpp index d71e65a98..1ce6e2f38 100644 --- a/src/gui/sysPartNumber.cpp +++ b/src/gui/sysPartNumber.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -277,6 +277,8 @@ const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { case DIV_SYSTEM_C219: return "C219"; break; + case DIV_SYSTEM_ESFM: + return "ES1xxx"; default: return FurnaceGUI::getSystemName(sys); break; diff --git a/src/gui/sysPicker.cpp b/src/gui/sysPicker.cpp index 8607de05d..b374a815f 100644 --- a/src/gui/sysPicker.cpp +++ b/src/gui/sysPicker.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/tutorial.cpp b/src/gui/tutorial.cpp index 7774b95f0..d3c45a95f 100644 --- a/src/gui/tutorial.cpp +++ b/src/gui/tutorial.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 80ed73781..f1b657725 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/util.h b/src/gui/util.h index 6dd2c3a6f..d82466a25 100644 --- a/src/gui/util.h +++ b/src/gui/util.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/volMeter.cpp b/src/gui/volMeter.cpp index a4cf11d7e..8252cccc5 100644 --- a/src/gui/volMeter.cpp +++ b/src/gui/volMeter.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/waveEdit.cpp b/src/gui/waveEdit.cpp index cb4cf0462..90f6e3f52 100644 --- a/src/gui/waveEdit.cpp +++ b/src/gui/waveEdit.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/gui/xyOsc.cpp b/src/gui/xyOsc.cpp index 28136d645..930ed5d60 100644 --- a/src/gui/xyOsc.cpp +++ b/src/gui/xyOsc.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/log.cpp b/src/log.cpp index 2fbf24dd3..3c6149fd3 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/main.cpp b/src/main.cpp index b3b9f3b04..df9a9577f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -188,7 +188,7 @@ TAParamResult pLogLevel(String val) { TAParamResult pVersion(String) { printf("Furnace version " DIV_VERSION ".\n\n"); - printf("copyright (C) 2021-2023 tildearrow and contributors.\n"); + printf("copyright (C) 2021-2024 tildearrow and contributors.\n"); printf("licensed under the GNU General Public License version 2 or later\n"); printf(".\n\n"); printf("this is free software with ABSOLUTELY NO WARRANTY.\n"); @@ -218,6 +218,7 @@ TAParamResult pVersion(String) { printf("- YM3812-LLE by nukeykt (GPLv2)\n"); printf("- YMF262-LLE by nukeykt (GPLv2)\n"); printf("- YMF276-LLE by nukeykt (GPLv2)\n"); + printf("- ESFMu by Kagamiin~ (LGPLv2.1)\n"); printf("- ymfm by Aaron Giles (BSD 3-clause)\n"); printf("- adpcm by superctr (public domain)\n"); printf("- MAME SN76496 emulation core by Nicola Salmoria (BSD 3-clause)\n"); diff --git a/src/pch.cpp b/src/pch.cpp index b1cd9d3f5..83194adff 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pch.h b/src/pch.h index 7821ee302..1d071166b 100644 --- a/src/pch.h +++ b/src/pch.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ta-log.h b/src/ta-log.h index de93e24a7..43aecaafb 100644 --- a/src/ta-log.h +++ b/src/ta-log.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ta-utils.h b/src/ta-utils.h index 6b3c201f5..93bbdf5b0 100644 --- a/src/ta-utils.h +++ b/src/ta-utils.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/utfutils.cpp b/src/utfutils.cpp index 408a5e712..fdbb989da 100644 --- a/src/utfutils.cpp +++ b/src/utfutils.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/utfutils.h b/src/utfutils.h index e55aa07ab..15b7c6685 100644 --- a/src/utfutils.h +++ b/src/utfutils.h @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/winMain.cpp b/src/winMain.cpp index 85dd27770..6453137db 100644 --- a/src/winMain.cpp +++ b/src/winMain.cpp @@ -1,6 +1,6 @@ /** * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2023 tildearrow and contributors + * Copyright (C) 2021-2024 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by