@@ -222,6 +222,91 @@ AudioWrapperBox[a_Audio, StandardForm] := With[{
222222 ]
223223]
224224
225+ AudioWrapperBox [a_ Audio , WLXForm ] := With [{
226+ options = < |SampleRate -> QuantityMagnitude [ Information [a ]["SampleRate" ] ] |> ,
227+ data = extractChannelTyped [a , "SignedInteger16" ],
228+ uid = CreateUUID []
229+ },
230+
231+ If [ByteCount [data ] > Internal ` Kernel ` $FrontEndObjectSizeLimit 1024 1024 / 8.0 ,
232+ LeakyModule [{
233+ bigBuffer , index = 1 , buffer , paused = False
234+ },
235+ AppendTo [garbage , Hold [buffer ] ];
236+ AppendTo [garbage , Hold [bigBuffer ] ];
237+
238+ bigBuffer = NumericArray [data , "SignedInteger16" ];
239+
240+ ClearAttributes [bigBuffer , Temporary ];
241+ ClearAttributes [buffer , Temporary ];
242+
243+ buffer = {};
244+
245+ EventHandler [uid , {
246+
247+ "More" -> Function [Null ,
248+ If [paused , Return [] ];
249+
250+ With [{
251+ newIndex = Min [index + 3 1024 , Length [bigBuffer ] ],
252+ from = index ,
253+ to = Min [Length [bigBuffer ], index + 3 1024 - 1 ]
254+ },
255+ buffer = bigBuffer [[from ;; to ]];
256+ If [index == newIndex ,
257+ paused = True ;
258+ index = 1 ;
259+ Return [];
260+ ];
261+ index = newIndex ;
262+ ]
263+ ],
264+
265+ "Stop" -> Function [Null ,
266+ index = 1 ;
267+ paused = True ;
268+ ],
269+
270+ "Pause" -> Function [Null ,
271+ paused = True ;
272+ ],
273+
274+ "Resume" -> Function [Null ,
275+ paused = False ;
276+ EventFire [uid , "More" , True ];
277+ ],
278+
279+ "Set" -> Function [position ,
280+ index = Max [1 , Floor [Length [bigBuffer ] position ] ];
281+ ]
282+ }];
283+
284+
285+ With [{o = PCMPlayer [buffer // Offload , {}, "SignedInteger16" , "AutoPlay" -> False , "DataOnKernel" -> True , "Event" -> uid , "FullLength" -> Length [bigBuffer ], SampleRate -> options [SampleRate ] ]},
286+ MakeBoxes [o , WLXForm ]
287+ ]
288+ ]
289+ ,
290+
291+ With [{},
292+ Module [{},
293+
294+ With [{virtualBuffer = CreateFrontEndObject [data ] },
295+ With [{result = With [{o = CreateFrontEndObject [PCMPlayer [virtualBuffer , "SignedInteger16" , "AutoPlay" -> False , SampleRate -> options [SampleRate ] ] ]},
296+ o
297+ ] },
298+
299+
300+ MakeBoxes [result , WLXForm ]
301+ ]
302+ ]
303+ ]
304+
305+ ]
306+
307+
308+ ]
309+ ]
225310
226311(* WL14 with no reason reloads the definitons of some symbols *)
227312(* It breaks ANY FormatValues *)
0 commit comments