Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestDBVolume {
- static int maxVolumeLevel = 20;
- static int minDBLevel = -100;
- public static void main(String[] args) {
- for (int volume = 0; volume <= maxVolumeLevel; ++volume) {
- int volumeInDecibels = calulateDSPVolume(volume);
- String output = String.format("volume: %d, db = %d", volume, volumeInDecibels);
- System.out.println(output);
- }
- }
- static private int calulateDSPVolume(int volume) {
- if (maxVolumeLevel == 0) {
- return 0;
- }
- int volumeInDecibels = (int) ((1 - Math.pow((volume / maxVolumeLevel), 0.125)) * (minDBLevel));
- return volumeInDecibels;
- }
- }
Add Comment
Please, Sign In to add comment