View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Swan's Quest, Chapter 2: A time for tones

    Swift Playgrounds presents "Swan's Quest,” an interactive adventure in four chapters for all ages. In this chapter, our Hero needs your help decoding the Swan's scroll. Call forth the best of your audio abilities on this one — you're going to need them.

    Discover how to convert Swift Playgrounds into a tone generator, and you just might help our Hero find the missing message… and move onto the next part of their quest.

    Swan's Quest was created for Swift Playgrounds on iPad and Mac, combining frameworks and resources which power the educational experiences in many of our playgrounds, including Sonic Workshop, Sensor Arcade, and Augmented Reality. To learn more about building your own playgrounds, be sure to watch "Create Swift Playgrounds content for iPad and Mac".

    And don't forget to stop by the Developer Forums and share your solution for our side quest.

    Recursos

    • Quest Create playground book
    • Swan's Quest: A time for tones playground book
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC20

    • Build a SwiftUI view in Swift Playgrounds
    • Create Swift Playgrounds content for iPad and Mac
    • Swan's Quest, Chapter 1: Voices in the dark
    • Swan's Quest, Chapter 3: The notable scroll
    • Swan's Quest, Chapter 4: The sequence completes
  • Buscar neste vídeo...
    • 1:09 - ToneOutput.swift

      //  ToneOutput.swift
      
      public class ToneOutput : AURenderCallbackDelegate {
          let sampleRate = 44100.0
      
          public func play(tone: Tone) { /**/ }
         
          public func stopTones() { /**/ }
      
          // ...
      
      }
    • 1:30 - Inside the Tone type

      //  ToneOutput.swift
       
      public struct Tone: Codable {
          public var pitch: Double
          public var volume: Double
          
          // ...
      }
    • 1:45 - Play a middle A

      // Play a middle A
      
      import SPCAudio
      
      let toneOutput = ToneOutput()
      let middleA = Tone(pitch: 440.0, volume: 0.3) 
      toneOutput.play(tone: middleA)
    • 2:21 - Play a middle A for 0.5 seconds

      // Play a middle A
      
      import SPCAudio
      
      let toneOutput = ToneOutput()
      let a4 = Tone(pitch: 440.0, volume: 0.3)
      toneOutput.play(tone: a4)
      
      DispatchQueue.main.asyncAfter(deadline: .now() + DispatchTimeInterval.milliseconds(400)) {
          toneOutput.stopTones()
      }
    • 2:51 - Play more than one tone

      // Play more than one tone
      
      let toneOutput = ToneOutput()
      let tones = [
          Tone(pitch: 440.00, volume: 0.3),
          Tone(pitch: 493.88, volume: 0.3),
          Tone(pitch: 523.25, volume: 0.3) 
      ]
      
      var toneIndex = 0
      Timer.scheduledTimer(withTimeInterval: 0.4, repeats: true) { timer in
          guard toneIndex < tones.count else {
              toneOutput.stopTones()
              timer.invalidate()
              owner.endPerformance()
              return
          }
          
          toneOutput.play(tone: tones[toneIndex])
          toneIndex += 1
      }

Developer Footer

  • Vídeos
  • WWDC20
  • Swan's Quest, Chapter 2: A time for tones
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines