Equalizer: Implemented new presets contributed by Oleg-Chashko

CQTexperiment
Christopher Snowhill 2022-01-24 20:01:22 -08:00
parent ec7009f3fc
commit e471945a08
4 changed files with 347 additions and 289 deletions

313
Cog.q1.json Executable file
View File

@ -0,0 +1,313 @@
{
"type": "Cog EQ library file v1.0",
"presets": [
{
"name": "Acoustic",
"hz32": 251,
"hz64": 250,
"hz128": 241,
"hz256": 212,
"hz512": 223,
"hz1000": 219,
"hz2000": 236,
"hz4000": 242,
"hz8000": 237,
"hz16000": 223,
"preamp": 201
},
{
"name": "Bass Booster",
"hz32": 256,
"hz64": 244,
"hz128": 236,
"hz256": 226,
"hz512": 214,
"hz1000": 201,
"hz2000": 201,
"hz4000": 201,
"hz8000": 201,
"hz16000": 201,
"preamp": 201
},
{
"name": "Bass Reducer",
"hz32": 146,
"hz64": 158,
"hz128": 166,
"hz256": 176,
"hz512": 188,
"hz1000": 201,
"hz2000": 201,
"hz4000": 201,
"hz8000": 201,
"hz16000": 201,
"preamp": 201
},
{
"name": "Classical",
"hz32": 249,
"hz64": 239,
"hz128": 231,
"hz256": 226,
"hz512": 186,
"hz1000": 186,
"hz2000": 201,
"hz4000": 224,
"hz8000": 234,
"hz16000": 239,
"preamp": 201
},
{
"name": "Dance",
"hz32": 237,
"hz64": 267,
"hz128": 251,
"hz256": 201,
"hz512": 220,
"hz1000": 238,
"hz2000": 253,
"hz4000": 246,
"hz8000": 237,
"hz16000": 201,
"preamp": 201
},
{
"name": "Deep",
"hz32": 251,
"hz64": 237,
"hz128": 219,
"hz256": 211,
"hz512": 230,
"hz1000": 226,
"hz2000": 216,
"hz4000": 179,
"hz8000": 165,
"hz16000": 155,
"preamp": 201
},
{
"name": "Electronic",
"hz32": 244,
"hz64": 239,
"hz128": 213,
"hz256": 201,
"hz512": 179,
"hz1000": 224,
"hz2000": 210,
"hz4000": 214,
"hz8000": 241,
"hz16000": 249,
"preamp": 201
},
{
"name": "Flat",
"hz32": 201,
"hz64": 201,
"hz128": 201,
"hz256": 201,
"hz512": 201,
"hz1000": 201,
"hz2000": 201,
"hz4000": 201,
"hz8000": 201,
"hz16000": 201,
"preamp": 201
},
{
"name": "Hip-Hop",
"hz32": 251,
"hz64": 244,
"hz128": 216,
"hz256": 231,
"hz512": 191,
"hz1000": 191,
"hz2000": 216,
"hz4000": 196,
"hz8000": 221,
"hz16000": 231,
"preamp": 201
},
{
"name": "Jazz",
"hz32": 241,
"hz64": 231,
"hz128": 216,
"hz256": 224,
"hz512": 186,
"hz1000": 186,
"hz2000": 201,
"hz4000": 216,
"hz8000": 231,
"hz16000": 239,
"preamp": 201
},
{
"name": "Latin",
"hz32": 246,
"hz64": 231,
"hz128": 201,
"hz256": 201,
"hz512": 186,
"hz1000": 186,
"hz2000": 186,
"hz4000": 201,
"hz8000": 231,
"hz16000": 246,
"preamp": 201
},
{
"name": "Loudness",
"hz32": 261,
"hz64": 241,
"hz128": 201,
"hz256": 201,
"hz512": 181,
"hz1000": 201,
"hz2000": 191,
"hz4000": 151,
"hz8000": 251,
"hz16000": 211,
"preamp": 201
},
{
"name": "Lounge",
"hz32": 171,
"hz64": 186,
"hz128": 196,
"hz256": 216,
"hz512": 241,
"hz1000": 176,
"hz2000": 201,
"hz4000": 186,
"hz8000": 221,
"hz16000": 211,
"preamp": 201
},
{
"name": "Piano",
"hz32": 231,
"hz64": 221,
"hz128": 201,
"hz256": 226,
"hz512": 231,
"hz1000": 216,
"hz2000": 236,
"hz4000": 246,
"hz8000": 231,
"hz16000": 236,
"preamp": 201
},
{
"name": "Pop",
"hz32": 186,
"hz64": 191,
"hz128": 201,
"hz256": 221,
"hz512": 241,
"hz1000": 241,
"hz2000": 221,
"hz4000": 201,
"hz8000": 191,
"hz16000": 186,
"preamp": 201
},
{
"name": "R&B",
"hz32": 227,
"hz64": 270,
"hz128": 258,
"hz256": 214,
"hz512": 179,
"hz1000": 186,
"hz2000": 224,
"hz4000": 228,
"hz8000": 231,
"hz16000": 239,
"preamp": 201
},
{
"name": "Rock",
"hz32": 251,
"hz64": 241,
"hz128": 231,
"hz256": 216,
"hz512": 196,
"hz1000": 191,
"hz2000": 206,
"hz4000": 226,
"hz8000": 236,
"hz16000": 246,
"preamp": 201
},
{
"name": "Small Speakers",
"hz32": 256,
"hz64": 244,
"hz128": 236,
"hz256": 226,
"hz512": 214,
"hz1000": 201,
"hz2000": 188,
"hz4000": 176,
"hz8000": 166,
"hz16000": 158,
"preamp": 201
},
{
"name": "Spoken Word",
"hz32": 166,
"hz64": 196,
"hz128": 201,
"hz256": 208,
"hz512": 236,
"hz1000": 247,
"hz2000": 249,
"hz4000": 244,
"hz8000": 226,
"hz16000": 201,
"preamp": 201
},
{
"name": "Treble Booster",
"hz32": 201,
"hz64": 201,
"hz128": 201,
"hz256": 201,
"hz512": 201,
"hz1000": 214,
"hz2000": 224,
"hz4000": 236,
"hz8000": 244,
"hz16000": 256,
"preamp": 201
},
{
"name": "Treble Reducer",
"hz32": 201,
"hz64": 201,
"hz128": 201,
"hz256": 201,
"hz512": 201,
"hz1000": 188,
"hz2000": 178,
"hz4000": 166,
"hz8000": 158,
"hz16000": 146,
"preamp": 201
},
{
"name": "Vocal Booster",
"hz32": 186,
"hz64": 171,
"hz128": 171,
"hz256": 216,
"hz512": 239,
"hz1000": 239,
"hz2000": 231,
"hz4000": 216,
"hz8000": 201,
"hz16000": 186,
"preamp": 201
}
]
}

View File

@ -97,6 +97,7 @@
8305963C277F013200EBFAAE /* File_Extractor.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83059639277F011100EBFAAE /* File_Extractor.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
83059690277F04AB00EBFAAE /* Ogg.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8305968D277F049600EBFAAE /* Ogg.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
830596EE277F05EE00EBFAAE /* Vorbis.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 830596E7277F05E200EBFAAE /* Vorbis.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
832923AF279FAC400048201E /* Cog.q1.json in Resources */ = {isa = PBXBuildFile; fileRef = 832923AE279FAC400048201E /* Cog.q1.json */; };
83293070277886250010C07E /* OpenMPTOld.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8329306D277885790010C07E /* OpenMPTOld.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
832C1253180BD1E2005507C1 /* Cog.help in Resources */ = {isa = PBXBuildFile; fileRef = 832C1252180BD1E2005507C1 /* Cog.help */; };
83489C6B2782F78700BDCEA2 /* libvgmPlayer.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83489C542782F2DF00BDCEA2 /* libvgmPlayer.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@ -112,7 +113,6 @@
8355D6B8180613FB00D05687 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8355D6B7180613FB00D05687 /* Security.framework */; };
8359009D17FF06570060F3ED /* ArchiveSource.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8359FF3117FEF35D0060F3ED /* ArchiveSource.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
835A8FD327957310005B3C39 /* json.c in Sources */ = {isa = PBXBuildFile; fileRef = 835A8FC627957310005B3C39 /* json.c */; };
835A8FD6279575B1005B3C39 /* Winamp.q1.json in Resources */ = {isa = PBXBuildFile; fileRef = 835A8FD5279575B1005B3C39 /* Winamp.q1.json */; };
835F00BB279BD1CD00055FCF /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 835F00B8279BD1CD00055FCF /* SecondsFormatter.m */; };
8360EF6D17F92E56005208A4 /* HighlyComplete.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8360EF0517F92B24005208A4 /* HighlyComplete.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */; };
@ -908,6 +908,7 @@
83059684277F049600EBFAAE /* Ogg.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Ogg.xcodeproj; path = Frameworks/Ogg/macosx/Ogg.xcodeproj; sourceTree = "<group>"; };
830596DA277F05E200EBFAAE /* Vorbis.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Vorbis.xcodeproj; path = Frameworks/Vorbis/macosx/Vorbis.xcodeproj; sourceTree = "<group>"; };
8314D63B1A354DFE00EEE8E6 /* sidplay.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = sidplay.xcodeproj; path = Plugins/sidplay/sidplay.xcodeproj; sourceTree = "<group>"; };
832923AE279FAC400048201E /* Cog.q1.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Cog.q1.json; sourceTree = "<group>"; };
83293065277885790010C07E /* OpenMPTOld.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OpenMPTOld.xcodeproj; path = Plugins/OpenMPT.old/OpenMPTOld.xcodeproj; sourceTree = "<group>"; };
832C1252180BD1E2005507C1 /* Cog.help */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Cog.help; sourceTree = "<group>"; };
833F681E1CDBCAA700AFB9F0 /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@ -920,7 +921,6 @@
8359FF2C17FEF35C0060F3ED /* ArchiveSource.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ArchiveSource.xcodeproj; path = Plugins/ArchiveSource/ArchiveSource.xcodeproj; sourceTree = "<group>"; };
835A8FC627957310005B3C39 /* json.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = json.c; sourceTree = "<group>"; };
835A8FC827957310005B3C39 /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = "<group>"; };
835A8FD5279575B1005B3C39 /* Winamp.q1.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Winamp.q1.json; sourceTree = "<group>"; };
835C888B22CC1881001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = en; path = en.lproj/Credits.html; sourceTree = "<group>"; };
835C888C22CC1882001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
835C888D22CC1882001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1464,9 +1464,9 @@
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
8E7575D909F31E930080F1EE /* Localizable.strings */,
835A8FD5279575B1005B3C39 /* Winamp.q1.json */,
1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */,
1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */,
832923AE279FAC400048201E /* Cog.q1.json */,
17D1B0D00F6320EA00694C57 /* InfoInspector.xib */,
17342A980D5FD20B00E8D854 /* MainMenu.xib */,
17342ABD0D5FD36400E8D854 /* OpenURLPanel.xib */,
@ -2337,7 +2337,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
835A8FD6279575B1005B3C39 /* Winamp.q1.json in Resources */,
83BC5AC420E4CE9000631CD4 /* Feedback.xib in Resources */,
83BC5AC320E4CE8D00631CD4 /* SpotlightPanel.xib in Resources */,
83BC5AC220E4CE8A00631CD4 /* FileTree.xib in Resources */,
@ -2390,6 +2389,7 @@
17D1B2800CF8B2830028F5B5 /* s3m.icns in Resources */,
8384916718083EAB00E7332D /* shuffleAlbumTemplate.pdf in Resources */,
17D1B2810CF8B2830028F5B5 /* song.icns in Resources */,
832923AF279FAC400048201E /* Cog.q1.json in Resources */,
17D1B2820CF8B2830028F5B5 /* vg.icns in Resources */,
17D1B2830CF8B2830028F5B5 /* xm.icns in Resources */,
83ED3AD1279A91C000904199 /* hdcdLogoTemplate.pdf in Resources */,

View File

@ -1,257 +0,0 @@
{
"type" : "Winamp EQ library file v1.1"
,"presets" : [
{
"name" : "Classical"
,"hz70" : 33
,"hz180" : 33
,"hz320" : 33
,"hz600" : 33
,"hz1000" : 33
,"hz3000" : 33
,"hz6000" : 20
,"hz12000" : 20
,"hz14000" : 20
,"hz16000" : 16
,"preamp" : 33
}
,{
"name" : "Club"
,"hz70" : 33
,"hz180" : 33
,"hz320" : 38
,"hz600" : 42
,"hz1000" : 42
,"hz3000" : 42
,"hz6000" : 38
,"hz12000" : 33
,"hz14000" : 33
,"hz16000" : 33
,"preamp" : 33
}
,{
"name" : "Dance"
,"hz70" : 48
,"hz180" : 44
,"hz320" : 36
,"hz600" : 32
,"hz1000" : 32
,"hz3000" : 22
,"hz6000" : 20
,"hz12000" : 20
,"hz14000" : 32
,"hz16000" : 32
,"preamp" : 33
}
,{
"name" : "Flat"
,"hz70" : 33
,"hz180" : 33
,"hz320" : 33
,"hz600" : 33
,"hz1000" : 33
,"hz3000" : 33
,"hz6000" : 33
,"hz12000" : 33
,"hz14000" : 33
,"hz16000" : 33
,"preamp" : 33
}
,{
"name" : "Laptop speakers/headphones"
,"hz70" : 40
,"hz180" : 50
,"hz320" : 41
,"hz600" : 26
,"hz1000" : 28
,"hz3000" : 35
,"hz6000" : 40
,"hz12000" : 48
,"hz14000" : 53
,"hz16000" : 56
,"preamp" : 33
}
,{
"name" : "Large hall"
,"hz70" : 49
,"hz180" : 49
,"hz320" : 42
,"hz600" : 42
,"hz1000" : 33
,"hz3000" : 24
,"hz6000" : 24
,"hz12000" : 24
,"hz14000" : 33
,"hz16000" : 33
,"preamp" : 33
}
,{
"name" : "Party"
,"hz70" : 44
,"hz180" : 44
,"hz320" : 33
,"hz600" : 33
,"hz1000" : 33
,"hz3000" : 33
,"hz6000" : 33
,"hz12000" : 33
,"hz14000" : 44
,"hz16000" : 44
,"preamp" : 33
}
,{
"name" : "Pop"
,"hz70" : 29
,"hz180" : 40
,"hz320" : 44
,"hz600" : 45
,"hz1000" : 41
,"hz3000" : 30
,"hz6000" : 28
,"hz12000" : 28
,"hz14000" : 29
,"hz16000" : 29
,"preamp" : 33
}
,{
"name" : "Reggae"
,"hz70" : 33
,"hz180" : 33
,"hz320" : 31
,"hz600" : 22
,"hz1000" : 33
,"hz3000" : 43
,"hz6000" : 43
,"hz12000" : 33
,"hz14000" : 33
,"hz16000" : 33
,"preamp" : 33
}
,{
"name" : "Rock"
,"hz70" : 45
,"hz180" : 40
,"hz320" : 23
,"hz600" : 19
,"hz1000" : 26
,"hz3000" : 39
,"hz6000" : 47
,"hz12000" : 50
,"hz14000" : 50
,"hz16000" : 50
,"preamp" : 33
}
,{
"name" : "Soft"
,"hz70" : 40
,"hz180" : 35
,"hz320" : 30
,"hz600" : 28
,"hz1000" : 30
,"hz3000" : 39
,"hz6000" : 46
,"hz12000" : 48
,"hz14000" : 50
,"hz16000" : 52
,"preamp" : 33
}
,{
"name" : "Ska"
,"hz70" : 28
,"hz180" : 24
,"hz320" : 25
,"hz600" : 31
,"hz1000" : 39
,"hz3000" : 42
,"hz6000" : 47
,"hz12000" : 48
,"hz14000" : 50
,"hz16000" : 48
,"preamp" : 33
}
,{
"name" : "Full Bass"
,"hz70" : 48
,"hz180" : 48
,"hz320" : 48
,"hz600" : 42
,"hz1000" : 35
,"hz3000" : 25
,"hz6000" : 18
,"hz12000" : 15
,"hz14000" : 14
,"hz16000" : 14
,"preamp" : 33
}
,{
"name" : "Soft Rock"
,"hz70" : 39
,"hz180" : 39
,"hz320" : 36
,"hz600" : 31
,"hz1000" : 25
,"hz3000" : 23
,"hz6000" : 26
,"hz12000" : 31
,"hz14000" : 37
,"hz16000" : 47
,"preamp" : 33
}
,{
"name" : "Full Treble"
,"hz70" : 16
,"hz180" : 16
,"hz320" : 16
,"hz600" : 25
,"hz1000" : 37
,"hz3000" : 50
,"hz6000" : 58
,"hz12000" : 58
,"hz14000" : 58
,"hz16000" : 60
,"preamp" : 33
}
,{
"name" : "Full Bass & Treble"
,"hz70" : 44
,"hz180" : 42
,"hz320" : 33
,"hz600" : 20
,"hz1000" : 24
,"hz3000" : 35
,"hz6000" : 46
,"hz12000" : 50
,"hz14000" : 52
,"hz16000" : 52
,"preamp" : 33
}
,{
"name" : "Live"
,"hz70" : 24
,"hz180" : 33
,"hz320" : 39
,"hz600" : 41
,"hz1000" : 42
,"hz3000" : 42
,"hz6000" : 39
,"hz12000" : 37
,"hz14000" : 37
,"hz16000" : 36
,"preamp" : 33
}
,{
"name" : "Techno"
,"hz70" : 45
,"hz180" : 42
,"hz320" : 33
,"hz600" : 23
,"hz1000" : 24
,"hz3000" : 33
,"hz6000" : 45
,"hz12000" : 48
,"hz14000" : 48
,"hz16000" : 47
,"preamp" : 33
}
]
}

View File

@ -22,13 +22,15 @@ static NSArray * equalizer_presets_processed = nil;
static NSDictionary * equalizer_presets_by_name = nil;
static json_value * equalizer_presets = NULL;
static NSArray* _winamp_equalizer_items() {
return @[@"name", @"hz70", @"hz180", @"hz320", @"hz600", @"hz1000", @"hz3000", @"hz6000", @"hz12000", @"hz14000", @"hz16000", @"preamp"];
static NSString* _cog_equalizer_type = @"Cog EQ library file v1.0";
static NSArray* _cog_equalizer_items() {
return @[@"name", @"hz32", @"hz64", @"hz128", @"hz256", @"hz512", @"hz1000", @"hz2000", @"hz4000", @"hz8000", @"hz16000", @"preamp"];
}
static const float winamp_equalizer_bands[10] = { 70, 180, 320, 600, 1000, 3000, 6000, 12000, 14000, 16000 };
static NSArray* winamp_equalizer_items = nil;
static NSString* winamp_equalizer_extra_genres = @"altGenres";
static const float cog_equalizer_bands[10] = { 32, 64, 128, 256, 512, 1000, 2000, 4000, 8000, 16000 };
static NSArray* cog_equalizer_items = nil;
static NSString* cog_equalizer_extra_genres = @"altGenres";
static const float apple_equalizer_bands_31[31] = { 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1200, 1600, 2000, 2500, 3100, 4000, 5000, 6300, 8000, 10000, 12000, 16000, 20000 };
static const float apple_equalizer_bands_10[10] = { 32, 64, 128, 256, 512, 1000, 2000, 4000, 8000, 16000 };
@ -36,16 +38,16 @@ static const float apple_equalizer_bands_10[10] = { 32, 64, 128, 256, 512, 1000,
static inline float quadra(float *p, float frac) { return (((((((((p[0] + p[2]) * 0.5) - p[1]) * frac) * 0.5) + p[1]) - ((p[2] + p[0] + (p[0] * 2.0)) / 2.0)) * frac) * 2.0) + p[0]; }
static inline float interpolatePoint(NSDictionary * preset, float freqTarget) {
if (!winamp_equalizer_items)
winamp_equalizer_items = _winamp_equalizer_items();
if (!cog_equalizer_items)
cog_equalizer_items = _cog_equalizer_items();
// predict extra bands! lpc was too broken, so use quadratic interpolation!
if (freqTarget <= winamp_equalizer_bands[0]) {
if (freqTarget <= cog_equalizer_bands[0]) {
float work[14];
float work_freq[14];
for (unsigned int i = 0; i < 10; ++i) {
work[9 - i] = [[preset objectForKey:[winamp_equalizer_items objectAtIndex:1 + i]] floatValue];
work_freq[9 - i] = winamp_equalizer_bands[i];
work[9 - i] = [[preset objectForKey:[cog_equalizer_items objectAtIndex:1 + i]] floatValue];
work_freq[9 - i] = cog_equalizer_bands[i];
}
for (unsigned int i = 10; i < 14; ++i) {
work[i] = quadra(work + i - 3, 0.94);
@ -67,12 +69,12 @@ static inline float interpolatePoint(NSDictionary * preset, float freqTarget) {
return work[13];
}
else if (freqTarget >= winamp_equalizer_bands[9]) {
else if (freqTarget >= cog_equalizer_bands[9]) {
float work[14];
float work_freq[14];
for (unsigned int i = 0; i < 10; ++i) {
work[i] = [[preset objectForKey:[winamp_equalizer_items objectAtIndex:1 + i]] floatValue];
work_freq[i] = winamp_equalizer_bands[i];
work[i] = [[preset objectForKey:[cog_equalizer_items objectAtIndex:1 + i]] floatValue];
work_freq[i] = cog_equalizer_bands[i];
}
for (unsigned int i = 10; i < 14; ++i) {
work[i] = quadra(work + i - 3, 0.94);
@ -98,12 +100,12 @@ static inline float interpolatePoint(NSDictionary * preset, float freqTarget) {
// interpolation time! linear is fine for this
for (size_t i = 0; i < 9; ++i) {
if (freqTarget >= winamp_equalizer_bands[i] &&
freqTarget < winamp_equalizer_bands[i + 1]) {
float freqLow = winamp_equalizer_bands[i];
float freqHigh = winamp_equalizer_bands[i + 1];
float valueLow = [[preset objectForKey:[winamp_equalizer_items objectAtIndex:i + 1]] floatValue];
float valueHigh = [[preset objectForKey:[winamp_equalizer_items objectAtIndex:i + 2]] floatValue];
if (freqTarget >= cog_equalizer_bands[i] &&
freqTarget < cog_equalizer_bands[i + 1]) {
float freqLow = cog_equalizer_bands[i];
float freqHigh = cog_equalizer_bands[i + 1];
float valueLow = [[preset objectForKey:[cog_equalizer_items objectAtIndex:i + 1]] floatValue];
float valueHigh = [[preset objectForKey:[cog_equalizer_items objectAtIndex:i + 2]] floatValue];
float delta = (freqTarget - freqLow) / (freqHigh - freqLow);
@ -130,7 +132,7 @@ static void loadPresets()
{
if ([equalizer_presets_processed count]) return;
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("Winamp.q1"), CFSTR("json"), NULL);
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("Cog.q1"), CFSTR("json"), NULL);
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
@ -152,7 +154,7 @@ static void loadPresets()
equalizer_presets->u.object.length == 2 &&
strncmp(equalizer_presets->u.object.values[0].name, "type", equalizer_presets->u.object.values[0].name_length) == 0 &&
equalizer_presets->u.object.values[0].value->type == json_string &&
strncmp(equalizer_presets->u.object.values[0].value->u.string.ptr, "Winamp EQ library file v1.1", equalizer_presets->u.object.values[0].value->u.string.length ) == 0 &&
strncmp(equalizer_presets->u.object.values[0].value->u.string.ptr, [_cog_equalizer_type UTF8String], equalizer_presets->u.object.values[0].value->u.string.length ) == 0 &&
strncmp(equalizer_presets->u.object.values[1].name, "presets", equalizer_presets->u.object.values[1].name_length) == 0 &&
equalizer_presets->u.object.values[1].value->type == json_array)
{
@ -163,9 +165,9 @@ static void loadPresets()
size_t count = equalizer_presets->u.object.values[1].value->u.array.length;
json_value ** values = equalizer_presets->u.object.values[1].value->u.array.values;
winamp_equalizer_items = _winamp_equalizer_items();
cog_equalizer_items = _cog_equalizer_items();
const size_t winamp_object_minimum = [winamp_equalizer_items count];
const size_t cog_object_minimum = [cog_equalizer_items count];
for (size_t i = 0; i < count; ++i) {
if (values[i]->type == json_object) {
@ -173,11 +175,11 @@ static void loadPresets()
size_t object_items = values[i]->u.object.length;
json_object_entry * object_entry = values[i]->u.object.values;
size_t requiredItemsPresent = 0;
if (object_items >= winamp_object_minimum) {
if (object_items >= cog_object_minimum) {
NSMutableDictionary * equalizerItem = [[NSMutableDictionary alloc] init];
for (size_t j = 0; j < object_items; ++j) {
NSString * key = [NSString stringWithUTF8String:object_entry[j].name];
NSInteger index = [winamp_equalizer_items indexOfObject:key];
NSInteger index = [cog_equalizer_items indexOfObject:key];
if (index != NSNotFound) {
if (index == 0 && object_entry[j].value->type == json_string) {
NSString * name = [NSString stringWithUTF8String:object_entry[j].value->u.string.ptr];
@ -186,12 +188,12 @@ static void loadPresets()
}
else if (object_entry[j].value->type == json_integer) {
int64_t value = object_entry[j].value->u.integer;
float floatValue = ((value <= 64 && value >= 1) ? ((float)(value - 33) / 32.0 * 12.0) : 0.0);
float floatValue = ((value <= 401 && value >= 1) ? ((float)(value - 201) / 10.0) : 0.0);
[equalizerItem setObject:[NSNumber numberWithFloat:floatValue] forKey:key];
++requiredItemsPresent;
}
}
else if ([key isEqualToString:winamp_equalizer_extra_genres]) {
else if ([key isEqualToString:cog_equalizer_extra_genres]) {
// Process alternate genre matches
if (object_entry[j].value->type == json_array) {
size_t value_count = object_entry[j].value->u.array.length;
@ -205,7 +207,7 @@ static void loadPresets()
}
}
if (requiredItemsPresent == winamp_object_minimum) {
if (requiredItemsPresent == cog_object_minimum) {
// Add the base item
NSDictionary *outItem = [NSDictionary dictionaryWithDictionary:equalizerItem];
[array addObject:outItem];