音量を変化させてみる
前回は、エンベロープで音程を変化させたけど、
今回は、音量を変更してみる。
use v5.14; use strict; use warnings; use Cassis; use constant SAMPLING_RATE => 44100; my $dco = Cassis::DCO::Pulse->new( fs => SAMPLING_RATE, pitch => 4.0 ); my @wav = (); foreach my $vol ( 1.0, 0.5, 0.25, 0.125 ) { my $amp = Cassis::Amp->new( volume => $vol ); my $tmp = $amp->exec( src => $dco->exec(num => SAMPLING_RATE * 0.5) ); push @wav, @{$tmp}; } Cassis::File::write( file => 'volume.wav', fs => SAMPLING_RATE, channels => [ \@wav ] );
こんな感じで、Cassis::Amp
を使うと音量を変更できる。
でもって、エンベロープの出力を使うと?
use v5.14; use strict; use warnings; use Cassis; use constant SAMPLING_RATE => 44100; my $dco = Cassis::DCO::Tri->new( fs => SAMPLING_RATE, pitch => 4.0 ); my $amp = Cassis::Amp->new(); my $eg = Cassis::EG->new( fs => SAMPLING_RATE, # sampling-rate adsr => [ 0.01, # Attack : time(sec) 0.01, # Decay : time(sec) 0.2, # Sustain: gain 0.5 # Release: time(sec) ], curve => 0.4 # default: 1.0 / exp(1.0) ); my $eg_out = $eg->one_shot( gatetime => 0.05 ); my $wav = $amp->exec( src => $dco->exec(num => scalar(@{$eg_out})), mod_volume => { src => $eg_out, depth => 1.0 } ); Cassis::File::write( file => 'mod_volume.wav', fs => SAMPLING_RATE, channels => [ $wav ] );
これで、少しだけ音色の幅が広がりましたね!
おしまい。
Leave a Comment