~ubuntu-branches/ubuntu/precise/csound/precise

« back to all changes in this revision

Viewing changes to iOS/Csound iOS Examples/Csound iOS Examples/ViewControllers/AudioInTest/ConsoleOutputViewController.m

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2012-04-19 09:26:46 UTC
  • mfrom: (3.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20120419092646-96xbj1n6atuqosk2
Tags: 1:5.17.6~dfsg-1
* New upstream release
 - Do not build the wiimote opcodes (we need wiiuse).
* Add new API function to symbols file
* Disable lua opcodes, they were broken. Requires OpenMP to be enabled.
* Backport fixes from upstream:
  - Link dssi4cs with dl. Backport
  - Fix building of CsoundAC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 
 
3
 ConsoleOutputViewController.m:
 
4
 
 
5
 Copyright (C) 2011 Thomas Hass
 
6
 
 
7
 This file is part of Csound iOS Examples.
 
8
 
 
9
 The Csound for iOS Library is free software; you can redistribute it
 
10
 and/or modify it under the terms of the GNU Lesser General Public
 
11
 License as published by the Free Software Foundation; either
 
12
 version 2.1 of the License, or (at your option) any later version.   
 
13
 
 
14
 Csound is distributed in the hope that it will be useful,
 
15
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 GNU Lesser General Public License for more details.
 
18
 
 
19
 You should have received a copy of the GNU Lesser General Public
 
20
 License along with Csound; if not, write to the Free Software
 
21
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
22
 02111-1307 USA
 
23
 
 
24
 */
 
25
 
 
26
#import "ConsoleOutputViewController.h"
 
27
 
 
28
@implementation ConsoleOutputViewController
 
29
 
 
30
@synthesize currentMessage = mCurrentMessage;
 
31
 
 
32
- (IBAction)run:(UIButton *)sender
 
33
{
 
34
        mTextView.text = @"";
 
35
        
 
36
        [self.csound stopCsound];
 
37
        self.csound = [[CsoundObj alloc] init];
 
38
        [self.csound addCompletionListener:self];
 
39
        
 
40
        [self.csound setMessageCallback:@selector(messageCallback:) withListener:self];
 
41
        
 
42
        NSString *csdPath = nil;
 
43
        csdPath = [[NSBundle mainBundle] pathForResource:@"consoleoutput" ofType:@"csd"];
 
44
        [self.csound startCsound:csdPath];
 
45
}
 
46
 
 
47
- (void)updateUIWithNewMessage:(NSString *)newMessage
 
48
{
 
49
        NSString *oldText = mTextView.text;
 
50
        NSString *fullText = [oldText stringByAppendingString:newMessage];
 
51
        mTextView.text = fullText;
 
52
}
 
53
 
 
54
- (void)messageCallback:(NSValue *)infoObj
 
55
{
 
56
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
57
        Message info;
 
58
        [infoObj getValue:&info];
 
59
        char message[1024];
 
60
        vsnprintf(message, 1024, info.format, info.valist);
 
61
        NSString *messageStr = [NSString stringWithFormat:@"%s", message];
 
62
        [self performSelectorOnMainThread:@selector(updateUIWithNewMessage:)
 
63
                                                   withObject:messageStr
 
64
                                                waitUntilDone:NO];
 
65
        [pool drain];
 
66
}
 
67
 
 
68
#pragma mark - CsoundObj Listener
 
69
 
 
70
- (void)csoundObjDidStart:(CsoundObj *)csoundObj {
 
71
}
 
72
 
 
73
 
 
74
- (void)csoundObjComplete:(CsoundObj *)csoundObj {
 
75
}
 
76
 
 
77
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 
78
{
 
79
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 
80
    if (self) {
 
81
        self.title = @"Console Output";
 
82
    }
 
83
    return self;
 
84
}
 
85
 
 
86
#pragma mark - View lifecycle
 
87
 
 
88
- (void)viewDidLoad
 
89
{
 
90
    [super viewDidLoad];
 
91
}
 
92
 
 
93
- (void)viewDidUnload
 
94
{
 
95
    [super viewDidUnload];
 
96
}
 
97
 
 
98
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 
99
{
 
100
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
 
101
}
 
102
 
 
103
- (void)dealloc
 
104
{
 
105
        [mTextView release];
 
106
}
 
107
 
 
108
@end