[go: up one dir, main page]

File: fmval.cpp

package info (click to toggle)
qliss3d 1.3.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 676 kB
  • ctags: 306
  • sloc: cpp: 1,303; sh: 153; makefile: 135; ansic: 10
file content (59 lines) | stat: -rw-r--r-- 2,224 bytes parent folder | download | duplicates (6)
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
/**************************************************************************
                   fmval.cpp  -  central computing function
                            -------------------
    begin                : January 03rd 2003
    copyright            : (C) 2003 by Daniel Gruen
    email                : daniel_gruen@web.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

// this is a slim and special fms version for qliss3d
// please use the original version from http://sourceforge.net/projects/fmsynth
// if you want to do anything on it

#include "include/fmval.h"
#include "include/version.h"
#include "include/fmifstream.h"

#include <iostream>
#include <cmath>

using namespace std;

float   fmval(FMData *f, float atime){
  int v = 0;

 	while(v < f->getVlen() && f->vtl[v].getTime() <= atime) {
		v++;
	}

	switch(f->vtl[v-1].getLinetype()){

	    case 0:
		return -1;  // just do nothing

	    case 2:
	/* linetype 2: sine, linear beginning */
		return f->vtl[v-1].getValue() +
		       sin((atime - f->vtl[v-1].getTime()) / (f->vtl[v].getTime() - f->vtl[v-1].getTime()) * 90.0 * PI180) *
					 (f->vtl[v].getValue() - f->vtl[v-1].getValue());

	    case 3:
	/* linetype 3: sine, curved beginning */
		return f->vtl[v].getValue() +
		       sin(((atime - f->vtl[v-1].getTime()) / (f->vtl[v].getTime() - f->vtl[v-1].getTime()) * 90.0 + 90.0) * PI180) *
					 (f->vtl[v-1].getValue() - f->vtl[v].getValue());
	}

	if(debug_level)
		cout << "linetype of " << v-1 << " (" << int(f->vtl[v-1].getLinetype()) << ") is wrong!" << endl;
	return -2; // wrong linetype
}