Class: RSGuitarTech::AudioExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/rsgt/audio_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ AudioExtractor

Returns a new instance of AudioExtractor.



6
7
8
9
# File 'lib/rsgt/audio_extractor.rb', line 6

def initialize(opts)
  @psarc = File.expand_path(opts.delete :psarc)
  @opts  = opts
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



4
5
6
# File 'lib/rsgt/audio_extractor.rb', line 4

def opts
  @opts
end

#psarcObject

Returns the value of attribute psarc.



4
5
6
# File 'lib/rsgt/audio_extractor.rb', line 4

def psarc
  @psarc
end

#unpackedObject

Returns the value of attribute unpacked.



4
5
6
# File 'lib/rsgt/audio_extractor.rb', line 4

def unpacked
  @unpacked
end

Instance Method Details

#extract!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rsgt/audio_extractor.rb', line 11

def extract!
  UnpackedPSARC.from_psarc(psarc, opts) do |unpacked|

    # Convert main track from wem to ogg:
    CommandRunner.run! RSCustomSongToolkit.ww2ogg(unpacked.audio_track)
    raise StandardError unless File.exist?(unpacked.ogg_track)

    # Revorb it so it doesn't sound bad...
    CommandRunner.run! RSCustomSongToolkit.revorb(unpacked.ogg_track)

    FileUtils.cp unpacked.ogg_track, "output.ogg"
  end
end