Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

発音中のループ処理をリファクタリング

  • Loading branch information...
commit 712a7a2620c1d037ff8936d86a45cfe86a7e3808 1 parent e5882fd
@techno-cat authored
Showing with 7 additions and 11 deletions.
  1. +7 −11 p5-NeSynth/lib/Sound/NeSynth.pm
View
18 p5-NeSynth/lib/Sound/NeSynth.pm
@@ -87,22 +87,18 @@ sub _create_oneshot {
if ( exists $amp->{attack} ) {
$attack = int( $samples_per_sec * $amp->{attack} );
}
- my $release = int( $samples_per_sec * $amp->{sec} ) - $attack;
+ my $gate_time = int( $samples_per_sec * $amp->{sec} );
- my @samples = ();
- if ( 0 < $attack ) {
- push @samples, map {
+ my @samples = map {
+ if ( $_ < $attack ) {
# 立ち上がりでプチッって言わないようにするための回避策なので、
# アタック感重視の係数が入れてある
$osc->() * $env->() * ( ($_ / $attack) ** 2.0 );
- } 0..($attack - 1);
- }
-
- if ( 0 < $release ) {
- push @samples, map {
+ }
+ else {
$osc->() * $env->();
- } 0..($release - 1);
- }
+ }
+ } 0..($gate_time - 1);
return \@samples;
}
Please sign in to comment.
Something went wrong with that request. Please try again.