Skip to content

Commit 03e9749

Browse files
committed
New function Y#: sound, soundsc, audiowrite.
1 parent 3e78c62 commit 03e9749

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

doc/MATL_spec.pdf

1.2 KB
Binary file not shown.

doc/function_table.pdf

38 Bytes
Binary file not shown.

funDef.mat

-66 Bytes
Binary file not shown.

funDef.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,30 @@ Z" 1 1 1 1 1 1 true true true true S = ' '; string or array of blanks \matlab+
3737
out{1} = y; clear S
3838
#
3939
X# 0 0 0 0 0 0 false false false true disp('/-------'), celldisp(STACK), disp('-------/') display stack contents display stack as a cell array
40-
Y#
41-
Z# 1 3 1 2 0 0 0 true true true false data = in{1}; if ~iscell(data), data = {data}; end write to file Writes first input to file \comp{inout}, creating it if necessary. If the file exists, by default its previous contents are overwritten. If the input is an array it is converted to char and written. If the input is a cell array input, the contents of each cell are converted to char and written, with a newline (character 10) in between. With $2$ inputs: second input specifies filename; it is converted to char is necessary; if empty defaults to \comp{inout}. With $3$ inputs: third input specifies whether previous contents of the file should be kept
40+
Y# 2 inf 2 3 0 0 0 true true true true if numel(in)==2 sound / soundsc / audiowrite (i) With $2$ inputs: \matlab+sound+. If second input is \matl+T+, it is interpreted as \matl+44100+. If second input is \matl+F+, it is interpreted as \matl+44100+ and \matlab+audiowrite+ is called instead of \matlab+sound+, with file name \matlab+'audio.wav'+. (ii) With $3$ inputs: if third input is a truthy scalar, \matlab+soundsc+ is called with the first two inputs. If third input is a numeric vector of size $2$, \matlab+soundsc+ is called with the three inputs. In both cases, \matl+T+ in second input is interpreted as \matl+44100+. If third input is a string, it defines a file name, and \matlab+audiowrite+ is called with that file name and the other two inputs. (iii) With more than $3$ inputs: \matlab+audiowrite+ is called using the third input as file name. Further inputs specify parameter-value pairs. \matl+T+ in second input is interpreted as \matl+44100+.
41+
if islogical(in{2})&&isscalar(in{2})&&in{2}
42+
sound(in{1},44100)
43+
elseif islogical(in{2})&&isscalar(in{2})&&~in{2}
44+
audiowrite('audio.wav',in{1},44100);
45+
else
46+
sound(in{:})
47+
end
48+
elseif numel(in)==3
49+
if islogical(in{2})&&isscalar(in{2})&&in{2}, in{2} = 44100; end
50+
if isscalar(in{3})&&in{3}
51+
soundsc(in{1},in{2})
52+
elseif isnumeric(in{3})&&numel(in{3})==2
53+
soundsc(in{:})
54+
elseif ischar(in{3})
55+
audiowrite(in{3},in{1},in{2})
56+
else
57+
error('MATL:runtime', 'MATL run-time error: input not allowed');
58+
end
59+
else
60+
if islogical(in{2})&&isscalar(in{2})&&in{2}, in{2} = 44100; end
61+
audiowrite(in{3},in{1},in{2},in{4:end})
62+
end
63+
Z# 1 3 1 2 0 0 0 true true true false data = in{1}; if ~iscell(data), data = {data}; end write to file Writes first input to file \comp{inout}, creating it if necessary. If the file exists, by default its previous contents are overwritten. If the input is an array it is converted to char and written. If the input is a cell array input, the contents of each cell are converted to char and written, with a newline (character 10) in between. With $2$ inputs: second input specifies file name; it is converted to char is necessary; if empty defaults to \comp{inout}. With $3$ inputs: third input specifies whether previous contents of the file should be kept
4264
sep = char(10);
4365
if numel(in)>=2 && ~isempty(in{2}), file = in{2}; else file = 'inout'; end
4466
if numel(in)>=3 && in{3}, perm = 'a'; else perm = 'w'; end
@@ -467,7 +489,7 @@ X9 1 1 1 1 1 1 true true true true fn = 'X9'; k = find(preLit.(fn).key==in{1},
467489
out{1} = preLit.(fn).val{k};
468490
Y9
469491
Z9
470-
: 1 3 1 2 1 1 1 true true true true if numel(in)==1 range; vector of equally spaced values \matlab+colon+ (with three inputs \matlab+x+, \matlab+y+, \matlab+z+ produces \matlab+x:y:z+; with two inputs \matlab+x+, \matlab+y+ produces \matlab+x:y+). If one input: produces \matlab+1:x+, or \matlab+' ':x+ if \matlab+x+ is char.
492+
: 1 3 1 2 1 1 1 true true true true if numel(in)==1 range; vector of equally spaced values \matlab+colon+ (with three inputs \matlab+x+, \matlab+y+, \matlab+z+ produces \matlab+x:y:z+; with two inputs \matlab+x+, \matlab+y+ produces \matlab+x:y+). If one input: produces \matlab+1:x+, or \matlab+' ':x+ if \matlab+x+ is char.
471493
if ischar(in{1}), s = ' '; else s = 1; end
472494
out{1} = colon(s,in{:}); clear s
473495
else

help.mat

853 Bytes
Binary file not shown.

preLit.mat

76 Bytes
Binary file not shown.

preLit.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ X6
119119
23 'InitialMagnification'
120120
24 'Parent'
121121
25 'Reduce'
122+
30 'BitsPerSample'
123+
31 'BitRate'
124+
32 'Quality'
122125

123126

124127
X7

0 commit comments

Comments
 (0)