webaudio.pas 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. Unit webaudio;
  2. {$MODE ObjFPC}
  3. {$H+}
  4. {$modeswitch externalclass}
  5. interface
  6. uses SysUtils, JS,web,types;
  7. {
  8. Automatically generated file by TWebIDLToPas on 2018-06-23 10:52:00
  9. Used command-line options :
  10. -i
  11. webaudio.idl
  12. -v
  13. v2
  14. -t
  15. EventTarget=TJSEventTarget,DOMHighResTimeStamp=TJSDOMHighResTimeStamp,HTMLMediaElement=TJSElement,MediaStream=JSValue,MediaStreamTrack=JSValue,EventHandler=TJSEVentHandler,Promise=TJSPromise,Event=TJSEvent,Worklet=TJSOBject,WorkletGlobalScope=TJSObject,VoidFunction=TProcedure,MessagePort=TJSMessagePort
  16. -x
  17. web,types
  18. -d
  19. -p
  20. Command-line options translate to:
  21. Options : [coDictionaryAsClass,coaddOptionsToheader]
  22. Keyword prefix :
  23. Keyword suffix : _
  24. Class prefix : TJS
  25. Class suffix :
  26. Field prefix : F
  27. WEBIDLversion : v2
  28. Type aliases:
  29. EventTarget=TJSEventTarget
  30. DOMHighResTimeStamp=TJSDOMHighResTimeStamp
  31. HTMLMediaElement=TJSElement
  32. MediaStream=JSValue
  33. MediaStreamTrack=JSValue
  34. EventHandler=TJSEVentHandler
  35. Promise=TJSPromise
  36. Event=TJSEvent
  37. Worklet=TJSOBject
  38. WorkletGlobalScope=TJSObject
  39. VoidFunction=TProcedure
  40. MessagePort=TJSMessagePort
  41. }
  42. Type
  43. // Forward class definitions
  44. TJSBaseAudioContext = Class;
  45. TJSAudioContext = Class;
  46. TJSOfflineAudioContext = Class;
  47. TJSOfflineAudioCompletionEvent = Class;
  48. TJSAudioBuffer = Class;
  49. TJSAudioNode = Class;
  50. TJSAudioParam = Class;
  51. TJSAudioScheduledSourceNode = Class;
  52. TJSAnalyserNode = Class;
  53. TJSAudioBufferSourceNode = Class;
  54. TJSAudioDestinationNode = Class;
  55. TJSAudioListener = Class;
  56. TJSAudioProcessingEvent = Class;
  57. TJSBiquadFilterNode = Class;
  58. TJSChannelMergerNode = Class;
  59. TJSChannelSplitterNode = Class;
  60. TJSConstantSourceNode = Class;
  61. TJSConvolverNode = Class;
  62. TJSDelayNode = Class;
  63. TJSDynamicsCompressorNode = Class;
  64. TJSGainNode = Class;
  65. TJSIIRFilterNode = Class;
  66. TJSMediaElementAudioSourceNode = Class;
  67. TJSMediaStreamAudioDestinationNode = Class;
  68. TJSMediaStreamAudioSourceNode = Class;
  69. TJSMediaStreamTrackAudioSourceNode = Class;
  70. TJSOscillatorNode = Class;
  71. TJSPannerNode = Class;
  72. TJSPeriodicWave = Class;
  73. TJSScriptProcessorNode = Class;
  74. TJSStereoPannerNode = Class;
  75. TJSWaveShaperNode = Class;
  76. TJSAudioWorklet = Class;
  77. TJSAudioWorkletGlobalScope = Class;
  78. TJSAudioParamMap = Class;
  79. TJSAudioWorkletNode = Class;
  80. TJSAudioWorkletProcessor = Class;
  81. TJSAudioContextOptions = Class;
  82. TJSAudioTimestamp = Class;
  83. TJSOfflineAudioContextOptions = Class;
  84. TJSOfflineAudioCompletionEventInit = Class;
  85. TJSAudioBufferOptions = Class;
  86. TJSAudioNodeOptions = Class;
  87. TJSAnalyserOptions = Class;
  88. TJSAudioBufferSourceOptions = Class;
  89. TJSAudioProcessingEventInit = Class;
  90. TJSBiquadFilterOptions = Class;
  91. TJSChannelMergerOptions = Class;
  92. TJSChannelSplitterOptions = Class;
  93. TJSConstantSourceOptions = Class;
  94. TJSConvolverOptions = Class;
  95. TJSDelayOptions = Class;
  96. TJSDynamicsCompressorOptions = Class;
  97. TJSGainOptions = Class;
  98. TJSIIRFilterOptions = Class;
  99. TJSMediaElementAudioSourceOptions = Class;
  100. TJSMediaStreamAudioSourceOptions = Class;
  101. TJSMediaStreamTrackAudioSourceOptions = Class;
  102. TJSOscillatorOptions = Class;
  103. TJSPannerOptions = Class;
  104. TJSPeriodicWaveConstraints = Class;
  105. TJSPeriodicWaveOptions = Class;
  106. TJSStereoPannerOptions = Class;
  107. TJSWaveShaperOptions = Class;
  108. TJSAudioWorkletNodeOptions = Class;
  109. TJSAudioParamDescriptor = Class;
  110. AudioContextState = String;
  111. AudioContextLatencyCategory = String;
  112. ChannelCountMode = String;
  113. ChannelInterpretation = String;
  114. AutomationRate = String;
  115. BiquadFilterType = String;
  116. OscillatorType = String;
  117. PanningModelType = String;
  118. DistanceModelType = String;
  119. OverSampleType = String;
  120. DecodeErrorCallback = Procedure (error : TJSError);
  121. DecodeSuccessCallback = Procedure (decodedData : TJSAudioBuffer);
  122. { --------------------------------------------------------------------
  123. TJSAudioContextOptions
  124. --------------------------------------------------------------------}
  125. TJSAudioContextOptions = class external name 'Object' (TJSObject)
  126. latencyHint : JSValue;
  127. sampleRate : Double;
  128. end;
  129. { --------------------------------------------------------------------
  130. TJSAudioTimestamp
  131. --------------------------------------------------------------------}
  132. TJSAudioTimestamp = class external name 'Object' (TJSObject)
  133. contextTime : Double;
  134. performanceTime : TJSDOMHighResTimeStamp;
  135. end;
  136. { --------------------------------------------------------------------
  137. TJSOfflineAudioContextOptions
  138. --------------------------------------------------------------------}
  139. TJSOfflineAudioContextOptions = class external name 'Object' (TJSObject)
  140. numberOfChannels : NativeInt;
  141. length_ : NativeInt;external name 'length';
  142. sampleRate : Double;
  143. end;
  144. { --------------------------------------------------------------------
  145. TJSOfflineAudioCompletionEventInit
  146. --------------------------------------------------------------------}
  147. TJSOfflineAudioCompletionEventInit = class external name 'Object' (TJSObject)
  148. renderedBuffer : TJSAudioBuffer;
  149. end;
  150. { --------------------------------------------------------------------
  151. TJSAudioBufferOptions
  152. --------------------------------------------------------------------}
  153. TJSAudioBufferOptions = class external name 'Object' (TJSObject)
  154. numberOfChannels : NativeInt;
  155. length_ : NativeInt;external name 'length';
  156. sampleRate : Double;
  157. end;
  158. { --------------------------------------------------------------------
  159. TJSAudioNodeOptions
  160. --------------------------------------------------------------------}
  161. TJSAudioNodeOptions = class external name 'Object' (TJSObject)
  162. channelCount : NativeInt;
  163. _channelCountMode : ChannelCountMode;external name 'channelCountMode';
  164. _channelInterpretation : ChannelInterpretation;external name 'channelInterpretation';
  165. end;
  166. { --------------------------------------------------------------------
  167. TJSAnalyserOptions
  168. --------------------------------------------------------------------}
  169. TJSAnalyserOptions = class external name 'Object' (TJSObject)
  170. fftSize : NativeInt;
  171. maxDecibels : Double;
  172. minDecibels : Double;
  173. smoothingTimeConstant : Double;
  174. end;
  175. { --------------------------------------------------------------------
  176. TJSAudioBufferSourceOptions
  177. --------------------------------------------------------------------}
  178. TJSAudioBufferSourceOptions = class external name 'Object' (TJSObject)
  179. buffer : TJSAudioBuffer;
  180. detune : Double;
  181. loop : boolean;
  182. loopEnd : Double;
  183. loopStart : Double;
  184. playbackRate : Double;
  185. end;
  186. { --------------------------------------------------------------------
  187. TJSAudioProcessingEventInit
  188. --------------------------------------------------------------------}
  189. TJSAudioProcessingEventInit = class external name 'Object' (TJSObject)
  190. playbackTime : Double;
  191. inputBuffer : TJSAudioBuffer;
  192. outputBuffer : TJSAudioBuffer;
  193. end;
  194. { --------------------------------------------------------------------
  195. TJSBiquadFilterOptions
  196. --------------------------------------------------------------------}
  197. TJSBiquadFilterOptions = class external name 'Object' (TJSObject)
  198. type_ : BiquadFilterType;external name 'type';
  199. Q : Double;
  200. detune : Double;
  201. frequency : Double;
  202. gain : Double;
  203. end;
  204. { --------------------------------------------------------------------
  205. TJSChannelMergerOptions
  206. --------------------------------------------------------------------}
  207. TJSChannelMergerOptions = class external name 'Object' (TJSObject)
  208. numberOfInputs : NativeInt;
  209. end;
  210. { --------------------------------------------------------------------
  211. TJSChannelSplitterOptions
  212. --------------------------------------------------------------------}
  213. TJSChannelSplitterOptions = class external name 'Object' (TJSObject)
  214. numberOfOutputs : NativeInt;
  215. end;
  216. { --------------------------------------------------------------------
  217. TJSConstantSourceOptions
  218. --------------------------------------------------------------------}
  219. TJSConstantSourceOptions = class external name 'Object' (TJSObject)
  220. offset : Double;
  221. end;
  222. { --------------------------------------------------------------------
  223. TJSConvolverOptions
  224. --------------------------------------------------------------------}
  225. TJSConvolverOptions = class external name 'Object' (TJSObject)
  226. buffer : TJSAudioBuffer;
  227. disableNormalization : boolean;
  228. end;
  229. { --------------------------------------------------------------------
  230. TJSDelayOptions
  231. --------------------------------------------------------------------}
  232. TJSDelayOptions = class external name 'Object' (TJSObject)
  233. maxDelayTime : Double;
  234. delayTime : Double;
  235. end;
  236. { --------------------------------------------------------------------
  237. TJSDynamicsCompressorOptions
  238. --------------------------------------------------------------------}
  239. TJSDynamicsCompressorOptions = class external name 'Object' (TJSObject)
  240. attack : Double;
  241. knee : Double;
  242. ratio : Double;
  243. release : Double;
  244. threshold : Double;
  245. end;
  246. { --------------------------------------------------------------------
  247. TJSGainOptions
  248. --------------------------------------------------------------------}
  249. TJSGainOptions = class external name 'Object' (TJSObject)
  250. gain : Double;
  251. end;
  252. { --------------------------------------------------------------------
  253. TJSIIRFilterOptions
  254. --------------------------------------------------------------------}
  255. TJSIIRFilterOptions = class external name 'Object' (TJSObject)
  256. feedforward : TDoubleDynArray;
  257. feedback : TDoubleDynArray;
  258. end;
  259. { --------------------------------------------------------------------
  260. TJSMediaElementAudioSourceOptions
  261. --------------------------------------------------------------------}
  262. TJSMediaElementAudioSourceOptions = class external name 'Object' (TJSObject)
  263. mediaElement : TJSElement;
  264. end;
  265. { --------------------------------------------------------------------
  266. TJSMediaStreamAudioSourceOptions
  267. --------------------------------------------------------------------}
  268. TJSMediaStreamAudioSourceOptions = class external name 'Object' (TJSObject)
  269. mediaStream : JSValue;
  270. end;
  271. { --------------------------------------------------------------------
  272. TJSMediaStreamTrackAudioSourceOptions
  273. --------------------------------------------------------------------}
  274. TJSMediaStreamTrackAudioSourceOptions = class external name 'Object' (TJSObject)
  275. mediaStreamTrack : JSValue;
  276. end;
  277. { --------------------------------------------------------------------
  278. TJSOscillatorOptions
  279. --------------------------------------------------------------------}
  280. TJSOscillatorOptions = class external name 'Object' (TJSObject)
  281. type_ : OscillatorType;external name 'type';
  282. frequency : Double;
  283. detune : Double;
  284. periodicWave : TJSPeriodicWave;
  285. end;
  286. { --------------------------------------------------------------------
  287. TJSPannerOptions
  288. --------------------------------------------------------------------}
  289. TJSPannerOptions = class external name 'Object' (TJSObject)
  290. panningModel : PanningModelType;
  291. distanceModel : DistanceModelType;
  292. positionX : Double;
  293. positionY : Double;
  294. positionZ : Double;
  295. orientationX : Double;
  296. orientationY : Double;
  297. orientationZ : Double;
  298. refDistance : Double;
  299. maxDistance : Double;
  300. rolloffFactor : Double;
  301. coneInnerAngle : Double;
  302. coneOuterAngle : Double;
  303. coneOuterGain : Double;
  304. end;
  305. { --------------------------------------------------------------------
  306. TJSPeriodicWaveConstraints
  307. --------------------------------------------------------------------}
  308. TJSPeriodicWaveConstraints = class external name 'Object' (TJSObject)
  309. disableNormalization : boolean;
  310. end;
  311. { --------------------------------------------------------------------
  312. TJSPeriodicWaveOptions
  313. --------------------------------------------------------------------}
  314. TJSPeriodicWaveOptions = class external name 'Object' (TJSObject)
  315. real : TDoubleDynArray;
  316. imag : TDoubleDynArray;
  317. end;
  318. { --------------------------------------------------------------------
  319. TJSStereoPannerOptions
  320. --------------------------------------------------------------------}
  321. TJSStereoPannerOptions = class external name 'Object' (TJSObject)
  322. pan : Double;
  323. end;
  324. { --------------------------------------------------------------------
  325. TJSWaveShaperOptions
  326. --------------------------------------------------------------------}
  327. TJSWaveShaperOptions = class external name 'Object' (TJSObject)
  328. curve : TDoubleDynArray;
  329. oversample : OverSampleType;
  330. end;
  331. { --------------------------------------------------------------------
  332. TJSAudioWorkletNodeOptions
  333. --------------------------------------------------------------------}
  334. TJSAudioWorkletNodeOptions = class external name 'Object' (TJSObject)
  335. numberOfInputs : NativeInt;
  336. numberOfOutputs : NativeInt;
  337. outputChannelCount : TNativeIntDynArray;
  338. parameterData : TJSObject;
  339. processorOptions : TJSObject;
  340. end;
  341. { --------------------------------------------------------------------
  342. TJSAudioParamDescriptor
  343. --------------------------------------------------------------------}
  344. TJSAudioParamDescriptor = class external name 'Object' (TJSObject)
  345. name : String;
  346. defaultValue : Double;
  347. minValue : Double;
  348. maxValue : Double;
  349. _automationRate : AutomationRate;external name 'automationRate';
  350. end;
  351. { --------------------------------------------------------------------
  352. TJSBaseAudioContext
  353. --------------------------------------------------------------------}
  354. TDoubleDynArray = Array of Double;
  355. TJSBaseAudioContext = class external name 'BaseAudioContext' (TJSEventTarget)
  356. Private
  357. Fdestination : TJSAudioDestinationNode; external name 'destination';
  358. FsampleRate : Double; external name 'sampleRate';
  359. FcurrentTime : Double; external name 'currentTime';
  360. Flistener : TJSAudioListener; external name 'listener';
  361. Fstate : AudioContextState; external name 'state';
  362. FaudioWorklet : TJSAudioWorklet; external name 'audioWorklet';
  363. Public
  364. onstatechange : TJSEVentHandler;
  365. function createAnalyser: TJSAnalyserNode;
  366. function createBiquadFilter: TJSBiquadFilterNode;
  367. function createBuffer(numberOfChannels : NativeInt; length_ : NativeInt; sampleRate : Double): TJSAudioBuffer;
  368. function createBufferSource: TJSAudioBufferSourceNode;
  369. function createChannelMerger(numberOfInputs : NativeInt): TJSChannelMergerNode; overload;
  370. function createChannelMerger: TJSChannelMergerNode; overload;
  371. function createChannelSplitter(numberOfOutputs : NativeInt): TJSChannelSplitterNode; overload;
  372. function createChannelSplitter: TJSChannelSplitterNode; overload;
  373. function createConstantSource: TJSConstantSourceNode;
  374. function createConvolver: TJSConvolverNode;
  375. function createDelay(maxDelayTime : Double): TJSDelayNode; overload;
  376. function createDelay: TJSDelayNode; overload;
  377. function createDynamicsCompressor: TJSDynamicsCompressorNode;
  378. function createGain: TJSGainNode;
  379. function createIIRFilter(feedforward : TDoubleDynArray; feedback : TDoubleDynArray): TJSIIRFilterNode;
  380. function createOscillator: TJSOscillatorNode;
  381. function createPanner: TJSPannerNode;
  382. function createPeriodicWave(real : TDoubleDynArray; imag : TDoubleDynArray; constraints : TJSPeriodicWaveConstraints): TJSPeriodicWave; overload;
  383. function createPeriodicWave(real : TDoubleDynArray; imag : TDoubleDynArray): TJSPeriodicWave; overload;
  384. function createScriptProcessor(bufferSize : NativeInt; numberOfInputChannels : NativeInt; numberOfOutputChannels : NativeInt): TJSScriptProcessorNode; overload;
  385. function createScriptProcessor: TJSScriptProcessorNode; overload;
  386. function createScriptProcessor(bufferSize : NativeInt): TJSScriptProcessorNode; overload;
  387. function createScriptProcessor(bufferSize : NativeInt; numberOfInputChannels : NativeInt): TJSScriptProcessorNode; overload;
  388. function createStereoPanner: TJSStereoPannerNode;
  389. function createWaveShaper: TJSWaveShaperNode;
  390. function decodeAudioData(audioData : TJSArrayBuffer; successCallback : DecodeSuccessCallback; errorCallback : DecodeErrorCallback): TJSPromise; overload;
  391. function decodeAudioData(audioData : TJSArrayBuffer): TJSPromise; overload;
  392. function decodeAudioData(audioData : TJSArrayBuffer; successCallback : DecodeSuccessCallback): TJSPromise; overload;
  393. function resume: TJSPromise;
  394. Property destination : TJSAudioDestinationNode Read Fdestination;
  395. Property sampleRate : Double Read FsampleRate;
  396. Property currentTime : Double Read FcurrentTime;
  397. Property listener : TJSAudioListener Read Flistener;
  398. Property state : AudioContextState Read Fstate;
  399. Property audioWorklet : TJSAudioWorklet Read FaudioWorklet;
  400. end;
  401. { --------------------------------------------------------------------
  402. TJSAudioContext
  403. --------------------------------------------------------------------}
  404. TJSAudioContext = class external name 'AudioContext' (TJSBaseAudioContext)
  405. Private
  406. FbaseLatency : Double; external name 'baseLatency';
  407. FoutputLatency : Double; external name 'outputLatency';
  408. Public
  409. function getOutputTimestamp: TJSAudioTimestamp;
  410. function suspend: TJSPromise;
  411. function close: TJSPromise;
  412. function createMediaElementSource(mediaElement : TJSElement): TJSMediaElementAudioSourceNode;
  413. function createMediaStreamSource(mediaStream : JSValue): TJSMediaStreamAudioSourceNode;
  414. function createMediaStreamTrackSource(mediaStreamTrack : JSValue): TJSMediaStreamTrackAudioSourceNode;
  415. function createMediaStreamDestination: TJSMediaStreamAudioDestinationNode;
  416. Property baseLatency : Double Read FbaseLatency;
  417. Property outputLatency : Double Read FoutputLatency;
  418. end;
  419. { --------------------------------------------------------------------
  420. TJSOfflineAudioContext
  421. --------------------------------------------------------------------}
  422. TJSOfflineAudioContext = class external name 'OfflineAudioContext' (TJSBaseAudioContext)
  423. Private
  424. Flength_ : NativeInt; external name 'length';
  425. Public
  426. oncomplete : TJSEVentHandler;
  427. function startRendering: TJSPromise;
  428. function suspend(suspendTime : Double): TJSPromise;
  429. Property length_ : NativeInt Read Flength_;
  430. end;
  431. { --------------------------------------------------------------------
  432. TJSOfflineAudioCompletionEvent
  433. --------------------------------------------------------------------}
  434. TJSOfflineAudioCompletionEvent = class external name 'OfflineAudioCompletionEvent' (TJSEvent)
  435. Private
  436. FrenderedBuffer : TJSAudioBuffer; external name 'renderedBuffer';
  437. Public
  438. Property renderedBuffer : TJSAudioBuffer Read FrenderedBuffer;
  439. end;
  440. { --------------------------------------------------------------------
  441. TJSAudioBuffer
  442. --------------------------------------------------------------------}
  443. TJSAudioBuffer = class external name 'AudioBuffer'
  444. Private
  445. FsampleRate : Double; external name 'sampleRate';
  446. Flength_ : NativeInt; external name 'length';
  447. Fduration : Double; external name 'duration';
  448. FnumberOfChannels : NativeInt; external name 'numberOfChannels';
  449. Public
  450. function getChannelData(channel : NativeInt): TJSFloat32Array;
  451. Procedure copyFromChannel(destination : TJSFloat32Array; channelNumber : NativeInt; startInChannel : NativeInt); overload;
  452. Procedure copyFromChannel(destination : TJSFloat32Array; channelNumber : NativeInt); overload;
  453. Procedure copyToChannel(source : TJSFloat32Array; channelNumber : NativeInt; startInChannel : NativeInt); overload;
  454. Procedure copyToChannel(source : TJSFloat32Array; channelNumber : NativeInt); overload;
  455. Property sampleRate : Double Read FsampleRate;
  456. Property length_ : NativeInt Read Flength_;
  457. Property duration : Double Read Fduration;
  458. Property numberOfChannels : NativeInt Read FnumberOfChannels;
  459. end;
  460. { --------------------------------------------------------------------
  461. TJSAudioNode
  462. --------------------------------------------------------------------}
  463. TJSAudioNode = class external name 'AudioNode' (TJSEventTarget)
  464. Private
  465. Fcontext : TJSBaseAudioContext; external name 'context';
  466. FnumberOfInputs : NativeInt; external name 'numberOfInputs';
  467. FnumberOfOutputs : NativeInt; external name 'numberOfOutputs';
  468. Public
  469. channelCount : NativeInt;
  470. _channelCountMode : ChannelCountMode;external name 'channelCountMode';
  471. _channelInterpretation : ChannelInterpretation;external name 'channelInterpretation';
  472. function connect(destinationNode : TJSAudioNode; output : NativeInt; input : NativeInt): TJSAudioNode; overload;
  473. function connect(destinationNode : TJSAudioNode): TJSAudioNode; overload;
  474. function connect(destinationNode : TJSAudioNode; output : NativeInt): TJSAudioNode; overload;
  475. Procedure connect(destinationParam : TJSAudioParam; output : NativeInt); overload;
  476. Procedure connect(destinationParam : TJSAudioParam); overload;
  477. Procedure disconnect;
  478. Procedure disconnect(output : NativeInt);
  479. Procedure disconnect(destinationNode : TJSAudioNode);
  480. Procedure disconnect(destinationNode : TJSAudioNode; output : NativeInt);
  481. Procedure disconnect(destinationNode : TJSAudioNode; output : NativeInt; input : NativeInt);
  482. Procedure disconnect(destinationParam : TJSAudioParam);
  483. Procedure disconnect(destinationParam : TJSAudioParam; output : NativeInt);
  484. Property context : TJSBaseAudioContext Read Fcontext;
  485. Property numberOfInputs : NativeInt Read FnumberOfInputs;
  486. Property numberOfOutputs : NativeInt Read FnumberOfOutputs;
  487. end;
  488. { --------------------------------------------------------------------
  489. TJSAudioParam
  490. --------------------------------------------------------------------}
  491. TJSAudioParam = class external name 'AudioParam'
  492. Private
  493. FdefaultValue : Double; external name 'defaultValue';
  494. FminValue : Double; external name 'minValue';
  495. FmaxValue : Double; external name 'maxValue';
  496. Public
  497. value : Double;
  498. _automationRate : AutomationRate;external name 'automationRate';
  499. function setValueAtTime(value : Double; startTime : Double): TJSAudioParam;
  500. function linearRampToValueAtTime(value : Double; endTime : Double): TJSAudioParam;
  501. function exponentialRampToValueAtTime(value : Double; endTime : Double): TJSAudioParam;
  502. function setTargetAtTime(target : Double; startTime : Double; timeConstant : Double): TJSAudioParam;
  503. function setValueCurveAtTime(values : TDoubleDynArray; startTime : Double; duration : Double): TJSAudioParam;
  504. function cancelScheduledValues(cancelTime : Double): TJSAudioParam;
  505. function cancelAndHoldAtTime(cancelTime : Double): TJSAudioParam;
  506. Property defaultValue : Double Read FdefaultValue;
  507. Property minValue : Double Read FminValue;
  508. Property maxValue : Double Read FmaxValue;
  509. end;
  510. { --------------------------------------------------------------------
  511. TJSAudioScheduledSourceNode
  512. --------------------------------------------------------------------}
  513. TJSAudioScheduledSourceNode = class external name 'AudioScheduledSourceNode' (TJSAudioNode)
  514. Private
  515. Public
  516. onended : TJSEVentHandler;
  517. Procedure start(when : Double); overload;
  518. Procedure start; overload;
  519. Procedure stop(when : Double); overload;
  520. Procedure stop; overload;
  521. end;
  522. { --------------------------------------------------------------------
  523. TJSAnalyserNode
  524. --------------------------------------------------------------------}
  525. TJSAnalyserNode = class external name 'AnalyserNode' (TJSAudioNode)
  526. Private
  527. FfrequencyBinCount : NativeInt; external name 'frequencyBinCount';
  528. Public
  529. fftSize : NativeInt;
  530. minDecibels : Double;
  531. maxDecibels : Double;
  532. smoothingTimeConstant : Double;
  533. Procedure getFloatFrequencyData(array_ : TJSFloat32Array);
  534. Procedure getByteFrequencyData(array_ : TJSUint8Array);
  535. Procedure getFloatTimeDomainData(array_ : TJSFloat32Array);
  536. Procedure getByteTimeDomainData(array_ : TJSUint8Array);
  537. Property frequencyBinCount : NativeInt Read FfrequencyBinCount;
  538. end;
  539. { --------------------------------------------------------------------
  540. TJSAudioBufferSourceNode
  541. --------------------------------------------------------------------}
  542. TJSAudioBufferSourceNode = class external name 'AudioBufferSourceNode' (TJSAudioScheduledSourceNode)
  543. Private
  544. FplaybackRate : TJSAudioParam; external name 'playbackRate';
  545. Fdetune : TJSAudioParam; external name 'detune';
  546. Public
  547. buffer : TJSAudioBuffer;
  548. loop : boolean;
  549. loopStart : Double;
  550. loopEnd : Double;
  551. Procedure start(when : Double; offset : Double; duration : Double); overload;
  552. Procedure start; overload;
  553. Procedure start(when : Double); overload;
  554. Procedure start(when : Double; offset : Double); overload;
  555. Property playbackRate : TJSAudioParam Read FplaybackRate;
  556. Property detune : TJSAudioParam Read Fdetune;
  557. end;
  558. { --------------------------------------------------------------------
  559. TJSAudioDestinationNode
  560. --------------------------------------------------------------------}
  561. TJSAudioDestinationNode = class external name 'AudioDestinationNode' (TJSAudioNode)
  562. Private
  563. FmaxChannelCount : NativeInt; external name 'maxChannelCount';
  564. Public
  565. Property maxChannelCount : NativeInt Read FmaxChannelCount;
  566. end;
  567. { --------------------------------------------------------------------
  568. TJSAudioListener
  569. --------------------------------------------------------------------}
  570. TJSAudioListener = class external name 'AudioListener'
  571. Private
  572. FpositionX : TJSAudioParam; external name 'positionX';
  573. FpositionY : TJSAudioParam; external name 'positionY';
  574. FpositionZ : TJSAudioParam; external name 'positionZ';
  575. FforwardX : TJSAudioParam; external name 'forwardX';
  576. FforwardY : TJSAudioParam; external name 'forwardY';
  577. FforwardZ : TJSAudioParam; external name 'forwardZ';
  578. FupX : TJSAudioParam; external name 'upX';
  579. FupY : TJSAudioParam; external name 'upY';
  580. FupZ : TJSAudioParam; external name 'upZ';
  581. Public
  582. Procedure setPosition(x : Double; y : Double; z : Double);
  583. Procedure setOrientation(x : Double; y : Double; z : Double; xUp : Double; yUp : Double; zUp : Double);
  584. Property positionX : TJSAudioParam Read FpositionX;
  585. Property positionY : TJSAudioParam Read FpositionY;
  586. Property positionZ : TJSAudioParam Read FpositionZ;
  587. Property forwardX : TJSAudioParam Read FforwardX;
  588. Property forwardY : TJSAudioParam Read FforwardY;
  589. Property forwardZ : TJSAudioParam Read FforwardZ;
  590. Property upX : TJSAudioParam Read FupX;
  591. Property upY : TJSAudioParam Read FupY;
  592. Property upZ : TJSAudioParam Read FupZ;
  593. end;
  594. { --------------------------------------------------------------------
  595. TJSAudioProcessingEvent
  596. --------------------------------------------------------------------}
  597. TJSAudioProcessingEvent = class external name 'AudioProcessingEvent' (TJSEvent)
  598. Private
  599. FplaybackTime : Double; external name 'playbackTime';
  600. FinputBuffer : TJSAudioBuffer; external name 'inputBuffer';
  601. FoutputBuffer : TJSAudioBuffer; external name 'outputBuffer';
  602. Public
  603. Property playbackTime : Double Read FplaybackTime;
  604. Property inputBuffer : TJSAudioBuffer Read FinputBuffer;
  605. Property outputBuffer : TJSAudioBuffer Read FoutputBuffer;
  606. end;
  607. { --------------------------------------------------------------------
  608. TJSBiquadFilterNode
  609. --------------------------------------------------------------------}
  610. TJSBiquadFilterNode = class external name 'BiquadFilterNode' (TJSAudioNode)
  611. Private
  612. Ffrequency : TJSAudioParam; external name 'frequency';
  613. Fdetune : TJSAudioParam; external name 'detune';
  614. FQ : TJSAudioParam; external name 'Q';
  615. Fgain : TJSAudioParam; external name 'gain';
  616. Public
  617. type_ : BiquadFilterType;external name 'type';
  618. Procedure getFrequencyResponse(frequencyHz : TJSFloat32Array; magResponse : TJSFloat32Array; phaseResponse : TJSFloat32Array);
  619. Property frequency : TJSAudioParam Read Ffrequency;
  620. Property detune : TJSAudioParam Read Fdetune;
  621. Property Q : TJSAudioParam Read FQ;
  622. Property gain : TJSAudioParam Read Fgain;
  623. end;
  624. { --------------------------------------------------------------------
  625. TJSChannelMergerNode
  626. --------------------------------------------------------------------}
  627. TJSChannelMergerNode = class external name 'ChannelMergerNode' (TJSAudioNode)
  628. Private
  629. Public
  630. end;
  631. { --------------------------------------------------------------------
  632. TJSChannelSplitterNode
  633. --------------------------------------------------------------------}
  634. TJSChannelSplitterNode = class external name 'ChannelSplitterNode' (TJSAudioNode)
  635. Private
  636. Public
  637. end;
  638. { --------------------------------------------------------------------
  639. TJSConstantSourceNode
  640. --------------------------------------------------------------------}
  641. TJSConstantSourceNode = class external name 'ConstantSourceNode' (TJSAudioScheduledSourceNode)
  642. Private
  643. Foffset : TJSAudioParam; external name 'offset';
  644. Public
  645. Property offset : TJSAudioParam Read Foffset;
  646. end;
  647. { --------------------------------------------------------------------
  648. TJSConvolverNode
  649. --------------------------------------------------------------------}
  650. TJSConvolverNode = class external name 'ConvolverNode' (TJSAudioNode)
  651. Private
  652. Public
  653. buffer : TJSAudioBuffer;
  654. normalize : boolean;
  655. end;
  656. { --------------------------------------------------------------------
  657. TJSDelayNode
  658. --------------------------------------------------------------------}
  659. TJSDelayNode = class external name 'DelayNode' (TJSAudioNode)
  660. Private
  661. FdelayTime : TJSAudioParam; external name 'delayTime';
  662. Public
  663. Property delayTime : TJSAudioParam Read FdelayTime;
  664. end;
  665. { --------------------------------------------------------------------
  666. TJSDynamicsCompressorNode
  667. --------------------------------------------------------------------}
  668. TJSDynamicsCompressorNode = class external name 'DynamicsCompressorNode' (TJSAudioNode)
  669. Private
  670. Fthreshold : TJSAudioParam; external name 'threshold';
  671. Fknee : TJSAudioParam; external name 'knee';
  672. Fratio : TJSAudioParam; external name 'ratio';
  673. Freduction : Double; external name 'reduction';
  674. Fattack : TJSAudioParam; external name 'attack';
  675. Frelease : TJSAudioParam; external name 'release';
  676. Public
  677. Property threshold : TJSAudioParam Read Fthreshold;
  678. Property knee : TJSAudioParam Read Fknee;
  679. Property ratio : TJSAudioParam Read Fratio;
  680. Property reduction : Double Read Freduction;
  681. Property attack : TJSAudioParam Read Fattack;
  682. Property release : TJSAudioParam Read Frelease;
  683. end;
  684. { --------------------------------------------------------------------
  685. TJSGainNode
  686. --------------------------------------------------------------------}
  687. TJSGainNode = class external name 'GainNode' (TJSAudioNode)
  688. Private
  689. Fgain : TJSAudioParam; external name 'gain';
  690. Public
  691. Property gain : TJSAudioParam Read Fgain;
  692. end;
  693. { --------------------------------------------------------------------
  694. TJSIIRFilterNode
  695. --------------------------------------------------------------------}
  696. TJSIIRFilterNode = class external name 'IIRFilterNode' (TJSAudioNode)
  697. Private
  698. Public
  699. Procedure getFrequencyResponse(frequencyHz : TJSFloat32Array; magResponse : TJSFloat32Array; phaseResponse : TJSFloat32Array);
  700. end;
  701. { --------------------------------------------------------------------
  702. TJSMediaElementAudioSourceNode
  703. --------------------------------------------------------------------}
  704. TJSMediaElementAudioSourceNode = class external name 'MediaElementAudioSourceNode' (TJSAudioNode)
  705. Private
  706. FmediaElement : TJSElement; external name 'mediaElement';
  707. Public
  708. Property mediaElement : TJSElement Read FmediaElement;
  709. end;
  710. { --------------------------------------------------------------------
  711. TJSMediaStreamAudioDestinationNode
  712. --------------------------------------------------------------------}
  713. TJSMediaStreamAudioDestinationNode = class external name 'MediaStreamAudioDestinationNode' (TJSAudioNode)
  714. Private
  715. Fstream : JSValue; external name 'stream';
  716. Public
  717. Property stream : JSValue Read Fstream;
  718. end;
  719. { --------------------------------------------------------------------
  720. TJSMediaStreamAudioSourceNode
  721. --------------------------------------------------------------------}
  722. TJSMediaStreamAudioSourceNode = class external name 'MediaStreamAudioSourceNode' (TJSAudioNode)
  723. Private
  724. FmediaStream : JSValue; external name 'mediaStream';
  725. Public
  726. Property mediaStream : JSValue Read FmediaStream;
  727. end;
  728. { --------------------------------------------------------------------
  729. TJSMediaStreamTrackAudioSourceNode
  730. --------------------------------------------------------------------}
  731. TJSMediaStreamTrackAudioSourceNode = class external name 'MediaStreamTrackAudioSourceNode' (TJSAudioNode)
  732. Private
  733. Public
  734. end;
  735. { --------------------------------------------------------------------
  736. TJSOscillatorNode
  737. --------------------------------------------------------------------}
  738. TJSOscillatorNode = class external name 'OscillatorNode' (TJSAudioScheduledSourceNode)
  739. Private
  740. Ffrequency : TJSAudioParam; external name 'frequency';
  741. Fdetune : TJSAudioParam; external name 'detune';
  742. Public
  743. type_ : OscillatorType;external name 'type';
  744. Procedure setPeriodicWave(periodicWave : TJSPeriodicWave);
  745. Property frequency : TJSAudioParam Read Ffrequency;
  746. Property detune : TJSAudioParam Read Fdetune;
  747. end;
  748. { --------------------------------------------------------------------
  749. TJSPannerNode
  750. --------------------------------------------------------------------}
  751. TJSPannerNode = class external name 'PannerNode' (TJSAudioNode)
  752. Private
  753. FpositionX : TJSAudioParam; external name 'positionX';
  754. FpositionY : TJSAudioParam; external name 'positionY';
  755. FpositionZ : TJSAudioParam; external name 'positionZ';
  756. ForientationX : TJSAudioParam; external name 'orientationX';
  757. ForientationY : TJSAudioParam; external name 'orientationY';
  758. ForientationZ : TJSAudioParam; external name 'orientationZ';
  759. Public
  760. panningModel : PanningModelType;
  761. distanceModel : DistanceModelType;
  762. refDistance : Double;
  763. maxDistance : Double;
  764. rolloffFactor : Double;
  765. coneInnerAngle : Double;
  766. coneOuterAngle : Double;
  767. coneOuterGain : Double;
  768. Procedure setPosition(x : Double; y : Double; z : Double);
  769. Procedure setOrientation(x : Double; y : Double; z : Double);
  770. Property positionX : TJSAudioParam Read FpositionX;
  771. Property positionY : TJSAudioParam Read FpositionY;
  772. Property positionZ : TJSAudioParam Read FpositionZ;
  773. Property orientationX : TJSAudioParam Read ForientationX;
  774. Property orientationY : TJSAudioParam Read ForientationY;
  775. Property orientationZ : TJSAudioParam Read ForientationZ;
  776. end;
  777. { --------------------------------------------------------------------
  778. TJSPeriodicWave
  779. --------------------------------------------------------------------}
  780. TJSPeriodicWave = class external name 'PeriodicWave'
  781. Private
  782. Public
  783. end;
  784. { --------------------------------------------------------------------
  785. TJSScriptProcessorNode
  786. --------------------------------------------------------------------}
  787. TJSScriptProcessorNode = class external name 'ScriptProcessorNode' (TJSAudioNode)
  788. Private
  789. FbufferSize : Integer; external name 'bufferSize';
  790. Public
  791. onaudioprocess : TJSEVentHandler;
  792. Property bufferSize : Integer Read FbufferSize;
  793. end;
  794. { --------------------------------------------------------------------
  795. TJSStereoPannerNode
  796. --------------------------------------------------------------------}
  797. TJSStereoPannerNode = class external name 'StereoPannerNode' (TJSAudioNode)
  798. Private
  799. Fpan : TJSAudioParam; external name 'pan';
  800. Public
  801. Property pan : TJSAudioParam Read Fpan;
  802. end;
  803. { --------------------------------------------------------------------
  804. TJSWaveShaperNode
  805. --------------------------------------------------------------------}
  806. TJSWaveShaperNode = class external name 'WaveShaperNode' (TJSAudioNode)
  807. Private
  808. Public
  809. curve : TJSFloat32Array;
  810. oversample : OverSampleType;
  811. end;
  812. { --------------------------------------------------------------------
  813. TJSAudioWorklet
  814. --------------------------------------------------------------------}
  815. TJSAudioWorklet = class external name 'AudioWorklet' (TJSOBject)
  816. Private
  817. Public
  818. end;
  819. { --------------------------------------------------------------------
  820. TJSAudioWorkletGlobalScope
  821. --------------------------------------------------------------------}
  822. TJSAudioWorkletGlobalScope = class external name 'AudioWorkletGlobalScope' (TJSObject)
  823. Private
  824. FcurrentFrame : NativeInt; external name 'currentFrame';
  825. FcurrentTime : Double; external name 'currentTime';
  826. FsampleRate : Double; external name 'sampleRate';
  827. Public
  828. Procedure registerProcessor(name : String; processorCtor : TProcedure);
  829. Property currentFrame : NativeInt Read FcurrentFrame;
  830. Property currentTime : Double Read FcurrentTime;
  831. Property sampleRate : Double Read FsampleRate;
  832. end;
  833. { --------------------------------------------------------------------
  834. TJSAudioParamMap
  835. --------------------------------------------------------------------}
  836. TJSAudioParamMap = class external name 'AudioParamMap'
  837. Private
  838. Public
  839. end;
  840. { --------------------------------------------------------------------
  841. TJSAudioWorkletNode
  842. --------------------------------------------------------------------}
  843. TJSAudioWorkletNode = class external name 'AudioWorkletNode' (TJSAudioNode)
  844. Private
  845. Fparameters : TJSAudioParamMap; external name 'parameters';
  846. Fport : TJSMessagePort; external name 'port';
  847. Public
  848. onprocessorerror : TJSEVentHandler;
  849. Property parameters : TJSAudioParamMap Read Fparameters;
  850. Property port : TJSMessagePort Read Fport;
  851. end;
  852. { --------------------------------------------------------------------
  853. TJSAudioWorkletProcessor
  854. --------------------------------------------------------------------}
  855. TJSAudioWorkletProcessor = class external name 'AudioWorkletProcessor'
  856. Private
  857. Fport : TJSMessagePort; external name 'port';
  858. Public
  859. Property port : TJSMessagePort Read Fport;
  860. end;
  861. implementation
  862. end.