Guest User

Untitled

a guest
Aug 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public class TestDBVolume {
  2. static int maxVolumeLevel = 20;
  3. static int minDBLevel = -100;
  4.  
  5. public static void main(String[] args) {
  6. for (int volume = 0; volume <= maxVolumeLevel; ++volume) {
  7. int volumeInDecibels = calulateDSPVolume(volume);
  8. String output = String.format("volume: %d, db = %d", volume, volumeInDecibels);
  9. System.out.println(output);
  10. }
  11. }
  12.  
  13. static private int calulateDSPVolume(int volume) {
  14. if (maxVolumeLevel == 0) {
  15. return 0;
  16. }
  17.  
  18. int volumeInDecibels = (int) ((1 - Math.pow((volume / maxVolumeLevel), 0.125)) * (minDBLevel));
  19.  
  20. return volumeInDecibels;
  21. }
  22. }
Add Comment
Please, Sign In to add comment