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

Accelerate.vDSPとSwift Chartsでぶち上がろう!/サイボウズモバイル ...

Accelerate.vDSPとSwift Chartsでぶち上がろう!/サイボウズモバイル Meetup 2023.04.20

Kyome (Takuto Nakamura)

December 20, 2023
Tweet

More Decks by Kyome (Takuto Nakamura)

Other Decks in Programming

Transcript

  1. #cybozu_mobile MediaPlayer Framework Λ࢖͏ MPMediaLibrary.requestAuthorization() ͰϛϡʔδοΫΞϓϦͷ
 ϥΠϒϥϦ΁ͷΞΫηεΛཁٻͰ͖Δ Info.plist ʹ NSAppleMusicUsageDescription

    Λهड़͢Δඞཁ͕͋Δ MPMediaQuery.songs().items ͰۂҰཡΛऔಘͰ͖Δ λΠτϧɺΞʔτϫʔΫɺԻݯϑΝΠϧͷύεͳͲ͕ೖखՄೳ ࣮૷ํ਑ɿϛϡʔδοΫΞϓϦ͔ΒۂͷϦετΛऔಘ
  2. #cybozu_mobile ࣮૷ํ਑ɿۂͷ࠶ੜ࣌ʹԻݯσʔλΛऔಘͯ͠దٓՃ޻ ۂ͸ AVFoundation Framework ͷ AVAudioPlayerNode() Ͱ࠶ੜ͢Δ Իݯσʔλ͸ AVAudioNode.installTap(onBus:

    bu ff erSize: format: ) Ͱ
 AVAudioPCMBu ff er ΛऔಘͰ͖Δ Accelerate Framework ͷ vDSP Λར༻ͯ͠ৼ෯εϖΫτϧ΍
 RMSʢԻͷฏۉΤωϧΪʔʣΛࢉग़͢Δ ৼ෯εϖΫτϧΛಘΔʹ͸ FFTʢߴ଎ϑʔϦΤม׵ʣΛߦ͏
  3. #cybozu_mobile ࣮૷ํ਑ɿۂͷ࠶ੜ࣌ʹԻݯσʔλΛऔಘͯ͠దٓՃ޻ ۂ͸ AVFoundation Framework ͷ AVAudioPlayerNode() Ͱ࠶ੜ͢Δ Իݯσʔλ͸ AVAudioNode.installTap(onBus:

    bu ff erSize: format: ) Ͱ
 AVAudioPCMBu ff er ΛऔಘͰ͖Δ Accelerate Framework ͷ vDSP Λར༻ͯ͠ৼ෯εϖΫτϧ΍
 RMSʢԻͷฏۉΤωϧΪʔʣΛࢉग़͢Δ ৼ෯εϖΫτϧΛಘΔʹ͸ FFTʢߴ଎ϑʔϦΤม׵ʣΛߦ͏ ਺ֶྗ͕ඞཁ 📐
  4. #cybozu_mobile ࣮૷ํ਑ɿԻݯσʔλΛجʹ SwiftUI Ͱ Audio Visualizer Λදࣔ iOS 16͔Β࢖͑Δ Charts

    Framework Λ׆༻͢Δ ંΕઢάϥϑɺ๮άϥϑɺࢄ෍ਤΛར༻͢Δ ࢄ෍ਤͰ͸ɺChartSymbolShape ʹ४ڌͨࣗ͠༝ͳਤܗΛࢦఆͨ͠࠲ඪʹ ϓϩοτͰ͖Δʢˡͱʹ͔͘ڧྗɻແݶͷՄೳੑΛײ͡Δʣ Charts ొ৔Ҏલ͸ Path ΍ Canvas (GraphicsContext) Λར༻ͯ͠
 άϥϑΛࣗલ࣮૷͠ͳ͍ͱ͍͚ͳ͔ͬͨͷͰศརʹͳͬͨ
  5. #cybozu_mobile গ͠ղઆ BarMark Λ༻͍ͨ๮άϥϑ BarMark ͷ stacking Λ .center ʹ͢Δͱ


    ઢରশͳάϥϑΛඳ͚Δ Source: https://github.com/Kyome22/ShootingStar.git
  6. #cybozu_mobile গ͠ղઆ ๮άϥϑʹݟ͑Δ͔΋͠Εͳ͍͕ɺ
 ͜Ε͸ࢄ෍ਤ Prot ͱ PointMark Λ࢖༻ͯ͠؀ঢ়ʹ௕ํܗ
 ͷج఺Λ഑ஔ͢Δ ֤௕ํܗ͸֯౓ͱ௕͞ΛมߋͰ͖ΔΑ͏ʹ


    ͓ͯ͘͠ தԝͷԁ͸RMSʹ߹Θͤͯ scaleE ff ect Ͱ
 େ͖͞ΛมԽ͍ͤͯ͞ΔʢάϥϑͰ͸ͳ͍ʣ Source: https://github.com/Kyome22/ShootingStar.git