MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 431 forks source link

Audio Support #75

Closed jcmnn closed 10 years ago

jcmnn commented 10 years ago

I'm sure everyone would like this idea. I was thinking you could add a sound card so we could play MIDI files, and possibly WAV.

MFernflower commented 10 years ago

70

fnuecke commented 10 years ago

At least from the description #70 is quite different. Or at least I understand the two suggestions quite differently:

If I were to implement a sound card (which I'm not saying I will - I might if no-one else does, though) I'd probably go for a kind of low level approach, that more or less provides a wrapper to what Java has to offer. Meaning a way to stream MIDI data that is then synthesized, and possibly a way to stream PCM data (streaming as in internet radio streaming). Either of these would come with a very limited bandwidth, since all audio data would be generated on the server (since Lua only runs on the server) and has then to be sent to the client for rendering.

Regarding "output", should the sound card require a note block for actually "rendering" the sound, a new speaker block, ...?

If some kind of sound card does get implemented, one idea to support records might be to allow them to be inserted into disk drives and play them/rip them from there, which would sort of resolve #70.

Vexatos commented 10 years ago
  1. Playing Music Disks via the Disk Drive would be great. And it would actually be a pretty obvious thing to do.
  2. I think there actually should be a new Speaker block to play MIDI sounds, but a normal Note Block will already allow to play Note Block sounds.
asiekierka commented 10 years ago

Immibis' Peripherals implements 8-channel, square wave audio.

asiekierka commented 10 years ago

Computronics has added support for audio tapes and I am working on more.

fnuecke commented 10 years ago

Computronics pretty much has this covered, so I'm closing this.

GopherAtl commented 10 years ago

forgive me for bumping a closed topic, but something to note. Robust sound is covered by computronics, and I'm happy with that. However, the ability to just emit a single, static system "beep" would be very nice. This was pretty much a staple feature of most early personal computers, as a simple beep can effectively communicate errors in some cases clearly and easily. Nothing approximating wav playback, even frequency or duration control aren't necessary, but a basic computer.beep() that doesn't require a peripheral or upgrade or anything would be very nice and quite reasonable, imo.

fnuecke commented 10 years ago

Good point. Maybe even make '\a' trigger it when it's passed to term.write?

Techokami commented 10 years ago

In that case, why not send a Redstone signal to a vanilla note block?

Sent from my Windows Phone


From: Will Thomasmailto:notifications@github.com Sent: ‎4/‎22/‎2014 5:35 PM To: MightyPirates/OpenComputersmailto:OpenComputers@noreply.github.com Subject: Re: [OpenComputers] Audio Support (#75)

forgive me for bumping a closed topic, but something to note. Robust sound is covered by computronics, and I'm happy with that. However, the ability to just emit a single, static system "beep" would be very nice. This was pretty much a staple feature of most early personal computers, as a simple beep can effectively communicate errors in some cases clearly and easily. Nothing approximating wav playback, even frequency or duration control aren't necessary, but a basic computer.beep() that doesn't require a peripheral or upgrade or anything would be very nice and quite reasonable, imo.


Reply to this email directly or view it on GitHub: https://github.com/MightyPirates/OpenComputers/issues/75#issuecomment-41098824

GopherAtl commented 10 years ago

fnuecke: that'd be awesome.

techokami: that would require a redstone card or peripheral and configuration of which adapter and which side of that adapter to emit on. I'm thinking of generic software, operating systems and the like, being able to use this feature, counting on it to exist on any computer. Requiring a redstone card or peripheral, and requiring a configuration setup where you tell it which side of which redstone object to emit redstone on to activate a note block, hardly qualifies. It's is, or at least was, a ubiquitous form of feedback used by terminal-based programs in the 80s and 90s, so ingrained that, as fnuecke referenced, in most terminals printing the special character "\a" caused a system beep. This was so fundamental it was used by interrupt handlers and the like. No combination of peripherals would serve in the same fundamental way.

Techokami commented 10 years ago

Yeah in retrospect, adding computer.bell() would be the best solution. I could go into the IRC script and add support for using it whenever your username is said in chat! I SHOULD go edit the IRC script anyway because it's lacking in support for the /me command... welp, time to go make my own fork and get to work.

asiekierka commented 10 years ago

Yes, computer.bell() could be a good thing. Or just implement a simple PC Speaker-like thing: computer.beep(frequency, duration) emits a square wave.

LordFokas commented 10 years ago

computer.bell() for a motherboard beep sounds great! Bonus points for an 8-bit "retro" sound.

It'd also be great if computers emitted said beep, in a pattern, if errors were found on boot, like a normal POST.

fnuecke commented 10 years ago

I played around with frequency+duration a little, but paulscode is just so horribad (in particular when it comes to raw audio data) that I give up for now. Might have another look in the future, directly using OpenAL. Maybe.

asiekierka commented 10 years ago

I use OpenAL for Computronics. If you need to, I can explain to you how to use the code I have for raw audio streams in AsieLib.

asiekierka commented 10 years ago

I use OpenAL for Computronics. If you need to, I can explain to you how to use the code I have for raw audio streams in AsieLib.

fnuecke commented 10 years ago

That would help. The main hurdles I saw was dynamically creating and destroying the sources (tick handler I suppose) and not interfering with the channels in use by paulscode. Some pointers there would be great.

fnuecke commented 10 years ago

Alright, as of 8978280e3c the name was changed to computer.beep, because that's more generic, and it accepts a frequency and duration - both are limited, the frequency to 20-2000Hz, the duration to 0.05 to 5 seconds. Also, the computer will pause for the duration of the tone, to avoid abuse. Default is a 100ms long 440Hz message for computer.beep().