diff --git a/common/JackNetAPI.cpp b/common/JackNetAPI.cpp index 137f3da9..f83cab53 100644 --- a/common/JackNetAPI.cpp +++ b/common/JackNetAPI.cpp @@ -448,9 +448,9 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf int fConnectTimeOut; JackNetExtSlave(const char* ip, - int port, - const char* name, - jack_slave_t* request) + int port, + const char* name, + jack_slave_t* request) :fThread(this), fProcessCallback(NULL),fProcessArg(NULL), fShutdownCallback(NULL), fShutdownArg(NULL), @@ -542,7 +542,6 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf return 0; } - void AllocPorts() { unsigned int port_index; diff --git a/common/JackNetTool.cpp b/common/JackNetTool.cpp index 210f1f94..5a9cf42d 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -476,7 +476,6 @@ namespace Jack fSubPeriodBytesSize = fCompressedSizeByte / fNumPackets; fSubPeriodSize = fSubPeriodBytesSize / sizeof(short); - //fLastSubPeriodBytesSize = fSubPeriodBytesSize + (fCompressedSizeByte - (fSubPeriodBytesSize * fNumPackets)); fLastSubPeriodBytesSize = fSubPeriodBytesSize + fCompressedSizeByte % fNumPackets; fLastSubPeriodSize = fLastSubPeriodBytesSize / sizeof(short); diff --git a/common/jack/net.h b/common/jack/net.h index 09ab5338..8a5894c7 100644 --- a/common/jack/net.h +++ b/common/jack/net.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009 Grame + Copyright (C) 2009-2010 Grame This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -44,9 +44,9 @@ enum JackNetMode { enum JackNetEncoder { - JackFloatEncoder = 0, - JackIntEncoder = 1, - JackCeltEncoder = 2, + JackFloatEncoder = 0, // Samples are transmitted as float + JackIntEncoder = 1, // Samples are transmitted as 16 bits integer + JackCeltEncoder = 2, // Samples are transmitted using CELT codec (http://www.celt-codec.org/) }; typedef struct { @@ -55,11 +55,11 @@ typedef struct { int audio_output; // to master or from slave int midi_input; // from master or to slave int midi_output; // to master or from slave - int mtu; + int mtu; // Network Maximum Transmission Unit int time_out; // in second, -1 means in infinite - int encoder; + int encoder; // Encoder type (one of JackNetEncoder) int kbps; // KB per second for CELT encoder - char mode; + char mode; } jack_slave_t; @@ -99,14 +99,14 @@ int jack_net_slave_close(jack_net_slave_t* net); /** * Prototype for Process callback. * @param nframes buffer size - * @param audio_input number of audio inputs - * @param audio_input_buffer an array of audio input buffers + * @param audio_input number of audio inputs + * @param audio_input_buffer an array of audio input buffers (from master) * @param midi_input number of MIDI inputs - * @param midi_input_buffer an array of MIDI input buffers + * @param midi_input_buffer an array of MIDI input buffers (from master) * @param audio_output number of audio outputs - * @param audio_output_buffer an array of audio output buffers + * @param audio_output_buffer an array of audio output buffers (to master) * @param midi_output number of MIDI outputs - * @param midi_output_buffer an array of MIDI output buffers + * @param midi_output_buffer an array of MIDI output buffers (to master) * @param arg pointer to a client supplied structure supplied by jack_set_net_process_callback(). * * @return zero on success, non-zero on error @@ -242,7 +242,7 @@ int jack_net_master_recv(jack_net_master_t* net, int audio_input, float** audio_ /** * Send sync and data to the network * @param net the network connection - * @param audio_output number of audio ouputs + * @param audio_output number of audio outputs * @param audio_output_buffer an array of audio output buffers * @param midi_output number of MIDI ouputs * @param midi_output_buffer an array of MIDI output buffers @@ -261,6 +261,12 @@ typedef struct _jack_adapter jack_adapter_t; /** * Create an adapter. + * @param input number of audio inputs + * @param output of audio outputs + * @param host_buffer_size the host buffer size in frames + * @param host_sample_rate the host buffer sample rate + * @param adapted_buffer_size the adapted buffer size in frames + * @param adapted_sample_rate the adapted buffer sample rate * * @return 0 on success, otherwise a non-zero error code */ @@ -272,29 +278,42 @@ jack_adapter_t* jack_create_adapter(int input, int output, /** * Destroy an adapter. + * @param adapter the adapter to be destroyed * * @return 0 on success, otherwise a non-zero error code */ int jack_destroy_adapter(jack_adapter_t* adapter); - +/** + * Flush internal state of an adapter. + * @param adapter the adapter to be flushed + * + * @return 0 on success, otherwise a non-zero error code + */ void jack_flush_adapter(jack_adapter_t* adapter); /** - * Push input to and pull output from ringbuffer + * Push input to and pull output from adapter ringbuffer + * @param adapter the adapter + * @param input an array of audio input buffers + * @param output an array of audio ouput buffers + * @param frames number of frames * * @return 0 on success, otherwise a non-zero error code */ int jack_adapter_push_and_pull(jack_adapter_t* adapter, float** input, float** output, unsigned int frames); /** - * Pull input to and push output from ringbuffer - * + * Pull input to and push output from adapter ringbuffer + * @param adapter the adapter + * @param input an array of audio input buffers + * @param output an array of audio ouput buffers + * @param frames number of frames + * * @return 0 on success, otherwise a non-zero error code */ int jack_adapter_pull_and_push(jack_adapter_t* adapter, float** input, float** output, unsigned int frames); - #ifdef __cplusplus } #endif diff --git a/macosx/iphone/MainWindow.xib b/macosx/iphone/MainWindow.xib index 175cb7bd..a36742fe 100644 --- a/macosx/iphone/MainWindow.xib +++ b/macosx/iphone/MainWindow.xib @@ -1,11 +1,15 @@ - + 528 - 9E17 - 672 - 949.33 - 352.00 + 10C540 + 740 + 1038.25 + 458.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 62 + YES @@ -14,6 +18,15 @@ YES com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + YES + + + YES + + YES @@ -26,6 +39,31 @@ 1316 + + YES + + + 1316 + {{25, 40}, {267, 21}} + + NO + YES + NO + NetJack : client on JACK server + + Helvetica-Bold + 17 + 16 + + + 1 + MCAwIDAAA + + + 1 + 10 + + {320, 480} @@ -63,9 +101,7 @@ YES 0 - - YES - + @@ -74,36 +110,44 @@ YES + - + -1 - - RmlsZSdzIE93bmVyA + + File's Owner 3 - + -2 - + + + + 10 + + YES - + YES -1.CustomClassName -2.CustomClassName + 10.IBPluginDependency 2.IBAttributePlaceholdersKey 2.IBEditorWindowLastContentRect 2.IBPluginDependency + 2.IBUserGuides 3.CustomClassName 3.IBPluginDependency @@ -111,26 +155,31 @@ YES UIApplication UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin YES - - YES - + YES - {{438, 320}, {320, 480}} + {{366, 320}, {320, 480}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + 153.5 + 0 + + iPhoneNetAppDelegate com.apple.InterfaceBuilder.IBCocoaTouchPlugin YES - - YES - + YES @@ -138,15 +187,13 @@ YES - - YES - + YES - 9 + 11 @@ -155,12 +202,21 @@ iPhoneNetAppDelegate NSObject - window - UIWindow + YES + + YES + navigationController + window + + + YES + UINavigationController + UIWindow + IBProjectSource - Classes/iPhoneNetAppDelegate.h + iPhoneNetAppDelegate.h @@ -172,9 +228,213 @@ + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIResponder + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + 0 + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES iPhoneNet.xcodeproj 3 + 3.1 diff --git a/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj b/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj index a5db89b8..4b976838 100755 --- a/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj +++ b/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 4B4146AA10BD3C4300C12F0C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 4B4146AB10BD3C4300C12F0C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 4B4146AC10BD3C4300C12F0C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1A95750F49CEAB00D3626B /* AudioToolbox.framework */; }; + 4B6B712C114BAE9A00ED9788 /* CAHostTimeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF15E2411356A3E00B36B9A /* CAHostTimeBase.cpp */; }; 4B9CB1371136CA99007DE01A /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B9CB1361136CA99007DE01A /* icon.png */; }; 4B9CB1381136CA99007DE01A /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B9CB1361136CA99007DE01A /* icon.png */; }; 4B9CB1391136CA99007DE01A /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B9CB1361136CA99007DE01A /* icon.png */; }; @@ -182,7 +183,7 @@ 4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaust.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4BCB37D5112D64B4008C7BC1 /* HardwareClock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareClock.cpp; sourceTree = SOURCE_ROOT; }; 4BCB37D8112D64D8008C7BC1 /* iphone-faust.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "iphone-faust.mm"; sourceTree = SOURCE_ROOT; }; - 4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaustNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneThruNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4BCF75F610BC30140082C526 /* audio_thru.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = audio_thru.mm; sourceTree = SOURCE_ROOT; }; 4BDFCD57113DB6B700D77992 /* NetJackSlave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackSlave.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4BF1360E0F4B0B4C00218A3F /* JackAudioAdapterInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackAudioAdapterInterface.cpp; path = ../../common/JackAudioAdapterInterface.cpp; sourceTree = SOURCE_ROOT; }; @@ -292,7 +293,7 @@ 4BFF45120F4D59DB00106083 /* libjacknet.a */, 4BFF45770F4D5D9700106083 /* iPhoneFaustNet.app */, 4B0772380F54018C000DC657 /* NetJackMaster.app */, - 4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */, + 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */, 4B4146B010BD3C4300C12F0C /* iPhoneFaustNet.app */, 4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */, 4BDFCD57113DB6B700D77992 /* NetJackSlave.app */, @@ -485,7 +486,7 @@ ); name = iPhoneThruNet; productName = iPhoneNet; - productReference = 4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */; + productReference = 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */; productType = "com.apple.product-type.application"; }; 4BDFCD3B113DB6B700D77992 /* iPhoneNetSlaveLib */ = { @@ -672,6 +673,7 @@ 4BF1364E0F4B0F7700218A3F /* JackResampler.cpp in Sources */, 4BF136560F4B0F9F00218A3F /* ringbuffer.c in Sources */, 4B2791890F72570C000536B7 /* JackGlobals.cpp in Sources */, + 4B6B712C114BAE9A00ED9788 /* CAHostTimeBase.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -885,6 +887,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; HEADER_SEARCH_PATHS = ( + /usr/local/include, ../../common/jack, ../../common, ../../posix, @@ -907,6 +910,7 @@ GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; HEADER_SEARCH_PATHS = ( + /usr/local/include, ../../macosx, ../../posix, ../../common, diff --git a/macosx/iphone/main_master.mm b/macosx/iphone/main_master.mm index 86fec8b3..7ec618b3 100644 --- a/macosx/iphone/main_master.mm +++ b/macosx/iphone/main_master.mm @@ -40,13 +40,11 @@ static void MasterAudioCallback(int frames, float** inputs, float** outputs, voi { int i; - // Copy from iPod input to network buffers for (i = 0; i < result.audio_input; i++) { memcpy(audio_input_buffer[i], inputs[i], buffer_size * sizeof(float)); } - /* // Copy from network out buffers to network in buffers (audio thru) for (i = 0; i < result.audio_input; i++) { @@ -76,9 +74,7 @@ static void MasterAudioCallback(int frames, float** inputs, float** outputs, voi int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int i; - int wait_usec = (unsigned long)((((float)buffer_size) / ((float)sample_rate)) * 1000000.0f); if ((net = jack_net_master_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPhone", &request, &result)) == 0) { printf("jack_net_master_open error..\n"); @@ -112,12 +108,12 @@ int main(int argc, char *argv[]) { return -1; } - // Run until interrupted - //while (1) {} - /* // Quite brutal way, the application actually does not start completely, the netjack audio processing loop is used instead... // Run until interrupted + + int wait_usec = (unsigned long)((((float)buffer_size) / ((float)sample_rate)) * 1000000.0f); + while (1) { // Copy input to output @@ -141,7 +137,6 @@ int main(int argc, char *argv[]) { audio_device.Stop(); audio_device.Close(); - // Wait for application end jack_net_master_close(net); diff --git a/macosx/iphone/main_slave.mm b/macosx/iphone/main_slave.mm index b3eea568..b4ef278b 100644 --- a/macosx/iphone/main_slave.mm +++ b/macosx/iphone/main_slave.mm @@ -31,13 +31,11 @@ static int net_process(jack_nframes_t buffer_size, void** midi_output_buffer, void* data) { - - //printf("audio_input %d audio_output %d \n", audio_input, audio_output); jack_adapter_pull_and_push(adapter, audio_output_buffer, audio_input_buffer, buffer_size); // Process input, produce output if (audio_input == audio_output) { - // Copy input to output + // Copy net input to net output for (int i = 0; i < audio_input; i++) { memcpy(audio_output_buffer[i], audio_input_buffer[i], buffer_size * sizeof(float)); } @@ -51,7 +49,6 @@ static void net_shutdown(void *arg) jack_flush_adapter(adapter); } - static void SlaveAudioCallback(int frames, float** inputs, float** outputs, void* arg) { jack_adapter_push_and_pull(adapter, inputs, outputs, frames); @@ -70,7 +67,7 @@ int main(int argc, char *argv[]) { //if ((net = jack_net_slave_open("169.254.112.119", DEFAULT_PORT, "iPhone", &request, &result)) == 0) { if ((net = jack_net_slave_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPod", &request, &result)) == 0) { - printf("jack_net_master_open error..\n"); + printf("jack_net_slave_open error..\n"); return -1; } @@ -85,7 +82,6 @@ int main(int argc, char *argv[]) { TiPhoneCoreAudioRenderer audio_device(NUM_INPUT, NUM_OUTPUT); - jack_set_net_slave_process_callback(net, net_process, NULL); jack_set_net_slave_shutdown_callback(net, net_shutdown, NULL); @@ -109,7 +105,6 @@ int main(int argc, char *argv[]) { audio_device.Stop(); audio_device.Close(); - // Wait for application end jack_net_slave_deactivate(net); jack_net_slave_close(net);