After I update pjsip from v2.6 to v2.7.1,my app will assertion failed with fuction pjsua_set_snd_dev().
According pjsip's ticket #1941:
To make outgoing call:
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
/* 1. We must not start call audio here, and can only do so
* once the audio session has been activated by the system
* after having its priority elevated. So, make sure that the sound
* device is closed at this point.
*/
/* 2. Provide your own implementation to configure
* the audio session here.
*/
configureAudioSession()
/* 3. Make call with pjsua_call_make_call().
* Then use pjsua's on_call_state() callback to report significant
* events in the call's lifecycle, by calling iOS API
* CXProvider.reportOutgoingCall(with: startedConnectingAt:) and
* CXProvider.reportOutgoingCall(with: ConnectedAt:)
*/
/* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
* otherwise call action.fail().
*/
}
To handle incoming call:
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
/* 1. We must not start call audio here, and can only do so
* once the audio session has been activated by the system
* after having its priority elevated. So, make sure that the sound
* device is closed at this point.
*/
/* 2. Provide your own implementation to configure
* the audio session here.
*/
configureAudioSession()
/* 3. Answer the call with pjsua_call_answer().
*/
/* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
* otherwise call action.fail().
*/
}
To start sound device:
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
/* Start call audio media, now that the audio session has been
* activated after having its priority boosted.
*
* Call pjsua API pjsua_set_snd_dev() here.
*/
}
When calling pjsua API pjsua_set_snd_dev(),there show:
Assertion failed: (param && id!=PJMEDIA_AUD_INVALID_DEV), function
pjmedia_aud_dev_default_param, file ../src/pjmedia/audiodev.c, line
487.
I found that v2.7.1, in pjsua_set_no_snd_dev(),there is
pjsua_var.cap_dev = PJSUA_SND_NO_DEV; pjsua_var.play_dev =
PJSUA_SND_NO_DEV;
but in v2.6 ,do not have this.
PJSUA_SND_NO_DEV and PJMEDIA_AUD_INVALID_DEV are same as -3.
Is this a bug,or I confuse anything?
Steve have you added
App provides Voice over IP services required background modes in Capabilities
Or you can add in to directly in Info.plist
Related
I have this automation test running on my local.
But every time when the test is executed, there is a onPrepare hook takes 3 to 8 minutes randomly.
Here is my config.js
exports.config = {
//
// ====================
// Runner Configuration
// ====================
//
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
// on a remote machine).
runner: 'local',
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called.
//
// The specs are defined as an array of spec files (optionally using wildcards
// that will be expanded). The test for each spec file will be run in a separate
// worker process. In order to have a group of spec files run in the same worker
// process simply enclose them in an array within the specs array.
//
// If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script),
// then the current working directory is where your `package.json` resides, so `wdio`
// will be called from there.
//
headless: true,
specs: [
'./features/logintrainer.feature'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
// First, you can define how many instances should be started at the same time. Let's
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
// files and you set maxInstances to 10, all spec files will get tested at the same time
// and 30 processes will get spawned. The property handles how many capabilities
// from the same test should run tests.
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
acceptInsecureCerts: true
// 'goog:chromeOptions': {
// // to run chrome headless the following flags are required
// // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
// args: ['--headless', '--disable-gpu'],
// }
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
}],
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
//
// Set specific log levels per logger
// loggers:
// - webdriver, webdriverio
// - #wdio/applitools-service, #wdio/browserstack-service, #wdio/devtools-service, #wdio/sauce-service
// - #wdio/mocha-framework, #wdio/jasmine-framework
// - #wdio/local-runner
// - #wdio/sumologic-reporter
// - #wdio/cli, #wdio/config, #wdio/utils
// Level of logging verbosity: trace | debug | info | warn | error | silent
// logLevels: {
// webdriver: 'info',
// '#wdio/applitools-service': 'info'
// },
//
// If you only want to run your tests until a specific amount of tests have failed use
// bail (default is 0 - don't bail, run all tests).
bail: 0,
//
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
// gets prepended directly.
baseUrl: 'https://test.com',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 120000,
//
// Default request retries count
connectionRetryCount: 3,
//
// Test runner services
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
services: [
['selenium-standalone', { drivers: { firefox: 'latest', chrome: 'latest', chromiumedge: 'latest' } }]
],
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: https://webdriver.io/docs/frameworks
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'cucumber',
//
// The number of times to retry the entire specfile when it fails as a whole
// specFileRetries: 1,
//
// Delay in seconds between the spec file retry attempts
// specFileRetriesDelay: 0,
//
// Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
// specFileRetriesDeferred: false,
//
// Test reporter for stdout.
// The only one supported by default is 'dot'
// see also: https://webdriver.io/docs/dot-reporter
reporters: ['spec'],
//
// If you are using Cucumber you need to specify the location of your step definitions.
cucumberOpts: {
// <string[]> (file/dir) require files before executing features
require: ['./stepdefinations/given.js', './stepdefinations/when.js', './stepdefinations/then.js'],
// <boolean> show full backtrace for errors
backtrace: false,
// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
requireModule: ['#babel/register'],
// <boolean> invoke formatters without executing steps
dryRun: false,
// <boolean> abort the run on first failure
failFast: false,
// <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
format: ['pretty'],
// <boolean> hide step definition snippets for pending steps
snippets: true,
// <boolean> hide source uris
source: true,
// <string[]> (name) specify the profile to use
profile: [],
// <boolean> fail if there are any undefined or pending steps
strict: false,
// <string> (expression) only execute the features or scenarios with tags matching the expression
tagExpression: '',
// <number> timeout for step definitions
timeout: 60000,
// <boolean> Enable this config to treat undefined definitions as warnings.
ignoreUndefinedDefinitions: false
},
reporters: [
'spec',
['allure', {
outputDir: './reports/allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: true,
}],
['json', {
outputDir: './reports/json-results'
}],
['junit', {
outputDir: './reports/junit-results',
outputFileFormat: function(options) {
return `results-${options.cid}.${options.capabilities}.xml`
}
}],
],
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
/**
* Gets executed once before all workers get launched.
* #param {Object} config wdio configuration object
* #param {Array.<Object>} capabilities list of capabilities details
*/
onPrepare: function (config, capabilities) {
console.log('Test is preparing');
},
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* for that worker as well as modify runtime environments in an async fashion.
* #param {String} cid capability id (e.g 0-0)
* #param {[type]} caps object containing capabilities for session that will be spawn in the worker
* #param {[type]} specs specs to be run in the worker process
* #param {[type]} args object that will be merged with the main configuration once worker is initialised
* #param {[type]} execArgv list of string arguments passed to the worker process
*/
// onWorkerStart: function (cid, caps, specs, args, execArgv) {
// },
/**
* Gets executed just before initialising the webdriver session and test framework. It allows you
* to manipulate configurations depending on the capability or spec.
* #param {Object} config wdio configuration object
* #param {Array.<Object>} capabilities list of capabilities details
* #param {Array.<String>} specs List of spec file paths that are to be run
*/
// beforeSession: function (config, capabilities, specs) {
// },
/**
* Gets executed before test execution begins. At this point you can access to all global
* variables like `browser`. It is the perfect place to define custom commands.
* #param {Array.<Object>} capabilities list of capabilities details
* #param {Array.<String>} specs List of spec file paths that are to be run
* #param {Object} browser instance of created browser/device session
*/
// before: function (capabilities, specs) {
// },
/**
* Runs before a WebdriverIO command gets executed.
* #param {String} commandName hook command name
* #param {Array} args arguments that command would receive
*/
// beforeCommand: function (commandName, args) {
// },
/**
* Runs before a Cucumber feature
*/
// beforeFeature: function (uri, feature) {
// },
/**
* Runs before a Cucumber scenario
*/
// beforeScenario: function (world) {
// },
/**
* Runs before a Cucumber step
*/
// beforeStep: function (step, context) {
// },
/**
* Runs after a Cucumber step
*/
// afterStep: function (step, context) {
// },
/**
* Runs after a Cucumber scenario
*/
// afterScenario: function (world) {
// },
/**
* Runs after a Cucumber feature
*/
// afterFeature: function (uri, feature) {
// },
/**
* Runs after a WebdriverIO command gets executed
* #param {String} commandName hook command name
* #param {Array} args arguments that command would receive
* #param {Number} result 0 - command success, 1 - command error
* #param {Object} error error object if any
*/
// afterCommand: function (commandName, args, result, error) {
// },
/**
* Gets executed after all tests are done. You still have access to all global variables from
* the test.
* #param {Number} result 0 - test pass, 1 - test fail
* #param {Array.<Object>} capabilities list of capabilities details
* #param {Array.<String>} specs List of spec file paths that ran
*/
// after: function (result, capabilities, specs) {
// },
/**
* Gets executed right after terminating the webdriver session.
* #param {Object} config wdio configuration object
* #param {Array.<Object>} capabilities list of capabilities details
* #param {Array.<String>} specs List of spec file paths that ran
*/
// afterSession: function (config, capabilities, specs) {
// },
/**
* Gets executed after all workers got shut down and the process is about to exit. An error
* thrown in the onComplete hook will result in the test run failing.
* #param {Object} exitCode 0 - success, 1 - fail
* #param {Object} config wdio configuration object
* #param {Array.<Object>} capabilities list of capabilities details
* #param {<Object>} results object containing test results
*/
// onComplete: function(exitCode, config, capabilities, results) {
// },
/**
* Gets executed when a refresh happens.
* #param {String} oldSessionId session ID of the old session
* #param {String} newSessionId session ID of the new session
*/
//onReload: function(oldSessionId, newSessionId) {
//}
}
Attaching the logs here too:
`2021-06-04T06:27:55.993Z DEBUG #wdio/config:utils: Couldn't find ts-node package, no TypeScript compiling
Execution of 1 spec files started at 2021-06-04T06:27:56.014Z
2021-06-04T06:27:56.086Z INFO #wdio/cli:launcher: Run onPrepare hook
Test is preparing
2021-06-04T06:30:48.355Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2021-06-04T06:30:48.359Z INFO #wdio/local-runner: Start worker 0-0 with arg: run,./config/wdio.conf.js
[0-0] 2021-06-04T06:30:49.021Z INFO #wdio/local-runner: Run worker command: run
[0-0] RUNNING in chrome - D:\webdriverIO-automation\features\logintrainer.feature
[0-0] 2021-06-04T06:30:49.974Z INFO webdriver: Initiate new session using the WebDriver protocol
I tried to comment the on prepare hook out, but still there is a onPrepare hook being run.`
This really slow the test down, appreciate if any idea on this issue.
PS: I'm using the latest webdriver-IO, nodeJS and chrome driver
Thank you
services: [
['selenium-standalone', { drivers: { firefox: 'latest', chrome: 'latest', chromiumedge: 'latest' },skipSeleniumInstall:true }]
],
add skipSeleniumInstall:true else it will try to download the drivers each time
I need to use more commands (cd, mkdir, rmdir) with SFTPOutboundGateway, but according to the official documentation, there is only a handful of commands available, none of the other ones I need being included. Is there a reason behind it ? Is there a(nother) way to use more commands such as cd, mkdir and rmdir ?
cd in a gateway makes no sense since it effectively would do nothing.
For commands not supported by the gateway, use the SftpRemoteFileGateway from your code in a service activator.
For commands not supported by the template, use
/**
* Execute the callback's doInSession method after obtaining a session.
* Reliably closes the session when the method exits.
*
* #param callback the SessionCallback.
* #param <T> The type returned by
* {#link SessionCallback#doInSession(org.springframework.integration.file.remote.session.Session)}.
* #return The result of the callback method.
*/
<T> T execute(SessionCallback<F, T> callback);
and
#FunctionalInterface
public interface SessionCallback {
/**
* Called within the context of a session.
* Perform some operation(s) on the session. The caller will take
* care of closing the session after this method exits.
*
* #param session The session.
* #return The result of type T.
* #throws IOException Any IOException.
*/
T doInSession(Session<F> session) throws IOException;
}
For commands not supported by Session, use
/**
* Get the underlying client library's client instance for this session.
* Returns an {#code Object} to avoid significant changes to -file, -ftp, -sftp
* modules, which would be required
* if we added another generic parameter. Implementations should narrow the
* return type.
* #return The client instance.
* #since 4.1
*/
Object getClientInstance();
#Override
public ChannelSftp getClientInstance() {
return this.channel;
}
and operate on the JSch client directly.
I have a question about ActiveMQ 5.11 broker with a local C++ CMS Client 3.9.3. I modified the sample code from the official site to use the pthread_create function to spawn a new thread and trying to ack the message (CLIENT_ACK mode) from the new thread. It turns out there is segmentation fault. How can we achieve that returning the ack from the newly spawned thread rather than current thread? Does ActiveMQ C++ Client support multi-thread to ack the message?
void* sendAckThreadFunc(void *pMessage) {
sleep(1);
const Message* message = (const Message*) pMessage;
message->acknowledge();
printf("ACK sent out.");
return NULL;
}
virtual void onMessage(const Message* message) {
static int count = 0;
try {
count++;
const TextMessage* textMessage = dynamic_cast<const TextMessage*>(message);
string text = "";
if (textMessage != NULL) {
text = textMessage->getText();
} else {
text = "NOT A TEXTMESSAGE!";
}
if (clientAck) {
//message->acknowledge(); --> instead of ack the message in the onMessage function, they use pthread_create to generate a new thread and trying to ack the message from there. Is is a supported way??
pthread_t sendAckThread;
if (pthread_create(&sendAckThread, NULL, sendAckThreadFunc,
(void*) message)) {
printf("Error occured when create threads.");
}
}
printf("A Message #%d Received: %s\n", count, text.c_str());
} catch (CMSException& e) {
e.printStackTrace();
}
}
When I run the consumer, it even failed with trying to ack one message:
[root#amq6-283-1 examples]# ./simple_async_consumer
=====================================================
Starting the example:
-----------------------------------------------------
The Connection's Transport has been Restored.
Press 'q' to quit
A Message #1 Received: Hello world! from thread 140486368756208
Segmentation fault (core dumped)
The thing here is, once the message object exits the OnMessage function, all the resources are gone and cannot pass to other threads.
The CMS API documentation spells it out pretty clearly:
/**
* Called asynchronously when a new message is received, the message
* reference can be to any of the Message types. a dynamic cast is used
* to find out what type of message this is. The lifetime of this
* object is only guaranteed to be for the life of the onMessage function
* after this call-back returns the message may no longer exist. Users should
* copy the data or clone the message if they wish to retain information that
* was contained in this Message.
*
* It is considered a programming error for this method to throw an
* exception. The method has been tagged with the 'throw()' qualifier,
* this implies that you application will segfault if you throw an error
* from an implementation of this method.
*
* #param message
* Message object {const} pointer recipient does not own.
*/
I understand the sample is only for serial processing, but I would sincerely request to have parallel processing, which means All the things are not done in a single thread. If it is serial, Before the current message gets processed and returns the ack, the current thread cannot receive more batch of messages. It really does not meet the customer's performance needs.
So can anyone illustrate how CMS API is designed to handle parallelism? Receiver thread just focuses on receiving messages inside OnMessage function while other business threads spawned focus on business processing and depending on the result to return the ack. I just want to know how CMS API is capable to handle the parallelism. That is how they used the CLIENT ACK Mode. Can anyone kindly provide a parallelism example?
Not sure which part of the 'onMessage' API documentation is unclear here but for help I'll paste it here:
/**
* Called asynchronously when a new message is received, the message
* reference can be to any of the Message types. a dynamic cast is used
* to find out what type of message this is. The lifetime of this
* object is only guaranteed to be for life of the onMessage function
* after this call-back returns the message may no longer exist. Users should
* copy the data or clone the message if they wish to retain information that
* was contained in this Message.
*
* It is considered a programming error for this method to throw an
* exception. The method has been tagged with the 'throw()' qualifier,
* this implies that you application will segfault if you throw an error
* from an implementation of this method.
*
* #param message
* Message object {const} pointer recipient does not own.
*/
virtual void onMessage(const Message* message) = 0;
So reading that it would seem clear that if you want to store the message for later acknowledgement you need to clone it using the built in Message object 'clone' API.
I'm trying to help a friend setup a bot for Picarto.tv, we have the bot LINK and there's no default plugin there for repeating messages, so I tried to make a very crude (seriously, it's terrible. I'm not a developer.) plugin for it, and I tried to use SetInterval/SetTimeout, and both times when I use them it will put the message in chat once, at the set interval, then it will wait, then after the interval it will say the message twice, then three times and so on.
It looks like this:
Time 1:
Testing...
Time 2:
Testing...
Testing...
And so on. Here's the code, as I said, it's terribly made, don't bash me too hard for it.
var api;
function handleChatMsg(data) {
var recursive = function () {
api.Messages.send("Testing Bot Repeat...");
setTimeout(recursive,15000);
}
recursive();
}
module.exports = {
meta_inf: {
name: "Repeat Message",
version: "1.0.0",
description: "Repeats a message every 5 minutes. Message and interval can be changed.",
author: "ZX6R"
},
load: function (_api) {
api = _api;
},
start: function () {
api.Events.on("userMsg", handleChatMsg);
}
}
Can anybody help me figure out why it's incrementally saying the message more times?
EDIT: Issue fixed, new code is
var api;
// Function to call for the repeating
function handleChatMsg() {
// This sets the interval of 5 minutes, and calls the variable. Edit the numbers after the comma to change the interval. You MUST put it into milliseconds.
setInterval(function(){xyz()}, 15000);
// This sets the variable, edit the text in "api.Messages.send" to change what the bot repeats.
var xyz = function()
{
api.Messages.send("Testing...")
}
}
// defines some information about the plugin, and sets up stuff we need.
module.exports = {
meta_inf: {
name: "Repeat Message",
version: "1.1.1",
description: "Repeats a message every 5 minutes. Message and interval can be changed.",
author: "ZX6R"
},
load: function (_api) {
api = _api;
},
start: function () {
handleChatMsg();
}
}
// The MIT License (MIT)
// Copyright (c) 2016 RedFalconv2 - ZX6R - WalnutGaming
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Let's not complicate things and make it simpler.
setInterval(function(){xyz()}, 300000);
var xyz = function()
{
//Do what you want your function to do.
}
Here function xyz will be called every 300,000 milliseconds which means 5 minutes.
Take a look at Node Cron btw if you are going to use it regularly for an application.
Perhaps something like the following:
// define and export module
var plugin = {};
module.exports = plugin;
// plugin metadata
plugin.meta_inf = {
name: "Repeat Message",
version: "1.0.0",
description: "Repeats a message every 5 minutes. Message and interval can be changed.",
author: "ZX6R"
};
/**
* To be called on plugin load.
* #param {Object} api - api instance.
*/
plugin.load = function(api){
plugin._api = api;
};
/**
* Called on plugin start.
*/
plugin.start = function(){
if(!plugin._api){
// api instance should have been available
throw new Error("api not defined, is plugin load()'ed ?");
}
// each user message event (re)configures the repeating timer
plugin._api.Events.on("userMsg",function(){
plugin._configure(true, "Testing echo bot...",15000);
});
};
/**
* Configure the repeating timer
* #param {Boolean} enabled - true to enable timer, false to disable
* #param {String} message - message to repeat, required if enabled
* #param {Number} interval - milliseconds between repeats, required if enabled
*/
plugin._configure = function(enabled, message, interval){
if(plugin._timer){
// always clear any old timer
clearInterval(plugin._timer);
}
if(enabled){
if(!message || !interval){
// message and interval are required
throw new Error("message and interval are required.");
}
// set a repeating timer
plugin._timer = setInterval(function(){
plugin._api.Messages.send(message);
},interval);
}
};
Notes:
user message events apply a new setting on timer. You can have the bot repeat user message, or something custom.
Or, you can only configure the timer once.
I am trying to learn how to use Processing, and so am attempting to use the sound library. When running the either of the first two example programs provided at https://processing.org/tutorials/sound/, the IDE responds with this error:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'RtAudioError'
what(): RtApiWasapi::getDeviceInfo: Unable to retrieve device mix format.
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
Also, whenever I try to run a sketch using this library, along with that error, windows says
Java(TM) Platform SE binary has stopped working
Windows is collecting more information about the problem. This might take several minutes...
Could you help me to resolve this issue? I am using a windows vista computer.
This is the second example code:
/**
* Processing Sound Library, Example 2
*
* This sketch shows how to use envelopes and oscillators.
* Envelopes describe to course of amplitude over time.
* The Sound library provides an ASR envelope which stands for
* attack, sustain, release.
*
* .________
* . ---
* . ---
* . ---
* A S R
*/
import processing.sound.*;
// Oscillator and envelope
TriOsc triOsc;
Env env;
// Times and levels for the ASR envelope
float attackTime = 0.001;
float sustainTime = 0.004;
float sustainLevel = 0.2;
float releaseTime = 0.2;
// This is an octave in MIDI notes.
int[] midiSequence = {
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72
};
// Set the duration between the notes
int duration = 200;
// Set the note trigger
int trigger = 0;
// An index to count up the notes
int note = 0;
void setup() {
size(640, 360);
background(255);
// Create triangle wave and envelope
triOsc = new TriOsc(this);
env = new Env(this);
}
void draw() {
// If value of trigger is equal to the computer clock and if not all
// notes have been played yet, the next note gets triggered.
if ((millis() > trigger) && (note<midiSequence.length)) {
// midiToFreq transforms the MIDI value into a frequency in Hz which we use
//to control the triangle oscillator with an amplitute of 0.8
triOsc.play(midiToFreq(midiSequence[note]), 0.8);
// The envelope gets triggered with the oscillator as input and the times and
// levels we defined earlier
env.play(triOsc, attackTime, sustainTime, sustainLevel, releaseTime);
// Create the new trigger according to predefined durations and speed
trigger = millis() + duration;
// Advance by one note in the midiSequence;
note++;
// Loop the sequence
if (note == 12) {
note = 0;
}
}
}
// This function calculates the respective frequency of a MIDI note
float midiToFreq(int note) {
return (pow(2, ((note-69)/12.0)))*440;
}