diff --git a/svg-lib.xcodeproj/buffer_proxy.cpp b/svg-lib.xcodeproj/buffer_proxy.cpp deleted file mode 100644 index a4e4e5e..0000000 --- a/svg-lib.xcodeproj/buffer_proxy.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -#include "buffer_proxy.hpp" - -static t_class *buffer_proxy_class = NULL; -static t_symbol *ps_buffer_modified = NULL; - -t_max_err buffer_proxy_notify(t_buffer_proxy *x, t_symbol *s, t_symbol *msg, void *sender, void *data) -{ - if (msg == ps_buffer_modified) - x->buffer_modified = true; - - //post("s %s msg %s", s->s_name, msg->s_name); - - return buffer_ref_notify(x->ref, s, msg, sender, data); -} - -void buffer_proxy_set_ref(t_buffer_proxy *x, t_symbol *s) -{ - x->name = s; - buffer_ref_set(x->ref, x->name); - x->buffer_modified = true; -} - -void buffer_proxy_free(t_buffer_proxy *x) -{ - if( x->ref ) - object_free(x->ref); - -} - -void buffer_proxy_markRead(t_buffer_proxy *x) -{ - x->buffer_modified = false; -} - -t_buffer_proxy *buffer_proxy_new(t_symbol *s) -{ - t_buffer_proxy *x = NULL; - - if((x = (t_buffer_proxy *)object_alloc(buffer_proxy_class))) - { - x->name = s; - x->ref = buffer_ref_new((t_object *)x, x->name); - if( !x->ref ) - { - object_error((t_object *)x, "failed to attach to buffer %s", s->s_name); - object_free(x); - return NULL; - } - - t_buffer_obj * buf = buffer_ref_getobject(x->ref); - - x->nframes = buffer_getframecount(buf); - x->nchans = buffer_getchannelcount(buf); - x->sr = buffer_getsamplerate(buf); - - x->buffer_modified = false; - - } - - return x; -} - -void buffer_proxy_init() -{ - t_class *bufpxy = class_new("bufferproxy", NULL, NULL, sizeof(t_buffer_proxy), 0L, 0); - class_addmethod(bufpxy, (method)buffer_proxy_notify, "notify", A_CANT, 0); - class_register(CLASS_NOBOX, bufpxy); - buffer_proxy_class = bufpxy; - ps_buffer_modified = gensym("buffer_modified"); -} diff --git a/svg-lib.xcodeproj/buffer_proxy.hpp b/svg-lib.xcodeproj/buffer_proxy.hpp deleted file mode 100644 index b3ad44c..0000000 --- a/svg-lib.xcodeproj/buffer_proxy.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "ext.h" -#include "ext_obex.h" -#include "ext_common.h" -#include "z_dsp.h" -#include "buffer.h" - -typedef struct _buffer_proxy -{ - t_object ob; - t_buffer_ref *ref; - t_symbol *name; - t_bool buffer_modified; - double sr; - double nframes; - long nchans; - -} t_buffer_proxy; - - -t_max_err buffer_proxy_notify(t_buffer_proxy *x, t_symbol *s, t_symbol *msg, void *sender, void *data); -void buffer_proxy_set_ref(t_buffer_proxy *x, t_symbol *s); -void buffer_proxy_free(t_buffer_proxy *x); -void buffer_proxy_markRead(t_buffer_proxy *x); -t_buffer_proxy *buffer_proxy_new(t_symbol *s); -void buffer_proxy_init(); diff --git a/svg-lib.xcodeproj/smc.c b/svg-lib.xcodeproj/smc.c deleted file mode 100755 index 5822451..0000000 --- a/svg-lib.xcodeproj/smc.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Apple System Management Control (SMC) Tool - * Copyright (C) 2006 devnull - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "smc.h" - -static io_connect_t conn; - -UInt32 _strtoul(char *str, int size, int base) -{ - UInt32 total = 0; - int i; - - for (i = 0; i < size; i++) - { - if (base == 16) - total += str[i] << (size - 1 - i) * 8; - else - total += (unsigned char) (str[i] << (size - 1 - i) * 8); - } - return total; -} - -void _ultostr(char *str, UInt32 val) -{ - str[0] = '\0'; - sprintf(str, "%c%c%c%c", - (unsigned int) val >> 24, - (unsigned int) val >> 16, - (unsigned int) val >> 8, - (unsigned int) val); -} - -kern_return_t SMCOpen(void) -{ - kern_return_t result; - io_iterator_t iterator; - io_object_t device; - - CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC"); - result = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &iterator); - if (result != kIOReturnSuccess) - { - printf("Error: IOServiceGetMatchingServices() = %08x\n", result); - return 1; - } - - device = IOIteratorNext(iterator); - IOObjectRelease(iterator); - if (device == 0) - { - printf("Error: no SMC found\n"); - return 1; - } - - result = IOServiceOpen(device, mach_task_self(), 0, &conn); - IOObjectRelease(device); - if (result != kIOReturnSuccess) - { - printf("Error: IOServiceOpen() = %08x\n", result); - return 1; - } - - return kIOReturnSuccess; -} - -kern_return_t SMCClose() -{ - return IOServiceClose(conn); -} - - -kern_return_t SMCCall(int index, SMCKeyData_t *inputStructure, SMCKeyData_t *outputStructure) -{ - size_t structureInputSize; - size_t structureOutputSize; - - structureInputSize = sizeof(SMCKeyData_t); - structureOutputSize = sizeof(SMCKeyData_t); - - #if MAC_OS_X_VERSION_10_5 - return IOConnectCallStructMethod( conn, index, - // inputStructure - inputStructure, structureInputSize, - // ouputStructure - outputStructure, &structureOutputSize ); - #else - return IOConnectMethodStructureIStructureO( conn, index, - structureInputSize, /* structureInputSize */ - &structureOutputSize, /* structureOutputSize */ - inputStructure, /* inputStructure */ - outputStructure); /* ouputStructure */ - #endif - -} - -kern_return_t SMCReadKey(UInt32Char_t key, SMCVal_t *val) -{ - kern_return_t result; - SMCKeyData_t inputStructure; - SMCKeyData_t outputStructure; - - memset(&inputStructure, 0, sizeof(SMCKeyData_t)); - memset(&outputStructure, 0, sizeof(SMCKeyData_t)); - memset(val, 0, sizeof(SMCVal_t)); - - inputStructure.key = _strtoul(key, 4, 16); - inputStructure.data8 = SMC_CMD_READ_KEYINFO; - - result = SMCCall(KERNEL_INDEX_SMC, &inputStructure, &outputStructure); - if (result != kIOReturnSuccess) - return result; - - val->dataSize = outputStructure.keyInfo.dataSize; - _ultostr(val->dataType, outputStructure.keyInfo.dataType); - inputStructure.keyInfo.dataSize = val->dataSize; - inputStructure.data8 = SMC_CMD_READ_BYTES; - - result = SMCCall(KERNEL_INDEX_SMC, &inputStructure, &outputStructure); - if (result != kIOReturnSuccess) - return result; - - memcpy(val->bytes, outputStructure.bytes, sizeof(outputStructure.bytes)); - - return kIOReturnSuccess; -} - -double SMCGetTemperature(char *key) -{ - SMCVal_t val; - kern_return_t result; - - result = SMCReadKey(key, &val); - if (result == kIOReturnSuccess) { - // read succeeded - check returned value - if (val.dataSize > 0) { - if (strcmp(val.dataType, DATATYPE_SP78) == 0) { - // convert sp78 value to temperature - int intValue = val.bytes[0] * 256 + (unsigned char)val.bytes[1]; - return intValue / 256.0; - } - } - } - // read failed - return 0.0; -} - -double SMCGetFanSpeed(char *key) -{ - SMCVal_t val; - kern_return_t result; - - result = SMCReadKey(key, &val); - if (result == kIOReturnSuccess) { - // read succeeded - check returned value - if (val.dataSize > 0) { - if (strcmp(val.dataType, DATATYPE_FPE2) == 0) { - // convert fpe2 value to rpm - int intValue = (unsigned char)val.bytes[0] * 256 + (unsigned char)val.bytes[1]; - return intValue / 4.0; - } - } - } - // read failed - return 0.0; -} - - -double convertToFahrenheit(double celsius) { - return (celsius * (9.0 / 5.0)) + 32.0; -} - -// Requires SMCOpen() -void readAndPrintCpuTemp(int show_title, char scale) { - double temperature = SMCGetTemperature(SMC_KEY_CPU_TEMP); - if (scale == 'F') { - temperature = convertToFahrenheit(temperature); - } - - char *title = ""; - if (show_title) { - title = "CPU: "; - } - printf("%s%0.1f°%c\n", title, temperature, scale); -} - -// Requires SMCOpen() -void readAndPrintGpuTemp(int show_title, char scale) { - double temperature = SMCGetTemperature(SMC_KEY_GPU_TEMP); - if (scale == 'F') { - temperature = convertToFahrenheit(temperature); - } - - char *title = ""; - if (show_title) { - title = "GPU: "; - } - printf("%s%0.1f°%c\n", title, temperature, scale); -} - -float SMCGetFanRPM(char *key) -{ - SMCVal_t val; - kern_return_t result; - - result = SMCReadKey(key, &val); - if (result == kIOReturnSuccess) { - // read succeeded - check returned value - if (val.dataSize > 0) { - if (strcmp(val.dataType, DATATYPE_FPE2) == 0) { - // convert fpe2 value to RPM - return ntohs(*(UInt16*)val.bytes) / 4.0; - } - } - } - // read failed - return -1.f; -} - -// Requires SMCOpen() -void readAndPrintFanRPMs(void) -{ - kern_return_t result; - SMCVal_t val; - UInt32Char_t key; - int totalFans, i; - - result = SMCReadKey("FNum", &val); - - if(result == kIOReturnSuccess) - { - totalFans = _strtoul((char *)val.bytes, val.dataSize, 10); - - printf("Num fans: %d\n", totalFans); - for(i = 0; i < totalFans; i++) { - sprintf(key, "F%dID", i); - result = SMCReadKey(key, &val); - if (result != kIOReturnSuccess) { - continue; - } - char* name = val.bytes + 4; - - sprintf(key, "F%dAc", i); - float actual_speed = SMCGetFanRPM(key); - if (actual_speed < 0.f) { - continue; - } - - sprintf(key, "F%dMn", i); - float minimum_speed = SMCGetFanRPM(key); - if (minimum_speed < 0.f) { - continue; - } - - sprintf(key, "F%dMx", i); - float maximum_speed = SMCGetFanRPM(key); - if (maximum_speed < 0.f) { - continue; - } - - float rpm = actual_speed - minimum_speed; - if (rpm < 0.f) { - rpm = 0.f; - } - float pct = rpm / (maximum_speed - minimum_speed); - - pct *= 100.f; - printf("Fan %d - %s at %.0f RPM (%.0f%%)\n", i, name, rpm, pct); - - //sprintf(key, "F%dSf", i); - //SMCReadKey(key, &val); - //printf(" Safe speed : %.0f\n", strtof(val.bytes, val.dataSize, 2)); - //sprintf(key, "F%dTg", i); - //SMCReadKey(key, &val); - //printf(" Target speed : %.0f\n", strtof(val.bytes, val.dataSize, 2)); - //SMCReadKey("FS! ", &val); - //if ((_strtoul((char *)val.bytes, 2, 16) & (1 << i)) == 0) - // printf(" Mode : auto\n"); - //else - // printf(" Mode : forced\n"); - } - } -} - -int main(int argc, char *argv[]) -{ - char scale = 'C'; - int cpu = 0; - int fan = 0; - int gpu = 0; - - int c; - while ((c = getopt(argc, argv, "CFcfgh?")) != -1) { - switch (c) { - case 'F': - case 'C': - scale = c; - break; - case 'c': - cpu = 1; - break; - case 'f': - fan = 1; - break; - case 'g': - gpu = 1; - break; - case 'h': - case '?': - printf("usage: osx-cpu-temp \n"); - printf("Options:\n"); - printf(" -F Display temperatures in degrees Fahrenheit.\n"); - printf(" -C Display temperatures in degrees Celsius (Default).\n"); - printf(" -c Display CPU temperature (Default).\n"); - printf(" -g Display GPU temperature.\n"); - printf(" -f Display fan speeds.\n"); - printf(" -h Display this help.\n"); - printf("\nIf more than one of -c, -f, or -g are specified, titles will be added\n"); - return -1; - } - } - - if (!fan && !gpu) { - cpu = 1; - } - - int show_title = fan + gpu + cpu > 1; - - SMCOpen(); - - if (cpu) { - readAndPrintCpuTemp(show_title, scale); - } - if (gpu) { - readAndPrintGpuTemp(show_title, scale); - } - if (fan) { - readAndPrintFanRPMs(); - } - - SMCClose(); - return 0; -} diff --git a/svg-lib.xcodeproj/smc.h b/svg-lib.xcodeproj/smc.h deleted file mode 100755 index bc0a1bb..0000000 --- a/svg-lib.xcodeproj/smc.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Apple System Management Control (SMC) Tool - * Copyright (C) 2006 devnull - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#pragma once - -#define VERSION "0.01" - -#define KERNEL_INDEX_SMC 2 - -#define SMC_CMD_READ_BYTES 5 -#define SMC_CMD_WRITE_BYTES 6 -#define SMC_CMD_READ_INDEX 8 -#define SMC_CMD_READ_KEYINFO 9 -#define SMC_CMD_READ_PLIMIT 11 -#define SMC_CMD_READ_VERS 12 - -#define DATATYPE_FPE2 "fpe2" -#define DATATYPE_UINT8 "ui8 " -#define DATATYPE_UINT16 "ui16" -#define DATATYPE_UINT32 "ui32" -#define DATATYPE_SP78 "sp78" - -// key values -#define SMC_KEY_CPU_TEMP "TC0P" -#define SMC_KEY_GPU_TEMP "TG0P" -#define SMC_KEY_FAN0_RPM_CUR "F0Ac" - -typedef struct { - char major; - char minor; - char build; - char reserved[1]; - UInt16 release; -} SMCKeyData_vers_t; - -typedef struct { - UInt16 version; - UInt16 length; - UInt32 cpuPLimit; - UInt32 gpuPLimit; - UInt32 memPLimit; -} SMCKeyData_pLimitData_t; - -typedef struct { - UInt32 dataSize; - UInt32 dataType; - char dataAttributes; -} SMCKeyData_keyInfo_t; - -typedef char SMCBytes_t[32]; - -typedef struct { - UInt32 key; - SMCKeyData_vers_t vers; - SMCKeyData_pLimitData_t pLimitData; - SMCKeyData_keyInfo_t keyInfo; - char result; - char status; - char data8; - UInt32 data32; - SMCBytes_t bytes; -} SMCKeyData_t; - -typedef char UInt32Char_t[5]; - -typedef struct { - UInt32Char_t key; - UInt32 dataSize; - UInt32Char_t dataType; - SMCBytes_t bytes; -} SMCVal_t; - diff --git a/tilde.xcodeproj/project.pbxproj b/tilde.xcodeproj/project.pbxproj index e1fb642..6413984 100755 --- a/tilde.xcodeproj/project.pbxproj +++ b/tilde.xcodeproj/project.pbxproj @@ -1006,6 +1006,7 @@ OTHER_CFLAGS = ( "-DNO_TRANSLATION_SUPPORT", "-g", + "-O3", ); OTHER_LDFLAGS = "@../../max-sdk/source/c74support/max-includes/c74_linker_flags.txt"; PRELINK_LIBS = "\"$(SRCROOT)/../../libo/libo.a\" \"$(SRCROOT)/../../libomax/libomax.a\""; diff --git a/tilde.xcodeproj/xcshareddata/xcschemes/granufm.mc~.xcscheme b/tilde.xcodeproj/xcshareddata/xcschemes/granufm.mc~.xcscheme index 6259de9..5da12ef 100644 --- a/tilde.xcodeproj/xcshareddata/xcschemes/granufm.mc~.xcscheme +++ b/tilde.xcodeproj/xcshareddata/xcschemes/granufm.mc~.xcscheme @@ -29,8 +29,6 @@ shouldUseLaunchSchemeArgsEnv = "YES"> - - - -