Class: StepSequencer::SoundBuilder::DefaultEffects::Pitch

Inherits:
Object
  • Object
show all
Defined in:
lib/step_sequencer/sound_builder/default_effects/pitch.rb

Class Method Summary collapse

Class Method Details

.build(sources:, value:, speed_correction: true) ⇒ Object



5
6
7
# File 'lib/step_sequencer/sound_builder/default_effects/pitch.rb', line 5

def self.build(sources:, value:, speed_correction: true)
  sources.map &change_pitch(value, speed_correction)
end

.change_pitch(value, speed_correction) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/step_sequencer/sound_builder/default_effects/pitch.rb', line 9

def self.change_pitch(value, speed_correction)
  ->(source){
    outfile = build_outfile_name(source, value)
    cmd = <<-SH
      ffmpeg -y -i #{source} -af   \
        asetrate=44100*#{value} \
        #{outfile}              \
        2> /dev/null
    SH
    system cmd
    return outfile unless speed_correction
    outfile_with_correct_speed = correct_speed(outfile, value)
    outfile_with_correct_speed
  }
end