1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.audio.wavelib; 18 19 public class DspBufferComplex extends DspBufferBase { 20 public double[] mReal; 21 public double[] mImag; 22 DspBufferComplex(int size)23 public DspBufferComplex(int size) { 24 super(size); 25 } 26 27 @Override setSize(int size)28 public void setSize(int size) { 29 if (size == getSize()) { 30 return; 31 } 32 mReal = new double[size]; 33 mImag = new double[size]; 34 super.setSize(size); 35 } 36 37 // Warning, these methods don't check for bounds! 38 @Override setValues(int index, double... values)39 public void setValues(int index, double... values) { 40 mReal[index] = values[0]; 41 mImag[index] = values[1]; 42 } 43 44 @Override setValue(int index, double value)45 public void setValue(int index, double value) { 46 mReal[index] = value; 47 mImag[index] = 0; 48 } 49 50 @Override toString()51 public String toString() { 52 StringBuilder sb = new StringBuilder(); 53 int size = getSize(); 54 sb.append(String.format("Size: %d { ", size)); 55 for (int i = 0; i < size; i++) { 56 sb.append(String.format("(%.3f, %3f) ", mReal[i], mImag[i])); 57 } 58 sb.append("}"); 59 return sb.toString(); 60 } 61 } 62