-
Posts
10,103 -
Joined
-
Last visited
-
Days Won
68
czardas last won the day on January 1 2022
czardas had the most liked content!
About czardas
Profile Information
-
Member Title
'shortest distance between 2 pints' - Euclid c. 300 BC
-
WWW
http://www.czardas.co.uk
Recent Profile Visitors
3,776 profile views
czardas's Achievements
-
Soa reacted to a post in a topic: Combine variable name
-
SkysLastChance reacted to a post in a topic: check array empty
-
Gulnar32 reacted to a post in a topic: Tic-Tac-Toe
-
NassauSky reacted to a post in a topic: GUI design concepts.
-
czardas reacted to a post in a topic: Why is _ArraySort so broken? Updated 1/9/22 630pm g2g
-
czardas reacted to a post in a topic: Trying to get a function to call in nanoseconds efficiently
-
New example: Calculate how long would it take to generate all melodies allowable under musical copyright laws. Requires ArrayWorkshop.au3 and Operator64.au3 - See signature below this post. Fraction.au3 can be found in the first post of this thread. After a recent discussion, I got curious about how long it would take to generate all musical melodies allowable under musical copyright. Nobody understands musical copyright: how does a judge differentiate between a badly played septuplet and a slightly slower quintuplet (LOL)? One rule that I heard (which may or may not apply internationally) is that a melodic sequence must vary after 11 notes (very vague). First it is necessary to grasp some basic theory. Durations are expressed as fractions of beats. The most commonly used beat value is 1/4 note (one quarter of a whole note). In the calculation below, quarter note beats are divided into (x8) 32ndNotes, (x7) septuplets, (x6) sextuplets, (x5) quintuplets. For the purpose of this calculation, these values are combined in every way possible to produce 3480 extended durations lasting between 1/32 note and 5 whole notes. I have posted the calculation here to demonstrate the suitability of this UDF for certain types of task. There's probably a simple formula for such a calculation - only I don't know it. #include-once #include 'fraction.au3' ; requires operator64.au3 #include 'ArrayWorkshop.au3' ; Brute Force Calculation for the Number of Exit Points Within One Quarter Note ; ============================================================================= ; graininess (shortest note) = 32ndNotes (x8), septuplets (x7), sextuplets (x6), quintuplets (x5) ; fractions needed: 1/8, 1/7, 1/6, 1/5 ; fractions not needed: 1/4, 1/3, 1/2 because ... ; multiples are generated by the process, eg 1/2 = 3/6 Local $aCombinations[8 *7 *6 *5][2], $aDuration[2] Local $iCount = 0 ; calculate the number of possible durations between 1/32 and a single whole note. For $8 = 0 To 7 ; 32ndNotes For $7 = 0 To 6 ; septuplets For $6 = 0 To 5 ; sextuplets For $5 = 0 To 4 ; quintuplets ; get sustained note combinations (tied note durations) $aDuration = _FractionAdd(_Fraction($5, 5), _FractionAdd(_Fraction($6, 6), _FractionAdd(_Fraction($7, 7), _Fraction($8, 8)))) If $aDuration[0] > $aDuration[1] Then ; total duration must remain within one beat $aDuration[0] = 0 ; set to zero seconds duration $aDuration[1] = 1 EndIf $aCombinations[$iCount][0] = $aDuration[0] $aCombinations[$iCount][1] = $aDuration[1] $iCount += 1 Next Next Next Next ; remove any duplicate combinations _ArrayUniqueXD($aCombinations) ; tests for duplicate (full) rows in 2D Local $iEndPoints = UBound($aCombinations) -1 ; 174 possible termination points within one quarter note ; 10 seconds is long enough for a singer to maintain a note. ; 10 seconds (longest note) @ 120 bpm (moderato) = 20 beats (sustained limit) $iEndPoints *= 20 ; simply multiply the number of end points by 20 ConsoleWrite("note end points between a 1/32 note and 5 whole beats = " & $iEndPoints & @LF) ; = 3480 ; taking a set of 11 pitched notes and 1 rest, calculate how many melodic sequences exist for the selected set Local $fMelodies = $iEndPoints ^12 ConsoleWrite("all possible melodic sequences from the 11 note set = " & $fMelodies & @LF) ; = 3.15464814713788e+042 ; How long would it take to generate all these melodies? ; A theoretical modern version of Deep Blue would be able to calculate 3 * 10^15 chess positions per second (2016). ; https://chess.stackexchange.com/questions/8117/how-many-positions-per-second-can-a-modern-supercomputer-calculate ; I'm just going to cheat and pretend these speeds are comparable. Local $fYears = ($fMelodies /3.0e+15) /(60 *60 *24 *356) ConsoleWrite("time in years to generate all sequences = " & $fYears & @LF) ; = 3.41873888882157e+019 ; 34,000,000,000,000,000,000 years :D Clearly brute force is a waste of time - especially when it would produce mostly arrhythmic rubbish anyway. Also consider the fact that this calculation only represents a subset of 11 pitched notes (pitch range can vary). The true answer is a heck of a lot larger than this.
- 36 replies
-
- whole numbers
- fraction
-
(and 1 more)
Tagged with:
-
Peace Equalizer shows power of AutoIt
czardas replied to PeterVerbeek's topic in AutoIt Example Scripts
This looks fantastic. I haven't time to test it right now, but I will do soon. Mooi!- 52 replies
-
string increment alphabetic to numeric or viceversa
czardas replied to ali_lbay's topic in AutoIt General Help and Support
A is zero! 🤔 For $i = 0 To 36^3 -1 ConsoleWrite(CustomBaseConversion($i) & @LF) Next Func CustomBaseConversion($iInt, $iLength = 4) Local $iBase = 36, $iRemainder, $sOutput = '' Do $iRemainder = Mod($iInt, $iBase) $sOutput = Chr($iRemainder < 26 ? $iRemainder + 65 : $iRemainder + 22) & $sOutput $iInt = Floor($iInt/$iBase) Until $iInt < 1 Return StringRight('AAAAAAAA' & $sOutput, $iLength) EndFunc ;==> CustomBaseConversion -
This seems very tricky. I would recommend looking at what software already exists that you might be able to use. It seems possible to record the sound with audacity and take a screenshot of the audio (wave) output in the display area. Then you could trace the outline using PixelSearch() and see if the sound matches a previously identified sound recording within a predetermined margin of error. This type of compromise would only work for prerecorded sounds and would be unable to determine melodic output. Not necessarily the most reliable method and sensitivity will depend on the sound source: experimentation needed.
-
Learn about function parameters and the syntax used to create them. #include <MsgBoxConstants.au3> Local $iVariable = Addition(7, 2) MsgBox($MB_OK, "Add Parameters", $iVariable) Func Addition($iParam_A, $iParam_B) ; example function with two parameters Return $iParam_A + $iParam_B ; add the parameters together and return the result EndFunc ;==> Addition Then rewrite the function _Counter() and add the parameters you need to do what you want.
-
Yes BrewManNH is correct (within the local scope) and I was just thinking about confusion relating to the global scope. With declaration outside a function, it doesn't make a difference (which keyword you use) beyond potentially bad syntax. Sticking to good syntax circumvents many potential problems.
-
Excellent!
-
Correct [in the global scope]. Local applies to the scope in which the declaration is made. If declared outside a function, then the variable is created in the global scope which is the (current local) scope as seen by the interpreter. Edit: Think of local as being in the same neighborhood.
-
There used to be a tool called AU3Record. This was removed from the package some time ago and if you read the forum rules, you just might figure out the reason - it's a must anyway. Secondly, this forum has a lot of examples of usage. Take a look at the topics in Example Scripts. Finally - after downloading, look at the Help File and especially look at the Tutorials.
-
Help File/Documentation Issues. (Discussion Only)
czardas replied to guinness's topic in AutoIt Technical Discussion
I mean that it's difficult to rewrite all the detail without making it harder to understand or overly verbose. Anyone using such advanced functions should be able to interpret the description on MSDN. I do believe the constant names ought to be listed, but rewording MSDN descriptions seems like a huge effort. -
@Deye This question should have been posted in GH&S. Here's a quick and simple method which does not verify whether paths exist, nor does it verify syntax. It might do what you want, or at least give you some ideas. #include <Array.au3> Local $aTest = _ ['H:\', _ 'False', _ 'False', _ 'False', _ 'Downloads', _ 'Documents', _ 'Control Panel\Network and Internet\Network Connections', _ 'C:\Users\', _ 'C:\'] _ArrayDisplay($aTest, 'Before') For $i = 0 To UBound($aTest) -1 If StringRegExp($aTest[$i], '(\A[A-Z]\:\\)') Then $aTest[$i] = 'z' & $aTest[$i] Else $aTest[$i] = 'a' & $aTest[$i] EndIf Next _ArraySort($aTest) For $i = 0 To UBound($aTest) -1 $aTest[$i] = StringTrimLeft($aTest[$i], 1) Next _ArrayDisplay($aTest, 'After')
-
Help File/Documentation Issues. (Discussion Only)
czardas replied to guinness's topic in AutoIt Technical Discussion
I agree with @Danyfirex about this. -
Help File/Documentation Issues. (Discussion Only)
czardas replied to guinness's topic in AutoIt Technical Discussion
To rewrite the description is risky.