Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-22-2008, 11:38 AM   #1
dubbeat
Registered User
 
Join Date: Feb 2008
Posts: 28
Default TypeError: Error #1006: value is not a function

Hi,

Im getting a weird error when I try to return an array in a function.
TypeError: Error #1006: value is not a function
The code calling the function is


[as] EQOutput=EQ.processSamples(44100,localPCMArray,num Samples,2);[\as]

EQOutput as already been defined as an array.

The function that im calliing that should return an array value is

[as]package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;

public class E_Q {
public var filterType:int=4;// filterType should be passed as 4 this sets up a peaking filter. Const for now
public var numberInFrames:int;// numberOfFrames is the length in samples of one channels worth of aduio
public var frequency:Number;// frequency, bandwidth, and gain range between 0 and 255
public var bandwidth:Number;
public var gain:Number;
public var sampleRate:int;
public var channels:int;
public var inputData:Array=new Array();// inputData is a buffer numberInFrames*channels long of floats
public var outputData:Array=new Array();// outputData is a buffer numberInFrames*channels long of floats
public var lastInput:Array=new Array();
public var secondlastInput:Array=new Array();
public var lastOutput:Array=new Array();
public var secondlastOutput:Array=new Array();
public var eqResult:Array=new Array();

var b0:Number=0;
var b1:Number=0;
var a0:Number=0;
var a1:Number=0;
var a2:Number=0;

var b2:Number;


public function E_Q():void {

}
/*public function EQ_Samples(sRate:int,input:Array,numSamples:int,nu mChannels:int):Array {
this.inputData=input;//outPutFrom DSP Volume
this.sampleRate=sRate;
this.channels=numChannels;
this.numberInFrames=numSamples;
eqResult=processSample();
return eqResult;
}*/
public function processSamples(sRate:int,input:Array,numSamples:in t,numChannels:int):Array {


this.inputData=input;//outPutFrom DSP Volume
this.sampleRate=sRate;
this.channels=numChannels;
this.numberInFrames=numSamples;
this.gain=0;
this.frequency=128;
this.bandwidth=128;
//gain = 12.0 * (gain - 128.0)/127.0;
//frequency = 50.0*Math.exp((10.0,Math.LN10(11025.0/50.0)*(frequency-1)/254.0));
//bandwidth = 0.333*Math.exp((10.0,Math.LN10(3.0/0.333)*(bandWidth-1)/254));

var w0:Number=(2.0*Math.PI*frequency/sampleRate);
var A:Number=Math.exp(10.0(gain/40.0));
bandwidth=Math.exp(((2.0,bandwidth)*frequency - frequency)*2.0);
var Q:Number=(frequency/bandwidth);
var alpha:Number=(Math.sin(w0)/2.0*Q);




switch (filterType) {
case 0 :
b0 = (1 - Math.cos(w0)/2);
b1 = (1 - Math.cos(w0));
b2 = (1 - Math.cos(w0)/2);
a0 = (1 + alpha);
a1 = (-2*Math.cos(w0));
a2 = (1 - alpha);
break;

case 1 :
b0 = ((1 + Math.cos(w0))/2);
b1 = (-(1 + Math.cos(w0)));
b2 = ((1 + Math.cos(w0))/2);
a0 = (1 + alpha);
a1 = (-2* Math.cos(w0));
a2 = (1 - alpha);
break;

case 2 :

b0 = (Q*alpha);
b1 = (0.0);
b2 = (-Q*alpha);
a0 = (1 + alpha);
a1 = (-2*Math.cos(w0));
a2 = (1 - alpha);
break;

case 3 :

b0 = (1.0);
b1 = (-2.0*Math.cos(w0));
b2 = (1.0);
a0 = (1.0 + alpha);
a1 = (-2.0*Math.cos(w0));
a2 = (1.0 - alpha);
break;

case 4 :

b0 = (1.0 - alpha*A);
b1 = (-2.0*Math.cos(w0));//was cos f not cos??
b2 = (1.0 + alpha*A);
a0 = (1.0 + alpha/A);
a1 = (-2.0*Math.cos(w0));//was cos f not cos??
a2 = (1.0 - alpha/A);
break;

case 5 :

b0 = (A*( (A+1) - (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha));
b1 = (2*A*( (A-1) - (A+1)*Math.cos(w0)));
b2 = (A*( (A+1) - (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha));
a0 = ((A+1) + (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha);
a1 = (-2*( (A-1) + (A+1)*Math.cos(w0)));
a2 = ((A+1) + (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha);
break;

case 6 :

b0 = (A*( (A+1) + (A-1)*Math.cos(w0) + 2*Math.sqrt(A)*alpha));
b1 = (-2*A*( (A-1) + (A+1)*Math.cos(w0)));
b2 = ((A*( (A+1) + (A-1)*Math.cos(w0) - 2*Math.sqrt(A)*alpha)));
a0 = ((A+1) - (A-1)*Math.cos(w0) + 2*Math.sqrt((A)*alpha));
a1 = (2*( (A-1) - (A+1)*Math.cos(w0)));
a2 = ((A+1) - (A-1)*Math.cos(w0) - 2*Math.sqrt((A)*alpha));
break;
}
for (var x:int=0; x < channels; x++) {
for (var i:int=0; i < numberInFrames; i++) {
this.outputData[i*channels + x] = ((b0/a0)*inputData[i*channels + x] + (b1/a0)*lastInput[x] + (b2/a0)*secondlastInput[x] - (a1/a0)*lastOutput[x] - (a2/a0)*secondlastOutput[x]);

secondlastOutput[x] = lastOutput[x];
lastOutput[x] = outputData[i*channels + x];
secondlastInput[x] = lastInput[x];
lastInput[x] = inputData[i*channels + x];
}
}
return this.outputData;
}
}
}[\as]


As far as I understand I have an array that I want to fill with the results of a function. Why on earth am I getting this error?

Thanks,
dub
dubbeat is offline   Reply With Quote
Old 02-22-2008, 03:32 PM   #2
ultraky
A flash Guy
 
Join Date: Mar 2007
Location: NYC
Posts: 79
Send a message via AIM to ultraky
Default

Could you post this in a code block. It's tough for mw to read.
ultraky is offline   Reply With Quote
Old 02-25-2008, 09:14 AM   #3
dubbeat
Registered User
 
Join Date: Feb 2008
Posts: 28
Default

Hi, I found out what the problem was. One of the formulas in the case statement was messed up. That was causing the problem. I was barking up the wrrong tree, I thought the error was related to the return value.

Thanks
dubbeat is offline   Reply With Quote
Old 02-25-2008, 03:09 PM   #4
xwielder
Senior Member
 
Join Date: Aug 2007
Location: NE Ohio
Posts: 520
Send a message via AIM to xwielder
Default

Quote:
Originally Posted by ultraky View Post
Could you post this in a code block. It's tough for mw to read.
Kinda looks like he tried. If you look at the top, you'll see the [as] tag, and at the bottom he used [\as] instead of [/as]. A simple mistake of the wrong slash.
xwielder is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
one template, many looks? subquark ActionScript 1.0 (and below) 1166 10-29-2013 07:18 PM
Ease parameter Clutchplate Simple Stuff (Newbies) 8 03-16-2007 12:21 PM
Photo switch on runtime problem provision ActionScript 2.0 0 01-17-2005 12:29 PM
flash movie plays in browser too slow m1cky ActionScript 2.0 7 01-11-2005 09:11 PM
can't call a function from within itself, what's my alternative? Jessica lucidiastudios ActionScript 1.0 (and below) 9 11-26-2003 11:03 AM


All times are GMT. The time now is 01:03 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.