--- libgig/trunk/src/gig.h 2018/12/22 18:59:29 3442 +++ libgig/trunk/src/gig.h 2019/10/02 16:30:29 3623 @@ -2,7 +2,7 @@ * * * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2018 by Christian Schoenebeck * + * Copyright (C) 2003-2019 by Christian Schoenebeck * * * * * * This library is free software; you can redistribute it and/or modify * @@ -148,6 +148,23 @@ curve_type_unknown = 0xffffffff /**< Unknown curve type. */ ); + /** Defines the wave form type used by an LFO (gig format extension). + * + * This is a gig format extension. The original Gigasampler/GigaStudio + * software always used a sine (sinus) wave form for all its 3 LFOs, so this + * was not configurable in the original gig format. Accordingly setting any + * other wave form than sine (sinus) will be ignored by the original + * Gigasampler/GigaStudio software. + * + * @see enumCount(), enumKey(), enumKeys(), enumValue() + */ + GIG_DECLARE_ENUM(lfo_wave_t, + lfo_wave_sine = 0, /**< Sine (sinus) wave form (this is the default wave form). */ + lfo_wave_triangle = 1, /**< Triangle wave form. */ + lfo_wave_saw = 2, /**< Saw (up) wave form (saw down wave form can be achieved by flipping the phase). */ + lfo_wave_square = 3, /**< Square wave form. */ + ); + /** Dimensions allow to bypass one of the following controllers. * * @see enumCount(), enumKey(), enumKeys(), enumValue() @@ -433,7 +450,7 @@ GIG_DECLARE_ENUM(sust_rel_trg_t, sust_rel_trg_none = 0x00, /**< No release triggered sample(s) are played on sustain pedal up (default). */ sust_rel_trg_maxvelocity = 0x01, /**< Play release trigger sample(s) on sustain pedal up, and simply use 127 as MIDI velocity for playback. */ - sust_rel_trg_keyvelocity = 0x02, /**< Play release trigger sample(s) on sustain pedal up, and use the key's last MIDI note-on velocity for playback. */ + sust_rel_trg_keyvelocity = 0x02 /**< Play release trigger sample(s) on sustain pedal up, and use the key`s last MIDI note-on velocity for playback. */ ); // just symbol prototyping @@ -505,11 +522,13 @@ uint8_t EG1ControllerAttackInfluence; ///< Amount EG1 Controller has influence on the EG1 Attack time (0 - 3, where 0 means off). uint8_t EG1ControllerDecayInfluence; ///< Amount EG1 Controller has influence on the EG1 Decay time (0 - 3, where 0 means off). uint8_t EG1ControllerReleaseInfluence; ///< Amount EG1 Controller has influence on the EG1 Release time (0 - 3, where 0 means off). + lfo_wave_t LFO1WaveForm; ///< [gig extension]: The fundamental wave form to be used by the amplitude LFO, e.g. sine, triangle, saw, square (default: sine). double LFO1Frequency; ///< Frequency of the sample amplitude LFO (0.10 - 10.00 Hz). + double LFO1Phase; ///< [gig extension]: Phase displacement of the amplitude LFO's wave form (0.0° - 360.0°). uint16_t LFO1InternalDepth; ///< Firm pitch of the sample amplitude LFO (0 - 1200 cents). uint16_t LFO1ControlDepth; ///< Controller depth influencing sample amplitude LFO pitch (0 - 1200 cents). lfo1_ctrl_t LFO1Controller; ///< MIDI Controller which controls sample amplitude LFO. - bool LFO1FlipPhase; ///< Inverts phase of the sample amplitude LFO wave. + bool LFO1FlipPhase; ///< Inverts the polarity of the sample amplitude LFO wave, so it flips the wave form vertically. bool LFO1Sync; ///< If set to true only one LFO should be used for all voices. // Filter Cutoff Frequency EG/LFO uint16_t EG2PreAttack; ///< Preattack value of the filter cutoff EG (0 - 1000 permille). @@ -524,19 +543,24 @@ uint8_t EG2ControllerAttackInfluence; ///< Amount EG2 Controller has influence on the EG2 Attack time (0 - 3, where 0 means off). uint8_t EG2ControllerDecayInfluence; ///< Amount EG2 Controller has influence on the EG2 Decay time (0 - 3, where 0 means off). uint8_t EG2ControllerReleaseInfluence; ///< Amount EG2 Controller has influence on the EG2 Release time (0 - 3, where 0 means off). + lfo_wave_t LFO2WaveForm; ///< [gig extension]: The fundamental wave form to be used by the filter cutoff LFO, e.g. sine, triangle, saw, square (default: sine). double LFO2Frequency; ///< Frequency of the filter cutoff LFO (0.10 - 10.00 Hz). + double LFO2Phase; ///< [gig extension]: Phase displacement of the filter cutoff LFO's wave form (0.0° - 360.0°). uint16_t LFO2InternalDepth; ///< Firm pitch of the filter cutoff LFO (0 - 1200 cents). uint16_t LFO2ControlDepth; ///< Controller depth influencing filter cutoff LFO pitch (0 - 1200). lfo2_ctrl_t LFO2Controller; ///< MIDI Controlle which controls the filter cutoff LFO. - bool LFO2FlipPhase; ///< Inverts phase of the filter cutoff LFO wave. + bool LFO2FlipPhase; ///< Inverts the polarity of the filter cutoff LFO wave, so it flips the wave form vertically. bool LFO2Sync; ///< If set to true only one LFO should be used for all voices. // Sample Pitch EG/LFO double EG3Attack; ///< Attack time of the sample pitch EG (0.000 - 10.000s). int16_t EG3Depth; ///< Depth of the sample pitch EG (-1200 - +1200). + lfo_wave_t LFO3WaveForm; ///< [gig extension]: The fundamental wave form to be used by the pitch LFO, e.g. sine, triangle, saw, square (default: sine). double LFO3Frequency; ///< Frequency of the sample pitch LFO (0.10 - 10.00 Hz). + double LFO3Phase; ///< [gig extension]: Phase displacement of the pitch LFO's wave form (0.0° - 360.0°). int16_t LFO3InternalDepth; ///< Firm depth of the sample pitch LFO (-1200 - +1200 cents). int16_t LFO3ControlDepth; ///< Controller depth of the sample pitch LFO (-1200 - +1200 cents). lfo3_ctrl_t LFO3Controller; ///< MIDI Controller which controls the sample pitch LFO. + bool LFO3FlipPhase; ///< [gig extension]: Inverts the polarity of the pitch LFO wave, so it flips the wave form vertically (@b NOTE: this setting for LFO3 is a gig format extension; flipping the polarity was only available for LFO1 and LFO2 in the original Gigasampler/GigaStudio software). bool LFO3Sync; ///< If set to true only one LFO should be used for all voices. // Filter bool VCFEnabled; ///< If filter should be used. @@ -577,6 +601,7 @@ eg_opt_t EG1Options; ///< [gig extension]: Behavior options which should be used for envelope generator 1 (volume amplitude EG). eg_opt_t EG2Options; ///< [gig extension]: Behavior options which should be used for envelope generator 2 (filter cutoff EG). sust_rel_trg_t SustainReleaseTrigger; ///< [gig extension]: Whether a sustain pedal up event shall play release trigger sample. + bool NoNoteOffReleaseTrigger; ///< [gig extension]: If @c true then don't play a release trigger sample on MIDI note-off events. // derived attributes from DLS::Sampler using DLS::Sampler::UnityNote; @@ -603,8 +628,8 @@ using DLS::Sampler::AddSampleLoop; using DLS::Sampler::DeleteSampleLoop; // overridden methods - virtual void SetGain(int32_t gain); - virtual void UpdateChunks(progress_t* pProgress); + virtual void SetGain(int32_t gain) OVERRIDE; + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; virtual void CopyAssign(const DimensionRegion* orig); protected: uint8_t* VelocityTable; ///< For velocity dimensions with custom defined zone ranges only: used for fast converting from velocity MIDI value to dimension bit number. @@ -730,6 +755,7 @@ double* GetCutoffVelocityTable(curve_type_t vcfVelocityCurve, uint8_t vcfVelocityDynamicRange, uint8_t vcfVelocityScale, vcf_cutoff_ctrl_t vcfCutoffController); double* GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling); double* CreateVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling); + bool UsesAnyGigFormatExtension() const; }; /** @brief Encapsulates sample waves of Gigasampler/GigaStudio files used for playback. @@ -796,7 +822,7 @@ file_offset_t ReadAndLoop(void* pBuffer, file_offset_t SampleCount, playback_state_t* pPlaybackState, DimensionRegion* pDimRgn, buffer_t* pExternalDecompressionBuffer = NULL); file_offset_t Write(void* pBuffer, file_offset_t SampleCount); Group* GetGroup() const; - virtual void UpdateChunks(progress_t* pProgress); + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; void CopyAssignMeta(const Sample* orig); void CopyAssignWave(const Sample* orig); uint32_t GetWaveDataCRC32Checksum(); @@ -890,8 +916,8 @@ void SplitDimensionZone(dimension_t type, int zone); void SetDimensionType(dimension_t oldType, dimension_t newType); // overridden methods - virtual void SetKeyRange(uint16_t Low, uint16_t High); - virtual void UpdateChunks(progress_t* pProgress); + virtual void SetKeyRange(uint16_t Low, uint16_t High) OVERRIDE; + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; virtual void CopyAssign(const Region* orig); protected: Region(Instrument* pInstrument, RIFF::List* rgnList); @@ -984,7 +1010,7 @@ protected: MidiRuleCtrlTrigger(RIFF::Chunk* _3ewg); MidiRuleCtrlTrigger(); - void UpdateChunks(uint8_t* pData) const; + void UpdateChunks(uint8_t* pData) const OVERRIDE; friend class Instrument; }; @@ -1024,7 +1050,7 @@ protected: MidiRuleLegato(RIFF::Chunk* _3ewg); MidiRuleLegato(); - void UpdateChunks(uint8_t* pData) const; + void UpdateChunks(uint8_t* pData) const OVERRIDE; friend class Instrument; }; @@ -1076,7 +1102,7 @@ protected: MidiRuleAlternator(RIFF::Chunk* _3ewg); MidiRuleAlternator(); - void UpdateChunks(uint8_t* pData) const; + void UpdateChunks(uint8_t* pData) const OVERRIDE; friend class Instrument; }; @@ -1096,7 +1122,7 @@ class MidiRuleUnknown : public MidiRule { protected: MidiRuleUnknown() { } - void UpdateChunks(uint8_t* pData) const { } + void UpdateChunks(uint8_t* pData) const OVERRIDE { } friend class Instrument; }; @@ -1120,7 +1146,7 @@ * - NKSP Reference Manual * - Using Instrument Scripts with Gigedit */ - class Script { + class Script : protected DLS::Storage { public: enum Encoding_t { ENCODING_ASCII = 0 ///< Standard 8 bit US ASCII character encoding (default). @@ -1146,7 +1172,8 @@ protected: Script(ScriptGroup* group, RIFF::Chunk* ckScri); virtual ~Script(); - void UpdateChunks(progress_t* pProgress); + void UpdateChunks(progress_t* pProgress) OVERRIDE; + void DeleteChunks() OVERRIDE; void RemoveAllScriptReferences(); friend class ScriptGroup; friend class Instrument; @@ -1168,7 +1195,7 @@ * not available in the GigaStudio 4 software. It is currently only * supported by LinuxSampler and gigedit. */ - class ScriptGroup { + class ScriptGroup : protected DLS::Storage { public: String Name; ///< Name of this script group. For example to be displayed in an instrument editor. @@ -1179,7 +1206,8 @@ ScriptGroup(File* file, RIFF::List* lstRTIS); virtual ~ScriptGroup(); void LoadScripts(); - void UpdateChunks(progress_t* pProgress); + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; + virtual void DeleteChunks() OVERRIDE; friend class Script; friend class File; private: @@ -1232,7 +1260,7 @@ Region* AddRegion(); void DeleteRegion(Region* pRegion); void MoveTo(Instrument* dst); - virtual void UpdateChunks(progress_t* pProgress); + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; virtual void CopyAssign(const Instrument* orig); // own methods Region* GetRegion(unsigned int Key); @@ -1286,7 +1314,7 @@ * there is always at least one Group in a .gig file, no matter if you * created one yet or not. */ - class Group { + class Group : public DLS::Storage { public: String Name; ///< Stores the name of this Group. @@ -1296,7 +1324,8 @@ protected: Group(File* file, RIFF::Chunk* ck3gnm); virtual ~Group(); - virtual void UpdateChunks(progress_t* pProgress); + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; + virtual void DeleteChunks() OVERRIDE; void MoveAll(); friend class File; private: @@ -1359,6 +1388,7 @@ using DLS::File::Save; using DLS::File::GetFileName; using DLS::File::SetFileName; + using DLS::File::GetRiffFile; // overridden methods File(); File(RIFF::File* pRIFF); @@ -1390,13 +1420,13 @@ ScriptGroup* AddScriptGroup(); void DeleteScriptGroup(ScriptGroup* pGroup); virtual ~File(); - virtual void UpdateChunks(progress_t* pProgress); + virtual void UpdateChunks(progress_t* pProgress) OVERRIDE; protected: // overridden protected methods from DLS::File - virtual void LoadSamples(); - virtual void LoadInstruments(); + virtual void LoadSamples() OVERRIDE; + virtual void LoadInstruments() OVERRIDE; virtual void LoadGroups(); - virtual void UpdateFileOffsets(); + virtual void UpdateFileOffsets() OVERRIDE; // own protected methods virtual void LoadSamples(progress_t* pProgress); virtual void LoadInstruments(progress_t* pProgress);