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

Contents of /linuxsampler/trunk/benchmarks/gigsynth.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 903 - (show annotations) (download)
Sat Jul 22 14:22:53 2006 UTC (14 years, 3 months ago) by persson
File size: 3258 byte(s)
* real support for 24 bit samples - samples are not truncated to 16
  bits anymore
* support for aftertouch (channel pressure, not polyphonic aftertouch)

1 /*
2 gig::Engine synthesis benchmark
3
4 This is a benchmark for testing the performance of the sampler's current
5 Gigasampler format synthesis algorithms. It benchmarks each possible
6 "synthesis mode" (that is all possible cases like filter on / off,
7 interpolation on / off, stereo / mono). It uses fake sample data and
8 fake audio outputs, so we don't have to load a .gig file or care about
9 drivers.
10
11 Copyright (C) 2005,2006 Christian Schoenebeck <cuse@users.sf.net>
12 */
13
14 #include <math.h>
15 #include <time.h>
16 #include <stdio.h>
17 #include <malloc.h>
18 #include <string.h>
19
20 #include <gig.h>
21
22 #include "../src/engines/gig/SynthesisParam.h"
23 #include "../src/engines/gig/Synthesizer.h"
24
25 #define FRAGMENTSIZE 200
26 #define RUNS 100000
27
28 using namespace LinuxSampler;
29 using namespace LinuxSampler::gig;
30
31 int16_t* pSampleInputBuf; // just a buffer with random data
32
33 float* pOutputL;
34 float* pOutputR;
35
36 void printmode(int mode) {
37 printf("Synthesis Mode: %d ",mode);
38 printf("(BITDEPTH=%s,%s,DOLOOP=%s,FILTER=%s,INTERPOLATE=%s)\n",
39 (SYNTHESIS_MODE_GET_BITDEPTH24(mode)) ? "24" : "16",
40 (SYNTHESIS_MODE_GET_CHANNELS(mode)) ? "STEREO" : "MONO",
41 (SYNTHESIS_MODE_GET_LOOP(mode)) ? "y" : "n",
42 (SYNTHESIS_MODE_GET_FILTER(mode)) ? "y" : "n",
43 (SYNTHESIS_MODE_GET_INTERPOLATE(mode)) ? "y" : "n"
44 );
45 fflush(stdout);
46 }
47
48 int main() {
49 pSampleInputBuf = new int16_t[FRAGMENTSIZE*2 + 100];
50 pOutputL = (float*) memalign(16,FRAGMENTSIZE*sizeof(float));
51 pOutputR = (float*) memalign(16,FRAGMENTSIZE*sizeof(float));
52
53 // prepare some input data for simulation
54 for (int i = 0; i < FRAGMENTSIZE*2; i++) {
55 pSampleInputBuf[i] = i;
56 }
57
58 SynthesisParam* pParam = new SynthesisParam;
59 pParam->filterLeft.SetParameters(5.26f, 127.0f, 44100);
60 pParam->filterRight.SetParameters(5.26f, 127.0f, 44100);
61 pParam->fFinalPitch = 0.5f;
62 pParam->fFinalVolumeLeft = 1.0f;
63 pParam->fFinalVolumeRight = 1.0f;
64 pParam->fFinalVolumeDeltaLeft = 0;
65 pParam->fFinalVolumeDeltaRight = 0;
66 pParam->pSrc = pSampleInputBuf;
67
68 // define some loop points
69 Loop* pLoop = new Loop;
70 pLoop->uiStart = 4;
71 pLoop->uiEnd = 20;
72 pLoop->uiSize = 16;
73 pLoop->uiTotalCycles = 0; // infinity
74
75 for (int mode = 0; mode < 32; mode++) {
76 // zero out output buffers
77 memset(pOutputL,0,FRAGMENTSIZE*sizeof(float));
78 memset(pOutputR,0,FRAGMENTSIZE*sizeof(float));
79
80 pParam->filterLeft.Reset();
81 pParam->filterRight.Reset();
82
83 printf("Benchmarking ");
84 printmode(mode);
85
86 clock_t stop_time;
87 clock_t start_time = clock();
88
89 for (uint i = 0; i < RUNS; i++) {
90 pParam->dPos = 0.0;
91 pParam->pOutLeft = pOutputL;
92 pParam->pOutRight = pOutputR;
93 pParam->uiToGo = FRAGMENTSIZE;
94 // now actually render audio
95 RunSynthesisFunction(mode, pParam, pLoop);
96 }
97
98 stop_time = clock();
99 float elapsed_time = (stop_time - start_time) / (double(CLOCKS_PER_SEC) / 1000.0);
100 printf("\t: %1.0f ms\n", elapsed_time);
101 }
102 }

  ViewVC Help
Powered by ViewVC