Skip to content

Commit

Permalink
chore: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
adrenak committed Dec 9, 2024
1 parent e2a61e3 commit f8411f2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 136 deletions.
96 changes: 28 additions & 68 deletions Assets/UniMic/README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,37 @@
![Cover](https://github.com/adrenak/UniMic/blob/master/cover.jpg)
## UniMic
A wrapper for Unity's Microphone class.
A wrapper for Unity's Microphone class. Proving easy APIs for mic input and management.

## API
`Mic` class in the `Adrenak.UniMic` namespace is a singleton and is accessed using `Mic.Instance`

### Properties
- `IsRecording`
Returns if the Mic instance is recording audio

- `Frequency`
The frequency of the Microphone AudioClip

- `Sample`
The last populated sample of the audio data

- `SampleDurationMS`
The duration of the sample segment in milliseconds that the instance maintains and fires in events.

- `SampleLength`
The number of samples in the sample segment

- `AudioClip`
The inner `AudioClip` of the instance

- `Devices`
The recording devices that are connected to the machine running the code

- `CurrentDeviceIndex`
The index of the active device in the `Devices` list

- `CurrentDeviceName`
The name of the active device

### Events
- `OnStartRecording`
Event fired when the instance starts to record the audio

- `OnStopRecording`
Event fired when the instance stops recording the audio

- `OnSampleReady`
Event fired when a sample of `SampleLength` has been populated by the instance.
Includes the sample count.

- `OnTimestampedSampleReady`
Event fired when a sample of `SampleLength` has been populated by the instance.
Includes the timestamp from when the sample was captured.

### Methods
- `SetDeviceIndex` changes the recording device. The method internally restarts the recording process
- `Arguments`
- `int index` the index of the device in the `Devices` list
- `Returns`
- `void`


- `StartRecording` starts the microphone recording
- `Arguments`
- `int frequency=16000` the frequency of the inner `AudioClip`
- `int sampleDurationMS` the duration of a single sample segment in milliseconds that the instance keeps and fires on event
- `Returns`
- `bool` if the microphone successfully started recording

- `ResumeRecording` resumes the microphone recording at the frequency and sampleDurationMS

- `StopRecording` stops the microphone recording
- `Returns`
- `void`
Scripting API page, better samples and more documentation coming soon.

### Usage
`Mic.Init()` to initialize UniMic

`Mic.AvailableDevices` to get a list of available `Mic.Device` objects

The following API is available in `Mic.Device`:
* `OnStartRecording` event fired when the device starts recording
* `OnFrameCollected` event fired when the device has gathered PCM data for one frame of user defined duration. Parameters:
- `int, float[]` the channel count and PCM float array of the frame
* `OnStopRecording` event fired when the device stops recording
* `Name` gets the name of the device
* `MaxFrequency` is the highest sampling frequency supported by the device
* `MinFrequency` is the lowest sampling frequency supported by the device
* `SupportsAnyFrequency` is true if the recording device supports any sampling frequeny
* `SamplingFrequency` is the user defined frequency at which is device will record
* `FrameDurationMS` is the audio duration of a single PCM frame that this device will report in the `OnFrameCollected` event
* `FrameLength` is the length of the float PCM array this device will report in the `OnFrameCollected` event
* `StartRecording(int frameDurationMS)` starts the device recording at the highest supported sampling frequency and the user defined frame duration
* `StartRecording(int samplingFrequency, int frameDurationMS)` starts the device recording at the user defined sampling frequency and frame duration
* `StopRecording()` stops the device recording
* `IsRecording` returns if the device is currently recording audio

`MicAudioSource` component is available for playing back microphone feed. This class is also a good reference for writing your own code for incoming audio data.

## Tips
Just open the Unity project in Unity 2017.4.40f1+ and try the sample scene.

## Contact
[@github](https://www.github.com/adrenak)
[@www](http://www.vatsalambastha.com)
[@website](http://www.vatsalambastha.com)
@discord: `adrenak#1934`
96 changes: 28 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,37 @@
![Cover](https://github.com/adrenak/UniMic/blob/master/cover.jpg)
## UniMic
A wrapper for Unity's Microphone class.
A wrapper for Unity's Microphone class. Proving easy APIs for mic input and management.

## API
`Mic` class in the `Adrenak.UniMic` namespace is a singleton and is accessed using `Mic.Instance`

### Properties
- `IsRecording`
Returns if the Mic instance is recording audio

- `Frequency`
The frequency of the Microphone AudioClip

- `Sample`
The last populated sample of the audio data

- `SampleDurationMS`
The duration of the sample segment in milliseconds that the instance maintains and fires in events.

- `SampleLength`
The number of samples in the sample segment

- `AudioClip`
The inner `AudioClip` of the instance

- `Devices`
The recording devices that are connected to the machine running the code

- `CurrentDeviceIndex`
The index of the active device in the `Devices` list

- `CurrentDeviceName`
The name of the active device

### Events
- `OnStartRecording`
Event fired when the instance starts to record the audio

- `OnStopRecording`
Event fired when the instance stops recording the audio

- `OnSampleReady`
Event fired when a sample of `SampleLength` has been populated by the instance.
Includes the sample count.

- `OnTimestampedSampleReady`
Event fired when a sample of `SampleLength` has been populated by the instance.
Includes the timestamp from when the sample was captured.

### Methods
- `SetDeviceIndex` changes the recording device. The method internally restarts the recording process
- `Arguments`
- `int index` the index of the device in the `Devices` list
- `Returns`
- `void`


- `StartRecording` starts the microphone recording
- `Arguments`
- `int frequency=16000` the frequency of the inner `AudioClip`
- `int sampleDurationMS` the duration of a single sample segment in milliseconds that the instance keeps and fires on event
- `Returns`
- `void`

- `ResumeRecording` resumes the microphone recording at the frequency and sampleDurationMS

- `StopRecording` stops the microphone recording
- `Returns`
- `void`
Scripting API page, better samples and more documentation coming soon.

### Usage
`Mic.Init()` to initialize UniMic

`Mic.AvailableDevices` to get a list of available `Mic.Device` objects

The following API is available in `Mic.Device`:
* `OnStartRecording` event fired when the device starts recording
* `OnFrameCollected` event fired when the device has gathered PCM data for one frame of user defined duration. Parameters:
- `int, float[]` the channel count and PCM float array of the frame
* `OnStopRecording` event fired when the device stops recording
* `Name` gets the name of the device
* `MaxFrequency` is the highest sampling frequency supported by the device
* `MinFrequency` is the lowest sampling frequency supported by the device
* `SupportsAnyFrequency` is true if the recording device supports any sampling frequeny
* `SamplingFrequency` is the user defined frequency at which is device will record
* `FrameDurationMS` is the audio duration of a single PCM frame that this device will report in the `OnFrameCollected` event
* `FrameLength` is the length of the float PCM array this device will report in the `OnFrameCollected` event
* `StartRecording(int frameDurationMS)` starts the device recording at the highest supported sampling frequency and the user defined frame duration
* `StartRecording(int samplingFrequency, int frameDurationMS)` starts the device recording at the user defined sampling frequency and frame duration
* `StopRecording()` stops the device recording
* `IsRecording` returns if the device is currently recording audio

`MicAudioSource` component is available for playing back microphone feed. This class is also a good reference for writing your own code for incoming audio data.

## Tips
Just open the Unity project in Unity 2017.4.40f1+ and try the sample scene.

## Contact
[@github](https://www.github.com/adrenak)
[@www](http://www.vatsalambastha.com)
[@website](http://www.vatsalambastha.com)
@discord: `adrenak#1934`

0 comments on commit f8411f2

Please sign in to comment.