/[svn]/linuxsampler/trunk/benchmarks/triang.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/benchmarks/triang.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3053 by schoenebeck, Sun Jul 24 20:01:39 2005 UTC revision 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC
# Line 4  Line 4 
4      This is a benchmark for comparison between a integer math, table lookup      This is a benchmark for comparison between a integer math, table lookup
5      and numeric sine wave harmonics solution.      and numeric sine wave harmonics solution.
6    
7      Copyright (C) 2005 Christian Schoenebeck <cuse@users.sf.net>      Copyright (C) 2005 - 2016 Christian Schoenebeck <cuse@users.sf.net>
8  */  */
9    
10  #include <math.h>  #include <math.h>
# Line 61  Line 61 
61  #define INVALID_RESULT          -1  #define INVALID_RESULT          -1
62    
63  // we use 32 bit single precision floating point as sample point format  // we use 32 bit single precision floating point as sample point format
64  typedef float sample_t;  typedef float smpl_t; // (sample_t is already defined as int16_t by global_private.h)
65    
66  using namespace LinuxSampler;  using namespace LinuxSampler;
67    
# Line 76  LFOTriangleDiHarmonic<range_unsigned>* p Line 76  LFOTriangleDiHarmonic<range_unsigned>* p
76  #endif  #endif
77    
78  // integer math solution  // integer math solution
79  float int_math(sample_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {  float int_math(smpl_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {
80      // pro forma      // pro forma
81      pIntLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);      pIntLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);
82    
# Line 100  float int_math(sample_t* pDestinationBuf Line 100  float int_math(sample_t* pDestinationBuf
100  }  }
101    
102  // integer math abs solution  // integer math abs solution
103  float int_math_abs(sample_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {  float int_math_abs(smpl_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {
104      // pro forma      // pro forma
105      pIntAbsLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);      pIntAbsLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);
106    
# Line 131  float int_math_abs(sample_t* pDestinatio Line 131  float int_math_abs(sample_t* pDestinatio
131  // anyway. If you found an architecture where this seems to be the best  // anyway. If you found an architecture where this seems to be the best
132  // solution, please let us know!  // solution, please let us know!
133  #if 0  #if 0
134  float table_lookup(sample_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {  float table_lookup(smpl_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {
135      // pro forma      // pro forma
136      const float r = frequency / SAMPLING_RATE; // frequency alteration quotient      const float r = frequency / SAMPLING_RATE; // frequency alteration quotient
137      #if SIGNED      #if SIGNED
# Line 194  float table_lookup(sample_t* pDestinatio Line 194  float table_lookup(sample_t* pDestinatio
194  #endif  #endif
195    
196  // numeric, di-harmonic solution  // numeric, di-harmonic solution
197  float numeric_di_harmonic_solution(sample_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {  float numeric_di_harmonic_solution(smpl_t* pDestinationBuffer, float* pAmp, const int steps, const float frequency) {
198      // pro forma      // pro forma
199      pDiHarmonicLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);      pDiHarmonicLFO->trigger(frequency, start_level_max, 1200 /* max. internal depth */, 0, false, (unsigned int) SAMPLING_RATE);
200    
# Line 218  float numeric_di_harmonic_solution(sampl Line 218  float numeric_di_harmonic_solution(sampl
218  }  }
219    
220  // output calculated values as RAW audio format (32 bit floating point, mono) file  // output calculated values as RAW audio format (32 bit floating point, mono) file
221  void output_as_raw_file(const char* filename, sample_t* pOutputBuffer, int steps) {  void output_as_raw_file(const char* filename, smpl_t* pOutputBuffer, int steps) {
222      FILE* file = fopen(filename, "w");      FILE* file = fopen(filename, "w");
223      if (file) {      if (file) {
224          fwrite((void*) pOutputBuffer, sizeof(float), steps, file);          fwrite((void*) pOutputBuffer, sizeof(float), steps, file);
# Line 253  int main() { Line 253  int main() {
253      #endif      #endif
254    
255      // output buffer for the calculated sinusoid wave      // output buffer for the calculated sinusoid wave
256      sample_t* pOutputBuffer = new sample_t[steps];      smpl_t* pOutputBuffer = new smpl_t[steps];
257      // just an arbitrary amplitude envelope to simulate a bit higher memory bandwidth      // just an arbitrary amplitude envelope to simulate a bit higher memory bandwidth
258      float* pAmplitude  = new float[steps];      float* pAmplitude  = new float[steps];
259    

Legend:
Removed from v.3053  
changed lines
  Added in v.3054

  ViewVC Help
Powered by ViewVC