Anyone got a rough idea of how I could write something to cut the last 20 seconds (or user-defined amount) from a list of audio files? Is this a good starter project?
(In C#, hopefully.)
[QUOTE=Jallen;23637192]That's more complicated than it sounds.
You could try messing with irr::scene::IMeshBuffer but that's not ideal. Ask on the irrlicht forums.[/QUOTE]
Shame, it'd be easy in OpenGL :v:
And I will, thank you
When I parse a string with float.Parse it ignores the dots int he number and uses commas as decimal points. How can I change that?
I saw that number format thing but I don't understand how to set the separator.
I know this isn't asking for help, well it sort of is, but does anyone remember the name of that project that allowed you to program using images, and it would click and type into specific areas on your screen that matched your images, I need it to make a automated macro. :P
Edit:
Dun worry found it :D.
[url]http://groups.csail.mit.edu/uid/sikuli/[/url]
After reading that article about asshole code I started reviewing the code of my project. Should I add a description of every function in my interfaces, the arguments and the return value? Also, should I add comments to this?
[cpp]BaseRenderTarget* IRender::CreateRenderTarget( unsigned int width, unsigned int height )
{
RenderTarget* rt = new RenderTarget();
glGenFramebuffersEXT( 1, &rt->m_framebuffer );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, rt->m_framebuffer );
glGenRenderbuffersEXT( 1, &rt->m_renderbuffer );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rt->m_renderbuffer );
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rt->m_renderbuffer );
glGenTextures( 1, &rt->m_rendertexture );
glBindTexture( GL_TEXTURE_2D, rt->m_rendertexture );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_FLOAT, NULL );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glGenerateMipmapEXT( GL_TEXTURE_2D );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rt->m_rendertexture, 0 );
SetRenderTarget( 0 );
SetTexture( 0 );
return rt;
}[/cpp]
Of course I'm the one who wrote this, but I think it's pretty obvious that first a frame buffer is created, then a render buffer and then they are bound to a texture.
-snyop-
-snip-
I had to name it via the id, not the name. Weird.
[QUOTE=Overv;23664963]After reading that article about asshole code I started reviewing the code of my project. Should I add a description of every function in my interfaces, the arguments and the return value? Also, should I add comments to this?[/QUOTE]
I'm not an OpenGL expert so my understanding of your code isn't perfect, but I'd comment it like this, more or less:
[cpp]// Creates a RenderTarget for rendering to a texture of the given dimensions
BaseRenderTarget* IRender::CreateRenderTarget( unsigned int width, unsigned int height )
{
RenderTarget* rt = new RenderTarget();
// Create and bind the FBO
glGenFramebuffersEXT( 1, &rt->m_framebuffer );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, rt->m_framebuffer );
// Create and bind a depth buffer for the FBO
glGenRenderbuffersEXT( 1, &rt->m_renderbuffer );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rt->m_renderbuffer );
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height );
// Attach the depth buffer to the FBO
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rt->m_renderbuffer );
// Create and bind a floating-point RGBA texture for the FBO
glGenTextures( 1, &rt->m_rendertexture );
glBindTexture( GL_TEXTURE_2D, rt->m_rendertexture );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_FLOAT, NULL );
// No wrapping; this isn't going to be tiled
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
// Linear scaling -- not using mipmaps for minification because (why?)
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
// Reserve space for mipmaps
glGenerateMipmapEXT( GL_TEXTURE_2D );
// Attach the texture to the FBO
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rt->m_rendertexture, 0 );
// Unbind the FBO and the texture
// (I'm guessing; it's not really clear to me what these do.)
SetRenderTarget( 0 );
SetTexture( 0 );
return rt;
}[/cpp]
[QUOTE=Overv;23664963]Of course I'm the one who wrote this, but I think it's pretty obvious that first a frame buffer is created, then a render buffer and then they are bound to a texture.[/QUOTE]
It's obvious enough if you read the code, but with the comments, you don't have to. Good comments help your eyes jump quickly to the parts of the code that you're interested in, without having to read through the rest to find your place.
Good comments also explain assumptions or design decisions that may not be apparent otherwise. I'm surprised you're using GL_LINEAR instead of one of the GL_*_MIPMAP_* filtering modes for texture minification, since you apparently intend to generate mipmaps. Maybe that's a mistake on your part, but if not, the comment should say why.
If I were writing this program I'd probably try to put some or all of this behavior into the RenderTarget class, btw. In particular, the glGen*() calls are breaking encapsulation: the second parameter technically points to an array, and the fact that RenderTarget contains "arrays" of length 1 is hard-coded into this function in your IRender class rather than kept as a private implementation detail within RenderTarget itself. In addition, RenderTarget's destructor could call the corresponding glDelete*() functions to avoid leaks.
-Snip-
[QUOTE=nevaeh;23673618]Wanting to get text from a txt file from fileave and then output that text to a textbox. The only way it works now is if I put a string in ANN like ANN = "this is text" and if i have this is text in the text file.[/QUOTE]
I'm not surprised. Look closer:
[lua]Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ANN As String = String.Empty
ANN = "" ' Redundant: you already set it to the empty string above
Dim wc As New WebClient
Dim strings As String
strings = wc.DownloadString("http://XXXXX.fileave.com/Ann.txt")
If strings.Contains(ANN) Then ' If the downloaded file contains the empty string (which all strings do)
TextBox1.Text = ANN ' then make the textbox empty
End If
End Sub
[/lua]
You probably want to do something like
[lua]TextBox1.Text = strings[/lua]
BTW, using the name "strings" for a single string variable (as opposed to an array or list of strings) is a bit confusing.
But now I need to know how to refresh the text every x minutes. Could you help?
I also shortened it a lot.
[lua]
Dim wc As New WebClient
Dim strings As String
strings = wc.DownloadString("http://nevaeh221.fileave.com/Ann.txt")
TextBox1.Text = strings
[/lua]
[QUOTE=nevaeh;23673817]Ok it works now! Except strings I used ANN = Strings. Thanks![/QUOTE]
What's the purpose of the ANN variable? It sounds like it's just a redundant copy of another variable (strings).
[QUOTE=Wyzard;23673854]What's the purpose of the ANN variable? It sounds like it's just a redundant copy of another variable (strings).[/QUOTE]
Yea I just realized that haha.
Some more info:
Ann.txt contains Announcements.
I need the announcements to update within the textbox every x minutes.
[QUOTE=nevaeh;23673817][lua]
If strings.Contains(strings) Then
[/lua][/QUOTE]
This line is pointless. Every string contains its own contents; you're wasting time checking a condition that's always true.
[QUOTE=Wyzard;23673884]This line is pointless. Every string contains its own contents; you're wasting time checking a condition that's always true.[/QUOTE]
Hmm yes you are very right. You'll have to excuse me I just started VB yesterday.
[QUOTE=nevaeh;23673902]You'll have to excuse me I just started VB yesterday.[/QUOTE]
I'm guessing you're new to programming in general, not just to the VB language. That's fine; everyone was a beginner once.
One skill that you'll find very valuable is the ability to "think through" a program in your head, understanding what you expect the computer to do and what the results should be at each line. When your code isn't doing what you expect, read through it and compare, step-by-step, what each line on the screen [i]does[/i] with what you intend to happen, and in many cases the error will jump out at you. Practice doing this and it'll take you a long way.
How do I get a textbox to only allow the input of numbers and a "." symbol? (Using Javascript and HTML.)
[QUOTE=Spartan One;23674980]How do I get a textbox to only allow the input of numbers and a "." symbol? (Using Javascript and HTML.)[/QUOTE]
[cpp]
var re = /^[\d.]+$/;
if(re.test(MyTextBoxText))
{
// MyTextBoxText contains only numbers or dots
}
[/cpp]
[QUOTE=Spartan One;23674980]How do I get a textbox to only allow the input of numbers and a "." symbol? (Using Javascript and HTML.)[/QUOTE]
In general, this sort of filtering is done with an "onkeypress" function, which gets called automatically whenever the user presses a key in the textbox. If the function returns false, the keystroke will be ignored.
To accept only digits and dots, you can use the regex-based test that jA_cOp posted, and return the result from your onkeypress function. Matches return true and allow the keystroke to go through; mismatches return false so the character doesn't get typed.
Remember that users can circumvent client-side restrictions, so to be safe you still need to verify on the server that the input doesn't contain any invalid characters. The client-side filtering just helps to provide a better user experience.
Here's a probably very dumb question regarding movement in [B]SFML[/B]
[code]
double PositionX = ball.Sprite.GetPosition().x;
double PositionY = ball.Sprite.GetPosition().y;
int MouseX = App.GetInput().GetMouseX();
int MouseY = App.GetInput().GetMouseY();
if (MouseX > PositionX) {
ball.Sprite.Move(100 * ElapsedTime, 0); }
if (MouseX < PositionX) {
ball.Sprite.Move(-100 * ElapsedTime, 0); }
if (MouseY > PositionY) {
ball.Sprite.Move(0, 100 * ElapsedTime); }
if (MouseY < PositionY) {
ball.Sprite.Move(0, -100 * ElapsedTime); }
[/code]
The goal of this code was to move the sprite to the position of the mouse and it does that quite finely.
There is a problem though: Whenever the sprite gets into the same position as the mouse it will simply spazz out. It will even do that when the PositionX/Y is the same as MouseX/Y.
So my question is: how can I fix my code up (in general) and fix the spazzing issue?
1.) Those curly brackets are horribly placed, but you don't need them anyway. Single line if statements don't need curly brackets
2.) You should probably change it into an if/else or switch-case structure, instead of 4 ifs
3.) To stop it spazzing out, just make it not move when it's within a certain distance of the mouse
Try multiplying the time with the distance to the mouse position instead.
[QUOTE=Overv;23680013]Try multiplying the time with the distance to the mouse position instead.[/QUOTE]
How would I get the distance though?
[cpp]double PositionX = ball.Sprite.GetPosition().x;
double PositionY = ball.Sprite.GetPosition().y;
int MouseX = App.GetInput().GetMouseX();
int MouseY = App.GetInput().GetMouseY();
if (MouseX > PositionX) {
ball.Sprite.Move((MouseX-PositionX) * ElapsedTime, 0); }
if (MouseX < PositionX) {
ball.Sprite.Move((MouseX-PositionX) * ElapsedTime, 0); }
if (MouseY > PositionY) {
ball.Sprite.Move(0, (MouseY-PositionY) * ElapsedTime); }
if (MouseY < PositionY) {
ball.Sprite.Move(0, (MouseY-PositionY) * ElapsedTime); }[/cpp]
and THAT'S how easy it was?
Oh god thank you Overv, here, take this heart.
and rate me boxes for being an idiot
[QUOTE=Nigey Nige;23637955]Anyone got a rough idea of how I could write something to cut the last 20 seconds (or user-defined amount) from a list of audio files? Is this a good starter project?
(In C#, hopefully.)[/QUOTE]
That depends on the sound library you want to use.
Basically, you have to cut time * sampleRate * bytesPerSample bytes - though for a file with varying bitrate this is going to be a little harder, since the sampleRate is not constant through the file.
[QUOTE=Darwin226;23646011]When I parse a string with float.Parse it ignores the dots int he number and uses commas as decimal points. How can I change that?
I saw that number format thing but I don't understand how to set the separator.[/QUOTE]
NumberFormatInfo.NumberDecimalSeperator and NumberFormatInfo.NumberGroupSeperator. It's probably wise to use NumberFormatInfo.CurrentInfo or NumberFormatInfo.InvariantInfo.
Ok, I've been annoying people with this for some time but apparently that didn't help.
So, I have this code (credits to Overv for the C++ version) that parses an .obj model and renders it. Unfortunately it draws nothing. The vertices array is fine so the problem must be in the loading into OpenGL or drawing it.
[URL="http://pastebin.com/KQnJDhu3"]CODE[/URL]
Please, if someone has any ideas what might be wrong with it...
I plan on getting the OpenGL superbible soon but I need to do something until then.
I sent you PM saying you haven't enabled the arrays yet.
[code]
<html>
<body>
<p> Enter the amount it costs per gallon. Do not use a '$'.</p>
<form>
<input type="textarea" id="textcash" name="textcash">
<br />
<input type="submit" value="Submit" onClick="valueprint()">
</form>
<select id="option">
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
</select>
<script type="text/javascript">
var cashgallon = document.getElementById("textcash").value;
function returnvalue()
{
document.getElementById("textcash").value;
}
var getoption = document.getElementById("option").selectedIndex;
function getselectedvalue()
{
var index = document.getElementById('option').selectedIndex;
}
function valueprint()
{
document.write(getoption);
}
</script>
</body>
</html>
[/code]
Now I'm trying to get the value from value box. It will get the value but prints 3. (An example.) If I select 14 it prints 4. If I select 15 it prints 5. If I select 25 it prints 15. If I select 35 it prints 25. Any ideas? (Also, please ignore how "unoptimized" it is.)
since 10 is the first value, add 10 to the value you're getting
Sorry, you need to Log In to post a reply to this thread.