File: Sample.h

package info (click to toggle)
gmod 3.1-8.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,340 kB
  • ctags: 808
  • sloc: cpp: 7,764; makefile: 76
file content (117 lines) | stat: -rw-r--r-- 2,529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// -*-C++-*-
// This file is part of the gmod package
// Copyright (C) 1997 by Andrew J. Robinson

#ifndef __SampleH
#define __SampleH

#include <stdio.h>

#ifdef USE_NCURSES
#include <curses.h>
#endif

#include "defines.h"

class Sequencer;

class Sample
{
public:
  Sample();
  virtual ~Sample() {};
  virtual int load(Sequencer &, FILE *, int, int, void * = 0, void * = 0) = 0;
  virtual int slideRate(int, unsigned char) const;
  virtual int volumeEnvelopeY(int &, char inSustain, unsigned short *) const
  { return (inSustain ? 64 : 0); }
  virtual int panEnvelopeY(int &, char) const
  { return 32; }
  virtual void decode(char *) const {}
  virtual int pan() const { return -1; }
  virtual int vibratoDepth() const { return -1; }
  virtual int vibratoRate() const { return 0; }
  virtual int vibratoType() const { return -1; }
  void cutFactor(int c) { cutFactor_ = c; }
  int cutFactor() const { return cutFactor_; }
  int number() const { return sampleNum_; }
  short finetune() const { return finetune_; }
  unsigned char volume() const { return volume_; }
  const char *name() const { return name_; }
  void getPatchInfo(struct patch_info &) const;
  int ok() const { return ok_; }
#ifndef USE_X
#ifdef USE_NCURSES
  void printInfo(WINDOW *, int);
#else
  void printInfo(int, const unsigned char);
#endif
#endif

protected:
  int sampleNum_;
  int length_;
  int loopStart;
  int loopEnd;
  int ok_;
  short finetune_;
  unsigned char cutFactor_;
  unsigned char volume_;
  char name_[SAMPNAME_LEN];

  unsigned int mode_;
  unsigned int baseFreq_;
  unsigned int baseNote_;
};

#ifndef USE_X
#ifdef USE_NCURSES
inline void
Sample::printInfo(WINDOW *win, int i)
{
  char num[4];
  
  if (ok_)
    sprintf(num, "%03d", i);
  else
    strcpy(num, "xxx");

  wprintw(win, "%s: L%06u B%06u E%06u V%03u %s\n",
	  num, length_, loopStart, loopEnd, volume_, name_);
}
#else
inline void
Sample::printInfo(int i, unsigned char showEmpty)
{
  char num[4];

  if ((length_ > 0) || showEmpty)
    {
      if (ok_)
	sprintf(num, "%03d", i);
      else
	strcpy(num, "xxx");

      PRINTF("%s: L%06u B%06u E%06u V%03u %s\n",
	     num, length_, loopStart, loopEnd, volume_, name_);
    }
}
#endif
#endif

inline int
Sample::slideRate(int rate, unsigned char slideDir) const
{
  if (slideDir == SLIDE_POS)
    return rate;
  else
    return -rate;
}

inline
Sample::Sample() : length_(0), loopStart(0), loopEnd(0), ok_(0),
  finetune_(0), cutFactor_(1), volume_(0), mode_(0), baseFreq_(0), baseNote_(0)
{
  name_[0] = '\0';
}

#endif