Music to spectrogram on iOS with the accelerate framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 

93 lines
2.4 KiB

//
// RuledScrollView.m
// SpectogramPrototype
//
// Created by Joshua Moerman on 24/12/13.
// Copyright (c) 2013 Joshua Moerman. All rights reserved.
//
#import "RuledScrollView.h"
#import "Ruler.h"
@interface RuledScrollView () <UIScrollViewDelegate> {
CGFloat rulerHeight;
CGFloat rulerWidth;
}
- (void) initView;
@end
@implementation RuledScrollView
@synthesize content, topRuler, leftRuler;
- (id)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[self initView];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder{
if(self = [super initWithCoder:aDecoder]){
[self initView];
}
return self;
}
- (void)initView {
rulerHeight = 44;
rulerWidth = 120;
self.delegate = self;
self.backgroundColor = [UIColor whiteColor];
content = [[UIView alloc] initWithFrame:self.frame];
content.autoresizesSubviews = NO;
[self addSubview:content];
CGRect frame2 = self.frame;
frame2.size.height = rulerHeight;
topRuler = [[HorizontalRuler alloc] initWithFrame:frame2];
topRuler.layer.opacity = 0.5;
[self addSubview:topRuler];
CGRect frame3 = self.frame;
frame3.size.width = rulerWidth;
leftRuler = [[VerticalRuler alloc] initWithFrame:frame3];
leftRuler.layer.opacity = 0.5;
[self addSubview:leftRuler];
}
- (void)layoutSubviews {
[super layoutSubviews];
const CGRect frame = {.origin = self.contentOffset, .size = self.bounds.size};
const CGRect vis_frame = [self convertRect:self.bounds toView:content];
{
CGRect frame2 = frame;
frame2.size.height = rulerHeight;
self.topRuler.frame = frame2;
CGFloat begin = vis_frame.origin.x;
CGFloat end = vis_frame.origin.x + vis_frame.size.width;
topRuler.visibleInterval = (Interval){.begin = begin, .end = end};
}
{
CGRect frame2 = frame;
frame2.size.width = rulerWidth;
self.leftRuler.frame = frame2;
CGFloat begin = vis_frame.origin.y;
CGFloat end = vis_frame.origin.y + vis_frame.size.height;
leftRuler.visibleInterval = (Interval){.begin = begin, .end = end};
}
}
- (void)setContentSize:(CGSize)contentSize{
[super setContentSize:CGSizeMake(contentSize.width + rulerWidth, contentSize.height + rulerHeight)];
content.frame = CGRectMake(rulerWidth, rulerHeight, contentSize.width, contentSize.height);
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)__unused scrollView{
return content;
}
@end