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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 851 - (hide annotations) (download)
Tue Apr 11 17:56:26 2006 UTC (18 years ago) by schoenebeck
File size: 3243 byte(s)
* added synthesis benchmark for gig::Engine

1 schoenebeck 851 /*
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("(%s,DOLOOP=%s,FILTER=%s,INTERPOLATE=%s)\n",
39     (SYNTHESIS_MODE_GET_CHANNELS(mode)) ? "STEREO" : "MONO",
40     (SYNTHESIS_MODE_GET_LOOP(mode)) ? "y" : "n",
41     (SYNTHESIS_MODE_GET_FILTER(mode)) ? "y" : "n",
42     (SYNTHESIS_MODE_GET_INTERPOLATE(mode)) ? "y" : "n"
43     );
44     fflush(stdout);
45     }
46    
47     int main() {
48     pSampleInputBuf = new int16_t[FRAGMENTSIZE*2 + 100];
49     pOutputL = (float*) memalign(16,FRAGMENTSIZE*sizeof(float));
50     pOutputR = (float*) memalign(16,FRAGMENTSIZE*sizeof(float));
51    
52     // prepare some input data for simulation
53     for (int i = 0; i < FRAGMENTSIZE*2; i++) {
54     pSampleInputBuf[i] = i;
55     }
56    
57     SynthesisParam* pParam = new SynthesisParam;
58     pParam->filterLeft.SetParameters(200.0f, 1.0f, 44100);
59     pParam->filterRight.SetParameters(200.0f, 1.0f, 44100);
60     pParam->fFinalPitch = 0.5f;
61     pParam->fFinalVolumeLeft = 1.0f;
62     pParam->fFinalVolumeRight = 1.0f;
63     /* For now we skip the CONFIG_INTERPOLATE_VOLUME case
64     pParam->fFinalVolumeDeltaLeft = ...
65     pParam->fFinalVolumeDeltaRight = ... */
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 < 16; 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