Tabnine Logo
AudioFormat.getSampleRate
Code IndexAdd Tabnine to your IDE (free)

How to use
getSampleRate
method
in
javax.media.format.AudioFormat

Best Java code snippets using javax.media.format.AudioFormat.getSampleRate (Showing top 20 results out of 315)

origin: jitsi/libjitsi

/**
 * Gets the clock rate associated with this <tt>MediaFormat</tt>.
 *
 * @return the clock rate associated with this <tt>MediaFormat</tt>
 * @see MediaFormat#getClockRate()
 */
public double getClockRate()
{
  return format.getSampleRate();
}
origin: jitsi/libjitsi

@Override
protected Format[] getMatchingOutputFormats(Format inputFormat)
{
  AudioFormat inputAudioFormat = (AudioFormat) inputFormat;
  return
    new AudioFormat[]
        {
          new AudioFormat(
              AudioFormat.LINEAR,
              inputAudioFormat.getSampleRate(),
              16,
              1,
              AudioFormat.LITTLE_ENDIAN,
              AudioFormat.SIGNED)
        };
}
origin: jitsi/libjitsi

@Override
protected Format[] getMatchingOutputFormats(Format in)
{
  AudioFormat af = (AudioFormat) in;
  double sampleRate = af.getSampleRate();
  supportedOutputFormats
    = new AudioFormat[]
        {
          new AudioFormat(
              Constants.ALAW_RTP,
              sampleRate,
              8,
              1,
              Format.NOT_SPECIFIED,
              Format.NOT_SPECIFIED,
              8,
              sampleRate,
              Format.byteArray)
        };
  return supportedOutputFormats;
}
origin: jitsi/libjitsi

/**
 * Lists the output formats that this codec can generate.
 *
 * @param input The <tt>Format</tt> of the data to be used as input to the
 * plug-in.
 * @return An array that contains the supported output <tt>Formats</tt>.
 */
public Format[] getSupportedOutputFormats(Format input)
{
  return
    new Format[]
        {
          new AudioFormat(
              AudioFormat.LINEAR,
              ((AudioFormat)input).getSampleRate(),
              16,
              1,
              AudioFormat.LITTLE_ENDIAN,
              AudioFormat.SIGNED,
              16,
              Format.NOT_SPECIFIED,
              Format.byteArray)
        };
}
origin: jitsi/libjitsi

/**
 * {@inheritDoc}
 */
@Override
protected Format[] getMatchingOutputFormats(Format inputFormat)
{
  AudioFormat af = (AudioFormat) inputFormat;
  return
    new Format[]
        {
          new AudioFormat(
              AudioFormat.LINEAR,
              af.getSampleRate(),
              16,
              1,
              AbstractAudioRenderer
                .NATIVE_AUDIO_FORMAT_ENDIAN,
              AudioFormat.SIGNED,
              /* frameSizeInBits */ Format.NOT_SPECIFIED,
              /* frameRate */ Format.NOT_SPECIFIED,
              Format.byteArray)
        };
}
origin: jitsi/libjitsi

/**
 * Returns the output formats according to the input.
 * @param in the input format.
 * @return the possible output formats.
 */
@Override
protected Format[] getMatchingOutputFormats(Format in)
{
  AudioFormat inFormat = (AudioFormat) in;
  int sampleRate = (int) (inFormat.getSampleRate());
  supportedOutputFormats = new AudioFormat[]
    {
    new AudioFormat(
      AudioFormat.ALAW,
      sampleRate,
      8,
      1,
      Format.NOT_SPECIFIED,
      Format.NOT_SPECIFIED
    )};
  return supportedOutputFormats;
}
origin: jitsi/libjitsi

/**
 * Lists the output formats that this codec can generate.
 *
 * @param input The <tt>Format</tt> of the data to be used as input to the
 * plug-in.
 * @return An array that contains the supported output <tt>Formats</tt>.
 */
public Format[] getSupportedOutputFormats(Format input)
{
  return
      new Format[]
          {
              new AudioFormat(
                  AudioFormat.LINEAR,
                  ((AudioFormat)input).getSampleRate(),
                  16,
                  1,
                  AudioFormat.LITTLE_ENDIAN,
                  AudioFormat.SIGNED,
                  16,
                  Format.NOT_SPECIFIED,
                  Format.byteArray)
          };
}
origin: jitsi/libjitsi

/**
 * Get the output formats matching a specific input format.
 *
 * @param inputFormat the input format to get the matching output formats of
 * @return the output formats matching the specified input format
 * @see AbstractCodecExt#getMatchingOutputFormats(Format)
 */
@Override
protected Format[] getMatchingOutputFormats(Format inputFormat)
{
  AudioFormat inputAudioFormat = (AudioFormat) inputFormat;
  return
    new Format[]
        {
          new AudioFormat(
              Constants.SPEEX_RTP,
              inputAudioFormat.getSampleRate(),
              Format.NOT_SPECIFIED,
              1,
              AudioFormat.LITTLE_ENDIAN,
              AudioFormat.SIGNED,
              Format.NOT_SPECIFIED,
              Format.NOT_SPECIFIED,
              Format.byteArray)
        };
}
origin: jitsi/libjitsi

/**
 * Get all supported output <tt>Format</tt>s.
 *
 * @param inputFormat input <tt>Format</tt> to determine corresponding output
 * <tt>Format/tt>s
 * @return array of supported <tt>Format</tt>
 * @see AbstractCodecExt#getMatchingOutputFormats(Format)
 */
@Override
protected Format[] getMatchingOutputFormats(Format inputFormat)
{
  AudioFormat inputAudioFormat = (AudioFormat) inputFormat;
  return
    new Format[]
        {
          new AudioFormat(
              AudioFormat.LINEAR,
              inputAudioFormat.getSampleRate(),
              16,
              1,
              AudioFormat.LITTLE_ENDIAN,
              AudioFormat.SIGNED,
              Format.NOT_SPECIFIED,
              Format.NOT_SPECIFIED,
              Format.byteArray)
        };
}
origin: jitsi/libjitsi

@Override
protected Format[] getMatchingOutputFormats(Format in)
{
  AudioFormat af = (AudioFormat) in;
  supportedOutputFormats =
    new AudioFormat[]
    { new AudioFormat(AudioFormat.LINEAR, af.getSampleRate(), 16,
      af.getChannels(), AudioFormat.LITTLE_ENDIAN, // isBigEndian(),
      AudioFormat.SIGNED // isSigned());
    ) };
  return supportedOutputFormats;
}
origin: jitsi/libjitsi

/**
 * Initializes and opens a new instance of {@link #resampler} if the
 * <tt>Format</tt>-related state of this instance deems its existence
 * necessary.
 */
private void maybeOpenResampler()
{
  AudioFormat inFormat = this.effectiveFormat;
  AudioFormat outFormat = this.format;
  // We are able to translate between mono and stereo.
  if ((inFormat.getSampleRate() == outFormat.getSampleRate())
      && (inFormat.getSampleSizeInBits()
          == outFormat.getSampleSizeInBits()))
  {
    return;
  }
  Codec resampler
    = WASAPIRenderer.maybeOpenResampler(inFormat, outFormat);
  if (resampler == null)
  {
    throw new IllegalStateException(
        "Failed to open a codec to resample [" + inFormat
          + "] into [" + outFormat + "].");
  }
  else
    this.resampler = resampler;
}
origin: jitsi/libjitsi

  /**
   * {@inheritDoc}
   */
  @Override
  public Format setOutputFormat(Format format)
  {
    Format setOutputFormat = super.setOutputFormat(format);

    if (setOutputFormat != null)
    {
      AudioFormat af = (AudioFormat) setOutputFormat;

      outputFrameSize = (af.getSampleSizeInBits() / 8) * af.getChannels();
      outputSampleRate = (int) af.getSampleRate();
    }
    return setOutputFormat;
  }
}
origin: jitsi/libjitsi

/**
 * {@inheritDoc}
 *
 * Automatically tracks and calculates the size in bytes of an audio frame
 * (to be) output by this instance.
 */
@Override
public Format setInputFormat(Format format)
{
  Format oldValue = getInputFormat();
  Format setInputFormat = super.setInputFormat(format);
  Format newValue = getInputFormat();
  if (oldValue != newValue)
  {
    AudioFormat af = (AudioFormat) newValue;
    int sampleRate = (int) af.getSampleRate();
    frameSizeInSamplesPerChannel
      = (sampleRate * frameSizeInMillis) / 1000;
    frameSizeInBytes
      = 2 /* sizeof(opus_int16) */
        * channels
        * frameSizeInSamplesPerChannel;
  }
  return setInputFormat;
}
origin: jitsi/libjitsi

@Override
public Format[] getSupportedOutputFormats(Format input)
{
  if (input == null)
  {
    return outputFormats;
  } else
  {
    if (!(input instanceof AudioFormat))
    {
      return new Format[]{null};
    }
    final AudioFormat inputCast = (AudioFormat) input;
    final AudioFormat result = new AudioFormat(
        AudioFormat.GSM,
        inputCast.getSampleRate(),
        8,
        1,
        inputCast.getEndian(),
        AudioFormat.SIGNED,
        264,
        inputCast.getFrameRate(),
        Format.byteArray);
    return new Format[]{result};
  }
}
origin: jitsi/libjitsi

@Override
protected Format[] getMatchingOutputFormats(Format in)
{
  AudioFormat inFormat = (AudioFormat) in;
  int channels = inFormat.getChannels();
  int sampleRate = (int) (inFormat.getSampleRate());
  if (channels == 2)
  {
    supportedOutputFormats = new AudioFormat[] {
        new AudioFormat(AudioFormat.ULAW, sampleRate, 8, 2,
            Format.NOT_SPECIFIED, Format.NOT_SPECIFIED),
        new AudioFormat(AudioFormat.ULAW, sampleRate, 8, 1,
            Format.NOT_SPECIFIED, Format.NOT_SPECIFIED) };
  }
  else
  {
    supportedOutputFormats = new AudioFormat[] { new AudioFormat(
        AudioFormat.ULAW, sampleRate, 8, 1, Format.NOT_SPECIFIED,
        Format.NOT_SPECIFIED) };
  }
  return supportedOutputFormats;
}
origin: jitsi/libjitsi

private void connect()
{
  AudioFormat format = (AudioFormat) getFormat();
  int channels = format.getChannels();
  if (channels == Format.NOT_SPECIFIED)
    channels = 1;
  int sampleSizeInBits = format.getSampleSizeInBits();
  double sampleRate = format.getSampleRate();
  int framesPerBuffer
    = (int) ((sampleRate * MacCoreAudioDevice.DEFAULT_MILLIS_PER_BUFFER)
        / (channels * 1000));
  bytesPerBuffer = (sampleSizeInBits / 8) * channels * framesPerBuffer;
  // Know the Format in which this MacCoreaudioStream will output audio
  // data so that it can report it without going through its DataSource.
  this.format = new AudioFormat(
      AudioFormat.LINEAR,
      sampleRate,
      sampleSizeInBits,
      channels,
      AudioFormat.LITTLE_ENDIAN,
      AudioFormat.SIGNED,
      Format.NOT_SPECIFIED /* frameSizeInBits */,
      Format.NOT_SPECIFIED /* frameRate */,
      Format.byteArray);
}
origin: jitsi/libjitsi

/**
 * Gets an <tt>AudioFormat</tt> instance which matches a specific
 * <tt>AudioFormat</tt> and has 1 channel if the specified
 * <tt>AudioFormat</tt> has its number of channels not specified.
 *
 * @param format the <tt>AudioFormat</tt> to get a match of
 * @return if the specified <tt>format</tt> has a specific number of
 * channels, <tt>format</tt>; otherwise, a new <tt>AudioFormat</tt> instance
 * which matches <tt>format</tt> and has 1 channel
 */
private static AudioFormat fixChannels(AudioFormat format)
{
  if (Format.NOT_SPECIFIED == format.getChannels())
    format
      = (AudioFormat)
        format
          .intersects(
            new AudioFormat(
                format.getEncoding(),
                format.getSampleRate(),
                format.getSampleSizeInBits(),
                1));
  return format;
}
origin: jitsi/libjitsi

@Override
protected void doOpen()
  throws ResourceUnavailableException
{
  decState = new SKP_Silk_decoder_state();
  if (DecAPI.SKP_Silk_SDK_InitDecoder(decState) != 0)
  {
    throw new ResourceUnavailableException(
        "DecAPI.SKP_Silk_SDK_InitDecoder");
  }
  AudioFormat inputFormat = (AudioFormat) getInputFormat();
  double sampleRate = inputFormat.getSampleRate();
  int channels = inputFormat.getChannels();
  decControl = new SKP_SILK_SDK_DecControlStruct();
  decControl.API_sampleRate = (int) sampleRate;
  frameLength = (short) ((FRAME_DURATION * sampleRate * channels) / 1000);
  lastSeqNo = Buffer.SEQUENCE_UNKNOWN;
}
origin: jitsi/libjitsi

/**
 * Returns the supported output formats
 * @param in Format
 * @return Format[]
 */
public Format[] getSupportedOutputFormats(Format in)
{
  if (in == null)
  {
    return new Format[]{new AudioFormat(AudioFormat.ALAW)};
  }
  if (matches(in, inputFormats) == null)
  {
    return new Format[1];
  }
  if (! (in instanceof AudioFormat))
  {
    return new Format[]{new AudioFormat(AudioFormat.ALAW)};
  }
  AudioFormat af = (AudioFormat) in;
  return new Format[]
  {
    new AudioFormat(
      AudioFormat.ALAW,
      af.getSampleRate(),
      af.getSampleSizeInBits(),
      af.getChannels())
  };
}
origin: jitsi/libjitsi

@Override
protected void doOpen()
  throws ResourceUnavailableException
{
  encState = new SKP_Silk_encoder_state_FLP();
  encControl = new SKP_SILK_SDK_EncControlStruct();
  if (EncAPI.SKP_Silk_SDK_InitEncoder(encState, encControl) != 0)
  {
    throw new ResourceUnavailableException(
        "EncAPI.SKP_Silk_SDK_InitEncoder");
  }
  AudioFormat inputFormat = (AudioFormat) getInputFormat();
  double sampleRate = inputFormat.getSampleRate();
  int channels = inputFormat.getChannels();
  encControl.API_sampleRate = (int) sampleRate;
  encControl.bitRate = BITRATE;
  encControl.complexity = COMPLEXITY;
  encControl.maxInternalSampleRate = encControl.API_sampleRate;
  setExpectedPacketLoss(0);
  encControl.packetSize
    = (int)
      ((JavaDecoder.FRAME_DURATION * sampleRate * channels) / 1000);
  encControl.useDTX = USE_DTX ? 1 : 0;
  encControl.useInBandFEC = useFec ? 1 : 0;
}
javax.media.formatAudioFormatgetSampleRate

Popular methods of AudioFormat

  • <init>
  • computeDuration
  • getChannels
  • getEncoding
  • getSampleSizeInBits
  • getDataType
  • getEndian
  • getFrameRate
  • getFrameSizeInBits
  • getSigned
  • intersects
  • matches
  • intersects,
  • matches

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now