Check-in [528d240a4a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:GUI for android play and recording
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 528d240a4a7ce22e23707267e6ead793fde30544
User & Date: bernd 2020-06-25 15:30:20
Context
2020-06-28
14:26
Audio player volume check-in: 05fbc5d044 user: bernd tags: trunk
2020-06-25
15:30
GUI for android play and recording check-in: 528d240a4a user: bernd tags: trunk
2020-06-18
13:23
Bump version number check-in: 5703baa868 user: bernd tags: trunk, 0.9.8-20200618
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to gui.fs.

1157
1158
1159
1160
1161
1162
1163






1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185

1186
1187
1188
1189
1190
1191
1192
....
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
....
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
....
1633
1634
1635
1636
1637
1638
1639




1640

1641
1642
1643
1644
1645
1646
1647

[IFDEF] linux
    also require minos2/pulse-audio.fs pulse-init
    require minos2/opus-codec.fs
    previous
    ' bye is net2o-bye
[ELSE]






    begin-structure idx-head
	4 +field idx-magic
	cfield: idx-channels
	cfield: idx-frames
	wfield: idx-samples
	8 +field idx-pos
    end-structure
    Variable idx-block
    Variable play-block
    1 Value channels
    
    : start-play ;
    : pause-play ;
    : resume-play ;
    : open-play 2drop 2drop ;
    : open-rec+ 2drop ;
    : close-rec-mono ;
    : close-rec-stereo ;
    scope: pulse
    #48000 Value sample-rate
    : record-mono ;
    }scope

[THEN]

: be-l, ( l -- ) here be-l! 4 allot ;

Create audio-colors
$0000FF00 be-l, $0008F700 be-l, $0010EF00 be-l, $0018E700 be-l,
$0020DF00 be-l, $0029D600 be-l, $0031CE00 be-l, $0039C600 be-l,
................................................................................
    2swap +imgs 64#1 +to msg:timestamp click[] ;

Variable current-play$
Variable current-player

: >msg-audio-player ( addr u -- )
    2dup current-play$ $@ str= IF
	resume-play
    ELSE
	2dup current-play$ $!  caller-w current-player !
	2dup key| ?read-enc-hashed idx-block $!
	keysize safe/string key| ?read-enc-hashed play-block $!
	start-play
    THEN ;

................................................................................
	THEN
	caller-w .text$ play$ $@ str=
	IF
	    addr data $@ ['] >msg-audio-player catch 0= IF
		pause$ $@ caller-w >o to text$ o> +sync
	    ELSE  2drop  THEN
	ELSE
	    pause-play
	    play$ $@ caller-w >o to text$ o> +sync
	THEN  ;]
    2swap $make 64#1 +to msg:timestamp click[] ;

:noname ( addr u type -- )
    obj-red
    case
................................................................................
	    {{
		glue*l send-color x-color font-size# 40% f* }}frame dup .button2
		!i18n blackish l" Record" }}text' !lit 25%b /center
	    }}z box[] /flip dup to chat-record-button
	    [:  chat-record-button /flip drop
		chat-recording-button /flop drop +resize +sync +lang
		"recording" .net2o-cache/ open-rec+




		1 to channels  pulse:sample-rate pulse:record-mono

	    ;] 0 click[]
	    {{
		glue*l recording-color# font-size# 40% f* }}frame dup .button3
		!i18n blackish l" Recording…" }}text' !lit 25%b /center
	    }}z box[] /flip dup to chat-recording-button
	    [:  chat-recording-button /flip drop
		chat-record-button /flop drop +resize +sync +lang







>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







 







|







 







|







 







>
>
>
>
|
>







1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
....
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
....
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
....
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659

[IFDEF] linux
    also require minos2/pulse-audio.fs pulse-init
    require minos2/opus-codec.fs
    previous
    ' bye is net2o-bye
[ELSE]
    [IFDEF] android
	also require minos2/sles-audio.fs sles-init
	require minos2/opus-codec.fs
	previous
	' bye is net2o-bye
    [ELSE]
	begin-structure idx-head
	    4 +field idx-magic
	    cfield: idx-channels
	    cfield: idx-frames
	    wfield: idx-samples
	    8 +field idx-pos
	end-structure
	Variable idx-block
	Variable play-block
	1 Value channels
	
	: start-play ;
	: pause-play ;
	: resume-play ;
	: open-play 2drop 2drop ;
	: open-rec+ 2drop ;
	: close-rec-mono ;
	: close-rec-stereo ;
	scope: pulse
	#48000 Value sample-rate
	: record-mono ;
	}scope
    [THEN]
[THEN]

: be-l, ( l -- ) here be-l! 4 allot ;

Create audio-colors
$0000FF00 be-l, $0008F700 be-l, $0010EF00 be-l, $0018E700 be-l,
$0020DF00 be-l, $0029D600 be-l, $0031CE00 be-l, $0039C600 be-l,
................................................................................
    2swap +imgs 64#1 +to msg:timestamp click[] ;

Variable current-play$
Variable current-player

: >msg-audio-player ( addr u -- )
    2dup current-play$ $@ str= IF
	[IFDEF] android opensles:resume-play [ELSE] resume-play [THEN]
    ELSE
	2dup current-play$ $!  caller-w current-player !
	2dup key| ?read-enc-hashed idx-block $!
	keysize safe/string key| ?read-enc-hashed play-block $!
	start-play
    THEN ;

................................................................................
	THEN
	caller-w .text$ play$ $@ str=
	IF
	    addr data $@ ['] >msg-audio-player catch 0= IF
		pause$ $@ caller-w >o to text$ o> +sync
	    ELSE  2drop  THEN
	ELSE
	    [IFDEF] android opensles:pause-play [ELSE] pause-play [THEN]
	    play$ $@ caller-w >o to text$ o> +sync
	THEN  ;]
    2swap $make 64#1 +to msg:timestamp click[] ;

:noname ( addr u type -- )
    obj-red
    case
................................................................................
	    {{
		glue*l send-color x-color font-size# 40% f* }}frame dup .button2
		!i18n blackish l" Record" }}text' !lit 25%b /center
	    }}z box[] /flip dup to chat-record-button
	    [:  chat-record-button /flip drop
		chat-recording-button /flop drop +resize +sync +lang
		"recording" .net2o-cache/ open-rec+
		1 to channels
		[IFDEF] android
		    opensles:sample-rate ['] write-record opensles:record-mono
		[ELSE]
		    pulse:sample-rate pulse:record-mono
		[THEN]
	    ;] 0 click[]
	    {{
		glue*l recording-color# font-size# 40% f* }}frame dup .button3
		!i18n blackish l" Recording…" }}text' !lit 25%b /center
	    }}z box[] /flip dup to chat-recording-button
	    [:  chat-recording-button /flip drop
		chat-record-button /flop drop +resize +sync +lang