javauis/amms_qt/javasrc/com/nokia/amms/control/audioeffect/EqualizerControl.java
branchRCL_3
changeset 24 0fd27995241b
equal deleted inserted replaced
20:f9bb0fca356a 24:0fd27995241b
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.amms.control.audioeffect;
       
    19 
       
    20 import com.nokia.microedition.media.NativeError;
       
    21 
       
    22 public class EqualizerControl
       
    23         extends com.nokia.amms.control.EffectControl
       
    24         implements javax.microedition.amms.control.audioeffect.EqualizerControl
       
    25 {
       
    26     private static final int MAX_LEVEL = 100;
       
    27     private static final int MIN_LEVEL = 0;
       
    28 
       
    29     /**
       
    30      * Constructor
       
    31      */
       
    32     public EqualizerControl()
       
    33     {
       
    34     }
       
    35 
       
    36     /**
       
    37      * Please refer to JSR 234 for more details.
       
    38      */
       
    39     public int getMinBandLevel()
       
    40     {
       
    41         checkValid();
       
    42 
       
    43         return _getMinBandLevel(iEventSource, iControlHandle);
       
    44     }
       
    45 
       
    46     /**
       
    47      * Please refer to JSR 234 for more details.
       
    48      */
       
    49     public int getMaxBandLevel()
       
    50     {
       
    51         checkValid();
       
    52 
       
    53         return _getMaxBandLevel(iEventSource, iControlHandle);
       
    54     }
       
    55 
       
    56     /**
       
    57      * Please refer to JSR 234 for more details.
       
    58      */
       
    59     public void setBandLevel(int aLevel, int aBand)
       
    60     throws IllegalArgumentException
       
    61     {
       
    62         checkValid();
       
    63 
       
    64         int err = _setBandLevel(iEventSource, iControlHandle, aLevel, aBand);
       
    65 
       
    66         // throws IllegalArgumentException on KErrArgument
       
    67         NativeError.check(err);
       
    68     }
       
    69 
       
    70     /**
       
    71      * Please refer to JSR 234 for more details.
       
    72      */
       
    73     public int getBandLevel(int aBand) throws IllegalArgumentException
       
    74     {
       
    75         checkValid();
       
    76 
       
    77         int[] level = new int[ 1 ];
       
    78 
       
    79         int error = _getBandLevel(iEventSource, iControlHandle, aBand, level);
       
    80 
       
    81         // throws IllegalArgumentException on KErrArgument
       
    82         NativeError.check(error);
       
    83 
       
    84         return level[ 0 ];
       
    85     }
       
    86 
       
    87     /**
       
    88      * Please refer to JSR 234 for more details.
       
    89      */
       
    90     public int getNumberOfBands()
       
    91     {
       
    92         checkValid();
       
    93 
       
    94         return _getNumberOfBands(iEventSource, iControlHandle);
       
    95     }
       
    96 
       
    97     /**
       
    98      * Please refer to JSR 234 for more details.
       
    99      */
       
   100     public int getCenterFreq(int aBand) throws IllegalArgumentException
       
   101     {
       
   102         checkValid();
       
   103 
       
   104         int err = _getCenterFreq(iEventSource, iControlHandle, aBand);
       
   105         NativeError.check(err);
       
   106 
       
   107         return err;
       
   108     }
       
   109 
       
   110     /**
       
   111      * Please refer to JSR 234 for more details.
       
   112      */
       
   113     public int getBand(int aFrequency)
       
   114     {
       
   115         checkValid();
       
   116 
       
   117         int band = _getBand(iEventSource, iControlHandle, aFrequency);
       
   118 
       
   119         return band;
       
   120     }
       
   121 
       
   122     /**
       
   123      * Please refer to JSR 234 for more details.
       
   124     */
       
   125     public int setBass(int aLevel) throws IllegalArgumentException
       
   126     {
       
   127         checkValid();
       
   128 
       
   129         if (aLevel < MIN_LEVEL || aLevel > MAX_LEVEL)
       
   130         {
       
   131             throw new IllegalArgumentException("Bass level out of range");
       
   132         }
       
   133 
       
   134         int err = _setBass(iEventSource, iControlHandle, aLevel);
       
   135         NativeError.check(err);
       
   136 
       
   137         return err;
       
   138     }
       
   139 
       
   140     /**
       
   141      * Please refer to JSR 234 for more details.
       
   142      */
       
   143     public int setTreble(int aLevel) throws IllegalArgumentException
       
   144     {
       
   145         checkValid();
       
   146 
       
   147         if (aLevel < MIN_LEVEL || aLevel > MAX_LEVEL)
       
   148         {
       
   149             throw new IllegalArgumentException("Treble level out of range");
       
   150         }
       
   151 
       
   152         int err = _setTreble(iEventSource, iControlHandle, aLevel);
       
   153         NativeError.check(err);
       
   154         return err;
       
   155     }
       
   156 
       
   157     /**
       
   158      * Please refer to JSR 234 for more details.
       
   159      */
       
   160     public int getBass()
       
   161     {
       
   162         checkValid();
       
   163 
       
   164         return _getBass(iEventSource, iControlHandle);
       
   165     }
       
   166 
       
   167     /**
       
   168      * Please refer to JSR 234 for more details.
       
   169      */
       
   170     public int getTreble()
       
   171     {
       
   172         checkValid();
       
   173 
       
   174         return _getTreble(iEventSource, iControlHandle);
       
   175     }
       
   176 
       
   177     private static native int _getMinBandLevel(
       
   178         int iEventSource,
       
   179         int iControlHandle);
       
   180     private static native int _getMaxBandLevel(
       
   181         int iEventSource,
       
   182         int iControlHandle);
       
   183     private static native int _setBandLevel(
       
   184         int iEventSource,
       
   185         int iControlHandle,
       
   186         int level,
       
   187         int band);
       
   188     private static native int _getBandLevel(
       
   189         int iEventSource,
       
   190         int iControlHandle,
       
   191         int band,
       
   192         int[] level);
       
   193     private static native int _getCenterFreq(
       
   194         int iEventSource,
       
   195         int iControlHandle,
       
   196         int band);
       
   197     private static native int _getBand(
       
   198         int iEventSource,
       
   199         int iControlHandle,
       
   200         int frequency);
       
   201     private static native int _setBass(
       
   202         int iEventSource,
       
   203         int iControlHandle,
       
   204         int level);
       
   205     private static native int _setTreble(
       
   206         int iEventSource,
       
   207         int iControlHandle,
       
   208         int level);
       
   209     private static native int _getBass(
       
   210         int iEventSource,
       
   211         int iControlHandle);
       
   212     private static native int _getTreble(
       
   213         int iEventSource,
       
   214         int iControlHandle);
       
   215     private static native int _getNumberOfBands(
       
   216         int iEventSource,
       
   217         int iControlHandle);
       
   218 }