• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2#
3# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import sys
8
9def GenerateSimpleStep(name, max_volume, step_size):
10  print '[%s]' % name
11  print '  ; Generated by create_volume_curve.py'
12  print '  ; simple_step curve, max %d, step %d' % (max_volume, step_size)
13  print '  volume_curve = simple_step'
14  print '  volume_step = %d' % step_size
15  print '  max_volume = %d' % max_volume
16
17def WriteExplicitCurveVal(step, value):
18  print '  db_at_%d = %d' % (step, value)
19
20def GenerateExplicit(name):
21  print '[%s]' % name
22  print '  ; Generated by create_volume_curve.py'
23  print '  ; explicit curve'
24  print '  volume_curve = explicit'
25  for i in range(100):
26    print 'Level at step %d:' % (100 - i)
27    level = int(raw_input(">"))
28    WriteExplicitCurveVal(100 - i, level)
29  print 'Level at step 0:'
30  level = int(raw_input(">"))
31  WriteExplicitCurveVal(0, level)
32
33def GenerateTwoSlope(name, max_volume, step_1, step_2, pivot_point):
34  print '[%s]' % name
35  print '  ; Generated by create_volume_curve.py'
36  print ('  ; two_slope, max = %d, pivot = %d, steps %d, %d' %
37         (max_volume, pivot_point, step_1, step_2))
38  print '  volume_curve = explicit'
39  for i in range(0, (100 - pivot_point)):
40    WriteExplicitCurveVal(100 - i, max_volume - step_1 * i)
41  pivot_dB_val = max_volume - step_1 * (100 - pivot_point)
42  WriteExplicitCurveVal(pivot_point, max_volume - step_1 * (100 - pivot_point))
43  for i in range(1, pivot_point):
44    WriteExplicitCurveVal(pivot_point - i,  pivot_dB_val - step_2 * i)
45  WriteExplicitCurveVal(0, pivot_dB_val - pivot_point * step_2)
46
47def main():
48  print 'What is the name of the jack or output to generate a curve for?'
49  jack_name = raw_input(">");
50  print 'Which type of curve? (simple_step, explicit, two_slope): '
51  curve_type = raw_input(">");
52  if curve_type == 'simple_step':
53    print 'max volume (dBFS * 100):'
54    max_volume = int(raw_input(">"))
55    print 'step size (in dBFS * 100)'
56    step_size = int(raw_input(">"))
57    GenerateSimpleStep(jack_name, max_volume, step_size)
58  elif curve_type == 'explicit':
59    GenerateExplicit(jack_name)
60  elif curve_type == 'two_slope':
61    print 'max volume (dBFS * 100):'
62    max_volume = int(raw_input(">"))
63    print 'Volume step where slope changes:'
64    pivot_point = int(raw_input(">"))
65    print 'step size 100 to %d(in dBFS * 100)' % pivot_point
66    step_1 = int(raw_input(">"))
67    print 'step size %d to 0(in dBFS * 100)' % pivot_point
68    step_2 = int(raw_input(">"))
69    GenerateTwoSlope(jack_name, max_volume, step_1, step_2, pivot_point)
70
71if __name__ == '__main__':
72  main()
73