I'm attempting to play a basic MIDI file using AudioKits legacy sequencer, AKAppleSequencer. I've gotten it to play the first note of the file, but nothing after. (I couldn't get any output from the new AKSequencer.) Here is my code which is essentially identical to the MIDI playback code from AudioKits Playgrounds.
class MIDIPlayer {
var piano: AKMIDISampler?
var sequencer: AKAppleSequencer?
var mixer: AKMixer?
var reverb: AKCostelloReverb?
var dryWetMixer: AKDryWetMixer?
func playMidiFile() {
piano = AKMIDISampler()
try? piano!.loadWav("FM Piano")
mixer = AKMixer(piano)
reverb = AKCostelloReverb(mixer)
dryWetMixer = AKDryWetMixer(mixer!, reverb!, balance: 0.2)
AudioKit.output = dryWetMixer
sequencer = AKAppleSequencer(filename: "Score")
sequencer!.setGlobalMIDIOutput(piano!.midiIn)
sequencer!.setLength(AKDuration(beats: 16))
try? AudioKit.start()
sequencer!.play()
print("MIDIPlayer playing...")
}
}
I hear the first note of the MIDI File and get the following errors/warnings.
2020-04-24 16:30:19.653852-0400 TauMusicTest[20668:3188919] [seq] SequenceTrack.cpp:918:Clear: Invalid beat range or track is empty
2020-04-24 16:30:19.654171-0400 TauMusicTest[20668:3188919] [seq] SequenceTrack.cpp:1028:Merge: Invalid beat range
2020-04-24 16:30:20.349048-0400 TauMusicTest[20668:3189067] HALC_ProxyIOContext::IOWorkLoop: failed to send the final message to the server, Error: 0x10000003
2020-04-24 16:30:20.450640-0400 TauMusicTest[20668:3189034] [ddagg] AggregateDevice.mm:331 Output: index 1 >= allChannelDescs size 1
2020-04-24 16:30:20.532394-0400 TauMusicTest[20668:3189251] [aqme] AQMEIO_HAL.cpp:1526:IOProc: AQDefaultDevice: Abandoning I/O cycle because reconfig pending (1).
MDIDPlayer playing...
2020-04-24 16:30:20.542721-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.542882-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.543023-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.543149-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.543264-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.698072-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.698443-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)
2020-04-24 16:30:20.698718-0400 TauMusicTest[20668:3188919] [general] AKAppleSequencer.swift:deinit:41:deinit: (AKAppleSequencer.swift:deinit:41)```
You've declared your sampler, mixer, sequencer etc all within the scope of a single function. When the function completes, the OS assumes you're done with them, and will try to free up the memory they used.
This function is actually a method within a class. Try declaring these variables at the class level, so that they can persist after the method completes. E.g.,
class MySequencer {
var piano: AKMIDISampler?
var sequencer: AKAppleSequencer?
// etc. . .
func playMIDIFile() {
piano = AKMIDISampler()
try? piano!.loadWav("FM Piano")
// etc . . .
}
}
Related
I can't get real-time tick with API for GBP.CHF#IDEALPRO/ My log:
0:53:36:282 <- 9-8-1073741829-0-GBP-CASH--0-----CHF---0---
10:53:36:282 <- 1-11-1073741830-0-GBP-CASH--0-----CHF---0-233,236,258-0-0--
10:53:36:282 -> ---R4-2-1073741830-321-Error validating request.-'bX' : cause - Please enter exchange-
10:53:36:283 <- 1-11--1073741830-0-GBP-CASH--0-----CHF---0--1-0--
10:53:36:283 -> ---S4-2--1073741830-321-Error validating request.-'bX' : cause - Please enter exchange-
10:53:36:318 <- 9-8-1073741831-0-GBP-CASH--0-----CHF---0---
Nothing incoming from tws. Please help.
Here's your log compared to my log.
1-11-1073741830-0-GBP-CASH--0 --- --CHF---0-233,236,258-0-0--
1-11-1 -0-GBP-CASH--0.0---IDEALPRO--CHF---0-233-0-0--
You just forgot the exchange.
contract = Contract()
contract.symbol = "GBP"
contract.secType = "CASH"
contract.exchange = "IDEALPRO"
contract.currency = "CHF"
app.reqMktData(1, contract, "233", False, False, None)
I'm not sure about your generic tick list, not all type are available for forex. I just threw in 233 to see if it would cause an error but it worked.
I'm currently working with some NFC Tags and iOS 13.
One problem is, that some of my NFC tags are delivered as NDEFFormatable. I know that I have to format the tag first to work with NDEF. I can do that with an 3rd party Android app. But how can I do that with my own iOS App?
Currently the tag is recognized as 'ISO15693' tag and the result of the queryNDEFStatus method is .notSupported.
I have also tried to write an empoty message to that NFC tag but iOS is responding with an error "NDEF tag is read only"
As I know you like to have some code here are the important parts:
session = NFCTagReaderSession(pollingOption: [.iso14443, .iso15693], delegate: self)
session?.alertMessage = "Bitte halten Sie das Gerät an den zu scannenden NFC Tag"
session?.begin()
...
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if tags.count > 1 {
// Restart polling in 500ms
let retryInterval = DispatchTimeInterval.milliseconds(500)
session.alertMessage = "Mehr als 1 NFC Tag gefunden. Bitte scannen Sie jeden Tag einzeln."
DispatchQueue.global().asyncAfter(deadline: .now() + retryInterval, execute: {
session.restartPolling()
})
return
}
let tag = tags.first!
// Connect to the found tag and perform NDEF message reading
session.connect(to: tag) { (error: Error?) in
if nil != error {
session.invalidate(errorMessage: "NFC Tag konnte nicht gelesen werden")
return
}
if case let NFCTag.iso15693(iso15693Tag) = tag{
iso15693Tag.queryNDEFStatus(completionHandler: { (ndefStatus: NFCNDEFStatus, capacity: Int, error: Error?) in
guard error == nil else {
session.invalidate(errorMessage: "Status des Tags konnte nicht gelesen werden")
return
}
switch ndefStatus {
case .notSupported:
//NDFEFFormatable tag is handled here !!!!
session.alertMessage = "Der Tag unterstützt das NFC Data Exchange Format (NDEF) nicht!"
session.invalidate()
case .readOnly:
//read tag
case .readWrite:
//read or write tag
#unknown default:
session.alertMessage = "Unbekannter Status"
session.invalidate()
}
})
} else if case let NFCTag.miFare(miFareTag) = tag { //check if we have a MiFare Tag
//other type of tags
} else {
session.invalidate(errorMessage: "Dieser Tag wird aktuell leider nicht unterstützt")
return
}
}
}
Some sources say that iOS can only work with already formatted cards
https://help.gototags.com/article/nfc-tag-encoding-iphone/
But you might be able to go to low level commands to write the correct blocks to format the card yourself.
You don't specify the type of card, so assuming it's a type 2 the http://apps4android.org/nfc-specifications/NFCForum-TS-Type-2-Tag_1.1.pdf (If not the other specs are at http://apps4android.org/nfc-specifications/ )
But possibly more like a Type 5 Card which I don't have access to the Specs of, but something similar could be done for Type 5 as Type 2 (You could use various android App's like NXP's Taginfo App to compare a formatted NDEF type V tag with a non formatted one to see if it is blocks 3 and 4 on type V cards as well)
But for Type 2
Section 6.4.1 shows how it detects that it is a NDEF formated card.
For Type 2 cards Block 03 has to have the NDEF capability container of 4 bytes, A lot of cards have this preset from the Factory, if not you need to write the 4 byte capability container to block 03.
The container format is in the spec's but below is a summary:-
Byte 0 = E1h indicates that NDEF data is present inside the tag
Byte 1 = 10h indicates support for version 1.0 (major number 1h, minor number 0h) of the mapping document (i.e., the version of this specification). - Version 1.0 is the latest version I believe.
Byte 2 = Size of the data area, so card specific value but the value is the data area size divided by 8 and represented in hex. e.g. 128 bytes of data storage are indicated value equal to 10h
Byte 3 = Is about security and value 0h indicates write access granted without any security
Then you need to format the card with a blank TLV message to block 4 to format the card.
A blank TLV message in block 4 is
Byte 0 = 03h
Byte 1 = 00h
Byte 2 = FEh
Which basically equates to Start NDEF message, Message is zero length in size, End NDEF message.
I've not done any of this on iOS but is seems that iOS does offer low level read and write access of ISO15693 Tags
https://developer.apple.com/documentation/corenfc/nfciso15693tag/3043817-writesingleblock
I'm trying to play an album, using the following code…
let predicate = MPMediaPropertyPredicate(value: "1459938538", forProperty: MPMediaItemPropertyAlbumPersistentID)
let iCloudPredicate = MPMediaPropertyPredicate(value: true, forProperty: MPMediaItemPropertyIsCloudItem)
let query = MPMediaQuery.albums()
query.filterPredicates = [predicate, iCloudPredicate]
let mp = MPMusicPlayerController.applicationMusicPlayer
mp.setQueue(with: query)
mp.play()
But it's failing with
[SDKPlayback] -[MPMusicPlayerController prepareToPlay] timeout
[MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x280f1a280 name=iPhone uid=LOCAL> origin=iPhoneID bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}
[SDKPlayback] -[MPMusicPlayerController play] completed error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x28344c810 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}
• If I remove the predicates, it'll play local albums OK.
• SKCloudServiceController.requestAuthorization is .authorized
• The device has both .musicCatalogPlayback and .addToCloudMusicLibrary capabilities.
• 1459938538 seems to be a valid id (it's for the latest Madonna album - https://music.apple.com/gb/album/madame-x-deluxe/1459938538)
Any hints as to how to play an album that's not in my library?
MPMediaQuery is only for Library items. You would need to use the web Apple Music search API to get store IDs to use in setting the queue.
I don't realize how yandex-tank-api-client example works.
I've made following corrections in tank-example.py:
replaced (the error was otherwise)
84: tsk = tankapi.shoot(*cfg)
with
84: tsk = tankapi.shoot(*cfg, f)
where f - is the function:
def f(status, t):
print "Status: %s" % status
I've replaced example's load.yaml file with my file:
- tanks: ['localhost']
config: ./load.ini
log_name: task-A
download: ['*.log','*.ini']
upload: ['*.ammo']
expected_codes: [0]
Where load.ini is:
[DEFAULT]
use_caching = 0
[phantom]
phantom_path = /home/krylov/prj/yandex/phantom/bin/phantom
phantom_modules_path = /home/krylov/prj/yandex/phantom/lib/phantom
address=localhost:8000
rps_schedule=const(10, 10s)
; Headers and URIs for GET requests
header_http = 1.1
headers = /
[Host: 127.0.0.1]
[Connection: close]
uris = /
/instances
/datastore
/datastore-indexes
After I run yandex-tank-api-server on localhost and tank-example.py script test starts but it cannot leave the configure stage:
2016-04-19 12:44:10,263 [DEBUG] Tank localhost: API returned code 200, contents:
{
"status": "running",
"retcode": null,
"stage_completed": true,
"break": "configure",
"current_stage": "lock",
"tank_status": {},
"failures": []
}
Status: 0
tank.log file ends by lines (you can here full tank.log):
2016-04-19 12:44:00,287 [INFO] yandex_tank_api.worker Changing the next break from lock to configure
2016-04-19 12:44:00,288 [WARNING] yandextank.core.tankcore Lock file present: /var/lock/lunapark_1WgKl6.lock
2016-04-19 12:44:00,288 [DEBUG] root No process[3]: [Errno 3] No such process
2016-04-19 12:44:00,288 [DEBUG] yandextank.core.tankcore Lock PID 13895 not exists, ignoring and trying to remove
I'd like to understand why PID not exists. Does the example have an error?
I'm trying to send sms using kannel & smppsim.
I use docker as container.
I use this kannel.conf:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
admin-allow-ip = "127.0.0.1;192.168.59.103"
box-allow-ip = "127.0.0.1;192.168.59.103"
group = smsc
smsc = smpp
smsc-id = SMPPSim
host = 192.168.59.103
port = 2775
transceiver-mode = 1
smsc-username = smppclient1
smsc-password = password
system-type = 'VMA'
#service-type = 'test'
interface-version = 34
#system-id = smppclient
preferred-smsc-id = SMPPSim
connect-allow-ip = 192.168.59.103
group = smsbox
bearerbox-host = bearerbox
sendsms-port = 13013
global-sender = 13013
group = sendsms-user
username = tester
password = foobar
group = sms-service
keyword = default
text = "No service specified"
when sending a request to send sms I get "0: Accepted for delivery"
I'm seeing these errors in smsbox log:
2015-03-21 20:20:52 [1] [3] DEBUG: Status: 202 Answer: <Sent.>
2015-03-21 20:20:52 [1] [3] DEBUG: Delayed reply - wait for bearerbox
2015-03-21 20:20:52 [1] [0] DEBUG: Got ACK (0) of 74f9cefe-db95-4b7d-aa99-f07395d32915
2015-03-21 20:20:52 [1] [0] DEBUG: HTTP: Resetting HTTPClient for `192.168.59.3'.
2015-03-21 20:20:52 [1] [1] ERROR: Error reading from fd 24:
2015-03-21 20:20:52 [1] [1] ERROR: System error 104: Connection reset by peer
2015-03-21 20:20:52 [1] [1] DEBUG: HTTP: Destroying HTTPClient area 0x7fe8d0000ad0.
Bearbox doesn't present any errors and seem to pass the message to smppsim, smppsim shows this in log:
21 Assessing state of 1 messages in the OutboundQueue
21 Message:2 state=DELIVERED
The sms is not sent, what could be wrong?
I think its a problem with your Kannel configuration file, specially with smsbox and later parts. I used following as smsbox
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = your sim number which you use in USB modem
sendsms-chars = "0123456789 +-"
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/access.log"
and you can get my full configuration file from here. This worked fine for me.
This might be a problem of lоѕѕ оf thе соnnесtіоn оn thе rеmоtе ѕосkеt due tо а tіmеоut.
And SMPPSim is just a testing tool for kannel. It won't really send a message to your or mentioned mobile number. To send real messages you need to add either gsm modems or SMS operator details.
You can refer to userGuide from kannel.org.
To check your kannel status simply go to http://localhost:13000/status?password=password(password of your kannel)