Mercurial > hg > x
view align8.cpp @ 12:4b35f8ac5113
Fix: do not synthesize sinusoids above Nyqvist freq.
author | wenx <xue.wen@eecs.qmul.ac.uk> |
---|---|
date | Fri, 12 Aug 2011 18:10:46 +0100 |
parents | 977f541d6683 |
children |
line wrap: on
line source
/* Harmonic sinusoidal modelling and tools C++ code package for harmonic sinusoidal modelling and relevant signal processing. Centre for Digital Music, Queen Mary, University of London. This file copyright 2011 Wen Xue. 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. */ //--------------------------------------------------------------------------- #include <memory.h> #include <stdlib.h> #include "align8.h" //--------------------------------------------------------------------------- /* function malloc8: 8-byte (64-bit) aligned memory allocation. Returns pointer to a memory block of $size starting at an address divisible by 8. */ void* malloc8(unsigned size) { #if (!defined(__SIZEOF_POINTER__) || (__SIZEOF_POINTER__ == 4)) char *buffer, *result; buffer=(char*)malloc(size+8+sizeof(void*)); if(!buffer) return(NULL); char* tmp=&buffer[sizeof(void*)]; result=&((char*)((unsigned)tmp&0xFFFFFFF8))[8]; ((void**)result)[-1]=buffer; return(result); #else return malloc(size); #endif }//malloc8 /* function free8: deallocation for malloc8() No return value. */ void free8(void* buffer8) { #if (!defined(__SIZEOF_POINTER__) || (__SIZEOF_POINTER__ == 4)) if (buffer8) free(((void**)buffer8)[-1]); #else free(buffer8); #endif }//free8