Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #pls report bugs to u/pavlukivan on reddit
  2. #dependencies (install via pip): osu; pydub.
  3. from osu import Beatmap, SampleSet
  4. from osu.events import BackgroundEvent
  5. from pydub import AudioSegment
  6. import random, os
  7.  
  8. #one file per line
  9. bmFiles = [f for f in '''
  10. /run/media/pavlukivan/7C6CE42C6CE3DF40/osu!/Songs/118 TRF - Survival dAnce _no no cry more_/TRF - Survival dAnce ~no no cry more~ (Echo49) [Insane].osu
  11. /run/media/pavlukivan/7C6CE42C6CE3DF40/osu!/Songs/141 FAIRY FORE - Vivid/FAIRY FORE - Vivid (Hitoshirenu Shourai) [Insane].osu
  12. '''.split('\n') if f]
  13.  
  14. bms = [Beatmap(f) for f in bmFiles]
  15.  
  16. newBM = bms[0]
  17. mapID = hex(random.randint(0, 0xFFFFFFFF))[2:].zfill(8)
  18. newBM.titleA = 'Marathon ' + mapID
  19. newBM.titleU = newBM.titleA
  20. newBM.artistA = 'Various artists (maybe)'
  21. newBM.artistU = newBM.artistA
  22. newBM.creator = ''
  23. newBM.diffName = 'long thing'
  24. newBM.source = ''
  25. newBM.mapID = 0
  26. newBM.mapsetID = 0
  27. newBM.tags = ' '.join(b.tags for b in bms)
  28.  
  29. print('Importing HP/OD/CS/AR/SV from the first map. Edit it later if necessary.')
  30. audio = AudioSegment.from_file(os.path.join(os.path.dirname(bms[0].filename), bms[0].audioFile))
  31. lastObj = bms[0].audioLeadIn + bms[0].hitObjects[-1].time
  32. if len(audio) > lastObj + 2500:
  33. audio = audio[:lastObj + 2500].fade_out(2500)
  34. else:
  35. audio = audio[:len(audio)]
  36. ofs = len(audio)
  37.  
  38. for b in bms[1:]:
  39. tp = b.timingPoints
  40. li = b.audioLeadIn
  41. fadeTime = min(li, 2500)
  42. lastObj = li + b.hitObjects[-1].time
  43. for p in tp:
  44. if p.time <= lastObj:
  45. p.time += len(audio) + fadeTime
  46. if p.hitSound.sampleSet == SampleSet.AUTO:
  47. p.hitSound.sampleSet = b.sampleSet
  48. newBM.timingPoints.append(p)
  49. for o in b.hitObjects:
  50. o.time += len(audio) + fadeTime
  51. newBM.hitObjects.append(o)
  52. for e in b.events:
  53. if e.time <= lastObj and not isinstance(e, BackgroundEvent):
  54. e.time += len(audio) + fadeTime
  55. newBM.events.append(e)
  56. seg = AudioSegment.from_file(os.path.join(os.path.dirname(b.filename), b.audioFile))
  57. if len(seg) - li > lastObj + 2500:
  58. seg = seg[:lastObj + 2500 + li].fade_out(2500)
  59. else:
  60. seg = seg[:len(seg)]
  61. seg = seg[max(0, li - 2500):].fade_in(fadeTime)
  62. audio = audio.append(seg)
  63.  
  64. newBM.audioFile = 'mix.mp3'
  65. audio.export('mix.mp3', format='mp3', bitrate='192k')
  66. newBM.save('map.osu')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement