Class: Sample

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

Overview

An SFZ Sample is a file that represents a single note.

Direct Known Subclasses

NamedSample

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sample, path = false) ⇒ Sample

sample = full path to sample



21
22
23
24
# File 'lib/Sample.rb', line 21

def initialize( sample, path=false )
  @sample = sample
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'lib/Sample.rb', line 19

def path
  @path
end

#sampleObject (readonly)

Returns the value of attribute sample.



19
20
21
# File 'lib/Sample.rb', line 19

def sample
  @sample
end

Class Method Details

.sample?(name) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/Sample.rb', line 61

def Sample.sample?( name )
  name =~ /*.#{Sample.suffix_regexp}$/i
end

.suffix_globObject

returns a Dir glob string for all possible sample suffixes



51
52
53
54
55
56
57
58
59
# File 'lib/Sample.rb', line 51

def Sample.suffix_glob
  # build filename suffix types

  types = "{"
  Sample.suffixes do |s|
    types = types + "#{s},"
  end  
  types.chop!
  types = types + "}"
end

.suffix_regexpObject

returns a regexp string for all possible sample suffixes



39
40
41
42
43
44
45
46
47
# File 'lib/Sample.rb', line 39

def Sample.suffix_regexp
  # build filename suffix types

  types = "("
  Sample.suffixes do |s|
    types = types + "#{s}|"
  end  
  types.chop!
  types = types + ")"
end

.suffixesObject

yields all the sample suffixes that SFZ supports



31
32
33
34
35
# File 'lib/Sample.rb', line 31

def Sample.suffixes
  ['wav', 'ogg', 'aif', 'aiff'].each do |type|
    yield type
  end
end

Instance Method Details

#noteObject



67
68
69
# File 'lib/Sample.rb', line 67

def note
  false
end

#to_sObject



76
77
78
79
80
81
82
# File 'lib/Sample.rb', line 76

def to_s
  if @path
    "#{@path}#{SFZer::SEPARATOR}#{@sample}"
  else
    "#{@sample}"
  end
end

#valueObject



72
73
74
# File 'lib/Sample.rb', line 72

def value
  false
end