Implemented a MOD-only plugin based on my fork of eightbitbubsy's playptmod

CQTexperiment
Chris Moeller 2013-10-22 10:03:18 -07:00
parent 87bf7bf833
commit 82d4d7b548
14 changed files with 4291 additions and 0 deletions

View File

@ -179,6 +179,7 @@
838491871808591F00E7332D /* NDHotKey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
838491881808593200E7332D /* NDHotKey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
8399D4E21805A55000B503B1 /* XmlContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8399D4E01805A55000B503B1 /* XmlContainer.m */; };
83A0F4E31816DBF900119DB4 /* playptmod.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83A0F4891816CE5E00119DB4 /* playptmod.bundle */; };
83B06704180D579E008E3612 /* MIDI.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B066A1180D5669008E3612 /* MIDI.bundle */; };
83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94350D747F7B0064F138 /* FFMPEG.bundle */; };
83E5E54C18087CA5001F3284 /* miniModeOffTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */; };
@ -467,6 +468,20 @@
remoteGlobalIDString = 32F1615514E6BB3B00D6AB2F;
remoteInfo = NDHotKey;
};
83A0F4881816CE5E00119DB4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83A0F4841816CE5E00119DB4 /* playptmod.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 83A0F46F1816CE5E00119DB4;
remoteInfo = playptmod;
};
83A0F4E11816DBE800119DB4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83A0F4841816CE5E00119DB4 /* playptmod.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 83A0F46E1816CE5E00119DB4;
remoteInfo = playptmod;
};
83B066A0180D5669008E3612 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83B0669C180D5668008E3612 /* MIDI.xcodeproj */;
@ -590,6 +605,7 @@
dstPath = "";
dstSubfolderSpec = 13;
files = (
83A0F4E31816DBF900119DB4 /* playptmod.bundle in CopyFiles */,
83B06704180D579E008E3612 /* MIDI.bundle in CopyFiles */,
8375B36517FFEF130092A79F /* Opus.bundle in CopyFiles */,
8359009D17FF06570060F3ED /* ArchiveSource.bundle in CopyFiles */,
@ -877,6 +893,7 @@
838491791808585C00E7332D /* NDHotKey.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NDHotKey.xcodeproj; path = Frameworks/NDHotKey/NDHotKey.xcodeproj; sourceTree = "<group>"; };
8399D4E01805A55000B503B1 /* XmlContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XmlContainer.m; sourceTree = "<group>"; };
8399D4E11805A55000B503B1 /* XmlContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlContainer.h; sourceTree = "<group>"; };
83A0F4841816CE5E00119DB4 /* playptmod.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = playptmod.xcodeproj; path = Plugins/playptmod/playptmod.xcodeproj; sourceTree = "<group>"; };
83B0669C180D5668008E3612 /* MIDI.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MIDI.xcodeproj; path = Plugins/MIDI/MIDI.xcodeproj; sourceTree = "<group>"; };
83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOffTemplate.pdf; path = Images/miniModeOffTemplate.pdf; sourceTree = "<group>"; };
83E5E54B18087CA5001F3284 /* miniModeOnTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOnTemplate.pdf; path = Images/miniModeOnTemplate.pdf; sourceTree = "<group>"; };
@ -1185,6 +1202,7 @@
8359FF2C17FEF35C0060F3ED /* ArchiveSource.xcodeproj */,
8375B05117FFEA400092A79F /* Opus.xcodeproj */,
83B0669C180D5668008E3612 /* MIDI.xcodeproj */,
83A0F4841816CE5E00119DB4 /* playptmod.xcodeproj */,
);
name = PlugIns;
sourceTree = "<group>";
@ -1550,6 +1568,14 @@
name = Products;
sourceTree = "<group>";
};
83A0F4851816CE5E00119DB4 /* Products */ = {
isa = PBXGroup;
children = (
83A0F4891816CE5E00119DB4 /* playptmod.bundle */,
);
name = Products;
sourceTree = "<group>";
};
83B0669D180D5668008E3612 /* Products */ = {
isa = PBXGroup;
children = (
@ -1702,6 +1728,7 @@
buildRules = (
);
dependencies = (
83A0F4E21816DBE800119DB4 /* PBXTargetDependency */,
83E6B7641816138800D4576D /* PBXTargetDependency */,
83B06703180D5776008E3612 /* PBXTargetDependency */,
838491861808591400E7332D /* PBXTargetDependency */,
@ -1830,6 +1857,10 @@
ProductGroup = 8375B05217FFEA400092A79F /* Products */;
ProjectRef = 8375B05117FFEA400092A79F /* Opus.xcodeproj */;
},
{
ProductGroup = 83A0F4851816CE5E00119DB4 /* Products */;
ProjectRef = 83A0F4841816CE5E00119DB4 /* playptmod.xcodeproj */;
},
{
ProductGroup = 8E8D41C30CBB0DA000135C1B /* Products */;
ProjectRef = 8E8D41C20CBB0DA000135C1B /* Pls.xcodeproj */;
@ -1996,6 +2027,13 @@
remoteRef = 8384917D1808585D00E7332D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
83A0F4891816CE5E00119DB4 /* playptmod.bundle */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = playptmod.bundle;
remoteRef = 83A0F4881816CE5E00119DB4 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
83B066A1180D5669008E3612 /* MIDI.bundle */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
@ -2351,6 +2389,11 @@
name = NDHotKey;
targetProxy = 838491851808591400E7332D /* PBXContainerItemProxy */;
};
83A0F4E21816DBE800119DB4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = playptmod;
targetProxy = 83A0F4E11816DBE800119DB4 /* PBXContainerItemProxy */;
};
83B06703180D5776008E3612 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = MIDI;

View File

@ -0,0 +1,308 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
83A0F4A61816CEAD00119DB4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 83A0F4A41816CEAD00119DB4 /* InfoPlist.strings */; };
83A0F4D31816CF9500119DB4 /* blip_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = 83A0F4CF1816CF9500119DB4 /* blip_buf.c */; };
83A0F4D41816CF9500119DB4 /* blip_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A0F4D01816CF9500119DB4 /* blip_buf.h */; settings = {ATTRIBUTES = (Public, ); }; };
83A0F4D51816CF9500119DB4 /* playptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 83A0F4D11816CF9500119DB4 /* playptmod.c */; };
83A0F4D61816CF9500119DB4 /* playptmod.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A0F4D21816CF9500119DB4 /* playptmod.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
83A0F4981816CEAD00119DB4 /* playptmod.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = playptmod.framework; sourceTree = BUILT_PRODUCTS_DIR; };
83A0F4A31816CEAD00119DB4 /* playptmod-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "playptmod-Info.plist"; sourceTree = "<group>"; };
83A0F4A51816CEAD00119DB4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
83A0F4CF1816CF9500119DB4 /* blip_buf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blip_buf.c; sourceTree = "<group>"; };
83A0F4D01816CF9500119DB4 /* blip_buf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blip_buf.h; sourceTree = "<group>"; };
83A0F4D11816CF9500119DB4 /* playptmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = playptmod.c; sourceTree = "<group>"; };
83A0F4D21816CF9500119DB4 /* playptmod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playptmod.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
83A0F4941816CEAD00119DB4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
83A0F48E1816CEAD00119DB4 = {
isa = PBXGroup;
children = (
83A0F4A11816CEAD00119DB4 /* playptmod */,
83A0F49A1816CEAD00119DB4 /* Frameworks */,
83A0F4991816CEAD00119DB4 /* Products */,
);
sourceTree = "<group>";
};
83A0F4991816CEAD00119DB4 /* Products */ = {
isa = PBXGroup;
children = (
83A0F4981816CEAD00119DB4 /* playptmod.framework */,
);
name = Products;
sourceTree = "<group>";
};
83A0F49A1816CEAD00119DB4 /* Frameworks */ = {
isa = PBXGroup;
children = (
83A0F49D1816CEAD00119DB4 /* Other Frameworks */,
);
name = Frameworks;
sourceTree = "<group>";
};
83A0F49D1816CEAD00119DB4 /* Other Frameworks */ = {
isa = PBXGroup;
children = (
);
name = "Other Frameworks";
sourceTree = "<group>";
};
83A0F4A11816CEAD00119DB4 /* playptmod */ = {
isa = PBXGroup;
children = (
83A0F4CF1816CF9500119DB4 /* blip_buf.c */,
83A0F4D01816CF9500119DB4 /* blip_buf.h */,
83A0F4D11816CF9500119DB4 /* playptmod.c */,
83A0F4D21816CF9500119DB4 /* playptmod.h */,
83A0F4A21816CEAD00119DB4 /* Supporting Files */,
);
path = playptmod;
sourceTree = "<group>";
};
83A0F4A21816CEAD00119DB4 /* Supporting Files */ = {
isa = PBXGroup;
children = (
83A0F4A31816CEAD00119DB4 /* playptmod-Info.plist */,
83A0F4A41816CEAD00119DB4 /* InfoPlist.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
83A0F4951816CEAD00119DB4 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F4D41816CF9500119DB4 /* blip_buf.h in Headers */,
83A0F4D61816CF9500119DB4 /* playptmod.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
83A0F4971816CEAD00119DB4 /* playptmod */ = {
isa = PBXNativeTarget;
buildConfigurationList = 83A0F4C01816CEAD00119DB4 /* Build configuration list for PBXNativeTarget "playptmod" */;
buildPhases = (
83A0F4931816CEAD00119DB4 /* Sources */,
83A0F4941816CEAD00119DB4 /* Frameworks */,
83A0F4951816CEAD00119DB4 /* Headers */,
83A0F4961816CEAD00119DB4 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = playptmod;
productName = playptmod;
productReference = 83A0F4981816CEAD00119DB4 /* playptmod.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83A0F48F1816CEAD00119DB4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Christopher Snowhill";
};
buildConfigurationList = 83A0F4921816CEAD00119DB4 /* Build configuration list for PBXProject "playptmod" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 83A0F48E1816CEAD00119DB4;
productRefGroup = 83A0F4991816CEAD00119DB4 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
83A0F4971816CEAD00119DB4 /* playptmod */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
83A0F4961816CEAD00119DB4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F4A61816CEAD00119DB4 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
83A0F4931816CEAD00119DB4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F4D51816CF9500119DB4 /* playptmod.c in Sources */,
83A0F4D31816CF9500119DB4 /* blip_buf.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
83A0F4A41816CEAD00119DB4 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
83A0F4A51816CEAD00119DB4 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
83A0F4BE1816CEAD00119DB4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Christopher Snowhill";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
83A0F4BF1816CEAD00119DB4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Christopher Snowhill";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
SDKROOT = macosx;
};
name = Release;
};
83A0F4C11816CEAD00119DB4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "playptmod/playptmod-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
WRAPPER_EXTENSION = framework;
};
name = Debug;
};
83A0F4C21816CEAD00119DB4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "playptmod/playptmod-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
WRAPPER_EXTENSION = framework;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
83A0F4921816CEAD00119DB4 /* Build configuration list for PBXProject "playptmod" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83A0F4BE1816CEAD00119DB4 /* Debug */,
83A0F4BF1816CEAD00119DB4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
83A0F4C01816CEAD00119DB4 /* Build configuration list for PBXNativeTarget "playptmod" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83A0F4C11816CEAD00119DB4 /* Debug */,
83A0F4C21816CEAD00119DB4 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 83A0F48F1816CEAD00119DB4 /* Project object */;
}

View File

@ -0,0 +1,197 @@
/* blip_buf 1.1.0. http://www.slack.net/~ant/ */
#include "blip_buf.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
/* Library Copyright (C) 2003-2009 Shay Green. 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 module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#if defined (BLARGG_TEST) && BLARGG_TEST
#include "blargg_test.h"
#endif
enum { time_bits = pre_shift + 20 };
static fixed_t const time_unit = (fixed_t) 1 << time_bits;
enum { bass_shift = 9 }; /* affects high-pass filter breakpoint frequency */
enum { end_frame_extra = 2 }; /* allows deltas slightly after frame length */
enum { half_width = 8 };
enum { buf_extra = half_width*2 + end_frame_extra };
enum { phase_bits = 5 };
enum { phase_count = 1 << phase_bits };
enum { delta_bits = 15 };
enum { delta_unit = 1 << delta_bits };
enum { frac_bits = time_bits - pre_shift };
/* We could eliminate avail and encode whole samples in offset, but that would
limit the total buffered samples to blip_max_frame. That could only be
increased by decreasing time_bits, which would reduce resample ratio accuracy.
*/
/* probably not totally portable */
#define SAMPLES( buf ) (buf->samples)
/* Arithmetic (sign-preserving) right shift */
#define ARITH_SHIFT( n, shift ) \
((n) >> (shift))
enum { max_sample = +32767 };
enum { min_sample = -32768 };
#define CLAMP( n ) \
{\
if ( (short) n != n )\
n = ARITH_SHIFT( n, 16 ) ^ max_sample;\
}
void ptm_blip_clear( blip_t* m )
{
/* We could set offset to 0, factor/2, or factor-1. 0 is suitable if
factor is rounded up. factor-1 is suitable if factor is rounded down.
Since we don't know rounding direction, factor/2 accommodates either,
with the slight loss of showing an error in half the time. Since for
a 64-bit factor this is years, the halving isn't a problem. */
m->offset = time_unit / 2;
m->index = 0;
m->integrator = 0;
m->last_value = 0;
memset( SAMPLES( m ), 0, 128 * sizeof (buf_t) );
}
int ptm_blip_read_sample( blip_t* m )
{
int retval;
{
buf_t * in = SAMPLES( m ) + m->index;
int sum = m->integrator;
{
/* Eliminate fraction */
int s = ARITH_SHIFT( sum, delta_bits );
sum += *in;
retval = s;
}
m->integrator = sum;
*in = 0;
m->index = ( m->index + 1 ) % 128;
}
return retval;
}
/* Things that didn't help performance on x86:
__attribute__((aligned(128)))
#define short int
restrict
*/
/* Sinc_Generator( 0.9, 0.55, 4.5 ) */
static short const bl_step [phase_count + 1] [half_width] =
{
{ 43, -115, 350, -488, 1136, -914, 5861,21022},
{ 44, -118, 348, -473, 1076, -799, 5274,21001},
{ 45, -121, 344, -454, 1011, -677, 4706,20936},
{ 46, -122, 336, -431, 942, -549, 4156,20829},
{ 47, -123, 327, -404, 868, -418, 3629,20679},
{ 47, -122, 316, -375, 792, -285, 3124,20488},
{ 47, -120, 303, -344, 714, -151, 2644,20256},
{ 46, -117, 289, -310, 634, -17, 2188,19985},
{ 46, -114, 273, -275, 553, 117, 1758,19675},
{ 44, -108, 255, -237, 471, 247, 1356,19327},
{ 43, -103, 237, -199, 390, 373, 981,18944},
{ 42, -98, 218, -160, 310, 495, 633,18527},
{ 40, -91, 198, -121, 231, 611, 314,18078},
{ 38, -84, 178, -81, 153, 722, 22,17599},
{ 36, -76, 157, -43, 80, 824, -241,17092},
{ 34, -68, 135, -3, 8, 919, -476,16558},
{ 32, -61, 115, 34, -60, 1006, -683,16001},
{ 29, -52, 94, 70, -123, 1083, -862,15422},
{ 27, -44, 73, 106, -184, 1152,-1015,14824},
{ 25, -36, 53, 139, -239, 1211,-1142,14210},
{ 22, -27, 34, 170, -290, 1261,-1244,13582},
{ 20, -20, 16, 199, -335, 1301,-1322,12942},
{ 18, -12, -3, 226, -375, 1331,-1376,12293},
{ 15, -4, -19, 250, -410, 1351,-1408,11638},
{ 13, 3, -35, 272, -439, 1361,-1419,10979},
{ 11, 9, -49, 292, -464, 1362,-1410,10319},
{ 9, 16, -63, 309, -483, 1354,-1383, 9660},
{ 7, 22, -75, 322, -496, 1337,-1339, 9005},
{ 6, 26, -85, 333, -504, 1312,-1280, 8355},
{ 4, 31, -94, 341, -507, 1278,-1205, 7713},
{ 3, 35, -102, 347, -506, 1238,-1119, 7082},
{ 1, 40, -110, 350, -499, 1190,-1021, 6464},
{ 0, 43, -115, 350, -488, 1136, -914, 5861}
};
/* Shifting by pre_shift allows calculation using unsigned int rather than
possibly-wider fixed_t. On 32-bit platforms, this is likely more efficient.
And by having pre_shift 32, a 32-bit platform can easily do the shift by
simply ignoring the low half. */
void ptm_blip_add_delta( blip_t* m, float time, int delta )
{
unsigned fixed = (unsigned) ((int)(time * time_unit + m->offset) >> pre_shift);
buf_t* out = SAMPLES( m ) + (m->index + (fixed >> frac_bits)) % 128;
buf_t* end = SAMPLES( m ) + 128;
int const phase_shift = frac_bits - phase_bits;
int phase = fixed >> phase_shift & (phase_count - 1);
short const* in = bl_step [phase];
short const* rev = bl_step [phase_count - phase];
int interp = fixed >> (phase_shift - delta_bits) & (delta_unit - 1);
int delta2 = (delta * interp) >> delta_bits;
delta -= delta2;
*out++ += in[0]*delta + in[half_width+0]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[1]*delta + in[half_width+1]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[2]*delta + in[half_width+2]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[3]*delta + in[half_width+3]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[4]*delta + in[half_width+4]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[5]*delta + in[half_width+5]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[6]*delta + in[half_width+6]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[7]*delta + in[half_width+7]*delta2;
if (out >= end) out = SAMPLES( m );
in = rev;
*out++ += in[7]*delta + in[7-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[6]*delta + in[6-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[5]*delta + in[5-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[4]*delta + in[4-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[3]*delta + in[3-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[2]*delta + in[2-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[1]*delta + in[1-half_width]*delta2;
if (out >= end) out = SAMPLES( m );
*out++ += in[0]*delta + in[0-half_width]*delta2;
}

View File

@ -0,0 +1,72 @@
/** \file
Sample buffer that resamples from input clock rate to output sample rate */
/* blip_buf 1.1.0 */
#ifndef BLIP_BUF_H
#define BLIP_BUF_H
#include <limits.h>
/* Equivalent to ULONG_MAX >= 0xFFFFFFFF00000000.
Avoids constants that don't fit in 32 bits. */
#if ULONG_MAX/0xFFFFFFFF > 0xFFFFFFFF
typedef unsigned long fixed_t;
enum { pre_shift = 32 };
#elif defined(ULLONG_MAX)
typedef unsigned long long fixed_t;
enum { pre_shift = 32 };
#else
typedef unsigned fixed_t;
enum { pre_shift = 0 };
#endif
typedef int buf_t;
/** Sample buffer that resamples to output rate and accumulates samples
until they're read out */
struct blip_t
{
fixed_t offset;
int index;
int avail;
int size;
int integrator;
int last_value;
buf_t samples[128];
};
#ifdef __cplusplus
extern "C" {
#endif
/** First parameter of most functions is blip_t*, or const blip_t* if nothing
is changed. */
typedef struct blip_t blip_t;
/** Clears entire buffer. Afterwards, blip_samples_avail() == 0. */
void ptm_blip_clear( blip_t* );
/** Adds positive/negative delta into buffer at specified clock time. */
void ptm_blip_add_delta( blip_t*, float clock_time, int delta );
/** Number of buffered samples available for reading. */
int ptm_blip_samples_avail( const blip_t* );
/** Reads and removes at most 'count' samples and writes them to 'out'. If
'stereo' is true, writes output to every other element of 'out', allowing easy
interleaving of two buffers into a stereo sample stream. Outputs 16-bit signed
samples. Returns number of samples actually read. */
int ptm_blip_read_sample( blip_t* );
/* Deprecated */
typedef blip_t blip_buffer_t;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>net.kode54.lib.playptmod</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013 Christopher Snowhill. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
#ifndef _PLAYPTMOD_H_
#define _PLAYPTMOD_H_
#ifdef __cplusplus
extern "C" {
#endif
void * playptmod_Create(int samplingFrequency);
#define PTMOD_OPTION_CLAMP_PERIODS 0
/* Set before loading module, or notes will be clamped accordingly
1 (default) = Amiga / Protracker range
* 0 = MSDOS / MTM / extended range */
#define PTMOD_OPTION_VSYNC_TIMING 1
/* 0 (default) = Speed command 20 or higher sets tempo
* 1 = Speed command always sets speed */
void playptmod_Config(void *p, int option, int value);
int playptmod_LoadMem(void *p, const unsigned char *buf, unsigned long bufLength);
int playptmod_Load(void *p, const char *filename);
void playptmod_Play(void *p, unsigned int startOrder);
void playptmod_Stop(void *p);
void playptmod_Render(void *p, signed short *target, int length);
void playptmod_Mute(void *p, int channel, int mute);
unsigned int playptmod_LoopCounter(void *p);
typedef struct _ptmi
{
unsigned char order;
unsigned char pattern;
unsigned char row;
unsigned char speed;
unsigned char tempo;
unsigned char channelsPlaying;
} playptmod_info;
void playptmod_GetInfo(void *p, playptmod_info *i);
void playptmod_Free(void *p);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,370 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
83A0F4731816CE5E00119DB4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83A0F4721816CE5E00119DB4 /* Cocoa.framework */; };
83A0F47D1816CE5E00119DB4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 83A0F47B1816CE5E00119DB4 /* InfoPlist.strings */; };
83A0F4D91816D03C00119DB4 /* playptmod.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83A0F4CC1816CEAE00119DB4 /* playptmod.framework */; };
83A0F4DB1816D04E00119DB4 /* playptmod.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83A0F4CC1816CEAE00119DB4 /* playptmod.framework */; };
83A0F4DE1816D09000119DB4 /* ptmodDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A0F4DD1816D09000119DB4 /* ptmodDecoder.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
83A0F4CB1816CEAE00119DB4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83A0F4C61816CEAD00119DB4 /* playptmod.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 83A0F4981816CEAD00119DB4;
remoteInfo = playptmod;
};
83A0F4D71816D03200119DB4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83A0F4C61816CEAD00119DB4 /* playptmod.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 83A0F4971816CEAD00119DB4;
remoteInfo = playptmod;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
83A0F4DA1816D04400119DB4 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
83A0F4DB1816D04E00119DB4 /* playptmod.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
83A0F46F1816CE5E00119DB4 /* playptmod.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = playptmod.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
83A0F4721816CE5E00119DB4 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
83A0F4751816CE5E00119DB4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
83A0F4761816CE5E00119DB4 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
83A0F4771816CE5E00119DB4 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
83A0F47A1816CE5E00119DB4 /* playptmod-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "playptmod-Info.plist"; sourceTree = "<group>"; };
83A0F47C1816CE5E00119DB4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
83A0F47E1816CE5E00119DB4 /* playptmod-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "playptmod-Prefix.pch"; sourceTree = "<group>"; };
83A0F4C61816CEAD00119DB4 /* playptmod.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = playptmod.xcodeproj; path = ../../Frameworks/playptmod/playptmod.xcodeproj; sourceTree = "<group>"; };
83A0F4DC1816D09000119DB4 /* ptmodDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ptmodDecoder.h; sourceTree = "<group>"; };
83A0F4DD1816D09000119DB4 /* ptmodDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ptmodDecoder.m; sourceTree = "<group>"; };
83A0F4DF1816D0AF00119DB4 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = "<group>"; };
83A0F4E01816D13000119DB4 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
83A0F46C1816CE5E00119DB4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F4D91816D03C00119DB4 /* playptmod.framework in Frameworks */,
83A0F4731816CE5E00119DB4 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
83A0F4661816CE5E00119DB4 = {
isa = PBXGroup;
children = (
83A0F4781816CE5E00119DB4 /* playptmod */,
83A0F4711816CE5E00119DB4 /* Frameworks */,
83A0F4701816CE5E00119DB4 /* Products */,
);
sourceTree = "<group>";
};
83A0F4701816CE5E00119DB4 /* Products */ = {
isa = PBXGroup;
children = (
83A0F46F1816CE5E00119DB4 /* playptmod.bundle */,
);
name = Products;
sourceTree = "<group>";
};
83A0F4711816CE5E00119DB4 /* Frameworks */ = {
isa = PBXGroup;
children = (
83A0F4721816CE5E00119DB4 /* Cocoa.framework */,
83A0F4741816CE5E00119DB4 /* Other Frameworks */,
83A0F4C61816CEAD00119DB4 /* playptmod.xcodeproj */,
);
name = Frameworks;
sourceTree = "<group>";
};
83A0F4741816CE5E00119DB4 /* Other Frameworks */ = {
isa = PBXGroup;
children = (
83A0F4751816CE5E00119DB4 /* Foundation.framework */,
83A0F4761816CE5E00119DB4 /* CoreData.framework */,
83A0F4771816CE5E00119DB4 /* AppKit.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
};
83A0F4781816CE5E00119DB4 /* playptmod */ = {
isa = PBXGroup;
children = (
83A0F4E01816D13000119DB4 /* Logging.h */,
83A0F4DF1816D0AF00119DB4 /* Plugin.h */,
83A0F4DC1816D09000119DB4 /* ptmodDecoder.h */,
83A0F4DD1816D09000119DB4 /* ptmodDecoder.m */,
83A0F4791816CE5E00119DB4 /* Supporting Files */,
);
path = playptmod;
sourceTree = "<group>";
};
83A0F4791816CE5E00119DB4 /* Supporting Files */ = {
isa = PBXGroup;
children = (
83A0F47A1816CE5E00119DB4 /* playptmod-Info.plist */,
83A0F47B1816CE5E00119DB4 /* InfoPlist.strings */,
83A0F47E1816CE5E00119DB4 /* playptmod-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
83A0F4C71816CEAD00119DB4 /* Products */ = {
isa = PBXGroup;
children = (
83A0F4CC1816CEAE00119DB4 /* playptmod.framework */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
83A0F46E1816CE5E00119DB4 /* playptmod */ = {
isa = PBXNativeTarget;
buildConfigurationList = 83A0F4811816CE5E00119DB4 /* Build configuration list for PBXNativeTarget "playptmod" */;
buildPhases = (
83A0F46B1816CE5E00119DB4 /* Sources */,
83A0F46C1816CE5E00119DB4 /* Frameworks */,
83A0F46D1816CE5E00119DB4 /* Resources */,
83A0F4DA1816D04400119DB4 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
83A0F4D81816D03200119DB4 /* PBXTargetDependency */,
);
name = playptmod;
productName = playptmod;
productReference = 83A0F46F1816CE5E00119DB4 /* playptmod.bundle */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83A0F4671816CE5E00119DB4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Christopher Snowhill";
};
buildConfigurationList = 83A0F46A1816CE5E00119DB4 /* Build configuration list for PBXProject "playptmod" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 83A0F4661816CE5E00119DB4;
productRefGroup = 83A0F4701816CE5E00119DB4 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 83A0F4C71816CEAD00119DB4 /* Products */;
ProjectRef = 83A0F4C61816CEAD00119DB4 /* playptmod.xcodeproj */;
},
);
projectRoot = "";
targets = (
83A0F46E1816CE5E00119DB4 /* playptmod */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
83A0F4CC1816CEAE00119DB4 /* playptmod.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = playptmod.framework;
remoteRef = 83A0F4CB1816CEAE00119DB4 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
83A0F46D1816CE5E00119DB4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F47D1816CE5E00119DB4 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
83A0F46B1816CE5E00119DB4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
83A0F4DE1816D09000119DB4 /* ptmodDecoder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
83A0F4D81816D03200119DB4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = playptmod;
targetProxy = 83A0F4D71816D03200119DB4 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
83A0F47B1816CE5E00119DB4 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
83A0F47C1816CE5E00119DB4 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
83A0F47F1816CE5E00119DB4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Christopher Snowhill";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SKIP_INSTALL = YES;
};
name = Debug;
};
83A0F4801816CE5E00119DB4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Christopher Snowhill";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
SDKROOT = macosx;
SKIP_INSTALL = YES;
};
name = Release;
};
83A0F4821816CE5E00119DB4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "playptmod/playptmod-Prefix.pch";
INFOPLIST_FILE = "playptmod/playptmod-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = bundle;
};
name = Debug;
};
83A0F4831816CE5E00119DB4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "playptmod/playptmod-Prefix.pch";
INFOPLIST_FILE = "playptmod/playptmod-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = bundle;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
83A0F46A1816CE5E00119DB4 /* Build configuration list for PBXProject "playptmod" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83A0F47F1816CE5E00119DB4 /* Debug */,
83A0F4801816CE5E00119DB4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
83A0F4811816CE5E00119DB4 /* Build configuration list for PBXNativeTarget "playptmod" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83A0F4821816CE5E00119DB4 /* Debug */,
83A0F4831816CE5E00119DB4 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 83A0F4671816CE5E00119DB4 /* Project object */;
}

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>net.kode54.playptmod</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013 Christopher Snowhill. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,9 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,27 @@
//
// ptmodDecoder.h
// playptmod
//
// Created by Christopher Snowhill on 10/22/13.
// Copyright 2013 __NoWork, Inc__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <playptmod/playptmod.h>
#import "Plugin.h"
@interface ptmodDecoder : NSObject <CogDecoder> {
void *ptmod;
void *data;
long size;
int track_num;
int isVblank;
long framesLength;
long totalFrames;
long framesRead;
}
@end

View File

@ -0,0 +1,224 @@
//
// ptmodDecoder.m
// playptmod
//
// Created by Christopher Snowhill on 10/22/13.
// Copyright 2013 __NoWork, Inc__. All rights reserved.
//
#import "ptmodDecoder.h"
#import "Logging.h"
@implementation ptmodDecoder
BOOL probe_length( unsigned long * intro_length, unsigned long * loop_length, int test_vblank, const void * src, unsigned long size, unsigned int subsong )
{
void * ptmod = playptmod_Create( 44100 );
if ( !ptmod ) return NO;
playptmod_Config( ptmod, PTMOD_OPTION_CLAMP_PERIODS, 0 );
playptmod_Config( ptmod, PTMOD_OPTION_VSYNC_TIMING, test_vblank );
if ( !playptmod_LoadMem( ptmod, src, size ) )
{
playptmod_Free( ptmod );
return NO;
}
playptmod_Play( ptmod, subsong );
unsigned long length_total = 0;
unsigned long length_saved;
while ( playptmod_LoopCounter( ptmod ) < 1 )
{
playptmod_Render( ptmod, NULL, 512 );
length_total += 512;
}
length_saved = length_total;
while ( playptmod_LoopCounter( ptmod ) < 2 )
{
playptmod_Render( ptmod, NULL, 512 );
length_total += 512;
}
playptmod_Stop( ptmod );
playptmod_Free( ptmod );
*loop_length = length_total - length_saved;
*intro_length = length_saved - *loop_length;
return YES;
}
- (BOOL)open:(id<CogSource>)s
{
[s seek:0 whence:SEEK_END];
size = [s tell];
[s seek:0 whence:SEEK_SET];
data = malloc(size);
[s read:data amount:size];
if ([[[s url] fragment] length] == 0)
track_num = 0;
else
track_num = [[[s url] fragment] intValue];
unsigned long normal_intro_length, normal_loop_length, vblank_intro_length, vblank_loop_length;
if ( !probe_length(&normal_intro_length, &normal_loop_length, 0, data, size, track_num) )
return NO;
if ( !probe_length(&vblank_intro_length, &vblank_loop_length, 1, data, size, track_num) )
return NO;
isVblank = ( vblank_intro_length + vblank_loop_length ) < ( normal_intro_length + normal_loop_length );
unsigned long intro_length = isVblank ? vblank_intro_length : normal_intro_length;
unsigned long loop_length = isVblank ? vblank_loop_length : normal_loop_length;
framesLength = intro_length + loop_length * 2;
totalFrames = framesLength + 44100 * 8;
[self willChangeValueForKey:@"properties"];
[self didChangeValueForKey:@"properties"];
return YES;
}
- (BOOL)decoderInitialize
{
ptmod = playptmod_Create( 44100 );
if ( !ptmod )
return NO;
playptmod_Config( ptmod, PTMOD_OPTION_CLAMP_PERIODS, 0 );
playptmod_Config( ptmod, PTMOD_OPTION_VSYNC_TIMING, isVblank );
if ( !playptmod_LoadMem( ptmod, data, size ) )
return NO;
playptmod_Play( ptmod, track_num );
framesRead = 0;
return YES;
}
- (void)decoderShutdown
{
if ( ptmod )
{
playptmod_Stop( ptmod );
playptmod_Free( ptmod );
ptmod = NULL;
}
}
- (NSDictionary *)properties
{
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:0], @"bitrate",
[NSNumber numberWithFloat:44100], @"sampleRate",
[NSNumber numberWithDouble:totalFrames], @"totalFrames",
[NSNumber numberWithInt:16], @"bitsPerSample", //Samples are short
[NSNumber numberWithBool:NO], @"floatingPoint",
[NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo
[NSNumber numberWithBool:YES], @"seekable",
@"host", @"endian",
nil];
}
- (int)readAudio:(void *)buf frames:(UInt32)frames
{
if ( framesRead >= totalFrames )
return 0;
if ( !ptmod )
{
if ( ![self decoderInitialize] )
return 0;
}
int total = 0;
while ( total < frames ) {
int framesToRender = 512;
if ( framesToRender > totalFrames - framesRead )
framesToRender = totalFrames - framesRead;
if ( framesToRender > frames - total )
framesToRender = frames - total;
int16_t * sampleBuf = ( int16_t * ) buf + total * 2;
playptmod_Render( ptmod, sampleBuf, framesToRender );
if ( framesRead + framesToRender > framesLength ) {
long fadeStart = ( framesLength > framesRead ) ? framesLength : framesRead;
long fadeEnd = ( framesRead + framesToRender < totalFrames ) ? framesRead + framesToRender : totalFrames;
const long fadeTotal = totalFrames - framesLength;
for ( long fadePos = fadeStart; fadePos < fadeEnd; ++fadePos ) {
const long scale = ( fadeTotal - ( fadePos - framesLength ) );
const long offset = fadePos - framesRead;
int16_t * samples = sampleBuf + offset * 2;
samples[ 0 ] = samples[ 0 ] * scale / fadeTotal;
samples[ 1 ] = samples[ 1 ] * scale / fadeTotal;
}
framesToRender = fadeEnd - framesRead;
}
if ( !framesToRender )
break;
total += framesToRender;
framesRead += framesToRender;
}
return total;
}
- (long)seek:(long)frame
{
if ( frame < framesRead || !ptmod )
{
[self decoderShutdown];
if ( ![self decoderInitialize] )
return 0;
}
playptmod_Render( ptmod, NULL, frame - framesRead );
framesRead = frame;
return frame;
}
- (void)close
{
[self decoderShutdown];
if (data) {
free( data );
data = NULL;
}
}
+ (NSArray *)fileTypes
{
return [NSArray arrayWithObjects:@"mod", @"mdz", @"stk", @"m15", @"fst", nil];
}
+ (NSArray *)mimeTypes
{
return [NSArray arrayWithObjects:@"audio/x-mod", nil];
}
+ (float)priority
{
return 1.5;
}
@end