Permalink
Browse files

Cleaned up - still bugs to fix

  • Loading branch information...
1 parent 2c8d1e5 commit 03b92657887427d47f6d091217053a2886d3b65e lmp committed Jan 15, 2014
Showing with 2 additions and 77 deletions.
  1. +2 −77 pyClickTrack.py
View
@@ -66,27 +66,17 @@ def build(path):
clicks = 0
+ log.debug('Preparing track')
for part in parts:
name = part['part']
bpm = part['bpm']
bar = part['bar']
bars = part['bars']
- # Beats per second
bps = float(bpm) / 60
- # Beats per bar
bpb = float(len(bar))
- # Beats = bars * beats per bar
beats = float(bars) * bpb
- # Length (in seconds)
length = float(beats) / bps
- # Bar length (in seconds)
- bar_length = ((length / bars) / bpb)
- #bar_length = round(bar_length_f)
-
- displacement = 0
-
- log.debug('Preparing "%s" as %s/%s @ %sbpm. %sbps %sbpb %sbeats, length: %s, bar length:%s',name,bars,bpb,bpm,bps,bpb,beats,length,bar_length)
track += AudioSegment.silent((length * 1000))
@@ -108,8 +98,6 @@ def build(path):
bar_length = ((length / bars) / bpb)
#bar_length = round(bar_length_f)
- displacement = 0
-
log.debug('Building "%s" as %s/%s @ %sbpm. %sbps %sbpb %sbeats, length: %s, bar length:%s',name,bars,bpb,bpm,bps,bpb,beats,length,bar_length)
for b in range(0, bars):
@@ -126,70 +114,7 @@ def build(path):
track = track.overlay(click, position=(position-click_displacement))
position += bar_length*1000
- """
- for b in range(0, bars):
- for symbol in bar:
- bars_length += bar_length_f
-
- clicks += 1
-
- try:
- sound = sounds[symbol]
- except KeyError:
- sound = sounds['+']
-
- click = sound['click']
- click_displacement = sound['displacement']
-
- if len(click) < bar_length_f:
- fill = round(bar_length_f - len(click))
- pad = AudioSegment.silent(fill)
- click = click + pad
-
- if len(click) > bar_length_f:
- log.debug('Click %s (longer than bar) length: %s displacement: %s. Track length: %s displacement: %s',clicks,len(click),click_displacement,len(track),displacement)
- mix_long = len(track)-displacement-click_displacement
- track += AudioSegment.silent(len(click)-displacement-click_displacement)
- track = track.overlay(click, position=mix_long)
- else:
- if displacement > 0:
- log.debug('Click %s (normal, displace) length: %s displacement: %s. Track length: %s displacement: %s',clicks,len(click),click_displacement,len(track),displacement)
- mix_from = len(track)-displacement-click_displacement
- track += AudioSegment.silent(len(click)-displacement-click_displacement)
- track = track.overlay(click, position=mix_from)
- else:
- log.debug('Click %s (normal) length: %s displacement: %s. Track length: %s displacement: %s',clicks,len(click),click_displacement,len(track),displacement)
- track += click
-
- #log.debug("before track: %s click: %s displace: %s",len(track),len(click),click_displacement)
- #if len(track) >= click_displacement and click_displacement > 0:
- #mix_from = len(track)-displacement-click_displacement
- ##track += AudioSegment.silent(len(click)-click_displacement)
- #track += click
- #else:
- #displace = len(click) - click_displacement
- #if displace < len(click):
- #click = click[displace:]
- #track += click
-
-
-
- #log.debug("after track: %s click: %s displace: %s",len(track),len(click),click_displacement)
-
- if len(click) > bar_length_f:
- displacement = int(round(len(click) - bar_length_f))
- else:
- displacement = 0
- #log.debug('Track displacement: %s',displacement)
-
- #track += click
- log.debug('Bars length %s Track length: %s',bars_length,len(track))
- if len(track) < bars_length:
- patch = round(bars_length - len(track))
- log.debug(patch)
- track += AudioSegment.silent(patch)
- log.debug('Click %s (end patch) length: %s displacement: %s. Track length: %s displacement: %s',clicks,len(click),click_displacement,len(track),displacement)
- """
+
if utility.file_exists(outfile):
os.unlink(outfile)
track.export(outfile,format="wav")

0 comments on commit 03b9265

Please sign in to comment.