<commit_before>//
//  YASAudioGraphSampleParameterCell.m
//

#import "YASAudioGraphSampleParameterCell.h"
#import <audio/yas_audio_umbrella.h>
#import <objc_utils/yas_objc_macros.h>

using namespace yas;

@interface YASAudioGraphSampleParameterCell ()

@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UILabel *valueLabel;
@property (nonatomic, strong) IBOutlet UISlider *valueSlider;

@end

@implementation YASAudioGraphSampleParameterCell {
    audio::avf_au_parameter_ptr _parameter;
}

- (void)dealloc {
    yas_release(_nameLabel);
    yas_release(_valueLabel);
    yas_release(_valueSlider);

    _nameLabel = nil;
    _valueLabel = nil;
    _valueSlider = nil;

    yas_super_dealloc();
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self reset];
}

- (void)prepareForReuse {
    [super prepareForReuse];
    [self reset];
}

- (void)reset {
    self->_parameter = nullptr;

    self.nameLabel.text = nil;
    self.valueSlider.minimumValue = 0.0;
    self.valueSlider.maximumValue = 1.0;
    self.valueSlider.value = 0.0;

    [self updateValueLabel];
}

- (void)set_parameter:(yas::audio::avf_au_parameter_ptr const &)parameter {
    self->_parameter = parameter;

    self.nameLabel.text = (__bridge NSString *)to_cf_object(parameter->display_name());
    self.valueSlider.minimumValue = parameter->min_value();
    self.valueSlider.maximumValue = parameter->max_value();
    self.valueSlider.value = parameter->value();

    [self updateValueLabel];
}

- (void)updateValueLabel {
    if (auto const &parameter = self->_parameter) {
        auto value_string = std::to_string(parameter->value());

        if (auto const unit_name = parameter->unit_name()) {
            value_string += " ";
            value_string += unit_name.value();
        }

        self.valueLabel.text = (__bridge NSString *)to_cf_object(value_string);
    } else {
        self.valueLabel.text = @"-";
    }
}

- (IBAction)sliderValueChanged:(UISlider *)sender {
    if (auto &parameter = self->_parameter) {
        parameter->set_value(sender.value);
        [self updateValueLabel];<commit_msg>fix sample<commit_after>//
//  YASAudioGraphSampleParameterCell.m
//

#import "YASAudioGraphSampleParameterCell.h"
#import <audio/yas_audio_umbrella.h>
#import <objc_utils/yas_objc_macros.h>

using namespace yas;

@interface YASAudioGraphSampleParameterCell ()

@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UILabel *valueLabel;
@property (nonatomic, strong) IBOutlet UISlider *valueSlider;

@end

@implementation YASAudioGraphSampleParameterCell {
    audio::avf_au_parameter_ptr _parameter;
}

- (void)dealloc {
    yas_release(_nameLabel);
    yas_release(_valueLabel);
    yas_release(_valueSlider);

    _nameLabel = nil;
    _valueLabel = nil;
    _valueSlider = nil;

    yas_super_dealloc();
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self reset];
}

- (void)prepareForReuse {
    [super prepareForReuse];
    [self reset];
}

- (void)reset {
    self->_parameter = nullptr;

    self.nameLabel.text = nil;
    self.valueSlider.minimumValue = 0.0;
    self.valueSlider.maximumValue = 1.0;
    self.valueSlider.value = 0.0;

    [self updateValueLabel];
}

- (void)set_parameter:(yas::audio::avf_au_parameter_ptr const &)parameter {
    self->_parameter = parameter;

    self.nameLabel.text = (__bridge NSString *)to_cf_object(parameter->display_name);
    self.valueSlider.minimumValue = parameter->min_value();
    self.valueSlider.maximumValue = parameter->max_value();
    self.valueSlider.value = parameter->value();

    [self updateValueLabel];
}

- (void)updateValueLabel {
    if (auto const &parameter = self->_parameter) {
        auto value_string = std::to_string(parameter->value());

        if (auto const unit_name = parameter->unit_name) {
            value_string += " ";
            value_string += unit_name.value();
        }

        self.valueLabel.text = (__bridge NSString *)to_cf_object(value_string);
    } else {
        self.valueLabel.text = @"-";
    }
}

- (IBAction)sliderValueChanged:(UISlider *)sender {
    if (auto &parameter = self->_parameter) {
        parameter->set_value(sender.value);
        [self updateValueLabel];
{'fraction_non_alphanumeric': 0.1261977097452676, 'fraction_numerical': 0.002804393549894835, 'mean_word_length': 3.808988764044944, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6273084', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1391, 'n_words': 238}