Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Missing Audio Nodes #1417

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

Palmer-JC
Copy link
Contributor

I wanted to get the first node, Dynamics Compressor, as a template for the others. I compiles, but has linker problems. Probably missed a spot in the related files that need changing. Here is console message:

 Creating library C:\exokit\build\Release\exokit.lib and object C:\exokit\build\Release\exokit.exp                                                                                                                                                                                                                       
AudioContext.obj : error LNK2001: unresolved external symbol "public: class v8::Local<class v8::Object> __cdecl webaudio::AudioContext::CreateDynamicsCompressor(class v8::Local<class v8::Function>,class v8::Local<class v8::Object>)" (?CreateDynamicsCompressor@AudioContext@webaudio@@QEAA?AV?$Local@VObject@v8@@@v8@@V?
$Local@VFunction@v8@@@4@V34@@Z) [C:\exokit\build\exokit.vcxproj]                                                                                                                                                                                                                                                             
C:\exokit\build\Release\exokit.node : fatal error LNK1120: 1 unresolved externals [C:\exokit\build\exokit.vcxproj]                                                                                                                                                                                                           

@avaer
Copy link
Member

avaer commented Nov 27, 2019

It looks like this method was not implemented?

@Palmer-JC
Copy link
Contributor Author

got it. Biquad filter coming before eod.

- linker problem with DynamicsCompressor fixed, and constructor runs
with success

- BiquadFilter.GetFrequencyResponse() still needs to make call to labsound level

- Constructor fails with
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: 00007FF729CFD50A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4618
 2: 00007FF729CA4F86 uv_loop_fork+79446
 3: 00007FF729CA5C21 uv_loop_fork+82673
 4: 00007FF72A1AF8C6 v8::V8::ToLocalEmpty+54
 5: 00007FFCF5598282 webaudio::AudioContext::CreateBiquadFilter+386 [c:\exokit\deps\exokit-bindings\webaudiocontext\src\audiocontext.cpp]:L355
@avaer
Copy link
Member

avaer commented Nov 28, 2019

Awesome, is this ready for review?

@Palmer-JC
Copy link
Contributor Author

Back after a few days off. Only the Dynamics compressor is. I left off with the Biquad Filter erroring, see its commit for msg.

Going to add Convolver today hopefully.

- Have not tried running convolver constructor yet.
- Biquad Filter contructor now runs, however this code:
      const filter = audioContext.createBiquadFilter();
      filter.frequency.setTargetAtTime(1024,0,0.0001);
  results in saying cannot call setTargetAtTime of undefined
@Palmer-JC Palmer-JC changed the title Dynamics Compressor Node Adding Missing Audio Nodes Nov 30, 2019
- fix previously added biquad filter node
- delay node from lab sound has an additional parameter than in Web
Audio
- testing on delay node has not yet occurred
@Palmer-JC
Copy link
Contributor Author

Ok, Delay node has also been added in addition to dynamics Compressor, Biquad filter, & convolver nodes. Both Delay & convolver have yet to be tried to run. The Biquad filter is now able to set its audio params.

Plan to still add Channel Merger & Channel Splitter nodes before beginning tests which actually generate sounds.

- Also BiquadFilterNode::GetFrequencyResponse()
- Switched the order of arguments for Delay Node
@Palmer-JC
Copy link
Contributor Author

Alright, all the Nodes are there which LabSound supports, & ready for testing / review. So far, the Dynamics Compressor & Biquad filter have been run & settings to their params performed. I have finished the complex BiquadFilterNode::GetFrequencyResponse(), which takes & updates 3 Float32Arrays. It has not been tried.

One note about the Delay node. In webaudio, it takes a max delay time (default 1), where as LabSound takes (float sampleRate, double maxDelayTime). I kept the first arg the max delay. If no 2nd arg is supplied use the sample rate of the context.

Tomorrow, will start running code which exercises by using examples in mozilla. Cannot run my stack yet, since this requires other fixes like missing context.decodeAudioData() & playbackRate missing from buffer source. Not sure if you want these right now too.

@Palmer-JC
Copy link
Contributor Author

Added a test file, which goes through all the Node types, does the create & sets all the values methods. It writes the results to the console. Here is what is produced right now on Exokit:

current times initial setting 0               
analyser created                              
biquad filter created                         
channel merger created                        
channel splitter created                      
constant source FAILED!                       
convolver created                             
dynamics compressor created                   
gain created                                  
oscillator created                            
panner created                                
script processor created                      
stereo panner created                         
wave shaper FAILED!                           
=====================                         
Param method Tests                            
                                              
setValueAtTime FAILED!                        
linearRampToValueAtTime FAILED!               
exponentialRampToValueAtTime FAILED!          
setTargetAtTime FAILED!                       
setValueCurveAtTime FAILED!                   
cancelScheduledValues worked                  
cancelAndHoldAtTime worked                    
current times final setting 2.0085260770975055

ConstantSource & Wave Shaper fail because there is no implementation. Not a priority, but wanted the test to have them.

Delay is commented out right now as it the program to cease.

None of the Param methods do not do anything. The cancel methods say they passed, but that is just because the method I use to test does not do anything, so it looks like it blocked it. This definitely needs looking at. The tests also fail in Chrome, but pass in FireFox & Edge.

There is also a short "Exokit rules!" spoken with a reverb echo using a convolver node. It has reverb when I run it in Firefox & Edge. Chrome gives me a message saying it was not allowed to start cause no clicks. Maybe that is why the Params also failed.

In exokit, you hear it but there is no reverb.

@Palmer-JC
Copy link
Contributor Author

Did some more by adding a dynamics compressor into the test speech graft. The sample still played.

More bad news however. If you push the playback to begin into the future, it still plays immediately. Effectively there is no queuing.

@avaer
Copy link
Member

avaer commented Dec 6, 2019

Hm, I think LabSound does support delayed playing in its nodes...

@Palmer-JC
Copy link
Contributor Author

Their code sure has spots for it. This sort of goes with all the Param methods, which essentially set the value member in the future, except these never seem to anything.

I started looking at their example code, and have not come across anywhere a Param method was called.

@avaer
Copy link
Member

avaer commented Dec 6, 2019

IIRC those parameter changes are processed on a change posted to the audio thread at a later point. It could be that this audio thread isn't being updated.

@Palmer-JC
Copy link
Contributor Author

I wonder about seeing what happens with an off line context? At first, it was just a contingency, but it clearly does not work in the same way.

@avaer
Copy link
Member

avaer commented Dec 7, 2019

Is Offline context done differently? As far as I know the main audio processing is exactly the same, the only difference being the destination node that pulls data.

@Palmer-JC
Copy link
Contributor Author

Well time would be different anyway, though now that I think about it context.currentTime could just be updated differently.

One I just noticed comparing AudioContext.h from currently in LabSound & exokit, is in the current Lab version (left), they have added methods for dispatching events manually. I wonder if stuff has been done in this area, since you cloned?
hFileCompare

@Palmer-JC
Copy link
Contributor Author

Think I found the starting in the future problem. There is a hardcode 0, in the when parameter of the wrapper call. Now that I can do something about for sure, if parameters are not be looked at.

NAN_METHOD(AudioBufferSourceNode::Start) {
  // Nan::HandleScope scope;

  AudioBufferSourceNode *audioBufferSourceNode = ObjectWrap::Unwrap<AudioBufferSourceNode>(info.This());
  ((lab::FinishableSourceNode *)audioBufferSourceNode->audioNode.get())->start(0);
}

@Palmer-JC
Copy link
Contributor Author

Now reading the when argument & playing & stopping in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants