Class: LiveAudioClip

Inherits:
Object
  • Object
show all
Defined in:
lib/live_set/live_set_audio_clip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, need_refreeze, clip_slot) ⇒ LiveAudioClip

Returns a new instance of LiveAudioClip.

Parameters:

  • audio_clip

    is an inner <ClipSlot/> element from an Ableton Live .als file as parsed by Nokogiri



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/live_set/live_set_audio_clip.rb', line 8

def initialize(id, need_refreeze, clip_slot)
  @id                 = id
  @need_refreeze      = need_refreeze

  @audio_clip         = clip_slot.Value.AudioClip
  @file_ref           = @audio_clip.SampleRef.FileRef
  @last_modified      = Time.at(@audio_clip.SampleRef.LastModDate['Value'].to_i).utc.to_datetime

  @absolute_path      = @file_ref.Path['Value']
  @file_size          = @file_ref.OriginalFileSize['Value'].to_i
  @file_type          = @file_ref.Type['Value'] # What do these values mean?
  @live_pack_name     = @file_ref.LivePackName['Value']
  @relative_path      = @file_ref.RelativePath['Value']
  @relative_path_type = @file_ref.RelativePathType['Value'] # What do these values mean?
end

Instance Attribute Details

#absolute_pathObject (readonly)

Returns the value of attribute absolute_path.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def absolute_path
  @absolute_path
end

#file_refObject (readonly)

Returns the value of attribute file_ref.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def file_ref
  @file_ref
end

#file_sizeObject (readonly)

Returns the value of attribute file_size.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def file_size
  @file_size
end

#file_typeObject (readonly)

Returns the value of attribute file_type.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def file_type
  @file_type
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def id
  @id
end

#last_modifiedObject (readonly)

Returns the value of attribute last_modified.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def last_modified
  @last_modified
end

#live_pack_nameObject (readonly)

Returns the value of attribute live_pack_name.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def live_pack_name
  @live_pack_name
end

#need_refreezeObject (readonly)

Returns the value of attribute need_refreeze.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def need_refreeze
  @need_refreeze
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def relative_path
  @relative_path
end

#relative_path_typeObject (readonly)

Returns the value of attribute relative_path_type.



4
5
6
# File 'lib/live_set/live_set_audio_clip.rb', line 4

def relative_path_type
  @relative_path_type
end

Instance Method Details

#collected?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/live_set/live_set_audio_clip.rb', line 24

def collected?
  @relative_path.start_with? 'Samples/Imported/'
end

#show_clipObject



28
29
30
# File 'lib/live_set/live_set_audio_clip.rb', line 28

def show_clip
  ["    #{@relative_path}", human_file_size(@file_size).rjust(8, ' '), @last_modified.strftime('%Y-%m-%d %H:%M:%S')]
end