電腦音樂



和弦轉 MIDI

要輸入和弦以生成MIDI音符組合的軟體有很多種,其中一些受歡迎的工具包括:
  • Captain Chords (Mixed In Key): 這是一個專業的和弦進程生成器,可以協助你創建和弦進程並將其轉換為MIDI音符。它通常作為一個插件集成到數字音頻工作站(DAW)中,例如Ableton Live、FL Studio等。
  • Scaler 2: 這是一個強大的和弦進程生成工具,可以用來探索和弦的不同變化和組合。Scaler 2也支援將生成的和弦轉換為MIDI。
  • Orb Composer: 這是一個擁有人工智慧元素的和弦生成軟體。它可以根據用戶的選擇生成新的和弦進程和旋律,並將其導出為MIDI文件。
  • RapidComposer: 這是一個音樂創作工具,可以用來生成和弦、旋律和伴奏。它有一個直觀的用戶界面,並支援MIDI導出。
  • Cthulhu (by Xfer Records): 這是一個MIDI和弦生成器,被設計成一個VST插件,可以集成到各種數字音頻工作站中。它有強大的和弦進程生成和編輯功能。
  • MIDIculous: 雖然主要是一個學習樂器演奏的軟體,但它也有一些和弦生成的功能,可以用來快速創建和弦進程。

    語音轉 MIDI

    語音轉 MIDI 技術可將聲音中的音訊訊號轉換為 MIDI 音符和資料。這使您可以唱歌或哼出旋律並將其實時轉換為音符,然後可以對其進行編輯或用於以數位方式演奏樂器。
  • 為什麼要使用語音轉 MIDI? 創意輸入:表達想法比在樂器上演奏快,特別是如果您不是訓練有素的樂器演奏家。 即興創作:透過唱歌或口技快速捕捉想法,並將其轉換為可用的 MIDI 資料。 控制虛擬樂器:使用您的聲音來控制合成器、鼓或任何可以接收 MIDI 資料的樂器。
  • 它是如何運作的? 音訊輸入:您向系統提供音訊訊號(您的聲音)。 音高偵測:軟體或外掛程式偵測您聲音的音高。 MIDI 轉換:將偵測到的音高和節奏轉換為對應的 MIDI 音符。 輸出:MIDI 資料可以觸發任何與 MIDI 相容的樂器,例如虛擬合成器或取樣器。
  • 用於語音轉 MIDI 的工具和軟體 以下是一些可以幫助您完成此過程的流行工具: Ableton Live(Max for Live Devices):Ableton 提供了一些音高轉 MIDI 外掛。 Max for Live 裝置(例如「音訊轉 MIDI」)可將人聲或音訊轉換為 MIDI。 Melodyne:一款功能強大的音調校正工具,還可以從音訊檔案匯出 MIDI 資料。 Antares Auto-Tune:這個著名的音調校正工具具有一些 MIDI 匯出功能。 WIDI 音訊到 MIDI VST:將任何音訊輸入即時轉換為 MIDI。 Reaper(附插件):Reaper DAW 可以使用 ReaTune 等插件進行即時音高追蹤和轉換。
  • 基本設定 麥克風:設定麥克風來捕捉您的聲音。 音訊介面:使用介面將音訊訊號引入 DAW(數位音訊工作站)。 語音轉 MIDI 軟體:選擇一個可以將音訊輸入轉換為 MIDI 的工具。設定插件或軟體來分析傳入的音訊。 虛擬樂器:路由 MIDI 輸出以控制虛擬樂器。
  • 在 DAW 中使用語音轉 MIDI 的步驟 錄製或輸入您的聲音:對著麥克風唱歌或哼唱。 分析音訊:使用語音轉 MIDI 插件或軟體來分析音訊。這會將其轉換為 MIDI 訊號。 編輯 MIDI 資料:轉換後,可以像 DAW 中的任何其他 MIDI 一樣編輯 MIDI 資料。您可以修正時間、更改音符或添加調變。 觸發樂器:使用 MIDI 來演奏 DAW 中的任何虛擬樂器。
  • 挑戰 準確性:語音到 MIDI 的轉換並不總是 100% 準確。可能會對音高或節奏產生誤解,尤其是在複雜的聲音輸入時。 延遲:根據您的設置,您唱歌和產生 MIDI 音符之間可能會有輕微的延遲(延遲)。 音調範圍:某些軟體可能難以偵測非常高或非常低的音調。 獲得更好結果的技巧 唱歌或哼唱時使用清晰、獨特的音高。 如果您要轉換單音符旋律,請在單音模式下工作以避免音符之間的混淆。 透過設定 MIDI 轉換,將人聲映射到特定的鼓聲,Beatbox 演奏者或打擊樂演奏者可以使用他們的聲音來觸發鼓聲。 離蒄 - 2024/10/14

    voice-to-MIDI converter using Python

    1. **Capture Audio Input**: We'll use a microphone to record the voice input.
    2. **Analyze Audio**: The audio needs to be analyzed for its frequency (pitch detection).
    3. **Convert Frequency to MIDI Notes**: The detected frequency can be mapped to MIDI notes.
    4. **Create MIDI File**: After converting the frequencies to MIDI notes, we can save them in a `.mid` file.
    
    We'll need some Python libraries to accomplish this:
    
    - `sounddevice`: For recording the audio.
    - `numpy` and `scipy`: For working with and analyzing audio signals.
    - `mido`: To create MIDI files.
    - `aubio`: For pitch detection (aubio specializes in audio-to-note detection).
    
    ### Step-by-Step Process
    
    #### Step 1: Install the Required Libraries
    First, we need to install the necessary Python libraries:
    
    ```bash
    pip install sounddevice numpy scipy mido python-rtmidi aubio
    ```
    
    #### Step 2: Capture Audio Input
    
    Here’s how you can capture audio input using `sounddevice`:
    
    ```python
    import sounddevice as sd
    import numpy as np
    
    def record_audio(duration, sample_rate=44100):
        print("Recording...")
        audio = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=1, dtype='float32')
        sd.wait()  # Wait until recording is finished
        print("Recording finished.")
        return audio.flatten()
    ```
    
    This function records audio from the microphone for a specified duration.
    
    #### Step 3: Analyze Audio for Pitch (Using `aubio`)
    
    Now, let's detect the pitch of the recorded audio using the `aubio` library:
    
    ```python
    import aubio
    
    def detect_pitch(audio, sample_rate=44100):
        pitch_detector = aubio.pitch("default", 2048, 512, sample_rate)
        pitch_detector.set_unit("Hz")
        pitch_detector.set_silence(-40)  # Adjust silence threshold if needed
        
        pitches = []
        for i in range(0, len(audio), 512):
            sample = audio[i:i + 512]
            pitch = pitch_detector(sample)[0]
            if pitch > 0:  # Only consider non-zero pitch values
                pitches.append(pitch)
        return pitches
    ```
    
    This function processes the audio and detects the pitch at regular intervals.
    
    #### Step 4: Convert Pitch to MIDI Notes
    
    MIDI notes correspond to specific frequencies. We can map detected frequencies to their nearest MIDI note numbers:
    
    ```python
    def frequency_to_midi(frequency):
        if frequency <= 0:
            return None
        midi_note = 69 + 12 * np.log2(frequency / 440.0)  # A4 = 440Hz corresponds to MIDI note 69
        return round(midi_note)
    ```
    
    #### Step 5: Create a MIDI File
    
    We can now convert the detected MIDI notes into a MIDI file using the `mido` library:
    
    ```python
    from mido import MidiFile, MidiTrack, Message
    
    def create_midi_from_pitches(pitches):
        midi_file = MidiFile()
        track = MidiTrack()
        midi_file.tracks.append(track)
        
        # Add some basic track information
        track.append(Message('program_change', program=12, time=0))
        
        # Convert each pitch to a MIDI note and add to the track
        for pitch in pitches:
            midi_note = frequency_to_midi(pitch)
            if midi_note is not None:
                track.append(Message('note_on', note=midi_note, velocity=64, time=100))
                track.append(Message('note_off', note=midi_note, velocity=64, time=200))
        
        return midi_file
    ```
    
    This function takes the detected pitches, converts them to MIDI notes, and creates a MIDI file. The `note_on` and `note_off` events are added to simulate playing and releasing the note.
    
    #### Step 6: Putting It All Together
    
    Now, we can record audio, detect the pitch, convert it to MIDI notes, and save it as a `.mid` file:
    
    ```python
    def voice_to_midi(duration):
        # Step 1: Record audio
        audio = record_audio(duration)
        
        # Step 2: Detect pitch from the recorded audio
        pitches = detect_pitch(audio)
        
        # Step 3: Create a MIDI file from the detected pitches
        midi_file = create_midi_from_pitches(pitches)
        
        # Step 4: Save the MIDI file
        midi_file.save('output.mid')
        print("MIDI file saved as 'output.mid'")
    
    # Record and convert voice to MIDI for 5 seconds
    voice_to_midi(5)
    ```
    
    ### Explanation:
    - **Step 1**: Records audio from your microphone for the given duration.
    - **Step 2**: The recorded audio is split into frames, and each frame is analyzed for its pitch.
    - **Step 3**: The detected pitch is converted to a MIDI note.
    - **Step 4**: A MIDI file is created with `note_on` and `note_off` events for each detected note.
    
    ### Notes:
    - The code is designed for monophonic melodies (i.e., one note at a time). For polyphonic melodies (multiple notes at once), more advanced techniques are required.
    - **Noise sensitivity**: Ensure that the environment is relatively quiet, as background noise can interfere with pitch detection.
    
    This script should give you a basic starting point for voice-to-MIDI conversion in Python.
    

    離蒄-柔音美景@Youtube
    . email: [email protected]
    
    T:0000
    資訊與搜尋 | 回music首頁 電話: 02-27566655 ,03-5924828 email: [email protected]