Class: DSP::PitchTrack

Inherits:
Data
  • Object
show all
Defined in:
lib/dsprb/pitch_track.rb,
sig/dsprb.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



4
5
6
# File 'lib/dsprb/pitch_track.rb', line 4

def confidence
  @confidence
end

#f0Object (readonly)

Returns the value of attribute f0

Returns:

  • (Object)

    the current value of f0



4
5
6
# File 'lib/dsprb/pitch_track.rb', line 4

def f0
  @f0
end

#hop_secondsObject (readonly)

Returns the value of attribute hop_seconds

Returns:

  • (Object)

    the current value of hop_seconds



4
5
6
# File 'lib/dsprb/pitch_track.rb', line 4

def hop_seconds
  @hop_seconds
end

#timesObject (readonly)

Returns the value of attribute times

Returns:

  • (Object)

    the current value of times



4
5
6
# File 'lib/dsprb/pitch_track.rb', line 4

def times
  @times
end

Class Method Details

.newObject



283
# File 'sig/dsprb.rbs', line 283

def self.new: (

Instance Method Details

#each_voicedvoid #each_voiced::Enumerator[[::Float, ::Float, ::Float], void]

Overloads:

  • #each_voicedvoid

    This method returns an undefined value.

  • #each_voiced::Enumerator[[::Float, ::Float, ::Float], void]

    Returns:

    • (::Enumerator[[::Float, ::Float, ::Float], void])

Yields:

Yield Parameters:

  • arg0 (::Float)
  • arg1 (::Float)
  • arg2 (::Float)

Yield Returns:

  • (void)


15
16
17
18
19
20
21
# File 'lib/dsprb/pitch_track.rb', line 15

def each_voiced
  return enum_for(:each_voiced) unless block_given?

  f0.each_with_index do |frequency, index|
    yield(frequency, times[index], confidence[index]) if frequency.positive?
  end
end

#empty?Boolean

Returns:

  • (Boolean)


7
# File 'lib/dsprb/pitch_track.rb', line 7

def empty? = f0.empty?

#length::Integer

Returns:

  • (::Integer)


5
# File 'lib/dsprb/pitch_track.rb', line 5

def length = f0.length

#voiced_f0::Array[::Float]

Returns:

  • (::Array[::Float])


13
# File 'lib/dsprb/pitch_track.rb', line 13

def voiced_f0 = f0.select(&:positive?)

#voiced_frames::Integer

Returns:

  • (::Integer)


9
# File 'lib/dsprb/pitch_track.rb', line 9

def voiced_frames = f0.count(&:positive?)

#voiced_ratio::Float

Returns:

  • (::Float)


11
# File 'lib/dsprb/pitch_track.rb', line 11

def voiced_ratio = f0.empty? ? 0.0 : voiced_frames.to_f / f0.length