Class: Sample
- Inherits:
-
Object
- Object
- Sample
- Defined in:
- lib/Sample.rb
Overview
An SFZ Sample is a file that represents a single note.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
Class Method Summary collapse
- .sample?(name) ⇒ Boolean
-
.suffix_glob ⇒ Object
returns a Dir glob string for all possible sample suffixes.
-
.suffix_regexp ⇒ Object
returns a regexp string for all possible sample suffixes.
-
.suffixes ⇒ Object
yields all the sample suffixes that SFZ supports.
Instance Method Summary collapse
-
#initialize(sample, path = false) ⇒ Sample
constructor
sample = full path to sample.
- #note ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
19 20 21 |
# File 'lib/Sample.rb', line 19 def path @path end |
#sample ⇒ Object (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
61 62 63 |
# File 'lib/Sample.rb', line 61 def Sample.sample?( name ) name =~ /*.#{Sample.suffix_regexp}$/i end |
.suffix_glob ⇒ Object
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_regexp ⇒ Object
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 |
.suffixes ⇒ Object
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
#note ⇒ Object
67 68 69 |
# File 'lib/Sample.rb', line 67 def note false end |
#to_s ⇒ Object
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 |
#value ⇒ Object
72 73 74 |
# File 'lib/Sample.rb', line 72 def value false end |