# "scrubbing" sound: playing sound from views rather than Arrays

**URL:** <https://discourse.julialang.org/t/scrubbing-sound-playing-sound-from-views-rather-than-arrays/115957>\
**Category:** Signal and Image Processing\
**Tags:** audio\
**Created:** [June 21, 2024, 1:02am UTC](https://discourse.julialang.org/t/scrubbing-sound-playing-sound-from-views-rather-than-arrays/115957 "2024-06-21T01:02:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [June 21, 2024, 1:02am UTC](https://discourse.julialang.org/t/scrubbing-sound-playing-sound-from-views-rather-than-arrays/115957/1 "2024-06-21T01:02:11Z")

</div>

In PortAudio, audio data is just a Nx1 (mono) or Nx2 (stereo) matrix with an associated sample rate. So if you had a sample rate of 44\_100 samples per second, a one-second-long audio will have 44\_100 rows.

Say I have two 1-second-long sounds (of same sample rate). They are unrelated sounds and are not meant to be played in order. I was thinking that, rather than storing them in two different matrices, I could store them in one matrix (contiguous in memory) and read views from them-- essentially accessing certain segments of the matrix. So if I wanted to play the first bit of sound, I could pass the view of the first 41\_000 rows to PortAudio. But this doesn’t seem possible currently. If I pass a view instead of a Matrix, I get:

`ERROR: MethodError: no method matching write(::PortAudio.PortAudioSink{…}, ::SubArray{…})`

I don’t know if this is a limitation of PortAudio and can be tweaked with there (or by me after import) or if this is a limitation of `Base.write` or some C liberary PortAudio is using under the hood.

Thoughts?
