Package ptolemy.media.javasound

Examples of ptolemy.media.javasound.SoundWriter


        int sampleRateInt = ((IntToken) sampleRate.getToken()).intValue();
        int bitsPerSampleInt = ((IntToken) bitsPerSample.getToken()).intValue();
        int channelsInt = ((IntToken) channels.getToken()).intValue();
        int putSamplesSize = _putSampleSize;

        _soundWriter = new SoundWriter(pathNameString, sampleRateInt,
                bitsPerSampleInt, channelsInt, putSamplesSize);

        int length = ((IntToken) bufferLength.getToken()).intValue();
        _audioBuffer = new double[length];
    }
View Full Code Here


        int sampleRateInt = ((IntToken) sampleRate.getToken()).intValue();
        int bitsPerSampleInt = ((IntToken) bitsPerSample.getToken()).intValue();
        int channelsInt = ((IntToken) channels.getToken()).intValue();
        int putSamplesSize = _putSampleSize;

        _soundWriter = new SoundWriter(pathNameString, sampleRateInt,
                bitsPerSampleInt, channelsInt, putSamplesSize);
        _curElement = 0;
    }
View Full Code Here

            int putSamplesSize = getSamplesSize;

            // Construct a sound writer object that is used to write
            // audio samples to a sound file.
            SoundWriter soundWriter = new SoundWriter(writeFile, sampleRate,
                    bitsPerSample, channels, putSamplesSize);

            double[][] capturedSamplesArray = new double[channels][getSamplesSize];
            boolean done = false;

            // The main loop.
            while (!done) {
                // Read in some audio samples.
                capturedSamplesArray = soundReader.getSamples();

                if (_debug) {
                    System.out.println("Read some samples...");
                }

                if (capturedSamplesArray == null) {
                    // reached end of file.
                    done = true;
                    System.out.println("Reached end of file.");
                } else {
                    // Do some simple processing on the
                    // captured audio.
                    for (int j = 0; j < channels; j++) {
                        for (int i = 0; i < getSamplesSize; i++) {
                            //  ********** INSERT PROCESSING CODE HERE ****
                            // Perform soft clipping using the arc tangent.
                            capturedSamplesArray[j][i] = java.lang.Math
                                    .atan(capturedSamplesArray[j][i]) * 0.6;
                        }
                    }

                    // Write the processed audio samples.
                    soundWriter.putSamples(capturedSamplesArray);
                }
            }

            // Close the input sound file, because we are done with it.
            soundReader.closeFile();

            // Close the output sound file, because we are done with it.
            soundWriter.closeFile();
        } catch (Exception ex) {
            System.err.println(ex);
        }

        System.out.println("Done.");
View Full Code Here

TOP

Related Classes of ptolemy.media.javasound.SoundWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.