sound in APL
27 posts
• Page 1 of 3 • 1, 2, 3
sound in APL
Is there some facility in, or available to, Dyalog APL that can play a vector of sound samples? I tried to use the Workspace Explorer to see what might be in .NET, but I haven't figured out how to use it yet.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: sound in APL
The following is working for me for playing a file:
- Code: Select all
⎕USING ← 'System.Windows.Media,WPF/PresentationCore.dll' 'System,System.dll'
mp ← ⎕NEW MediaPlayer
uri ← ⎕NEW Uri (⊂'d:\kalimba.mp3')
mp.Open uri
mp.Play
mp.Stop
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: sound in APL
This is helpful, but I still have some questions:
1) Is there a facility for converting a vector into a file in some standard audio format, like .wav or .mp3? I want to generate my own sound samples rather than use some pre-recorded file.
2) Where is the documentation that describes how you used the media player?
1) Is there a facility for converting a vector into a file in some standard audio format, like .wav or .mp3? I want to generate my own sound samples rather than use some pre-recorded file.
2) Where is the documentation that describes how you used the media player?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: sound in APL
I have found that link for the examples.
For the other question I don't understand, would you like to save a sound file (like mp3) in the workspace and play it later or define yourself a vector of numbers that represent your music and save it as a mp3 (in the WS or disk) ?
For the other question I don't understand, would you like to save a sound file (like mp3) in the workspace and play it later or define yourself a vector of numbers that represent your music and save it as a mp3 (in the WS or disk) ?
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: sound in APL
What I would like to do is compute vectors containing samples of different kinds of sounds and then play them directly without converting the vectors to some audio file format. If you're familiar with Matlab, you'll recognize that I'm interested in the equivalent of sound() and soundsc(). I already have a "toolbox" of audio generating and processing functions that I'd like to translate into APL. I just need the sound player.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: sound in APL
I'm still searching for a way to play my computed sounds in Dyalog. There are apparently .NET classes to allow this, but I can't find them. In the Dyalog .NET guide it says:
"To enable the display of Metadata in the Workspace Explorer, you must have the Type
Libraries option of the View menu checked."
My View menu doesn't have this option (it's mostly about icons). So what do I need to do to be able to browse the .NET classes?
"To enable the display of Metadata in the Workspace Explorer, you must have the Type
Libraries option of the View menu checked."
My View menu doesn't have this option (it's mostly about icons). So what do I need to do to be able to browse the .NET classes?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: sound in APL
Hi Stu,
The advice about the View menu in our .NET interface documentation is wrong, and I'll tell our docs team about this.
In the Workspace Explorer, you can right click on Metadata.
For a example, you could choose Load and load the following assembly c:\windows\Microsoft.NET\Framework\v4.0.30319\system.dll
I am not sure if browsing the metadata in this way will be of much help. You may still need to continue searching the internet to find any references to an OLE or .NET tool which does what you need.
Regards,
Vince
The advice about the View menu in our .NET interface documentation is wrong, and I'll tell our docs team about this.
In the Workspace Explorer, you can right click on Metadata.
For a example, you could choose Load and load the following assembly c:\windows\Microsoft.NET\Framework\v4.0.30319\system.dll
I am not sure if browsing the metadata in this way will be of much help. You may still need to continue searching the internet to find any references to an OLE or .NET tool which does what you need.
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: sound in APL
Looks like that Mathlab has its own format for storing/playing sound files. If you could convert them to .wav files then it is possible to store them in the workspace and play them with SoundPlayer as a stream without saving any intermediary file to disk.
I could prepare some examples of how to store a .wav file in the WS and how to play it back as a stream if this is helpful but you would need to convert your Mathlab sound files to .wav files which I don't know how to do.
There is nothing in Dyalog APL that is native to playing/storing sounds so we have to use Windows.
I could prepare some examples of how to store a .wav file in the WS and how to play it back as a stream if this is helpful but you would need to convert your Mathlab sound files to .wav files which I don't know how to do.
There is nothing in Dyalog APL that is native to playing/storing sounds so we have to use Windows.
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: sound in APL
I know how to make a .wav file in C and C++. .wav files are all about byte counts, so I still have to master that aspect of Dyalog. I'll get back to you on how to play the files once I'm able to make them.
It would be nice if Dyalog had something like Matlab's sound() function. I'm sure it's based on the underlying Windows audio player, but all the Matlab programmer needs to do is plug in the name of the vector (and, optionally, the sample rate), i.e., sound(samples, samplerate). I'm not a real fan of Matlab. Its implementation of the array programming paradigm is very weak compared with APL's, but it does make life easy in the specific area of creating and playing sound.
It would be nice if Dyalog had something like Matlab's sound() function. I'm sure it's based on the underlying Windows audio player, but all the Matlab programmer needs to do is plug in the name of the vector (and, optionally, the sample rate), i.e., sound(samples, samplerate). I'm not a real fan of Matlab. Its implementation of the array programming paradigm is very weak compared with APL's, but it does make life easy in the specific area of creating and playing sound.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: sound in APL
Making a .wav file is more difficult than I'd thought. I have to be able write into the file some character strings that occupy exactly 4 bytes each, and also some little-endian unsigned ints that occupy 2 or 4 bytes each depending on the particular data item. The audio sample data has to end on an even byte boundary. I don't know how to do any of this in Dyalog, so I really could use some help.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
27 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: Bing [Bot] and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group