zoukankan      html  css  js  c++  java
  • javax.sound.sampled.AudioFormat.java

    Viewing the Java Code javax.sound.sampled.AudioFormat.java line 252:

    frameSize 
    
        ((sampleSizeInBits + 7) / 8) * channels

    When is Different to http://soundfile.sapp.org/doc/WaveFormat/

    BlockAlign == NumChannels * BitsPerSample/8

    I can't understand Why use + 7.

    加上7再除以8是为了防止sampleSizeInBits不能被8整除以保证返回的整数大于等于1。

    Frame size is in bytes. Let's say channels=2. So, for sampleSizeInBits=8 or 16 we still will have frameSize=2 or 4 bytes,

    as it should be. +7 is neglected as we have integer division here. +7 starts playing role when sampleSizeInBits is not multiple to 8.

    E.g. sampleSizeInBits=10. So, for sampleSizeInBits=10 and channels=2 frameSize=((12+7)/8)*2=(19/8)*2=4. Briefly, +7 takes

    into account cases when sampleSizeInBits is not multiple to 8 to have correct number of bytes for frameSize

  • 相关阅读:
    SpringRequestContext源码阅读
    MyBatis事务管理源码阅读
    linux查找依赖文件
    GitHub
    Qt Quick
    centos7下安装chrome
    软件使用
    排序算法之冒泡排序
    c++学习
    cent6.4使用
  • 原文地址:https://www.cnblogs.com/passedbylove/p/12199896.html
Copyright © 2011-2022 走看看