3v324v23 commited on
Commit
9e57738
1 Parent(s): 4326fd1
Files changed (1) hide show
  1. app.py +22 -51
app.py CHANGED
@@ -71,73 +71,44 @@ Colab version - https://colab.research.google.com/drive/1gEsZCCh2zMKqLmaGH5BPPLr
71
  ### Basic usage
72
  Upload your audio, enter the beat swapping pattern, change scale and shift if needed, and run it.
73
 
74
- ### pattern syntax
75
- `1, 3, 2, 4` means every 4 beats, swap 2nd and 3rd beats. You can do much more, like applying audio effects, shuffling beats, slicing them, mixing two songs, adding samples, sidechain.
 
 
 
76
 
77
- You can use spaces freely in patterns for formatting. Most other symbols have some use though. Here is the full syntax:
78
- ##### beats
79
- * `1` - 1st beat;
80
- * `1>0.5` - first half of first beat
81
- * `1<0.5` - second half of first beat
82
- * `0:0.5` - range of beats, this also means first half of first beat, but with this you can do complex stuff like `1.25:1.5`. However this one is a bit more confusing because indexing starts from 0, so 1:2 is second beat, not first.
83
- * Also sometimes it is more convenient to use smaller `scale`, like 0.5 or 0.25, instead of slicing beats.
84
- ##### basic patterns
85
- - `1, 3, 2, 4` - 3rd and 2nd beats will be swapped every 4 beats. Happens every 4 beats because 4 is the biggest number in the pattern.
86
- - `1, 2, 3, 4!` - every 4 beats, it will remove the 4th beat. `!` allows you to skip a beat but it still counts for pattern size.
87
- - `1, 4` skips 2nd and 3rd beat
88
- - `1; 2` plays 1st and second beat at the same time.
89
- ##### joining operators
90
- `,` and `;` are beat joining operators. Here are all available joiners:
91
- - `,` puts the beat next to previous beat.
92
- - `;` puts the beat on top of previous beat. Normalizes the volume to avoid clipping. If previous beat is shorter, your beat will be shortened to match it.
93
- - `^` multiplies previous beat by your beat. This can be used for fake sidechain.
94
- - `$` adds the beat on top of previous beat + sidechains previous beat by your beat (I haven't tested this one)
95
- ##### effects
96
- beats can be followed by effects. For example `1s0.75` means take first beat and play it at 0.75x speed. Here are all available effects:
97
- - `s` - speed. `1s2` means first beat will be played at 2x speed.
98
- - `r` - reverse. `1r` means first beat will have reversed audio.
99
- - `v` - volume. `1v0.5` means 1st beat will have 50% volume
100
- - `d` - downsample, or 8-bit sound. `1d10` will downsample the first beat so that it sounds 8-bit. Good values start above 7.
101
- - `b` - bitcrush. `1b4` will bitcrush it.
102
- - `g` - gradient, sounds like highpass. `1g1` is the recommended value
103
- - `c` - channel. If not followed by number, swaps channels. If followed by 0, plays only left channel. If 1, only right channel
104
- - mixing effects - `1s2rd8` - take first beat, play at 2x speed, reversed, and downsampled.
105
- ##### math
106
- mathematical expressions with `+`, `-`, `*`, `/`, and `**` are supported. For example, if you write `1/3` anywhere in the pattern, to slice beats or as effect value, it will be replaced by `0.33333333`
107
- ##### using samples, mixing two songs
108
- - WIP (you can do that if you run locally, I am just figuring out gradio UI because that requires a bunch of new input interface)
109
- ##### other stuff
110
- - `i` will be replaced by current position, e.g. `i, i, i, i+1` is equvalent to `1, 2, 3, 4 + 1`, or `1, 2, 3, 5`.
111
- - `#` will add shuffle all beats with the same number after it. `1#1, 2#2, 3#1, 4#2, 5#1, 6#2, 7#1, 8#2` will shuffle 1st, 3rd, 5th and 7th beats (the are in 1st group), and 2nd, 4th, 6th and 8th beats - from 2nd shuffle group.
112
- - `!` skips that beat. If you want to remove every 4th beat, you can't just do `1, 2, 3`, because that would simply play every 3 beats. So to play 3 beats every 4 beats, you can write `1, 2, 3, 4!`
113
- - `?` makes that beat not count for pattern size. For example, `1, 2, 3, 8` will normally repeat every 8 beats because 8 is the highest number, but `1, 2, 3, 8?` will repeat every 3 beats.
114
- - `@` allows you to take a random beat with the following syntax: @start_stop_step. For example, `@1_4_0.5` means it will take a random beat out of 1st, 1.5, 2nd, 2.5, 3rd, 3.5, and 4th. It will take whole beat, so you can also add `>0.5` to take only first half.
115
- - `%` - for very advanced patterns you can create variables from various metrics. For example, `%v` will create a variable with average volume of that beat, and all following `%` will be replaced by that variable until you create a new one. Useful for applying different effects based on different song metrics. All metrics are in `beat_manipulator/metrics.py`.
116
- ##### special patterns
117
- You can write special commands into the `pattern` argument instead of actual patterns.
118
- - `reverse` - plays all beats in reverse chronological order
119
- - `shuffle` - shuffles all beats
120
- - `test` - puts different pitched cowbells on each beat, useful for testing beat detection and adjusting it using scale and shift. Each cowbell is 1 beat, highest pitched cowbell is the 1st beat, lowest pitched - 4th.
121
- #### complex patterns
122
- You should be able to use all of the above operators in any combination, as complex as you want. Very low scales should also be fine, up to 0.01.
123
  #### scale
124
  `scale = 0.5` will insert a new beat position between every existing beat position in the beatmap. That allows you to make patterns on smaller intervals.
125
 
126
  `scale = 2`, on the other hand, will merge every two beat positions in the beatmap. Useful, for example, when beat map detection puts sees BPM as two times faster than it actually is, and puts beats in between every actual beat.
127
  #### shift
128
  Shifts the beatmap, in beats. For example, if you want to remove 4th beat every four beats, you can do it by writing `1, 2, 3, 4!`. However sometimes it doesn't properly detect which beat is first, and for example remove 2nd beat every 4 beats instead. In that case, if you want 4th beat, use `shift = 2`. Also sometimes beats are detected right in between actual beats, so shift = 0.5 or -0.5 will fix it.
129
- ## creating images
130
  You can create cool images based on beat positions. Each song produces its own unique image. This gradio app creates a 2048x2048 image from each song.
131
- ### presets
132
  A bunch of example patterns: https://github.com/stunlocked1/beat_manipulator/blob/main/beat_manipulator/presets.yaml
133
 
134
  Those are supposed to be used on normalized beat maps, where kick + snare is two beats, so make sure to adjust beatmaps using `scale` and `shift`.
135
 
136
  ### Changelog:
137
  - play two beats at the same time by using `;` instead of `,`
 
138
  - shuffle and randomize beats
139
  - gradient effect, similar to high pass
140
- - significantly reduced clicking
 
141
 
142
  ### My soundcloud https://soundcloud.com/stunlocked
143
  """
 
71
  ### Basic usage
72
  Upload your audio, enter the beat swapping pattern, change scale and shift if needed, and run it.
73
 
74
+ #### pattern syntax
75
+ patterns are sequences of **beats**, separated by commas or other separators. You can use spaces freely in patterns to make them look prettier.
76
+ * `1, 3, 2, 4` - swap 2nd and 3rd beat every four beats. Repeats every four beats because `4` is the biggest number in it.
77
+ * `1, 3, 4` - skip 2nd beat every four beats
78
+ * `1, 2, 3, 4!` - skip 4th beat every four beats. `!` skips the beat.
79
 
80
+ * `1>0.5` - plays first half of 1st beat
81
+ * `1<0.5` - plays last half of 1st beat
82
+ * `1 > 1/3, 2, 3, 4` - every four beats, plays first third of the first beat - you can use math expressions anywhere in your pattern.
83
+ * also instead of slicing beats you can use a smaller `scale` parameter to make more precise beat edits
84
+
85
+ * `1; 2, 3, 4` - every four beats, play 1st and 2nd beats at the same time.
86
+
87
+ * `1, 2r` - 2nd beat will be reversed
88
+ * `1, 2s0.5` - 2nd beat will be played at 0.5x speed
89
+ * `1, 2d10` - 2nd beat will have 8-bit effect (downsampled)
90
+
91
+ You can do much more with the syntax - shuffle/randomize beats, use samples, mix two songs, etc. Syntax is described in detail at https://huggingface.co/spaces/dpe1/BeatManipulator
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  #### scale
93
  `scale = 0.5` will insert a new beat position between every existing beat position in the beatmap. That allows you to make patterns on smaller intervals.
94
 
95
  `scale = 2`, on the other hand, will merge every two beat positions in the beatmap. Useful, for example, when beat map detection puts sees BPM as two times faster than it actually is, and puts beats in between every actual beat.
96
  #### shift
97
  Shifts the beatmap, in beats. For example, if you want to remove 4th beat every four beats, you can do it by writing `1, 2, 3, 4!`. However sometimes it doesn't properly detect which beat is first, and for example remove 2nd beat every 4 beats instead. In that case, if you want 4th beat, use `shift = 2`. Also sometimes beats are detected right in between actual beats, so shift = 0.5 or -0.5 will fix it.
98
+ #### creating images
99
  You can create cool images based on beat positions. Each song produces its own unique image. This gradio app creates a 2048x2048 image from each song.
100
+ #### presets
101
  A bunch of example patterns: https://github.com/stunlocked1/beat_manipulator/blob/main/beat_manipulator/presets.yaml
102
 
103
  Those are supposed to be used on normalized beat maps, where kick + snare is two beats, so make sure to adjust beatmaps using `scale` and `shift`.
104
 
105
  ### Changelog:
106
  - play two beats at the same time by using `;` instead of `,`
107
+ - significantly reduced clicking
108
  - shuffle and randomize beats
109
  - gradient effect, similar to high pass
110
+ - add samples to beats
111
+ - use beats from other songs
112
 
113
  ### My soundcloud https://soundcloud.com/stunlocked
114
  """