Trouble updating parameters between two classes - Page 2


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Trouble updating parameters between two classes

  1. #16
    Join Date
    Apr 2004
    Posts
    11
    By the way, when you say "calling resetForwardMemory(int forwardMemSize) will wipe out all data in your forwardMemory array." do u mean it will do that everytime initialiseForward is called? because i need to add the forwardMemory (which is essentially an 'echo')to the next chunk of data (otherwise you won't hear the echo)

  2. #17
    Join Date
    Apr 2004
    Posts
    11
    Hi. I'll post the method. I've cut bits out but this could get very longwinded pretty quickly as i have to post the preProcess method too
    Code:
    	public short[] singleDelayProcessChunked(short input[]){
    
    		// inserts current data into array which comprises of current data + forward data
    		super.preProcess(input);
    
    		short[] forwardBuffer = new short[delaySamples];
    		short[] output = new short [input.length + delaySamples];
    
    		// For each sample in the output array
    		for (int n=0; n < output.length; n++){
    
    			int delayedPosition = n-delaySamples;
    
    			if (delayedPosition < 0)
    			{
    				delayedInput = 0;
    				delayedOutput = 0;
    			}
    
    			else {
    				delayedInput = input[delayedPosition];
    				delayedOutput = output[delayedPosition];
    			}
    
    			short inputSample =0;
    
    			if (n<input.length){
    			   inputSample = input[n];
    			}
    
    			// This adds together the input sample plus the attenuated delayedInput.
    			int outputSample = (int)((inputSample) + (feedbackFactor*delayedInput/100));
    
    			}
    		}// End of for loop
    
    		try {
    			super.initialiseForward(forwardBuffer);
    			// this will set up the forward data so that it gets added to the 'allData' in AudioEffect16bit
    			// next time preProcess is called
    		}
    
    		catch (Exception ee) {
    				ee.printStackTrace();
    		}
    
    		return output;
    	}
    }
    Would you like to see the code for postProcess() (which is also in audioeffect16bit)? what it does is inserts the given data into an array which comprises of the previous data, the given data and the forward data (respectively).

    Sorry for posting so much i feel bad

  3. #18
    Join Date
    Dec 2002
    Posts
    83
    I think my level of help is diminishing heh. I also have to head out, hopefully you can make some progress on your own.

    Find out why the array you are passing in to initializeForward (in that method it's forwardBuffer) is not the same length as forwardMemory. Them being different length is what triggers the exception.
    -- Steven

  4. #19
    Join Date
    Feb 2004
    Posts
    808
    arrays in java, cannot be resized. if you plan on resizing the data array often, you should use another container, such as a linked list. if resizing occurs infrequently, it is acceptable to declare a larger array, copy the contents of the smaller array into it, and then assign the new larger array to the variable of the older one:

    int[] myArray = new int[10];
    int[] myLargerArray = new int[100];
    System.arrayCopy(myArray,0,myLargerArray,0,myArray.length);
    myArray = myLargerArray;

    the small array is lost, and myArray becomes an array of 100 length..

    dont do this often, it takes too much time to shift massive amounts of data around..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center