--- libgig/trunk/src/gig.h 2019/02/22 12:12:50 3481 +++ libgig/trunk/src/gig.h 2020/01/22 15:48:32 3723 @@ -2,7 +2,7 @@ * * * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2018 by Christian Schoenebeck * + * Copyright (C) 2003-2020 by Christian Schoenebeck * * * * * * This library is free software; you can redistribute it and/or modify * @@ -50,6 +50,7 @@ # define LIST_TYPE_3GNL 0x33676E6C # define LIST_TYPE_3LS 0x334c5320 // own gig format extension # define LIST_TYPE_RTIS 0x52544953 // own gig format extension +# define LIST_TYPE_3DNM 0x33646e6d # define CHUNK_ID_3GIX 0x33676978 # define CHUNK_ID_3EWA 0x33657761 # define CHUNK_ID_3LNK 0x336C6E6B @@ -62,6 +63,7 @@ # define CHUNK_ID_LSNM 0x4c534e4d // own gig format extension # define CHUNK_ID_SCSL 0x5343534c // own gig format extension # define CHUNK_ID_LSDE 0x4c534445 // own gig format extension +# define CHUNK_ID_3DDP 0x33646470 #else // little endian # define LIST_TYPE_3PRG 0x67727033 # define LIST_TYPE_3EWL 0x6C776533 @@ -69,6 +71,7 @@ # define LIST_TYPE_3GNL 0x6C6E6733 # define LIST_TYPE_3LS 0x20534c33 // own gig format extension # define LIST_TYPE_RTIS 0x53495452 // own gig format extension +# define LIST_TYPE_3DNM 0x6d6e6433 # define CHUNK_ID_3GIX 0x78696733 # define CHUNK_ID_3EWA 0x61776533 # define CHUNK_ID_3LNK 0x6B6E6C33 @@ -81,6 +84,7 @@ # define CHUNK_ID_LSNM 0x4d4e534c // own gig format extension # define CHUNK_ID_SCSL 0x4c534353 // own gig format extension # define CHUNK_ID_LSDE 0x4544534c // own gig format extension +# define CHUNK_ID_3DDP 0x70646433 #endif // WORDS_BIGENDIAN #ifndef GIG_DECLARE_ENUM @@ -148,6 +152,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() @@ -338,16 +359,37 @@ float zone_size; ///< Intended for internal usage: reflects the size of each zone (128/zones) for normal split types only, 0 otherwise. }; - /** Defines which frequencies are filtered by the VCF. + /** Audio filter types. + * + * The first 5 filter types are the ones which exist in GigaStudio, and + * which are very accurately modeled on LinuxSampler side such that they + * would sound with LinuxSampler exactly as with GigaStudio. + * + * The other filter types listed here are extensions to the gig format and + * are LinuxSampler specific filter type implementations. Note that none of + * these are duplicates of the GigaStudio filter types. For instance + * @c vcf_type_lowpass (GigaStudio) and @c vcf_type_lowpass_2p + * (LinuxSampler) are both lowpass filters with 2 poles, however they do + * sound differently. * * @see enumCount(), enumKey(), enumKeys(), enumValue() */ GIG_DECLARE_ENUM(vcf_type_t, - vcf_type_lowpass = 0x00, /**< Standard lowpass filter type. */ - vcf_type_lowpassturbo = 0xff, /**< More poles than normal lowpass. */ - vcf_type_bandpass = 0x01, /**< Bandpass filter type. */ - vcf_type_highpass = 0x02, /**< Highpass filter type. */ - vcf_type_bandreject = 0x03 /**< Band reject filter type. */ + vcf_type_lowpass = 0x00, /**< Standard lowpass filter type (GigaStudio). */ + vcf_type_lowpassturbo = 0xff, /**< More poles than normal lowpass (GigaStudio). */ + vcf_type_bandpass = 0x01, /**< Bandpass filter type (GigaStudio). */ + vcf_type_highpass = 0x02, /**< Highpass filter type (GigaStudio). */ + vcf_type_bandreject = 0x03, /**< Band reject filter type (GigaStudio). */ + vcf_type_lowpass_1p = 0x11, /**< [gig extension]: 1-pole lowpass filter type (LinuxSampler). */ + vcf_type_lowpass_2p = 0x12, /**< [gig extension]: 2-pole lowpass filter type (LinuxSampler). */ + vcf_type_lowpass_4p = 0x14, /**< [gig extension]: 4-pole lowpass filter type (LinuxSampler). */ + vcf_type_lowpass_6p = 0x16, /**< [gig extension]: 6-pole lowpass filter type (LinuxSampler). */ + vcf_type_highpass_1p = 0x21, /**< [gig extension]: 1-pole highpass filter type (LinuxSampler). */ + vcf_type_highpass_2p = 0x22, /**< [gig extension]: 2-pole highpass filter type (LinuxSampler). */ + vcf_type_highpass_4p = 0x24, /**< [gig extension]: 4-pole highpass filter type (LinuxSampler). */ + vcf_type_highpass_6p = 0x26, /**< [gig extension]: 6-pole highpass filter type (LinuxSampler). */ + vcf_type_bandpass_2p = 0x32, /**< [gig extension]: 2-pole bandpass filter type (LinuxSampler). */ + vcf_type_bandreject_2p = 0x42 /**< [gig extension]: 2-pole bandreject filter type (LinuxSampler). */ ); /** @@ -433,7 +475,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 +547,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 +568,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. @@ -731,6 +780,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. @@ -903,6 +953,8 @@ DimensionRegion* GetDimensionRegionByBit(const std::map& DimCase); ~Region(); friend class Instrument; + private: + bool UsesAnyGigFormatExtension() const; }; /** @brief Abstract base class for all MIDI rules. @@ -1138,6 +1190,7 @@ Encoding_t Encoding; ///< Format the script's source code text is encoded with. Language_t Language; ///< Programming language and dialect the script is written in. bool Bypass; ///< Global bypass: if enabled, this script shall not be executed by the sampler for any instrument. + uint8_t Uuid[16]; ///< Persistent Universally Unique Identifier of this script, which remains identical after any changes to this script. String GetScriptAsText(); void SetScriptAsText(const String& text); @@ -1150,6 +1203,7 @@ void UpdateChunks(progress_t* pProgress) OVERRIDE; void DeleteChunks() OVERRIDE; void RemoveAllScriptReferences(); + void GenerateUuid(); friend class ScriptGroup; friend class Instrument; private: @@ -1276,6 +1330,8 @@ MidiRule** pMidiRules; std::vector<_ScriptPooolEntry> scriptPoolFileOffsets; std::vector<_ScriptPooolRef>* pScriptRefs; + + bool UsesAnyGigFormatExtension() const; }; /** @brief Group of Gigasampler samples @@ -1422,6 +1478,8 @@ std::list::iterator GroupsIterator; bool bAutoLoad; std::list* pScriptGroups; + + bool UsesAnyGigFormatExtension() const; }; /**