rflex / scwaveformview Goto Github PK
View Code? Open in Web Editor NEWA blazing fast customizable waveform view
License: Apache License 2.0
A blazing fast customizable waveform view
License: Apache License 2.0
Hi,
This is superb library thank you very much. How can I get it to load a file that I recorded instead of a file stored in the NS Main Bundle? I have tried the following but they don't work:
// "myURL" being a string like so:
// file:///var/mobile/Containers/Data/Application/35B72EE7-7320-4185-9B2E-55C540F738FD/Documents/23Feb2015_065229am.aif
NSURL *assetURL = [NSURL URLWithString:myURL];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
I have tried so many different things and they dont work :(
Hi,
I want to use this lib while recording as well, how to do this?
Thanks.
how to get this working for online url music? it only works with saved music but i want it to work with online too, any ideas?
There is some performance issue (lagging) when trying to reload the tableview which contains a number of cells that was added with the waveform view. I have tried to concurrently load the waveform view with GCD but it is not very stable — keep crashing.
When I call SCWaveformView generateWaveformImage:asset withColor:[UIColor purpleColor] andSize:CGSizeMake(640, 332) antialiasingEnabled:YES];, the entire image is output as about 75% transparent, whereas if I pass in NO for antialiasingEnabled, I miss out on the smoothing of the edges, but at least the center of the waveform is fully opaque.
First off, Love this component - kudos. Can't wait to get it working!
I am building an SCWaveformView through code, and using autolayout (SnapKit, to be exact). Here is the code for doing so:
waveformView = SCWaveformView(frame: CGRectZero)
waveformView.precision = 0.25
waveformView.lineWidthRatio = 0.5
waveformView.normalColor = UIColor.lightGrayColor()
waveformView.progressColor = UIColor.mbTurquoiseColor()
waveformView.progressTime = kCMTimeZero
mainPlayerPanel.addSubview(waveformView)
waveformView.snp_makeConstraints { (make) in
make.width.equalTo(UIScreen.mainScreen().bounds.width * 0.7)
make.top.equalTo(artistNameFull.snp_bottom).offset(45)
make.centerX.equalTo(mainPlayerPanel)
make.height.equalTo(75)
}
However. I'm not adding the asset until viewDidLayoutSubviews is being called. Here is the code for that.
let asset = AVAsset(URL: NSURL(string: NSBundle.mainBundle().pathForResource("credits", ofType: "mp3")!)!)
waveformView.asset = asset
let timeRang = CMTimeRangeMake(kCMTimeZero, waveformView.actualAssetDuration)
waveformView.timeRange = timeRang
Once this is done, I would expect my waveform view to show up/be drawn. However, its not. Am I doing something incorrect that I'm not seeing?
Thanks!
I have a couple of crashes reported where it looks like the SCScrollableWaveformView
gets into a nasty loop when the KVO observing function changes the time range and then this somehow results in the observing function triggering again to update the scroll view which then triggers the observing function to trigger and update the waveform which changes the time range again.
Here is a chunk of the stack trace that started it (which then effectively repeats many many times before crashing):
0x1002bcc28 -SCScrollableWaveformView _updateWaveform
0x1002bcf7c -SCScrollableWaveformView observeValueForKeyPath:ofObject:change:context:
4113 Foundation 0x18499bf64 NSKeyValueNotifyObserver + 304
4114 Foundation 0x18499ba8c NSKeyValueDidChange + 404
4115 Foundation 0x184a461ac -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:] + 732
4116 Foundation 0x18499afc0 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 64
4117 Foundation 0x184a43b38 _NSSetPointValueAndNotify + 284
0x1002bce34 -SCScrollableWaveformView _updateScrollView
0x1002bcf7c -SCScrollableWaveformView observeValueForKeyPath:ofObject:change:context:
4120 Foundation 0x18499bf64 NSKeyValueNotifyObserver + 304
4121 Foundation 0x18499ba8c NSKeyValueDidChange + 404
4122 Foundation 0x184986624 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 120
0x1002c01dc -SCWaveformView setTimeRange:
4124 CoreFoundation 0x1840a4a60 invoking_ + 144
4125 CoreFoundation 0x183f9c488 -[NSInvocation invoke] + 284
4126 Foundation 0x1849ad270 NSKVOForwardInvocation + 300
4127 CoreFoundation 0x1840a2a1c _forwarding_ + 408
4128 CoreFoundation 0x183fa0c5c _CF_forwarding_prep_0 + 92
0x1002bcc28 -SCScrollableWaveformView _updateWaveform
0x1002bcf7c -SCScrollableWaveformView observeValueForKeyPath:ofObject:change:context:
4131 Foundation 0x18499bf64 NSKeyValueNotifyObserver + 304
4132 Foundation 0x18499ba8c NSKeyValueDidChange + 404
4133 Foundation 0x184a461ac -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:] + 732
4134 Foundation 0x18499afc0 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 64
4135 Foundation 0x184a43b38 _NSSetPointValueAndNotify + 284
4136 UIKit 0x1893b8c54 -[UIScrollView _smoothScrollWithUpdateTime:] + 2400
`
Is anyone else encountering this problem?
I don't have direct steps to reproduce this problem but I have 3 reports in the last 2 days (two on iPhone 6 with iOS 9.3.4 and one on iPhone 6s with iOS 9.3.3).
Here is my code:
UIButton *tempButton = (UIButton *) sender;
SCWaveformView *waveformView = [[SCWaveformView alloc] init];
AVAsset *asset = [AVURLAsset URLAssetWithURL:currentRecordingPath options:nil];
waveformView.asset = asset;
waveformView.normalColor = [UIColor greenColor];
[waveformView generateWaveforms];
UIImage *normalWaveformImage = waveformView.generatedNormalImage;
UIImageView *waveformimageview = [[UIImageView alloc] initWithFrame:tempButton.frame];
waveformimageview.image = normalWaveformImage;
waveformimageview.backgroundColor = [UIColor purpleColor];
[scrollView addSubview:waveformimageview];
I can see the purple background color but I never actually get a waveform.
This gets printed to the console when my app runs through your code:
: CGContextSetAllowsAntialiasing: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
How can I map the data from EZAudio microphone when user is recording the data from EZMicrophone class to the SC Waveforms? Can you give me some ideas?
Xcode 8 is throwing a warning at
_waveformSuperlayer.delegate = _waveformLayersDelegate;
This is happening because SCWaveformLayerDelegate is not explicitly declared to implement CALayerDelegate, and CALayer has delegate property now defined as
@Property(nullable, weak) id delegate;
Im using your demo ios app to show the waves related to this file: https://drive.google.com/file/d/0B898a2Y5OUavQUZUQjNfQlFzSWM/view?usp=sharing
but the output shows the waves in a constant value.
The same file using this web audio editor https://twistedwave.com/ show the correct output
Is there any special configuration that in the demo app to change the output? Thanks
I would like to be able to show a left and right channel waveform. Is this possible?
I know Swift is in flux, but a Swift version (start with 2.0) would be nice. Bridging headers are always an option, but how about Swift? ;)
I'm seeing this error after setting the asset. Any ideas?
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [0 nan]'
Trace leads to SCWaveformView.m's layoutSubviews
.
Throws the following errors:
SCWaveformView Group
Parse Issue Group
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:26:1: Unexpected '@' in program
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:28:1: '@EnD' must appear in an Objective-C context
Semantic Issue Group
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:30:17: Cannot find interface declaration for 'SCWaveformLayer'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:30:17: Class 'SCWaveformLayer' defined without specifying a base class
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:35:1: Duplicate interface definition for class 'SCWaveformLayerDelegate'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:126:19: Property 'anchorPoint' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:127:19: Property 'delegate' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:129:46: Incompatible pointer types sending 'SCWaveformLayer *' to parameter of type 'CALayer * _Nonnull'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:238:27: Property 'backgroundColor' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:239:27: Property 'backgroundColor' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:242:23: Property 'frame' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:245:23: Property 'waveformTime' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:298:49: Property 'waveformTime' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:302:27: Property 'backgroundColor' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:303:27: Property 'backgroundColor' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:308:39: Property 'bounds' not found on object of type 'SCWaveformLayer *'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:310:23: Property 'bounds' not found on object of type 'SCWaveformLayer *'
ARC Semantic Issue Group
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:114:24: No visible @interface for 'SCWaveformLayer' declares the selector 'removeFromSuperlayer'
/Downloads/SCWaveformView-master/Sources/SCWaveformView.m:125:55: No known class method for selector 'new'
The file “SCWaveformViewTests-Info.plist” couldn’t be opened because there is no such file.
how can i add zoom in zoom out to scroll view and also a timeline.
and also selection range.
please help me?
The wave not working for file more 20 minutes.
how do I fix it?
Thanks.
This project appears to be a fork of https://github.com/fulldecent/FDWaveformView
Would you like to contribute back an anti-aliasing code to that project?
Hi,
This is just a quick note to anyone using this library. You have to include UIKit framework on the SCWaveformView class for it to work without errors like so:
In SCWaveformView.h add the following:
#import <UIKit/UIKit.h>
All the processing of reading the audio-file & generating the waveform occurs on the main thread which locks up the UI when giving the view a large file.
Everything should occur off the main thread (rendering waveform + reading assets) with occasional refreshes of updates as more of the waveform is processed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.