Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.

Conversation

@ilyamore88
Copy link
Member

Closes #26

* Get current time of audio context
* @return {Number}
*/
public getCurrentTime(): number {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно сделать геттер currentTime

/**
* Class represents noise node
*/
export default class Noise {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export default class Noise {
export default abstract class Noise {

* @param destination {AudioDestinationNode} - audio context destination
*/
public connect(destination: AudioDestinationNode): void {
if (this.isConfigured) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем везде эти проверки?

/**
* Configure noise node
*/
private configure(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

приваты идут ниже пабликов

this.buffer = audioContextManager.getAudioContext().createBuffer(1, 4096, audioContextManager.getAudioContext().sampleRate);
this.buffersChannelData = this.buffer.getChannelData(0);

for (let i = 0; i < 4096; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужен коммент, или вынести в отдельный метод

/**
* Noise node status
*/
private isConfigured: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

избыточное свойство

this.bufferSourceNode.loop = true;

/**
* Add bandpass filter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не написано, для чего

if (frequency) {
this.setNoiseFrequency(frequency);
} else {
this.setNoiseFrequency(1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

просто внеси 1000 как дефолтное значение параметра

constructor(frequency?: number) {
this.configure();
if (frequency) {
this.currentFrequency = frequency;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дублирование кода

private currentFrequency: number = 1000;

/**
* Destination for noise node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

коммент не понятен

/**
* Current frequency of noise node in hertz
*/
private currentFrequency: number = 1000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это свойство сейчас нигде не используется

/**
* Configure noise node
*/
private configure(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может этот код лучше в конструктор перенести? тк тут определяются основные свойства, а приватный метод где-то внизу. Пусть лучше будет в конструкторе наверху

if (newDestination) {
this.destination = newDestination;
}
if (this.destination) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не вижу в коде, где назначается this.destination

/**
* Add bandpass filter for filtering required noise frequency
*/
this.bandpass = new BandPassFilter();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это можно сразу при объявлении свойства назначить

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create noise module

3 participants