react-native-sound-generator
v0.1.0
Published
sound generator
Readme
react-native-sound-generator
A React Native library for generating and playing sine wave sounds.
Installation
npm install react-native-sound-generatoror
yarn add react-native-sound-generatoriOS Setup
Ensure you have AVFoundation linked in your Xcode project:
- Open
ios/SoundGeneratorExample.xcworkspacein Xcode. - Select your project in the left sidebar.
- Go to Build Phases > Link Binary With Libraries.
- Add
AVFoundation.frameworkif it's not already there. - Run
cd ios && pod installin your terminal.
Usage
Import the module
import SoundGenerator from 'react-native-sound-generator';Play a Sound
SoundGenerator.playSound(440); // Plays a 440 Hz sine wave (A4 note)Stop the Sound
SoundGenerator.stopSound();API
playSound(frequency: number): void
Plays a sine wave of the given frequency (in Hz).
Example:
SoundGenerator.playSound(528); // Play a 528 Hz frequencystopSound(): void
Stops the currently playing sound.
Example:
SoundGenerator.stopSound();Platform Support
- Android: Uses
AudioTrackAPI for sound synthesis. - iOS: Uses
AVFoundationfor sound synthesis.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
