Skip to content

Commit

Permalink
FIXED BUG in AddPart()
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandpaBond committed Nov 24, 2023
1 parent e1e0095 commit 1efe075
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ The attack chooses how fast the pitch moves from the start-point to the end-poin

### ~reminder
Note that the Attack can only apply to pitch changes: the internal soundEffects synthesiser only ever changes the volume linearly from start-point
to end-point. So percussive sounds (where an initial rapid fall in volume is followed by a slower decay) will require two or more parts.
to end-point. So percussive, bell-like sounds (where an initial rapid fall in volume is followed by a slower decay) will require two or more parts.
### ~

### Style: Effect
Expand Down Expand Up @@ -460,7 +460,6 @@ Obviously, each ``||flexFX:FlexFX||`` you create will take up memory: if you cr
at which memory runs out!
### ~


-----------------------------------------------------------------------
-----------------------------------------------------------------------
# Acknowledgements
Expand Down
13 changes: 8 additions & 5 deletions flexFX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,20 @@ namespace flexFX {

this.pitchProfile.push(this.goodPitch(endPitch));

let v = this.goodVolume(endVolume*4);
this.volumeProfile.push(v);
this.peakVolume = Math.max(this.peakVolume, v);
let bigV = this.goodVolume(endVolume*4);
this.volumeProfile.push(bigV);
this.peakVolume = Math.max(this.peakVolume, bigV);

let d = this.goodDuration(duration);
this.durationProfile.push(d);

// turn our enums into simple numbers & create the sound string for this part
// turn our enums into simple numbers
let waveNumber: number = wave;
let effectNumber: number = effect;
let attackNumber: number = attack;

// start where the [pitch,volume] last ended:
// (this.nParts hasn't yet been incremented, so indexes the previous part)
let startPitch = this.pitchProfile[this.nParts];
let startVolume = this.volumeProfile[this.nParts]

Expand Down Expand Up @@ -393,7 +396,7 @@ namespace flexFX {

// create the SoundExpression
let soundExpr = music.createSoundExpression(waveNumber, startPitch, endPitch,
startVolume, endVolume, duration, effectNumber, attackNumber);
startVolume, bigV, duration, effectNumber, attackNumber);

/* The underlying implementation in "codal-microbit-v2/source/SoundSynthesizerEffects.cpp"
of the functions:
Expand Down
4 changes: 2 additions & 2 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// *********** test codes **********

/***
***/

// perform a built-in FlexFX with all the defaults
basic.showIcon(IconNames.Target);
flexFX.playFlexFX("uhoh");
basic.showIcon(IconNames.Yes);
pause(2000);

// perform the simple built-in chime flexFX
basic.showIcon(IconNames.Target);
flexFX.playFlexFX("chime", true, Note.G5, 180, 400); // up a fifth
Expand Down Expand Up @@ -266,4 +267,3 @@ while (flexFX.isActive()) {
}
basic.showIcon(IconNames.Yes);


0 comments on commit 1efe075

Please sign in to comment.