0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

なんでもガバにする2

Last updated at Posted at 2021-12-06

これの続き

今回の課題

ゲイン調整するってのがあったのでやる

今回のアプローチ

pydubのドキュメント見たら波形を上げれる最大まで上げるマキシマイザーフルテンみたいな機能があったのでこれ使ってみる
https://github.com/jiaaro/pydub/blob/master/API.markdown#audiosegmentmax_dbfs

実装

import numpy as np
import librosa
import pydub
from pydub import AudioSegment

path = "motoneta.mp3"
kick =  "gabba-kick.wav" # ガバキック音源

# とりあえずまず元ネタ音源のBPM取る
y, sr = librosa.load(path)
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)

# BPMから4分のタイムを計算する
tempo_one = 60 / (tempo*4) 


# 拡張子はうまいこと合わせて音源読み込み
base_sound = AudioSegment.from_file(path, format="mp3") 
kick_sound = AudioSegment.from_file(kick, format="wav") 


# 元ネタ曲とキックのゲインをフルテンにする
base_sound = base_sound.apply_gain(-base_sound.max_dBFS)
kick_sound = base_sound.apply_gain(-kick_sound.max_dBFS)

# 元ネタ曲の長さを取る
time = base_sound.duration_seconds

# ここがメイン処理!!!!!!!!!
#キック音源を元ネタ音源の上に載せる
start_time_ms = 0  
while(True):
        

        base_sound = base_sound.overlay(kick_sound, start_time_ms)
        start_time_ms =  start_time_ms + tempo_one * 1000

        # 適当に終わらせる
        if time * 1000 < start_time_ms:
            break
# 早くする
base_sound = base_sound.speedup(playback_speed=2.0, crossfade=0)

# 出力する
base_sound.export("gabba.mp3", format="mp3")

おしまい

聞いてみた

ゴミみたいだった

キックの音圧めっちゃ下がっとる

今後の展開

もうちょい音圧上げたい

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?