Upgrade to Pro — share decks privately, control downloads, hide ads and more …

遺伝的FM音源

Fadis
October 08, 2016

 遺伝的FM音源

遺伝的アルゴリズムを使って人間がパラメータを調整する事なくFM音源から意図した音色の音を出す手法を解説します
https://github.com/Fadis/genetic_fm
追記: 発表の動画を用意しました
https://www.youtube.com/watch?v=oJy0g0mt8LA

Fadis

October 08, 2016
Tweet

More Decks by Fadis

Other Decks in Technology

Transcript

  1. Ի֊ͷҧ͍͸प೾਺ͷҧ͍Ͱ͋Δ υ $  Ϩ %  ϛ & 

    ϑΝ '  ι (  ϥ "  γ #  υ $ 
  2. $ $ $ $ ඵ ඵ ඵ ඵ ඵ ඵ

    ϐΞϊͷ$ͷԻͷप೾਺ղੳͷ݁Ռ $ $
  3. $ $ $ $ ඵ ඵ ඵ ඵ ඵ ඵ

    ϐΞϊͷ$ͷԻͷप೾਺ղੳͷ݁Ռ $ $ $ͷप೾਺)[෇ۙʹ εϖΫτϧઢ͕ݟΒΕΔ جԻ
  4. $ $ $ $ ඵ ඵ ඵ ඵ ඵ ඵ

    ϐΞϊͷ$ͷԻͷप೾਺ղੳͷ݁Ռ $ $ جԻͷ੔਺ഒͷप೾਺ʹ εϖΫτϧઢ͕ݟΒΕΔ ഒԻ
  5.       $$ $ $ $

    ЋΛม͑ͳ͕Βप೾਺ղੳΛߦͳͬͨ݁Ռ Ћ ഒԻͷେ͖͞Λௐઅ
  6. ഒ ഒ ഒ ഒ ഒ ഒ $$ $ $ $

    ТTΛม͑ͳ͕Βप೾਺ղੳΛߦͳͬͨ݁Ռ ТT ഒԻͷִؒΛௐઅ
  7. ஈ֊໨ ஈ֊໨ ஈ֊໨ ஈ֊໨ ஈ֊໨ ஈ֊໨ ஈ֊໨ ࠷ॳ͸෼ղೳͷ௿͍ प೾਺ղੳͰ ൺֱΛߦͳ͏

    ݱࡏͷ෼ղೳͰ ࠷େదԠ౓͕Ұఆճ਺ ߋ৽͞Εͳ͔ͬͨΒ ࣍ͷ෼ղೳʹਐΉ
  8. αϯϓϦϯάԻΛप೾਺ղੳ ϥϯμϜͳҨ఻ࢠΛੜ੒ ֤Ҩ఻ࢠΛ'.ԻݯͰԋ૗ ֤Ҩ఻ࢠͷԻΛप೾਺ղੳ Ұ༷ަ伹ͱಥવมҟͰҨ఻ࢠΛੜ੒ αϯϓϦϯάԻͱͷڑ཭Λܭࢉ ϧʔϨοτબ୒ͰݸମΛݫબ ࠷େ෼ղೳͰ ্ҐʹมԽ͕ݟΒΕͳ͍ ͸͍

    ͍͍͑ ෼ղೳΛ্͛Δ͔Ͳ͏͔Λ൑அ αϯϓϦϯάԻ͕ ։࢝ԿඵͰ伴൫Λԡͯ͠ /05&0/  ։࢝ԿඵͰ伴൫Λ཭ͨ͠ͷ͔ /05&0''  ͷ৘ใ͕ແ͍ͱಉ͡Α͏ʹԋ૗Ͱ͖ͳ͍
  9. $ ./find_fm_params -i ./Piano.mf.C3.aiff -o out -n 36! real 1681m6.281s!

    user 6494m54.098s! sys 72m33.467s! $ ࣌ؒ෼ඵ 04 (FOUPP-JOVYY@ MJOVY ίϯύΠϥ ($$ ''5ʹ࢖༻ͨ͠ϥΠϒϥϦ ''58 ୯ਫ਼౓ɺ0QFO.1ରԠɺ"79ରԠ $16 *OUFM$PSFJ 4LZMBLF ()[ίΞ ϝϞϦ (# αϯϓϦϯάσʔλͷ௕͞ ඵ L)[ ऴྃ৚݅ ੈ୅໨ΛٻΊͨΒऴྃ
  10. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ (1(16ͷమଇ (16͕σʔλΛॲཧ͢Δ଎͞ʹରͯ͠ 1$*&YQSFTT͸஗͍ ͜͜Λ௨Δσʔλ͸࠷খݶʹ
  11. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ (1(16ͷమଇ (16͸4*.%ͷԽ͚෺ ฒྻ౓ΛՔ͕ͳ͍ͱੑೳ͕ग़ͳ͍ QBSBMMFMPSEJF
  12. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ ϦϦʔε΍ΞλοΫΛਪఆ͢Δʹ͸ Իྔͷ࣌ؒมԽΛઢܗʹᢞΊΔඞཁ͕͋Γ ฒྻԽʹ޻෉͕ཁΓͦ͏
  13. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ ϧʔϓόοΫ෇͖ͷ'.Իݯ͸ ࣌ࠁUͷ஋Λܾఆ͢Δҝʹ ࣌ࠁUͷΦϖϨʔλͷঢ়ଶ͕ඞཁʹͳΔͨΊ ฒྻԽʹ޻෉͕ཁΓͦ͏
  14. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ େ͖͍ খ͍͞ ͦͦ͜͜ ฒྻԽ͕؆୯ͦ͏ͳ ੺ઢͷൣғΛ(16ʹ΍ͬͯ΋Β͏
  15. '.ԻݯͰԋ૗ MPHεέʔϧʹม׵ ը૾Λൺֱ ΤϯϕϩʔϓΛൺֱ ೾ܗσʔλ '.Իݯͷύϥϝʔλ ϑʔϦΤม׵ ࣌ࠁຖʹ૯࿨ΛͱΔ Իྔͷ࣌ؒมԽ ࣌ؒຖͷεϖΫτϧ

    εϖΫτϧը૾ प೾਺੒෼ͷͣΕ Իྔͷ࣌ؒมԽͷͣΕ Ի৭ͷڑ཭ OWJEJBۘ੡ͷ''5ϥΠϒϥϦDV⒎UͰย෇͚Δ
  16. __device__ void output_comp_cb(! void *dataOut, size_t offset, cufftComplex element,! void

    *callerInfo, void *sharedPtr! ) {! fft_detail *detail = (fft_detail*)callerInfo;! const size_t index =! offset % ( (detail->resolution/2) + 1 );! const size_t batch =! detail->batch_offset + offset /! ( (detail->resolution/2) + 1 );! if( index < detail->width ) {! if( batch < detail->reference_batch_count ) {! const float value = cuCabsf( element );! atomicAdd( detail->envelope + batch, value );! const float log_value_ =! 80.f * __log10f( value < 1.f ? 1.f : value );! const int log_value =! log_value_ > 255.f ?! int( 255 ) : int( log_value_ );! atomicAdd( &detail->diff, float( __sad(! log_value,! int( detail->reference[ index + detail->width * batch ] ),! 0! ) ) );! }! else {! ''5ޙͷग़ྗʹίʔϧόοΫΛઃఆ
  17. void *dataOut, size_t offset, cufftComplex element,! void *callerInfo, void *sharedPtr!

    ) {! fft_detail *detail = (fft_detail*)callerInfo;! const size_t index =! offset % ( (detail->resolution/2) + 1 );! const size_t batch =! detail->batch_offset + offset /! ( (detail->resolution/2) + 1 );! if( index < detail->width ) {! if( batch < detail->reference_batch_count ) {! const float value = cuCabsf( element );! atomicAdd( detail->envelope + batch, value );! const float log_value_ =! 80.f * __log10f( value < 1.f ? 1.f : value );! const int log_value =! log_value_ > 255.f ?! int( 255 ) : int( log_value_ );! atomicAdd( &detail->diff, float( __sad(! log_value,! int( detail->reference[ index + detail->width * batch ] ),! 0! ) ) );! }! else {! const float value = cuCabsf( element );! Իྔͷ࣌ؒมԽʹݱࡏͷ஋ΛՃࢉ
  18. ) {! fft_detail *detail = (fft_detail*)callerInfo;! const size_t index =!

    offset % ( (detail->resolution/2) + 1 );! const size_t batch =! detail->batch_offset + offset /! ( (detail->resolution/2) + 1 );! if( index < detail->width ) {! if( batch < detail->reference_batch_count ) {! const float value = cuCabsf( element );! atomicAdd( detail->envelope + batch, value );! const float log_value_ =! 80.f * __log10f( value < 1.f ? 1.f : value );! const int log_value =! log_value_ > 255.f ?! int( 255 ) : int( log_value_ );! atomicAdd( &detail->diff, float( __sad(! log_value,! int( detail->reference[ index + detail->width * batch ] ),! 0! ) ) );! }! else {! const float value = cuCabsf( element );! atomicAdd( detail->envelope + batch, value );! const float log_value_ =! 80.f * __log10f( value < 1.f ? 1.f : value );! ϦϑΝϨϯεͷεϖΫτϧը૾ͱͷ ͣΕΛٻΊͯڑ཭ʹՃࢉ
  19. $ ./find_fm_params -i ./Piano.mf.C3.aiff -o out -n 36! real 145m51.199s!

    user 126m37.108s! sys 18m57.556s! $ ࣌ؒ෼ඵ 04 (FOUPP-JOVYY@ MJOVY ίϯύΠϥ OWDD ''5ʹ࢖༻ͨ͠ϥΠϒϥϦ $V''5 $16 *OUFM$PSFJ 4LZMBLF ()[ίΞ (16 OWJEJB(F'PSDF(59()[$6%"ίΞ ϝϞϦ IPTU(#EFWJDF(# αϯϓϦϯάσʔλͷ௕͞ ඵ L)[ ऴྃ৚݅ ੈ୅໨ΛٻΊͨΒऴྃ