| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/Bindings/GainNodePrototype.h>
 | 
					
						
							| 
									
										
										
										
											2024-07-27 14:37:27 +03:00
										 |  |  | #include <LibWeb/WebAudio/AudioNode.h>
 | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::WebAudio { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://webaudio.github.io/web-audio-api/#GainOptions
 | 
					
						
							|  |  |  | struct GainOptions : AudioNodeOptions { | 
					
						
							|  |  |  |     float gain { 1.0 }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://webaudio.github.io/web-audio-api/#GainNode
 | 
					
						
							|  |  |  | class GainNode : public AudioNode { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(GainNode, AudioNode); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_DECLARE_ALLOCATOR(GainNode); | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual ~GainNode() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     static WebIDL::ExceptionOr<GC::Ref<GainNode>> create(JS::Realm&, GC::Ref<BaseAudioContext>, GainOptions const& = {}); | 
					
						
							|  |  |  |     static WebIDL::ExceptionOr<GC::Ref<GainNode>> construct_impl(JS::Realm&, GC::Ref<BaseAudioContext>, GainOptions const& = {}); | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-08 12:03:50 +02:00
										 |  |  |     WebIDL::UnsignedLong number_of_inputs() override { return 1; } | 
					
						
							|  |  |  |     WebIDL::UnsignedLong number_of_outputs() override { return 1; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ref<AudioParam const> gain() const { return m_gain; } | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GainNode(JS::Realm&, GC::Ref<BaseAudioContext>, GainOptions const& = {}); | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							|  |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     // https://webaudio.github.io/web-audio-api/#dom-gainnode-gain
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ref<AudioParam> m_gain; | 
					
						
							| 
									
										
										
										
											2024-05-28 15:42:07 +12:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |