~ubuntu-branches/ubuntu/quantal/freewheeling/quantal

« back to all changes in this revision

Viewing changes to src/fweelin_fluidsynth.h

  • Committer: Bazaar Package Importer
  • Author(s): Paul Brossier
  • Date: 2005-08-06 15:11:54 UTC
  • Revision ID: james.westby@ubuntu.com-20050806151154-nvhhuxtyvgweh75u
Tags: upstream-0.5pre4
ImportĀ upstreamĀ versionĀ 0.5pre4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __FWEELIN_FLUIDSYNTH_H
 
2
#define __FWEELIN_FLUIDSYNTH_H
 
3
 
 
4
#if USE_FLUIDSYNTH
 
5
 
 
6
#include <fluidsynth.h>
 
7
 
 
8
#include "fweelin_core_dsp.h"
 
9
#include "fweelin_browser.h"
 
10
 
 
11
// Whacky FluidSynth center of pitchbend is 0x2000 not 0
 
12
#define FLUIDSYNTH_PITCHBEND_CENTER 0x2000
 
13
 
 
14
// Small class to encapsulate FluidSynth patches
 
15
class FluidPatch : public BrowserItem {
 
16
public:
 
17
 
 
18
  FluidPatch (int sfontid = 0, int bank = 0, int prog = 0, char *name = 0) :
 
19
    BrowserItem(name), sfontid(sfontid), bank(bank), prog(prog) {};
 
20
 
 
21
  virtual BrowserItemType GetType() { return B_FluidPatch; };
 
22
 
 
23
  int sfontid,
 
24
    bank,
 
25
    prog;
 
26
};
 
27
 
 
28
// Integrated soft-synth based on libfluidsynth
 
29
class FluidSynthProcessor : public Processor, public EventListener, 
 
30
                            public BrowserCallback {
 
31
  friend class Fweelin;
 
32
 
 
33
public:
 
34
  FluidSynthProcessor(Fweelin *app, char stereo);
 
35
  virtual ~FluidSynthProcessor();
 
36
 
 
37
  virtual void process(char pre, nframes_t len, AudioBuffers *ab);
 
38
 
 
39
  virtual void ReceiveEvent(Event *ev, EventProducer *from);
 
40
 
 
41
  virtual void ItemBrowsed(BrowserItem *i) { ItemSelected(i); };
 
42
  virtual void ItemSelected(BrowserItem *i);
 
43
 
 
44
  // Send a new patch to synth
 
45
  void SendPatchChange(FluidPatch *p);
 
46
 
 
47
  // Change patches by moving 'patchofs' patches forward or 'fontofs' 
 
48
  // soundfonts forward.
 
49
  void AdjustPatch (int patchofs, int fontofs);
 
50
 
 
51
  // Enable/disable FluidSynth- if disabled, bypasses
 
52
  // processor stage to reduce CPU usage, but leaves memory allocated
 
53
  void SetEnable(char en) { 
 
54
    // Preprocess audio for smoothing
 
55
    //dopreprocess();
 
56
    this->enable = en;
 
57
  };
 
58
 
 
59
  char GetEnable() { return enable; };
 
60
 
 
61
  // Sets up browser patches based on loaded soundfonts
 
62
  void SetupPatches();
 
63
 
 
64
 private:
 
65
 
 
66
  // Run FluidSynth in stereo?
 
67
  char stereo;
 
68
 
 
69
  // Left and right output buffers
 
70
  sample_t *leftbuf, 
 
71
    *rightbuf;
 
72
 
 
73
  // And fluidsynth variables..
 
74
  fluid_settings_t *settings;
 
75
  fluid_synth_t *synth;
 
76
 
 
77
  // Currently processing?
 
78
  char enable;
 
79
};
 
80
 
 
81
#endif
 
82
#endif