|
1 /* |
|
2 * Copyright (c) 2002 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: PitchControl controls the pitch. |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.microedition.media.control; |
|
19 |
|
20 /** |
|
21 * TempoControl or RateControl methods cannot throw any exceptions. |
|
22 * If an error occurs in native side, native side return default value. |
|
23 */ |
|
24 public class PitchControl extends ControlImpl |
|
25 implements javax.microedition.media.control.PitchControl |
|
26 { |
|
27 // these constants come from native side |
|
28 protected static final int NO_ERROR = 0; // native side returns if OK |
|
29 protected static final int PITCH_OFFSET = 1000000; |
|
30 |
|
31 /** |
|
32 * @see PitchControl |
|
33 */ |
|
34 public int setPitch(int aMillisemitones) |
|
35 { |
|
36 checkState(); |
|
37 int pitch = |
|
38 _setPitch(iControlHandle, iEventSource, aMillisemitones); |
|
39 if (pitch < NO_ERROR) |
|
40 { |
|
41 throw new Error("setPitch() failed, Symbian OS error: " |
|
42 + pitch); |
|
43 } |
|
44 return pitch - PITCH_OFFSET; |
|
45 } |
|
46 |
|
47 /** |
|
48 * @see PitchControl |
|
49 */ |
|
50 public int getPitch() |
|
51 { |
|
52 checkState(); |
|
53 int pitch = _getPitch(iControlHandle, iEventSource); |
|
54 if (pitch < NO_ERROR) |
|
55 { |
|
56 throw new Error( |
|
57 "getPitch() failed, SymbianOS error: " + pitch); |
|
58 } |
|
59 return pitch - PITCH_OFFSET; |
|
60 } |
|
61 |
|
62 /** |
|
63 * @see PitchControl |
|
64 */ |
|
65 public int getMaxPitch() |
|
66 { |
|
67 checkState(); |
|
68 int pitch = _getMaxPitch(iControlHandle, iEventSource); |
|
69 if (pitch < NO_ERROR) |
|
70 { |
|
71 throw new Error( |
|
72 "getMaxPitch() failed, SymbianOS error: " |
|
73 + pitch); |
|
74 } |
|
75 return pitch - PITCH_OFFSET; |
|
76 } |
|
77 |
|
78 /** |
|
79 * @see PitchControl |
|
80 */ |
|
81 public int getMinPitch() |
|
82 { |
|
83 checkState(); |
|
84 int pitch = _getMinPitch(iControlHandle, iEventSource); |
|
85 if (pitch < NO_ERROR) |
|
86 { |
|
87 throw new Error( |
|
88 "getMinPitch() failed, SymbianOS error: " |
|
89 + pitch); |
|
90 } |
|
91 return pitch - PITCH_OFFSET; |
|
92 } |
|
93 |
|
94 /** |
|
95 * Native implementation. |
|
96 * |
|
97 * @param aControlHandle Pointer to the native PitchControl object. |
|
98 * @param aEventSourceHandle Pointer to the native event source object. |
|
99 * @param aMillisemitones The number of semi tones to raise the playback |
|
100 * pitch. |
|
101 * @return The actual pitch raise set |
|
102 */ |
|
103 private native int _setPitch(int aControlHandle, |
|
104 int aEventSourceHandle, |
|
105 int aMillisemitones); |
|
106 |
|
107 /** |
|
108 * Native implementation. |
|
109 * |
|
110 * @param aControlHandle Pointer to the native PitchControl object. |
|
111 * @param aEventSourceHandle Pointer to the native event source object. |
|
112 * @return the current playback pitch raise in "milli-semitones". |
|
113 */ |
|
114 private native int _getPitch(int aControlHandle, |
|
115 int aEventSourceHandle); |
|
116 |
|
117 |
|
118 /** |
|
119 * Native implementation. |
|
120 * |
|
121 * @param aControlHandle Pointer to the native PitchControl object. |
|
122 * @param aEventSourceHandle Pointer to the native event source object. |
|
123 * @return the maximum pitch raise in "milli-semitones". |
|
124 */ |
|
125 private native int _getMaxPitch(int aControlHandle, |
|
126 int aEventSourceHandle); |
|
127 |
|
128 /** |
|
129 * Native implementation. |
|
130 * |
|
131 * @param aControlHandle Pointer to the native PitchControl object. |
|
132 * @param aEventSourceHandle Pointer to the native event source object. |
|
133 * @return the minimum pitch raise in "milli-semitones". |
|
134 */ |
|
135 private native int _getMinPitch(int aControlHandle, |
|
136 int aEventSourceHandle); |
|
137 |
|
138 } |