LoginSignup
2
3

More than 1 year has passed since last update.

【Swift】ボイスチェンジャーアプリでBluetoothイヤホンを使用して録音再生できるようにしてみた

Last updated at Posted at 2021-09-13

「おばけだぞう」と子供がしつこく言うので、変声機アプリを作ってみた。

サンプル画像:

RPReplay_Final1631489151.gif

アプリ概要:

-「Record」ボタンで音声を録音
-スライダー「Speed」「Pitch」、スイッチ「Echo」「Reverb」で声のエフェクトをかける
-「Play」ボタンで再生、モーダルに画面遷移してお化けアイコンの表示

参考サイト:
[Swift4.2]蝶ネクタイ型変声期作ってみた

課題:

再生時に「音量」が上がらない。
Bluetoothイヤホンを接続すると「録音・再生」が機能しない。

下記のサイトを参考:
AVAudioSessionで録音する際に、音はbluetoothイヤホン、マイクはデバイスマイクを使いたい

追加したコード。

Audio.swift

try session.setCategory(
                .playAndRecord,
                mode: .default,
                // オプションの内容は[]で閉じると良い
                options: [.defaultToSpeaker,      // マイク/レシーバーからマイク/スピーカーに変更
                          .allowAirPlay,          // AirPlayデバイスにストリーミング
                          .allowBluetoothA2DP])   // Bluetoothイヤホンで録音再生可能

githubにコード全文を載せています。
(https://github.com/r-tattsu2060/Voicechange/tree/main/Voicechange)

2
3
0

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
2
3