Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
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
1058c5d9
Commit
1058c5d9
authored
Apr 17, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename safe_add to clamp_add
parent
68590900
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
18 deletions
+18
-18
Makefile
Makefile
+1
-1
clamp_add.c
clamp_add.c
+2
-2
clamp_add.h
clamp_add.h
+8
-0
dac.c
dac.c
+2
-2
pitch.c
pitch.c
+5
-5
safe_add.h
safe_add.h
+0
-8
No files found.
Makefile
View file @
1058c5d9
PRG
=
crowbx
OBJ
=
crowbx.o midi.o dac.o uart.o gate.o poly.o mono.o list.o vibrato.o poly2.o
safe
_add.o pitch.o pitch_env.o vibrato_rate.o mono2.o voice.o
OBJ
=
crowbx.o midi.o dac.o uart.o gate.o poly.o mono.o list.o vibrato.o poly2.o
clamp
_add.o pitch.o pitch_env.o vibrato_rate.o mono2.o voice.o
MCU_TARGET
=
atmega328p
OPTIMIZE
=
-O3
...
...
safe
_add.c
→
clamp
_add.c
View file @
1058c5d9
#include "
safe
_add.h"
#include "
clamp
_add.h"
uint16_t
safe
_add
(
uint16_t
x
,
int16_t
delta
)
{
uint16_t
clamp
_add
(
uint16_t
x
,
int16_t
delta
)
{
if
(
delta
<
0
)
{
uint16_t
sub
=
-
delta
;
if
(
x
<
sub
)
{
...
...
clamp_add.h
0 → 100644
View file @
1058c5d9
#ifndef CLAMP_ADD_H
#define CLAMP_ADD_H
#include <stdint.h>
uint16_t
clamp_add
(
uint16_t
x
,
int16_t
delta
);
#endif
dac.c
View file @
1058c5d9
#include "dac.h"
#include "
safe
_add.h"
#include "
clamp
_add.h"
#include "voice.h"
#include <avr/io.h>
#include <util/delay.h>
...
...
@@ -84,7 +84,7 @@ uint16_t dac_note_pitch(uint8_t v, uint8_t note) {
return
0
;
}
return
safe
_add
(
return
clamp
_add
(
d
->
offset
+
octave
*
d
->
scale
,
dac_semitone_offset
((
note
-
MIDI_LOWEST
)
%
NUM_SEMITONES
));
}
pitch.c
View file @
1058c5d9
#include "pitch.h"
#include "dac.h"
#include "pitch_env.h"
#include "
safe
_add.h"
#include "
clamp
_add.h"
#include "vibrato.h"
#include "voice.h"
...
...
@@ -19,7 +19,7 @@ void pitch_set_note(uint8_t voice, uint8_t note, int16_t detune) {
return
;
}
base_pitch
[
voice
]
=
safe
_add
(
dac_note_pitch
(
voice
,
note
),
detune
);
base_pitch
[
voice
]
=
clamp
_add
(
dac_note_pitch
(
voice
,
note
),
detune
);
}
void
pitch_set_bend
(
uint16_t
bend
)
{
...
...
@@ -32,10 +32,10 @@ void pitch_update_clock(uint8_t delta) {
pitch_env_update_clock
(
delta
);
for_each_voice
(
v
)
{
uint16_t
data
=
safe
_add
(
base_pitch
[
v
],
vibrato_detune
());
data
=
safe
_add
(
data
,
uint16_t
data
=
clamp
_add
(
base_pitch
[
v
],
vibrato_detune
());
data
=
clamp
_add
(
data
,
pitch_env_delta
(
v
)
*
(
float
)
dac_pitch_delta
(
5
));
data
=
safe
_add
(
data
,
bend_data
);
data
=
clamp
_add
(
data
,
bend_data
);
dac_send
(
dac_command_set
(
v
),
data
);
}
}
safe_add.h
deleted
100644 → 0
View file @
68590900
#ifndef SAFE_ADD_H
#define SAFE_ADD_H
#include <stdint.h>
uint16_t
safe_add
(
uint16_t
x
,
int16_t
delta
);
#endif
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