Skip to content

Commit

Permalink
drumkit.xsd / adsr fix accepted values
Browse files Browse the repository at this point in the history
even if it is weird, the unit of the adsr values is the tick.
their range defined by the gui are:
  [0 ; 100000] for attack and decay
  [0.0 ; 1.0] for sustain
  [256 ; 100256] for release
  • Loading branch information
jeremyz committed Sep 16, 2018
1 parent 39a17d6 commit c00f9bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions data/xsd/drumkit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<xsd:element name="filterActive" type="h2:bool" default="false"/>
<xsd:element name="filterCutoff" type="h2:psfloat" default="1.0"/>
<xsd:element name="filterResonance" type="h2:psfloat" default="0.0"/>
<xsd:element name="Attack" type="h2:psfloat" default="0.0"/>
<xsd:element name="Decay" type="h2:psfloat" default="0.0"/>
<xsd:element name="Attack" type="xsd:nonNegativeInteger" default="0"/>
<xsd:element name="Decay" type="xsd:nonNegativeInteger" default="0"/>
<xsd:element name="Sustain" type="h2:psfloat" default="1.0"/>
<xsd:element name="Release" type="xsd:nonNegativeInteger" default="5800"/>
<xsd:element name="muteGroup" type="xsd:integer" default="-1"/>
Expand Down
15 changes: 9 additions & 6 deletions src/core/src/basics/adsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ void ADSR::normalise()
if (__sustain < 0.0) {
__sustain = 0.0;
}
if (__release < 0.0) {
__release = 0.0;
if (__release < 256) {
__release = 256;
}
if (__attack > 1.0) {
__attack = 1.0;
if (__attack > 100000) {
__attack = 100000;
}
if (__decay > 1.0) {
__decay = 1.0;
if (__decay > 100000) {
__decay = 100000;
}
if (__sustain > 1.0) {
__sustain = 1.0;
}
if (__release > 100256) {
__release = 100256;
}
}

ADSR::ADSR( float attack, float decay, float sustain, float release ) : Object( __class_name ),
Expand Down

0 comments on commit c00f9bc

Please sign in to comment.