annotate audio/rawpipe.m @ 2:7357e1dc2ad6
Simplified scheduler library with new schedule representation.
author |
samer |
date |
Sat, 22 Dec 2012 16:17:51 +0000 |
parents |
672052bd81f8 |
children |
62e31e7980e6 |
rev |
line source |
samer@0
|
1 % rawpipe - pipe reader implementation of sndstream (raw audio stream)
|
samer@0
|
2 %
|
samer@0
|
3 % rawpipe ::
|
samer@0
|
4 % string ~'shell pipe',
|
samer@0
|
5 % AudioFormat~'stream format',
|
samer@0
|
6 % options {
|
samer@0
|
7 % channels :: natural/nan ~'desired number of channels';
|
samer@0
|
8 % rate :: nonneg/nan ~'desired sampling rate';
|
samer@0
|
9 % bits :: natural/16 ~'desired bits per sample';
|
samer@0
|
10 % }
|
samer@0
|
11 % -> signal(C,R).
|
samer@0
|
12 %
|
samer@0
|
13 % If channels or rate are not nan, audio format will be converted to match.
|
samer@0
|
14 % If either of them are nan, the corresponding value from the audio file will
|
samer@0
|
15 % be left unchanged.
|
samer@0
|
16 function s=rawpipe(cmd,fmt,varargin)
|
samer@0
|
17 s=sndstream(@pipestream,'stringfn',@()sprintf('rawpipe(''%s'')',cmd),varargin{:});
|
samer@0
|
18
|
samer@0
|
19 function [str,cleanup]=pipestream(q)
|
samer@0
|
20 [str,cleanup]=pipein(cmd,q);
|
samer@0
|
21 str=javax.sound.sampled.AudioInputStream(str,fmt,-1);
|
samer@0
|
22 end
|
samer@0
|
23 end
|
samer@0
|
24
|
samer@0
|
25
|
samer@0
|
26
|