Sha256: 1984a741280d995aa1e83dab8866b3e88176359c4c86943c86362815f34fa003

Contents?: true

Size: 865 Bytes

Versions: 9

Compression:

Stored size: 865 Bytes

Contents

module CoreAudio
  class AudioFile
    def read(frames=nil)
      if frames
        frames = Integer(frames)
        if frames and frames > 0
          return read_frames(frames)
        elsif frames == 0
          return NArray.sint(0)
        else
          raise ArgumentError,
            "coreaudio: read frame number must be zero or positive"
        end
      end

      # read all frames
      chunk = self.inner_rate.to_i * 10
      total = nil
      loop do
        tmp = read_frames(chunk)
        if tmp.nil?
          break
        end
        if total.nil?
          total = tmp
        else
          new_na = NArray.sint(total.shape[0], tmp.shape[1] + total.shape[1])
          new_na[false, 0...total.shape[1]] = total
          new_na[false, total.shape[1]..-1] = tmp
          total = new_na
        end
      end

      total
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
coreaudio-0.0.12 lib/coreaudio/audiofile.rb
coreaudio-0.0.11 lib/coreaudio/audiofile.rb
coreaudio-0.0.10 lib/coreaudio/audiofile.rb
coreaudio-0.0.9 lib/coreaudio/audiofile.rb
coreaudio-0.0.8 lib/coreaudio/audiofile.rb
coreaudio-0.0.7 lib/coreaudio/audiofile.rb
coreaudio-0.0.6 lib/coreaudio/audiofile.rb
coreaudio-0.0.5 lib/coreaudio/audiofile.rb
coreaudio-0.0.4 lib/coreaudio/audiofile.rb