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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*****************************************************************************
*
* Copyright (C) 2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name>
*
* 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; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************/
#include <stdbool.h>
#include <assert.h>
#include "globals.h"
#include "fft.h"
#include "resonance.h"
#include "oscillator.h"
#include "addsynth.h"
#include "portamento.h"
#include "addsynth_component.h"
#include "log.h"
#define oscillator_ptr ((struct zyn_oscillator * )context)
float
zyn_oscillator_get_float(
void * context,
unsigned int parameter)
{
switch (parameter)
{
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_WAVESHAPE_DRIVE:
return oscillator_ptr->waveshaping_drive;
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_BASE_FUNCTION_ADJUST:
return oscillator_ptr->base_function_adjust;
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_SPECTRUM_ADJUST:
return oscillator_ptr->spectrum_adjust;
}
LOG_ERROR("Unknown oscillator float parameter %u", parameter);
assert(0);
return 0.0;
}
void
zyn_oscillator_set_float(
void * context,
unsigned int parameter,
float value)
{
switch (parameter)
{
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_WAVESHAPE_DRIVE:
assert(value >= 0.0 && value <= 100.0);
oscillator_ptr->waveshaping_drive = value;
oscillator_ptr->prepared = false;
return;
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_BASE_FUNCTION_ADJUST:
assert(value >= 0.0 && value <= 1.0);
oscillator_ptr->base_function_adjust = value;
oscillator_ptr->prepared = false;
oscillator_ptr->base_function_needs_prepare = true;
return;
case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_SPECTRUM_ADJUST:
assert(value >= 0.0 && value <= 100.0);
oscillator_ptr->spectrum_adjust = value;
oscillator_ptr->prepared = false;
return;
}
LOG_ERROR("Unknown oscillator float parameter %u", parameter);
assert(0);
}
signed int
zyn_oscillator_get_int(
void * context,
unsigned int parameter)
{
switch (parameter)
{
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_BASE_FUNCTION:
return oscillator_ptr->base_function;
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_WAVESHAPE_TYPE:
return oscillator_ptr->waveshaping_function;
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_SPECTRUM_ADJUST_TYPE:
return oscillator_ptr->spectrum_adjust_type;
}
LOG_ERROR("Unknown oscillator int/enum parameter %u", parameter);
assert(0);
return 0;
}
void
zyn_oscillator_set_int(
void * context,
unsigned int parameter,
signed int value)
{
switch (parameter)
{
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_BASE_FUNCTION:
assert(value >= 0 && value < ZYN_OSCILLATOR_BASE_FUNCTIONS_COUNT);
oscillator_ptr->base_function = value;
oscillator_ptr->prepared = false;
oscillator_ptr->base_function_needs_prepare = true;
return;
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_WAVESHAPE_TYPE:
assert(value >= 0 && value < ZYN_OSCILLATOR_WAVESHAPE_TYPES_COUNT);
oscillator_ptr->waveshaping_function = value;
oscillator_ptr->prepared = false;
return;
case ZYNADD_PARAMETER_ENUM_OSCILLATOR_SPECTRUM_ADJUST_TYPE:
assert(value >= 0 && value < ZYN_OSCILLATOR_SPECTRUM_ADJUST_TYPES_COUNT);
oscillator_ptr->spectrum_adjust_type = value;
oscillator_ptr->prepared = false;
return;
}
LOG_ERROR("Unknown oscillator int/enum parameter %u", parameter);
assert(0);
}
bool
zyn_oscillator_get_bool(
void * context,
unsigned int parameter)
{
switch (parameter)
{
}
LOG_ERROR("Unknown oscillator bool parameter %u", parameter);
assert(0);
}
void
zyn_oscillator_set_bool(
void * context,
unsigned int parameter,
bool value)
{
switch (parameter)
{
}
LOG_ERROR("Unknown oscillator bool parameter %u", parameter);
assert(0);
}
#undef oscillator_ptr
void
zyn_addsynth_component_init_oscillator(
struct zyn_component_descriptor * component_ptr,
struct zyn_oscillator * oscillator_ptr)
{
ZYN_INIT_COMPONENT(component_ptr, oscillator_ptr, zyn_oscillator_);
}
|