summaryrefslogtreecommitdiff
path: root/songdbj/javazoom/jl/decoder/SampleBuffer.java
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/javazoom/jl/decoder/SampleBuffer.java')
-rw-r--r--songdbj/javazoom/jl/decoder/SampleBuffer.java132
1 files changed, 0 insertions, 132 deletions
diff --git a/songdbj/javazoom/jl/decoder/SampleBuffer.java b/songdbj/javazoom/jl/decoder/SampleBuffer.java
deleted file mode 100644
index ba4bfa060f..0000000000
--- a/songdbj/javazoom/jl/decoder/SampleBuffer.java
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * 11/19/04 1.0 moved to LGPL.
3 *
4 * 12/12/99 Initial Version based on FileObuffer. mdm@techie.com.
5 *
6 * FileObuffer:
7 * 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net
8 *
9 *-----------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Library General Public License as published
12 * by the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *----------------------------------------------------------------------
24 */
25
26package javazoom.jl.decoder;
27
28/**
29 * The <code>SampleBuffer</code> class implements an output buffer
30 * that provides storage for a fixed size block of samples.
31 */
32public class SampleBuffer extends Obuffer
33{
34 private short[] buffer;
35 private int[] bufferp;
36 private int channels;
37 private int frequency;
38
39 /**
40 * Constructor
41 */
42 public SampleBuffer(int sample_frequency, int number_of_channels)
43 {
44 buffer = new short[OBUFFERSIZE];
45 bufferp = new int[MAXCHANNELS];
46 channels = number_of_channels;
47 frequency = sample_frequency;
48
49 for (int i = 0; i < number_of_channels; ++i)
50 bufferp[i] = (short)i;
51
52 }
53
54 public int getChannelCount()
55 {
56 return this.channels;
57 }
58
59 public int getSampleFrequency()
60 {
61 return this.frequency;
62 }
63
64 public short[] getBuffer()
65 {
66 return this.buffer;
67 }
68
69 public int getBufferLength()
70 {
71 return bufferp[0];
72 }
73
74 /**
75 * Takes a 16 Bit PCM sample.
76 */
77 public void append(int channel, short value)
78 {
79 buffer[bufferp[channel]] = value;
80 bufferp[channel] += channels;
81 }
82
83 public void appendSamples(int channel, float[] f)
84 {
85 int pos = bufferp[channel];
86
87 short s;
88 float fs;
89 for (int i=0; i<32;)
90 {
91 fs = f[i++];
92 fs = (fs>32767.0f ? 32767.0f
93 : (fs < -32767.0f ? -32767.0f : fs));
94
95 s = (short)fs;
96 buffer[pos] = s;
97 pos += channels;
98 }
99
100 bufferp[channel] = pos;
101 }
102
103
104 /**
105 * Write the samples to the file (Random Acces).
106 */
107 public void write_buffer(int val)
108 {
109
110 //for (int i = 0; i < channels; ++i)
111 // bufferp[i] = (short)i;
112
113 }
114
115 public void close()
116 {}
117
118 /**
119 *
120 */
121 public void clear_buffer()
122 {
123 for (int i = 0; i < channels; ++i)
124 bufferp[i] = (short)i;
125 }
126
127 /**
128 *
129 */
130 public void set_stop_flag()
131 {}
132}