Rename nokia-api to vendor-api-nokia.
[SquirrelJME.git] / modules / vendor-api-nokia / src / main / java / com / nokia / mid / sound / Sound.java
blob12cabd46bb2ace2f5d471a637fe99555731399c8
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package com.nokia.mid.sound;
12 import cc.squirreljme.runtime.cldc.annotation.Api;
13 import cc.squirreljme.runtime.cldc.annotation.ApiDefinedDeprecated;
14 import cc.squirreljme.runtime.cldc.debug.Debugging;
15 import javax.microedition.media.Manager;
16 import javax.microedition.media.MediaException;
18 /**
19 * Provides an interface for playing digitized audio along with simple sounds.
21 * All implementations must support tone based sounds.
23 * @since 2022/02/03
25 @ApiDefinedDeprecated
26 @Api
27 public class Sound
29 /** A simple tone based sound. */
30 @Api
31 @ApiDefinedDeprecated
32 public static final int FORMAT_TONE = 1;
34 /** A digitized waveform audio. */
35 @Api
36 @ApiDefinedDeprecated
37 public static final int FORMAT_WAVE = 5;
39 /** A sound is playing. */
40 @Api
41 @ApiDefinedDeprecated
42 public static final int SOUND_PLAYING = 0;
44 /** A sound is stopped. */
45 @Api
46 @ApiDefinedDeprecated
47 public static final int SOUND_STOPPED = 1;
49 /** A sound is not initialized. */
50 @Api
51 @ApiDefinedDeprecated
52 public static final int SOUND_UNINITIALIZED = 3;
54 @Api
55 @ApiDefinedDeprecated
56 public Sound(byte[] __data, int __type)
58 this.init(__data, __type);
61 @Api
62 @ApiDefinedDeprecated
63 public Sound(int __freq, long __duration)
65 this.init(__freq, __duration);
68 @Api
69 @ApiDefinedDeprecated
70 public int getGain()
72 throw Debugging.todo();
75 @Api
76 @ApiDefinedDeprecated
77 public int getState()
79 throw Debugging.todo();
82 @Api
83 @ApiDefinedDeprecated
84 public void init(byte[] __data, int __type)
86 Debugging.todoNote("init(%p, %d)", __data, __type);
87 throw new IllegalArgumentException("TODO");
90 /**
91 * Plays a simple tone through the device speaker.
93 * @param __freq The frequency to play the sound at.
94 * @param __duration The duration in milliseconds to play the sound for.
95 * @throws IllegalArgumentException If the frequency is not within range
96 * of what the device support, or the duration is zero or negative.
97 * @see Manager#playTone(int, int, int)
98 * @since 2022/02/03
100 @Api
101 @ApiDefinedDeprecated
102 public void init(int __freq, long __duration)
103 throws IllegalArgumentException
105 // {@squirreljme.error AI01 Invalid frequency and/or duration.}
106 if (__freq < 0 || __duration <= 0)
107 throw new IllegalArgumentException("AI01");
111 Manager.playTone(__freq,
112 (int)Math.min(__duration, Integer.MAX_VALUE), 100);
114 catch (MediaException e)
116 // {@squirreljme.error AI02 Sound out of range or failed to
117 // properly play.}
118 throw new IllegalArgumentException("AI02", e);
122 @Api
123 @ApiDefinedDeprecated
124 public void play(int __loop)
126 throw Debugging.todo();
129 @Api
130 @ApiDefinedDeprecated
131 public void release()
133 throw Debugging.todo();
136 @Api
137 @ApiDefinedDeprecated
138 public void resume()
140 throw Debugging.todo();
143 @Api
144 @ApiDefinedDeprecated
145 public void setGain(int __gain)
147 throw Debugging.todo();
150 @Api
151 @ApiDefinedDeprecated
152 public void setSoundListener(SoundListener __listener)
154 throw Debugging.todo();
157 @Api
158 @ApiDefinedDeprecated
159 public void stop()
161 throw Debugging.todo();
164 @Api
165 @ApiDefinedDeprecated
166 public static int getConcurrentSoundCount(int __type)
168 throw Debugging.todo();
171 @Api
172 @ApiDefinedDeprecated
173 public static int[] getSupportedFormats()
175 throw Debugging.todo();