SlideShare a Scribd company logo
1 of 32
Download to read offline
初心者でもわかる
サウンドプログラミング
Who am I ?
氏名:小林慶祐
年齢:大人7歳
出身:北陸先端科学技術大学院大学
 ピアノ音の研究など
現在:会社員(スマホゲーム制作等)
正直Unity って便利ですよね
Hierarchyにサウンド配置すると
自動的に再生可能な設定に
もちろんコードでも簡単に生成可能
でもUnityでも出来ない事や苦手な事ってあるんです
Unityが苦手なこと
● イントロ付ループBGM再生
● 部分ループ
● ダッキング <- Unity5では少し改善(SnapShotを使う)
● 同時発音数制御
● 音量評価(ラウドネス計算)<- Unity5ではついに導入
● フェードIn/Out
● グループ単位での音量制御 <- Unity5では改善(AudioMixerの導入)
● etc
何かの都合でUnity4 を未だに使っている人たちにはツライ状況なんです...
今回はUnity4 でも出来るノウハウの紹介です
今回Getできるノウハウ
● 意外にやってないサウンド制御の基本
● 効果音(SE)を聞こえやすくする工夫
● 他の音を鳴らす時のBGM制御の工夫
基本 SEの工夫 BGMの工夫
意外とやってないサウンド制御の基本
■STOP処理
■フェード実装
■再生タイミングに気をつける
■グループ単位での音量指定
基本 SEの工夫 BGMの工夫
STOP処理
音鳴らすよ
再生中
あ、終わったわ
STOP
音無いから
停止っと
音鳴らすよ
再生中
途中だけど
曲変えるね
_人人人人人_
>ノイズ発生<
 ̄Y^Y^Y^Y^Y ̄
停止っと
通常
やりがち
基本 SEの工夫 BGMの工夫
STOP処理
・音が鳴っている状態で突然STOPすると「プツッ」というノイズの原因になる
・頻繁に発生すると煩わしいです
・急に大音量のノイズになることも
 ⇨耳に負荷がかかると「聴力の低下」や「難聴」の危険があります
基本 SEの工夫 BGMの工夫
STOP処理
Q. どうすればいいのか
A. 停止するときは音量が0になってからおこなう
もっと具体的に言えば、短時間のフェードアウトをかけて音量を0にしてから
基本 SEの工夫 BGMの工夫
STOP処理
音鳴らすよ
再生中
途中だけど
曲変えるね
FO
流れ STOP
PLAYPRELOAD PRESTOP
State
PRESTOP
&
FADING
STOP
STOPステートなら
リソースの破棄などを
行ってもOK
基本 SEの工夫 BGMの工夫
フェード実装
ネイティブが書けないのならコルーチンで実装すればいいじゃない。
ネイティブなら1サンプル(1/48k ~ 1/44.1k 秒単位) で制御可能
今回はフレーム単位( 0.016[s] ~ 0.03[s]) で制御(ちょっと荒い)
StartCoroutine( Fade( vol_from, vol_to, audioSource) );
基本 SEの工夫 BGMの工夫
再生タイミングに気をつける
Q. Play() すればいいじゃない
A. 一音のみならOK. それ以外はOUT
Why: 複数音を鳴らす場合、(特に同じ音の場合)
   再生タイミングがずれると変にエフェクトがかかってしまう
基本 SEの工夫 BGMの工夫
どんなことが起きるのか
■再生タイミングがズレる
→エコー、コーラス
→もしフェードアウトしつつならリバーブ
■再生タイミングが徐々にずれていく
→フランジャー
基本 SEの工夫 BGMの工夫
グループ単位での音量指定
・まず音量には全てを統括する MASTER が存在
・大抵のゲームは「BGM」「SE」「JINGLE」「VOICE」程度
(環境音とかもあるけど)
 それぞれにMasterVolume を定義してあげる。
BGMであれば、( 0.0 MASTER_VOLUME * MasterVolume_BGM )
の範囲に音量が収まっていればOK
基本 SEの工夫 BGMの工夫
グループ単位での音量指定
基本 SEの工夫 BGMの工夫
効果音を聞こえやすくする方法
■音量制御
音割れしないように何らかの工夫を施す
■同時発音数制御
同時に鳴らす事のできる数に制限を加える
基本 SEの工夫 BGMの工夫
音量制御
● 基本的に音量の最大値は1.0
● 1.0 を超える音量は1.0に抑えられる
→ 波形が変化する
→ 音が歪んだり、ノイズが入ることもある
→音割れの原因
音は基本的に波形の加算。
大量に音を鳴らすと上記問題が生じる
基本 SEの工夫 BGMの工夫
音量制御
元波形
3つ重ね
2つ重ね
4つ重ね
波形を維持できていない
基本 SEの工夫 BGMの工夫
音量制御
■実現方法
音量抑制率α[0.0 1.0]を定義
前の音を volume * α
次鳴らす音を volume * ( 1-α )とする
■問題点
・急に前の音の音量が変わって、違和感が出る可能性がある
・αが高いと次鳴らす音が十分目立たない可能性もある
基本 SEの工夫 BGMの工夫
同時発音数制御
初代ポケモンのHPが低くなった時に「ピコピコ」うるさくなるアレ
元々コンシューマーなど、ハードに音をならすチャンネル数の上限がある場合に、どう対
処するかというところからきている。
基本 SEの工夫 BGMの工夫
同時発音数制御
■実現方法A
1. まずは最大同時発音数M を定義
a. 同時にM個のオーディオ再生用オブジェクトを生成(要はオブジェクトプール)
2. 発音数がMを超える時
a. 一番再生タイミングが古い Audio をSTOPし
そこのチャンネル(オブジェクト)を使って再生
b. 鳴らさない
c. 優先度(Priority)が設定されている場合は、その優先度に合わせて適切な再生オブジェクトを見つ
ける。あれば再生、なければ再生しない
基本 SEの工夫 BGMの工夫
同時発音数制御
■実現方法B
・同じ音(SE)がある一定時間内に複数
 再生される場合2個目以降を無効
■実現方法C
・予め大量の音が鳴るとわかっている場合、律儀に一つ一つ再生せず、
 用意してある「たくさん音が鳴っている音ファイル」を再生する
基本 SEの工夫 BGMの工夫
他の音を鳴らすときのBGM制御方法
■ダッキングをしてみよう
基本 SEの工夫 BGMの工夫
ダッキングとは
ある音を鳴らす時に、その音が聞こえやすくなるようBGM等を抑制する処理
DTM でよく聞く「サイドチェーン(コンプレッサー)」もダッキングの一種。
サイドチェーンはダッキングの抑制度合いを別の音が決めるというもの
基本 SEの工夫 BGMの工夫
実際のゲームでのイメージ
Scene A: バトル中
Scene B: 会話パート
音量
時間
0
Scene A
Scene B
Start
Scene B
End
Scene A
Start
FO FI
Scene B
SceneA
この下げた分
聞き取りやすくなる
基本 SEの工夫 BGMの工夫
ダッキング
■実現方法
Unity5 のスナップショットを使う or それっぽい動作を作ろう
■それっぽい動作を作る場合
1. ダッキングが必要なシーンでBGMをある程度までフェードアウト
2. そのシーンが終了したら元の音量までフェードイン
基本 SEの工夫 BGMの工夫
ダッキング
Q. 実際ダッキングを行うとしてどれくらい下げればいいのさ?
A. サウンドデザイナーさんに聞きましょう
プログラマーはあくまでもダッキングを可能にするシステム設計がお仕事。
具体的な調整はサウンドディレクターやサウンドデザイナーさんと相談しながら行う
のがBEST.
Q. うち、サウンドデザイナーさんがいないのですが...
A. CRI・ミドルウェアさんの言葉を借りるなら「気持ち抑えているかな」程度
(UNITE での講演より)
まとめ
● 意外にやってないサウンド制御の基本
- 再生タイミング、終了タイミングに気をつけよう
- フェード実装で幅が広がる
- グループ単位の音量制御を行えるようにしよう
● 効果音(SE)を聞こえやすくする工夫
- 音量制御
- 同時発音数制御
● 他の音を鳴らす時のBGM制御の工夫
- ダッキング
ありがとうございました

More Related Content

Recently uploaded

モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 

Recently uploaded (8)

モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

初心者でもわかる サウンドプログラミング