Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
crowbx
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacob Vosmaer
crowbx
Commits
8c29b80d
Commit
8c29b80d
authored
May 01, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline vibrato.c
parent
1da1646c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
40 deletions
+40
-40
Makefile
Makefile
+1
-1
crowbx.c
crowbx.c
+39
-0
vibrato.c
vibrato.c
+0
-39
No files found.
Makefile
View file @
8c29b80d
PRG
=
crowbx
OBJ
=
crowbx.o midi.o dac.o list.o
vibrato.o
clamp_add.o pitch.o pitch_env.o vibrato_rate.o voice.o
OBJ
=
crowbx.o midi.o dac.o list.o clamp_add.o pitch.o pitch_env.o vibrato_rate.o voice.o
MCU_TARGET
=
atmega328p
OPTIMIZE
=
-O3
...
...
crowbx.c
View file @
8c29b80d
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/atomic.h>
#include "array_size.h"
...
...
@@ -12,6 +13,7 @@
#include "pitch_env.h"
#include "uart.h"
#include "vibrato.h"
#include "vibrato_rate.h"
#include "voice.h"
static
struct
{
...
...
@@ -484,3 +486,40 @@ void mono_control_change(uint8_t ctl, uint8_t val) {
break
;
}
}
struct
{
uint32_t
phase
;
int16_t
amount
;
uint8_t
rate
;
uint8_t
depth
;
}
vibrato
;
void
vibrato_set_rate
(
uint8_t
val
)
{
vibrato
.
rate
=
val
;
}
void
vibrato_set_depth
(
uint8_t
val
)
{
vibrato
.
depth
=
val
;
}
int16_t
vibrato_detune
(
void
)
{
return
vibrato
.
amount
;
}
void
vibrato_update
(
uint8_t
delta
)
{
enum
{
VIB_MID
=
INT16_MAX
>>
1
};
vibrato
.
phase
+=
delta
*
pgm_read_float
(
&
(
vibrato_rate_table
[
vibrato
.
rate
]));
uint16_t
phase16
=
vibrato
.
phase
>>
16
;
if
(
phase16
<
INT16_MAX
)
{
vibrato
.
amount
=
phase16
-
VIB_MID
;
}
else
{
vibrato
.
amount
=
phase16
-
INT16_MAX
;
vibrato
.
amount
=
INT16_MAX
-
vibrato
.
amount
;
vibrato
.
amount
-=
VIB_MID
;
}
float
pitch_factor
=
dac_pitch_delta
(
7
)
/
((
float
)
INT16_MAX
);
vibrato
.
amount
*=
pitch_factor
;
float
depth_factor
=
vibrato
.
depth
/
127
.
0
;
vibrato
.
amount
*=
depth_factor
;
if
(
!
vibrato
.
depth
)
{
vibrato
.
amount
=
0
;
}
}
vibrato.c
deleted
100644 → 0
View file @
1da1646c
#include "vibrato.h"
#include "dac.h"
#include "vibrato_rate.h"
#include <avr/pgmspace.h>
static
uint32_t
phase
;
static
uint8_t
rate
;
static
int16_t
vibrato
;
static
uint8_t
depth
;
void
vibrato_set_rate
(
uint8_t
val
)
{
rate
=
val
;
}
void
vibrato_set_depth
(
uint8_t
val
)
{
depth
=
val
;
}
int16_t
vibrato_detune
(
void
)
{
return
vibrato
;
}
enum
{
VIB_MID
=
INT16_MAX
>>
1
,
};
void
vibrato_update
(
uint8_t
delta
)
{
phase
+=
delta
*
pgm_read_float
(
&
(
vibrato_rate_table
[
rate
]));
uint16_t
phase16
=
phase
>>
16
;
if
(
phase16
<
INT16_MAX
)
{
vibrato
=
phase16
-
VIB_MID
;
}
else
{
vibrato
=
phase16
-
INT16_MAX
;
vibrato
=
INT16_MAX
-
vibrato
;
vibrato
-=
VIB_MID
;
}
float
pitch_factor
=
dac_pitch_delta
(
7
)
/
((
float
)
INT16_MAX
);
vibrato
*=
pitch_factor
;
float
depth_factor
=
depth
/
127
.
0
;
vibrato
*=
depth_factor
;
if
(
!
depth
)
{
vibrato
=
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment