1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#ifndef UDO_AUTORECORD
#define UDO_AUTORECORD ##
/*
Automatic sound file recorder using the monitor opcode
This file is part of the SONICS UDO collection by Richard Knight 2021, 2024
License: GPL-2.0-or-later
http://1bpm.net
*/
#include "host_tools.udo"
#ifndef AUTORECORD_PATH
if (gihost_type == 0) then
gSautorecordPath = "d:/temp"
else
gSautorecordPath = "/tmp"
endif
#else
gSautorecordPath = "$AUTORECORD_PATH"
#end
/*
Auto file recorder
usage - either in score:
i"udo_autorecord" 0 5
or in instr globals:
autorecord 5
*/
#define MONTHIF(MS'MI) #
isame strcmp "$MS", Smonth
if (isame == 0) then
Smonth = $MI
goto monthdone
endif
#
opcode autorecord, 0, aap
aL, aR, istereo xin
itim date
Stim dates itim
Sday strsub Stim, 8, 10
Shour strsub Stim, 11, 13
Smin strsub Stim, 14, 16
Ssec strsub Stim, 17, 19
Syear strsub Stim, 20, 24
Smonth strsub Stim, 4, 7
ichr strchar Sday
if (ichr == 32) then
Sday2 strsub Sday, 1, 2
Sday strcat "0", Sday2
endif
$MONTHIF(Jan'"01")
$MONTHIF(Feb'"02")
$MONTHIF(Mar'"03")
$MONTHIF(Apr'"04")
$MONTHIF(May'"05")
$MONTHIF(Jun'"06")
$MONTHIF(Jul'"07")
$MONTHIF(Aug'"08")
$MONTHIF(Sep'"09")
$MONTHIF(Oct'"10")
$MONTHIF(Nov'"11")
$MONTHIF(Dec'"12")
monthdone:
/*
Smkdir = "mkdir -p "
if (gihost_type != 0) then
Smkdir = strcat(Smkdir, "-p ")
endif
; make day dir
Sdir sprintf "/%s%s%s", Syear, Smonth, Sday
prints Sdir
Sdaydir strcat Sbasedir, Sdir
Scmd strcat Smkdir, Sdaydir
ires system_i 1, Scmd
Sfile sprintf "/%s%s%s.wav", Shour, Smin, Ssec
Spath strcat Sdaydir, Sfile
*/
Spath sprintf "%s/%s-%s-%s.%s-%s-%s.wav", gSautorecordPath, Syear, Smonth, Sday, Shour, Smin, Ssec
prints sprintf("\n----------------------------------------------------------------------------------------------------------\n Autorecording to %s\n----------------------------------------------------------------------------------------------------------\n", Spath)
if (istereo == 1) then
fout Spath, 14, aL, aR
else
fout Spath, 14, aL
endif
endop
opcode autorecord, 0, a
ain xin
autorecord ain, ain, 0
endop
instr autorecord
aL, aR monitor
autorecord aL, aR
endin
#end
|