Add beginnings of lfo, fast exp

This patch adds the low-level implementation of an LFO, with the DX7
waveforms, but doesn't yet contain the note wiring. It also adds a fast
lookup table based exp function, which is mostly used for envelopes.

There are also some build tweaks. It's possible some build files are
out of sync with the source, but at least the Android app seems to
build.
master
Raph Levien 12 years ago
parent 423408ec9f
commit 10392e8260
  1. 4
      cpp/README
  2. 123
      cpp/src/SynthApp.xcodeproj/project.pbxproj
  3. 3
      cpp/src/core.gyp
  4. 84
      cpp/src/core.xcodeproj/project.pbxproj
  5. 36
      cpp/src/exp2.cc
  6. 46
      cpp/src/exp2.h
  7. 69
      cpp/src/lfo.cc
  8. 36
      cpp/src/lfo.h
  9. 15
      cpp/src/main.cc

@ -18,3 +18,7 @@ The File Open menu command is hooked up as well and will load SYX format
DX7 patch files (32 patches per file). Send program change midi events DX7 patch files (32 patches per file). Send program change midi events
with the first 32 program numbers. with the first 32 program numbers.
The xcodeproj files are checked into the repo, but they are autogenerated
from .gyp files, which are the authoritative masters. To modify the
build, change the .gyp file, then run "gyp" in this dir. For changes
to the core, also change ../../android/jni/Android.mk .

@ -7,20 +7,20 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
070048C57FCB5F31827D61CD /* midi_in_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9CC658C4805259001BB2BA70 /* midi_in_mac.cc */; }; 0AF9B4E130CD067B67982EBD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB723D6CDE6B962FBA69894 /* main.m */; };
444FC1A8A4F4BFBB71A55578 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 106567A2B2FDE65A2547B9C0 /* InfoPlist.strings */; }; 1C5DE660EC77BB10207B2287 /* SynthMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = AFA13CCA8E0B32555D59A9B3 /* SynthMain.mm */; };
4EC6E0A88AFE158936E7DF22 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3EDCE57490308092B70255E /* CoreFoundation.framework */; }; 2BA8FE676832264E0511D537 /* midi_in_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9CC658C4805259001BB2BA70 /* midi_in_mac.cc */; };
6004825C9C1BA9246F032431 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D3126A377165245C44B6C8A /* CoreAudio.framework */; }; 5EAECBD70CBEA73B2779206F /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0638CA1C453E326E762DA4BE /* Carbon.framework */; };
6824545AE8F4DAFB95F6CDDB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB723D6CDE6B962FBA69894 /* main.m */; }; 8F78BB0F8E5ABD62E94E9033 /* libcore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BACEAAFABBABE1D12902220B /* libcore.a */; };
752469DD01013D889966B42C /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F664EAAFF41058799553650 /* AudioUnit.framework */; }; 934113319D00751E8E25D151 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9DC34125BEDD68ABCAB055D /* AudioToolbox.framework */; };
7E84D499B82B6C02EB8AA96C /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D651559601BF84BEA261778D /* MainMenu.xib */; }; 99BC8AF04EDB098B35258E82 /* SynthAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 22758A226C30B8A0C2E095B2 /* SynthAppDelegate.mm */; };
7F9707F48C04E2AE1EB5C866 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4618975BF19F21FC2A429474 /* Cocoa.framework */; }; B4DE673655497871A3BBC156 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3EDCE57490308092B70255E /* CoreFoundation.framework */; };
9366D617A2CE978AEA3555B3 /* libcore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BACEAAFABBABE1D12902220B /* libcore.a */; }; D19B14BE69AE22E170B65E39 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D3126A377165245C44B6C8A /* CoreAudio.framework */; };
982E3B747974F63D8B4482B2 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9DC34125BEDD68ABCAB055D /* AudioToolbox.framework */; }; D981AAA9AAF8D88A04A6C48B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3E06DBD96E36EB93BEA0FC1B /* InfoPlist.strings */; };
98F8F0314510BD0F6AA320CE /* SynthMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = AFA13CCA8E0B32555D59A9B3 /* SynthMain.mm */; }; E55D320615482E26123191C2 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F664EAAFF41058799553650 /* AudioUnit.framework */; };
B6BA9FF151AD9A0D309C0D53 /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1680278C574FAEFF7657992 /* CoreMIDI.framework */; }; F7624EA1A8133B1F867A515E /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1680278C574FAEFF7657992 /* CoreMIDI.framework */; };
C5E74E9A85CDC29EB3DCCBF7 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0638CA1C453E326E762DA4BE /* Carbon.framework */; }; FB09285A67966501565CC485 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = CF2DC82EE50B750198149118 /* MainMenu.xib */; };
D6CAF0C6797908C34B18E987 /* SynthAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 22758A226C30B8A0C2E095B2 /* SynthAppDelegate.mm */; }; FEDE0E473529E7B58EAA6CF3 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4618975BF19F21FC2A429474 /* Cocoa.framework */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -65,54 +65,51 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9366D617A2CE978AEA3555B3 /* libcore.a in Frameworks */, 8F78BB0F8E5ABD62E94E9033 /* libcore.a in Frameworks */,
982E3B747974F63D8B4482B2 /* AudioToolbox.framework in Frameworks */, 934113319D00751E8E25D151 /* AudioToolbox.framework in Frameworks */,
752469DD01013D889966B42C /* AudioUnit.framework in Frameworks */, E55D320615482E26123191C2 /* AudioUnit.framework in Frameworks */,
C5E74E9A85CDC29EB3DCCBF7 /* Carbon.framework in Frameworks */, 5EAECBD70CBEA73B2779206F /* Carbon.framework in Frameworks */,
7F9707F48C04E2AE1EB5C866 /* Cocoa.framework in Frameworks */, FEDE0E473529E7B58EAA6CF3 /* Cocoa.framework in Frameworks */,
6004825C9C1BA9246F032431 /* CoreAudio.framework in Frameworks */, D19B14BE69AE22E170B65E39 /* CoreAudio.framework in Frameworks */,
4EC6E0A88AFE158936E7DF22 /* CoreFoundation.framework in Frameworks */, B4DE673655497871A3BBC156 /* CoreFoundation.framework in Frameworks */,
B6BA9FF151AD9A0D309C0D53 /* CoreMIDI.framework in Frameworks */, F7624EA1A8133B1F867A515E /* CoreMIDI.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
08D7B67857704EB61BBC1112 /* Frameworks */ = { 048E2E4F06C19059DA10948A /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F9DC34125BEDD68ABCAB055D /* AudioToolbox.framework */, E4B4F7598D96CC2CE29666B4 /* SynthApp.app */,
6F664EAAFF41058799553650 /* AudioUnit.framework */,
0638CA1C453E326E762DA4BE /* Carbon.framework */,
4618975BF19F21FC2A429474 /* Cocoa.framework */,
2D3126A377165245C44B6C8A /* CoreAudio.framework */,
C3EDCE57490308092B70255E /* CoreFoundation.framework */,
B1680278C574FAEFF7657992 /* CoreMIDI.framework */,
); );
name = Frameworks; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
26BC9EF25519FDFECC66EBA5 /* Products */ = { 06DC9AAFE57AC70F6D82C9B8 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E4B4F7598D96CC2CE29666B4 /* SynthApp.app */, BACEAAFABBABE1D12902220B /* libcore.a */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
56669AEF9C728CE587C3E8A3 = { 571F3C9918276141BDFD1F04 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
C611344839FF3B4608474E37 /* Source */, F9DC34125BEDD68ABCAB055D /* AudioToolbox.framework */,
710624B4F3ADB1F020942DB0 /* Projects */, 6F664EAAFF41058799553650 /* AudioUnit.framework */,
08D7B67857704EB61BBC1112 /* Frameworks */, 0638CA1C453E326E762DA4BE /* Carbon.framework */,
26BC9EF25519FDFECC66EBA5 /* Products */, 4618975BF19F21FC2A429474 /* Cocoa.framework */,
FF670D1787E80284877493D1 /* Build */, 2D3126A377165245C44B6C8A /* CoreAudio.framework */,
C3EDCE57490308092B70255E /* CoreFoundation.framework */,
B1680278C574FAEFF7657992 /* CoreMIDI.framework */,
); );
name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
710624B4F3ADB1F020942DB0 /* Projects */ = { 652E39EBA60801294DEE7827 /* Projects */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B5F1A11C57F7DE82D8F9F9C2 /* core.xcodeproj */, B5F1A11C57F7DE82D8F9F9C2 /* core.xcodeproj */,
@ -120,11 +117,11 @@
name = Projects; name = Projects;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
C611344839FF3B4608474E37 /* Source */ = { 8C541AB012A6421C156ED3CC /* Source */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
106567A2B2FDE65A2547B9C0 /* InfoPlist.strings */, 3E06DBD96E36EB93BEA0FC1B /* InfoPlist.strings */,
D651559601BF84BEA261778D /* MainMenu.xib */, CF2DC82EE50B750198149118 /* MainMenu.xib */,
22758A226C30B8A0C2E095B2 /* SynthAppDelegate.mm */, 22758A226C30B8A0C2E095B2 /* SynthAppDelegate.mm */,
3C854865960DE58DBB62E200 /* SynthApp_Prefix.pch */, 3C854865960DE58DBB62E200 /* SynthApp_Prefix.pch */,
AFA13CCA8E0B32555D59A9B3 /* SynthMain.mm */, AFA13CCA8E0B32555D59A9B3 /* SynthMain.mm */,
@ -135,20 +132,23 @@
path = SynthApp; path = SynthApp;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D9149B7557AF29282FBD3555 /* Products */ = { AE142D1365FF48FD556E86BC /* Build */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BACEAAFABBABE1D12902220B /* libcore.a */, 645192D86D7D39B0CAB2E0FC /* SynthApp.gyp */,
); );
name = Products; name = Build;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
FF670D1787E80284877493D1 /* Build */ = { EEAFDBA4970041AA25C22652 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
645192D86D7D39B0CAB2E0FC /* SynthApp.gyp */, 8C541AB012A6421C156ED3CC /* Source */,
652E39EBA60801294DEE7827 /* Projects */,
571F3C9918276141BDFD1F04 /* Frameworks */,
048E2E4F06C19059DA10948A /* Products */,
AE142D1365FF48FD556E86BC /* Build */,
); );
name = Build;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
/* End PBXGroup section */ /* End PBXGroup section */
@ -185,16 +185,13 @@
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = ( knownRegions = (
English, en,
Japanese,
French,
German,
); );
mainGroup = 56669AEF9C728CE587C3E8A3; mainGroup = EEAFDBA4970041AA25C22652;
projectDirPath = ""; projectDirPath = "";
projectReferences = ( projectReferences = (
{ {
ProductGroup = D9149B7557AF29282FBD3555 /* Products */; ProductGroup = 06DC9AAFE57AC70F6D82C9B8 /* Products */;
ProjectRef = B5F1A11C57F7DE82D8F9F9C2 /* core.xcodeproj */; ProjectRef = B5F1A11C57F7DE82D8F9F9C2 /* core.xcodeproj */;
}, },
); );
@ -220,8 +217,8 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
444FC1A8A4F4BFBB71A55578 /* InfoPlist.strings in Resources */, D981AAA9AAF8D88A04A6C48B /* InfoPlist.strings in Resources */,
7E84D499B82B6C02EB8AA96C /* MainMenu.xib in Resources */, FB09285A67966501565CC485 /* MainMenu.xib in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -232,10 +229,10 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
6824545AE8F4DAFB95F6CDDB /* main.m in Sources */, 0AF9B4E130CD067B67982EBD /* main.m in Sources */,
070048C57FCB5F31827D61CD /* midi_in_mac.cc in Sources */, 2BA8FE676832264E0511D537 /* midi_in_mac.cc in Sources */,
D6CAF0C6797908C34B18E987 /* SynthAppDelegate.mm in Sources */, 99BC8AF04EDB098B35258E82 /* SynthAppDelegate.mm in Sources */,
98F8F0314510BD0F6AA320CE /* SynthMain.mm in Sources */, 1C5DE660EC77BB10207B2287 /* SynthMain.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -250,7 +247,7 @@
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
106567A2B2FDE65A2547B9C0 /* InfoPlist.strings */ = { 3E06DBD96E36EB93BEA0FC1B /* InfoPlist.strings */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
AC00D3CE197617EB5BC7110C /* English */, AC00D3CE197617EB5BC7110C /* English */,
@ -258,7 +255,7 @@
name = InfoPlist.strings; name = InfoPlist.strings;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D651559601BF84BEA261778D /* MainMenu.xib */ = { CF2DC82EE50B750198149118 /* MainMenu.xib */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
47E3EC1A3593850470FB7E33 /* English */, 47E3EC1A3593850470FB7E33 /* English */,

@ -6,9 +6,12 @@
'sources': [ 'sources': [
'dx7note.cc', 'dx7note.cc',
'env.cc', 'env.cc',
'exp2.cc',
'fm_core.cc', 'fm_core.cc',
'fm_op_kernel.cc', 'fm_op_kernel.cc',
'freqlut.cc', 'freqlut.cc',
'lfo.cc',
'patch.cc',
'resofilter.cc', 'resofilter.cc',
'ringbuffer.cc', 'ringbuffer.cc',
'sawtooth.cc', 'sawtooth.cc',

@ -3,38 +3,42 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 46; objectVersion = 45;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1DBA85B761236957DF00CF7B /* fm_core.cc in Sources */ = {isa = PBXBuildFile; fileRef = DA7AAEE2AD874001F6B71D52 /* fm_core.cc */; }; 2DD71F3E9AE0C4253B8B7747 /* exp2.cc in Sources */ = {isa = PBXBuildFile; fileRef = D5669C7FDAF95F10639CF5AB /* exp2.cc */; };
2FB5AF9855596821669CAE1F /* dx7note.cc in Sources */ = {isa = PBXBuildFile; fileRef = BA00975977E2704F74104728 /* dx7note.cc */; }; 391223C6D7249361C00A14AF /* dx7note.cc in Sources */ = {isa = PBXBuildFile; fileRef = BA00975977E2704F74104728 /* dx7note.cc */; };
36D08A0FEA591FC0EF188469 /* env.cc in Sources */ = {isa = PBXBuildFile; fileRef = B73D485E55EBD9CD5950A375 /* env.cc */; }; 3DFFE98F73F04D2F66DA9FA4 /* env.cc in Sources */ = {isa = PBXBuildFile; fileRef = B73D485E55EBD9CD5950A375 /* env.cc */; };
4FB7FFF436D333023EC91E2C /* sin.cc in Sources */ = {isa = PBXBuildFile; fileRef = D1D8B6FB01C9E7E2D99378F0 /* sin.cc */; }; 50C9BC20B9DB9E51A9B852BC /* test_ringbuffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 521793C71CAA078F5598EFC0 /* test_ringbuffer.cc */; };
5FA224E159A6B07188657BA8 /* freqlut.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9FF02D488CE6FD5017D7D81A /* freqlut.cc */; }; 6E01450F6BFF126216C8164C /* ringbuffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 68FD17910F296961541A67E4 /* ringbuffer.cc */; };
71911D7305F0175DC4A3FF17 /* sawtooth.cc in Sources */ = {isa = PBXBuildFile; fileRef = 48B6535400CF3AC8BABB3299 /* sawtooth.cc */; }; 79D1CB0F9A4671DA79729544 /* fm_op_kernel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 509D811344DB98984FD6C126 /* fm_op_kernel.cc */; };
80D3C6DC6F5236826B6AB404 /* test_ringbuffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 521793C71CAA078F5598EFC0 /* test_ringbuffer.cc */; }; 97788F06DA1810835D9F0A50 /* lfo.cc in Sources */ = {isa = PBXBuildFile; fileRef = 42D2A2AD8EDACBEF9B884718 /* lfo.cc */; };
8D41064389CC8FD281956BF7 /* fm_op_kernel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 509D811344DB98984FD6C126 /* fm_op_kernel.cc */; }; AA0F43347EBDEE6D29032DAF /* sin.cc in Sources */ = {isa = PBXBuildFile; fileRef = D1D8B6FB01C9E7E2D99378F0 /* sin.cc */; };
908EAB1EE59231C41FD88BCD /* ringbuffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 68FD17910F296961541A67E4 /* ringbuffer.cc */; }; AA1CD32CDCFEB4469067D98E /* resofilter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 97A5CBACD479212282D0BFD6 /* resofilter.cc */; };
A16F70FD02394895C6FA7326 /* synth_unit.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2082841A11DF6E62596265CF /* synth_unit.cc */; }; B64D26CA7CC8017052D3E963 /* patch.cc in Sources */ = {isa = PBXBuildFile; fileRef = 779AFCD7AFEB1CDEACBC0425 /* patch.cc */; };
AECC016D16C70F9300FBD4E4 /* patch.cc in Sources */ = {isa = PBXBuildFile; fileRef = AECC016C16C70F9300FBD4E4 /* patch.cc */; }; D80FBC17492647DCFDE96F75 /* fm_core.cc in Sources */ = {isa = PBXBuildFile; fileRef = DA7AAEE2AD874001F6B71D52 /* fm_core.cc */; };
D5ECD09EBEB1684C00616248 /* resofilter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 97A5CBACD479212282D0BFD6 /* resofilter.cc */; }; E2649182D734B708D5E72B66 /* synth_unit.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2082841A11DF6E62596265CF /* synth_unit.cc */; };
E31A9F6965B9E56115BAE59F /* sawtooth.cc in Sources */ = {isa = PBXBuildFile; fileRef = 48B6535400CF3AC8BABB3299 /* sawtooth.cc */; };
FB78A2E9904695ABCC799CC3 /* freqlut.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9FF02D488CE6FD5017D7D81A /* freqlut.cc */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
2082841A11DF6E62596265CF /* synth_unit.cc */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = synth_unit.cc; sourceTree = "<group>"; tabWidth = 2; }; 2082841A11DF6E62596265CF /* synth_unit.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = synth_unit.cc; sourceTree = "<group>"; };
42D2A2AD8EDACBEF9B884718 /* lfo.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = lfo.cc; sourceTree = "<group>"; };
48B6535400CF3AC8BABB3299 /* sawtooth.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sawtooth.cc; sourceTree = "<group>"; }; 48B6535400CF3AC8BABB3299 /* sawtooth.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sawtooth.cc; sourceTree = "<group>"; };
509D811344DB98984FD6C126 /* fm_op_kernel.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = fm_op_kernel.cc; sourceTree = "<group>"; }; 509D811344DB98984FD6C126 /* fm_op_kernel.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = fm_op_kernel.cc; sourceTree = "<group>"; };
521793C71CAA078F5598EFC0 /* test_ringbuffer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = test_ringbuffer.cc; sourceTree = "<group>"; }; 521793C71CAA078F5598EFC0 /* test_ringbuffer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = test_ringbuffer.cc; sourceTree = "<group>"; };
68FD17910F296961541A67E4 /* ringbuffer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ringbuffer.cc; sourceTree = "<group>"; }; 68FD17910F296961541A67E4 /* ringbuffer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ringbuffer.cc; sourceTree = "<group>"; };
6C1B71FBACD041F20E7F828A /* core.gyp */ = {isa = PBXFileReference; lastKnownFileType = text; path = core.gyp; sourceTree = "<group>"; }; 6C1B71FBACD041F20E7F828A /* core.gyp */ = {isa = PBXFileReference; lastKnownFileType = text; path = core.gyp; sourceTree = "<group>"; };
779AFCD7AFEB1CDEACBC0425 /* patch.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = patch.cc; sourceTree = "<group>"; };
8B1FC9FF853D5C32F4771091 /* libcore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcore.a; sourceTree = BUILT_PRODUCTS_DIR; }; 8B1FC9FF853D5C32F4771091 /* libcore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcore.a; sourceTree = BUILT_PRODUCTS_DIR; };
97A5CBACD479212282D0BFD6 /* resofilter.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = resofilter.cc; sourceTree = "<group>"; }; 97A5CBACD479212282D0BFD6 /* resofilter.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = resofilter.cc; sourceTree = "<group>"; };
9FF02D488CE6FD5017D7D81A /* freqlut.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = freqlut.cc; sourceTree = "<group>"; }; 9FF02D488CE6FD5017D7D81A /* freqlut.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = freqlut.cc; sourceTree = "<group>"; };
AECC016C16C70F9300FBD4E4 /* patch.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = patch.cc; sourceTree = "<group>"; };
B73D485E55EBD9CD5950A375 /* env.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = env.cc; sourceTree = "<group>"; }; B73D485E55EBD9CD5950A375 /* env.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = env.cc; sourceTree = "<group>"; };
BA00975977E2704F74104728 /* dx7note.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dx7note.cc; sourceTree = "<group>"; }; BA00975977E2704F74104728 /* dx7note.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dx7note.cc; sourceTree = "<group>"; };
D1D8B6FB01C9E7E2D99378F0 /* sin.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sin.cc; sourceTree = "<group>"; }; D1D8B6FB01C9E7E2D99378F0 /* sin.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sin.cc; sourceTree = "<group>"; };
D5669C7FDAF95F10639CF5AB /* exp2.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = exp2.cc; sourceTree = "<group>"; };
DA7AAEE2AD874001F6B71D52 /* fm_core.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = fm_core.cc; sourceTree = "<group>"; }; DA7AAEE2AD874001F6B71D52 /* fm_core.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = fm_core.cc; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -49,24 +53,26 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
1CE02724939AB46300B24440 = { 19BC3E7E3EDF760717F26DF5 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
AECC016C16C70F9300FBD4E4 /* patch.cc */, 1B875637F4FC04501E9170B8 /* Source */,
521E615727EAD5BFC2BFE8C3 /* Source */, E53EB7DD466ADEEC9F094623 /* Products */,
ADABDC1FC75C07B5469F92DE /* Products */, 8512968DD6AB145582824E65 /* Build */,
72A5A7469C1AF9FDDAB23BD1 /* Build */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
521E615727EAD5BFC2BFE8C3 /* Source */ = { 1B875637F4FC04501E9170B8 /* Source */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BA00975977E2704F74104728 /* dx7note.cc */, BA00975977E2704F74104728 /* dx7note.cc */,
B73D485E55EBD9CD5950A375 /* env.cc */, B73D485E55EBD9CD5950A375 /* env.cc */,
D5669C7FDAF95F10639CF5AB /* exp2.cc */,
DA7AAEE2AD874001F6B71D52 /* fm_core.cc */, DA7AAEE2AD874001F6B71D52 /* fm_core.cc */,
509D811344DB98984FD6C126 /* fm_op_kernel.cc */, 509D811344DB98984FD6C126 /* fm_op_kernel.cc */,
9FF02D488CE6FD5017D7D81A /* freqlut.cc */, 9FF02D488CE6FD5017D7D81A /* freqlut.cc */,
42D2A2AD8EDACBEF9B884718 /* lfo.cc */,
779AFCD7AFEB1CDEACBC0425 /* patch.cc */,
97A5CBACD479212282D0BFD6 /* resofilter.cc */, 97A5CBACD479212282D0BFD6 /* resofilter.cc */,
68FD17910F296961541A67E4 /* ringbuffer.cc */, 68FD17910F296961541A67E4 /* ringbuffer.cc */,
48B6535400CF3AC8BABB3299 /* sawtooth.cc */, 48B6535400CF3AC8BABB3299 /* sawtooth.cc */,
@ -77,7 +83,7 @@
name = Source; name = Source;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
72A5A7469C1AF9FDDAB23BD1 /* Build */ = { 8512968DD6AB145582824E65 /* Build */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
6C1B71FBACD041F20E7F828A /* core.gyp */, 6C1B71FBACD041F20E7F828A /* core.gyp */,
@ -85,7 +91,7 @@
name = Build; name = Build;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
ADABDC1FC75C07B5469F92DE /* Products */ = { E53EB7DD466ADEEC9F094623 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
8B1FC9FF853D5C32F4771091 /* libcore.a */, 8B1FC9FF853D5C32F4771091 /* libcore.a */,
@ -122,12 +128,8 @@
}; };
buildConfigurationList = 2F684B8427DC8F5001D9A5B0 /* Build configuration list for PBXProject "core" */; buildConfigurationList = 2F684B8427DC8F5001D9A5B0 /* Build configuration list for PBXProject "core" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = ( mainGroup = 19BC3E7E3EDF760717F26DF5;
en,
);
mainGroup = 1CE02724939AB46300B24440;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
targets = ( targets = (
@ -141,18 +143,20 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2FB5AF9855596821669CAE1F /* dx7note.cc in Sources */, 391223C6D7249361C00A14AF /* dx7note.cc in Sources */,
36D08A0FEA591FC0EF188469 /* env.cc in Sources */, 3DFFE98F73F04D2F66DA9FA4 /* env.cc in Sources */,
1DBA85B761236957DF00CF7B /* fm_core.cc in Sources */, 2DD71F3E9AE0C4253B8B7747 /* exp2.cc in Sources */,
8D41064389CC8FD281956BF7 /* fm_op_kernel.cc in Sources */, D80FBC17492647DCFDE96F75 /* fm_core.cc in Sources */,
5FA224E159A6B07188657BA8 /* freqlut.cc in Sources */, 79D1CB0F9A4671DA79729544 /* fm_op_kernel.cc in Sources */,
D5ECD09EBEB1684C00616248 /* resofilter.cc in Sources */, FB78A2E9904695ABCC799CC3 /* freqlut.cc in Sources */,
908EAB1EE59231C41FD88BCD /* ringbuffer.cc in Sources */, 97788F06DA1810835D9F0A50 /* lfo.cc in Sources */,
71911D7305F0175DC4A3FF17 /* sawtooth.cc in Sources */, B64D26CA7CC8017052D3E963 /* patch.cc in Sources */,
4FB7FFF436D333023EC91E2C /* sin.cc in Sources */, AA1CD32CDCFEB4469067D98E /* resofilter.cc in Sources */,
A16F70FD02394895C6FA7326 /* synth_unit.cc in Sources */, 6E01450F6BFF126216C8164C /* ringbuffer.cc in Sources */,
80D3C6DC6F5236826B6AB404 /* test_ringbuffer.cc in Sources */, E31A9F6965B9E56115BAE59F /* sawtooth.cc in Sources */,
AECC016D16C70F9300FBD4E4 /* patch.cc in Sources */, AA0F43347EBDEE6D29032DAF /* sin.cc in Sources */,
E2649182D734B708D5E72B66 /* synth_unit.cc in Sources */,
50C9BC20B9DB9E51A9B852BC /* test_ringbuffer.cc in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

@ -0,0 +1,36 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <math.h>
#include "synth.h"
#include "exp2.h"
int32_t exp2tab[EXP2_N_SAMPLES << 1];
void Exp2::init() {
double inc = exp2(1.0 / EXP2_N_SAMPLES);
double y = 1 << 30;
for (int i = 0; i < EXP2_N_SAMPLES; i++) {
exp2tab[(i << 1) + 1] = (int32_t)floor(y + 0.5);
y *= inc;
}
for (int i = 0; i < EXP2_N_SAMPLES - 1; i++) {
exp2tab[i << 1] = exp2tab[(i << 1) + 3] - exp2tab[(i << 1) + 1];
}
exp2tab[(EXP2_N_SAMPLES << 1) - 2] = (1U << 31) - exp2tab[(EXP2_N_SAMPLES << 1) - 1];
}

@ -0,0 +1,46 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Exp2 {
public:
Exp2();
static void init();
// Q24 in, Q24 out
static int32_t lookup(int32_t x);
};
#define EXP2_LG_N_SAMPLES 10
#define EXP2_N_SAMPLES (1 << EXP2_LG_N_SAMPLES)
#define EXP2_INLINE
extern int32_t exp2tab[EXP2_N_SAMPLES << 1];
#ifdef EXP2_INLINE
inline
int32_t Exp2::lookup(int32_t x) {
const int SHIFT = 24 - EXP2_LG_N_SAMPLES;
int lowbits = x & ((1 << SHIFT) - 1);
int x_int = (x >> (SHIFT - 1)) & ((EXP2_N_SAMPLES - 1) << 1);
int dy = exp2tab[x_int];
int y0 = exp2tab[x_int + 1];
int y = y0 + (((int64_t)dy * (int64_t)lowbits) >> SHIFT);
return y >> (6 - (x >> 24));
}
#endif

@ -0,0 +1,69 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Low frequency oscillator, compatible with DX7
#include "synth.h"
#include "sin.h"
#include "lfo.h"
void Lfo::init(double sample_rate) {
// constant is 1 << 32 / 15.5s / 11
Lfo::unit_ = (int32_t)(N * 25190424 / sample_rate + 0.5);
}
void Lfo::reset(const char params[6]) {
int rate = params[0]; // 0..99
int sr = rate == 0 ? 1 : (165 * rate) >> 6;
sr *= sr < 160 ? 11 : (11 + ((sr - 160) >> 4));
delta_ = unit_ * sr;
waveform_ = params[5];
sync_ = params[4] != 0;
}
int32_t Lfo::getsample() {
phase_ += delta_;
int32_t x;
switch (waveform_) {
case 0: // triangle
x = phase_ >> 7;
x ^= -(phase_ >> 31);
x &= (1 << 24) - 1;
return x;
case 1: // sawtooth down
return (~phase_ ^ (1U << 31)) >> 8;
case 2: // sawtooth up
return (phase_ ^ (1U << 31)) >> 8;
case 3: // square
return ((~phase_) >> 7) & (1 << 24);
case 4: // sine
return (1 << 23) + (Sin::lookup(phase_ >> 8) >> 1);
case 5: // s&h
if (phase_ < delta_) {
randstate_ = (randstate_ * 179 + 17) & 0xff;
}
x = randstate_ ^ 0x80;
return (x + 1) << 16;
}
return 1 << 23;
}
void Lfo::keydown() {
if (sync_) {
phase_ = (1U << 31) - 1;
}
}

@ -0,0 +1,36 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Low frequency oscillator, compatible with DX7
class Lfo {
public:
static void init(double sample_rate);
void reset(const char params[6]);
// result is 0..1 in Q24
int32_t getsample();
void keydown();
private:
static uint32_t unit_;
uint32_t phase_; // Q32
uint32_t delta_;
uint8_t waveform_;
uint8_t randstate_;
bool sync_;
};

@ -24,6 +24,7 @@
#include "wavout.h" #include "wavout.h"
#include "sawtooth.h" #include "sawtooth.h"
#include "sin.h" #include "sin.h"
#include "exp2.h"
#include "resofilter.h" #include "resofilter.h"
#include "fm_core.h" #include "fm_core.h"
#include "fm_op_kernel.h" #include "fm_op_kernel.h"
@ -217,11 +218,24 @@ void mkdx7note(double sample_rate) {
void test_ringbuffer(); void test_ringbuffer();
void test_exp2() {
for (int32_t i = -16 << 24; i < 6 << 24; i += 123) {
int32_t result = Exp2::lookup(i);
int32_t accurate = floor((1<<24) * pow(2, i * 1.0 / (1<<24)) + .5);
int32_t error = accurate - result;
if (abs(error) > 1 && abs(error) > accurate / 10000000) {
std::cout << i << ": " << result << " " << accurate << std::endl;
// TODO (maybe): hook into automated test runner & report results
}
}
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
double sample_rate = 44100.0; double sample_rate = 44100.0;
Freqlut::init(sample_rate); Freqlut::init(sample_rate);
Sawtooth::init(sample_rate); Sawtooth::init(sample_rate);
Sin::init(); Sin::init();
Exp2::init();
//FmCore::dump(); //FmCore::dump();
//test_sin_accuracy(); //test_sin_accuracy();
@ -234,5 +248,6 @@ int main(int argc, char **argv) {
//mkdx7note(sample_rate); //mkdx7note(sample_rate);
mksaw(sample_rate); mksaw(sample_rate);
//test_ringbuffer(); //test_ringbuffer();
test_exp2();
return 0; return 0;
} }

Loading…
Cancel
Save