libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
sound.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
3#pragma once
4
5#include "spimpl.h"
6
7#include "asset.h"
8
9namespace libscratchcpp
10{
11
12class Thread;
13class SoundPrivate;
14
17{
18 public:
19 enum class Effect
20 {
23 };
24
25 Sound(const std::string &name, const std::string &id, const std::string &format);
26 Sound(const Sound &) = delete;
27 virtual ~Sound() { }
28
29 int rate() const;
30 void setRate(int newRate);
31
32 int sampleCount() const;
33 void setSampleCount(int newSampleCount);
34
35 virtual void setVolume(double volume);
36 virtual void setEffect(Effect effect, double value);
37
38 virtual void start(Thread *owner = nullptr);
39 virtual void stop();
40
41 virtual bool isPlaying() const;
42
43 std::shared_ptr<Sound> clone() const;
44
45 Thread *owner() const;
46
47 protected:
48 void processData(unsigned int size, void *data) override;
49 virtual bool isClone() const override;
50
51 private:
52 void stopCloneSounds();
53
54 spimpl::unique_impl_ptr<SoundPrivate> impl;
55};
56
57} // namespace libscratchcpp
Asset(const std::string &name, const std::string &id, const std::string &format)
Definition asset.cpp:10
The Sound class represents a Scratch sound.
Definition sound.h:17
virtual ~Sound()
Definition sound.h:27
Sound(const Sound &)=delete
Effect
Definition sound.h:20
@ Pitch
Definition sound.h:21
@ Pan
Definition sound.h:22
Sound(const std::string &name, const std::string &id, const std::string &format)
Definition sound.cpp:15
The Thread class represents a running Scratch script.
Definition thread.h:19
#define LIBSCRATCHCPP_EXPORT
Definition global.h:17
The main namespace of the library.
Definition asset.h:10