@wakapro
Revisions
Report this question
Subscribe question
Help us understand the problem. What is going on with this question?
Q&A

AudioKitのメトロノームについて

解決したいこと

AudioKit ver 4.10.1を導入し、メトロノームを使用してみようと思いましたが、戻り値の型をどう指定してあげればいいのかがわからず、困っています。
ご助言頂けるとありがたいです。

xcode ver 11.7

発生している問題・エラー

Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type

該当するソースコード

import SwiftUI
import AudioKit

struct ContentView: View {//ここでエラー発生

    var body: some View {

        let metronome = AKMetronome()

        metronome.callback = {
             print("call back")
        }

        metronome.tempo = 60.0
        metronome.subdivision = 3
        metronome.frequency1 = 2000
        metronome.frequency2 = 1000
        AudioKit.output = metronome

        do {
          try AudioKit.start()
        } catch {
            print ("error")
        }

        metronome.start()

        _ = Button(action: {
            metronome.reset()
            metronome.restart()
        }) {
            Text("START")
        }

        _ = Button(action: {
            metronome.stop()
            metronome.reset()
        }) {
            Text("STOP")
               }

       }

     }


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

自分で試したこと

ボタン以外のコードを別構造体に移せばいいのかと思いましたが、それでも同じエラーが出てしまいます。

0
1
Answer

もしかして、returnがないからではないでしょうか?

0
Help us understand the problem. What is going on with this answer?
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした